From b4336458fccb6c78303e38ef2cf59720d2f74174 Mon Sep 17 00:00:00 2001 From: Andrew Joslin Date: Thu, 14 Dec 2017 16:26:55 -0700 Subject: [PATCH 001/108] Add vertcoin --- src/currencies.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/currencies.js b/src/currencies.js index 740521bb..8809215b 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -48,6 +48,10 @@ name: 'biocoin', symbol: 'bio', addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} + },{ + name: 'vertcoin', + symbol: 'vtc', + addressTypes: {prod: ['71', '05'], testnet: ['6f', 'c4']} }]; From 01fc48d29821c2d3ed6884edca6d04aed21e3588 Mon Sep 17 00:00:00 2001 From: Andrew Joslin Date: Thu, 14 Dec 2017 16:30:32 -0700 Subject: [PATCH 002/108] Covnert to hex --- src/currencies.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/currencies.js b/src/currencies.js index 8809215b..0eb97e5f 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -51,7 +51,7 @@ },{ name: 'vertcoin', symbol: 'vtc', - addressTypes: {prod: ['71', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} }]; From 04e865a41f355c1574ed60e9b70a78c5c4006681 Mon Sep 17 00:00:00 2001 From: Martin Kuvandzhiev Date: Sun, 24 Dec 2017 21:51:12 +0200 Subject: [PATCH 003/108] Added bitcoin gold --- src/currencies.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/currencies.js b/src/currencies.js index 740521bb..568d29df 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -48,6 +48,10 @@ name: 'biocoin', symbol: 'bio', addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} + },{ + name: 'bitcoinGold', + symbol: 'btg', + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} }]; From 21b5458488eb9dce9af0a4905425e543dc5c450b Mon Sep 17 00:00:00 2001 From: Dylan Myers <246db485@opayq.com> Date: Sat, 27 Jan 2018 00:02:55 +0000 Subject: [PATCH 004/108] added Garlicoin --- src/currencies.js | 4 ++++ test/wallet_address_validator.js | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/currencies.js b/src/currencies.js index 740521bb..6cefe7c4 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -48,6 +48,10 @@ name: 'biocoin', symbol: 'bio', addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} + },{ + name: 'garlicoin', + symbol: 'grlc', + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} }]; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 0f6632fc..bc977303 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -163,6 +163,14 @@ describe('WAValidator.validate()', function () { valid('muH8LL42DiMs8GEQ6Grfi8KUw2uFvuKr1J', 'BIO', 'testnet'); valid('B8zjmYFGhWmiaQSJshfrnefE72xCapCkvo', 'BIO'); }); + + it('should return true for correct Garlicoin addresses', function () { + valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'garlicoin'); + valid('GNWeWaoQ6rv21ZFjJWT9vb91hXUzFTLkru', 'garlicoin'); + valid('mjKbQTkgwzmsL3J86tdVzhyW9pc4NePqTb', 'garlicoin', 'testnet'); + valid('mnYp36NuyRavMKQ9Q9Q6oGqoorAs9p3zYn', 'GRLC', 'testnet'); + valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'GRLC'); + }); }); describe('invalid results', function () { @@ -226,5 +234,9 @@ describe('WAValidator.validate()', function () { commonTests('biocoin'); }); + it('should return false for incorrect garlicoin addresses', function () { + commonTests('garlicoin'); + }); + }); }); From bae20b165aecddabf7607eef8eda7d0092ba9474 Mon Sep 17 00:00:00 2001 From: cernael Date: Tue, 27 Feb 2018 18:17:20 +0100 Subject: [PATCH 005/108] Add new LTC P2SH prefix --- src/currencies.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/currencies.js b/src/currencies.js index 740521bb..9ad3de2c 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -7,7 +7,7 @@ },{ name: 'litecoin', symbol: 'ltc', - addressTypes: {prod: ['30', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} },{ name: 'peercoin', symbol: 'ppc', From 08746f6c63f522609660a030c3fa86c74169c652 Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Fri, 2 Mar 2018 12:08:39 +0900 Subject: [PATCH 006/108] Dropped bower, fixed travis CI config. Updated README. --- .gitignore | 2 ++ .travis.yml | 3 +++ Gruntfile.js | 2 +- README.md | 9 ++------- bower.json | 23 ----------------------- dist/wallet-address-validator.min.js | 2 +- package.json | 1 + 7 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 bower.json diff --git a/.gitignore b/.gitignore index a088b6f0..b6e6fb35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules bower_components +.idea +.DS_Store diff --git a/.travis.yml b/.travis.yml index 63f7b350..0611ff21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ language: node_js node_js: - "4" + - "6" + - "8" + - "9" diff --git a/Gruntfile.js b/Gruntfile.js index 11c2d51f..e0343423 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,7 +8,7 @@ module.exports = function(grunt) { dist: { files: { 'dist/wallet-address-validator.min.js': [ - 'bower_components/jssha/src/sha256.js', + 'node_modules/jssha/src/sha256.js', 'src/base58.js', 'src/crypto_utils.js', 'src/currencies.js', diff --git a/README.md b/README.md index 394d8a0b..d02282bc 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ I forked it to remove all Node.js dependencies (crypro, Buffer etc.) to make it ## Installation -### Node +### NPM ``` npm install wallet-address-validator ``` @@ -17,12 +17,6 @@ npm install wallet-address-validator ``` -#### Using bower -``` -bower install wallet-address-validator -``` - - ## API ##### validate (address [, currency = 'bitcoin'[, networkType = 'prod']]) @@ -55,6 +49,7 @@ bower install wallet-address-validator * Auroracoin/AUR, `'auroracoin'` or `'AUR'` * Namecoin/NMC, `'namecoin'` or `'NMC'` * Biocoin/BIO, `'biocoin'` or `'BIO'` +* Garlicoin/GRLC, `'garlicoin'` or `'grlc'` ### Usage example diff --git a/bower.json b/bower.json deleted file mode 100644 index 028d7055..00000000 --- a/bower.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "wallet-address-validator", - "description": "Wallet address validator for Bitcoin and other Altcoins.", - "version": "0.1.0", - "keywords": [ - "bitcoin", - "litecoin", - "dogecoin", - "altcoin", - "address", - "wallet", - "validator", - "javascript", - "browser", - "nodejs" - ], - "license": "MIT", - "homepage": "https://github.com/ognus/wallet-address-validator", - "main": "dist/wallet-address-validator.min.js", - "devDependencies": { - "jssha": "2.3.1" - } -} diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index c058c30f..e82f65a5 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(e){for(var r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",o={},t=0;t>8,s[t]&=255;for(;a;)s.push(255&a),a>>=8}for(r=0;"1"===e[r]&&r=0}};e?module.exports=s:window.WAValidator=s}("undefined"!=typeof module&&void 0!==module.exports); \ No newline at end of file +"use strict";!function(r){function e(r,e,t){var f,c,d,p,l,h,m,b,A,w=0,g=[],E=0,H=!1,T=[],U=[],S=!1;if(f=(t=t||{}).encoding||"UTF8",(A=t.numRounds||1)!==parseInt(A,10)||1>A)throw Error("numRounds must a integer >= 1");if(0!==r.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(e,t){return y(e,t,r)},m=function(e,t,n,o){var a,i;if("SHA-224"!==r&&"SHA-256"!==r)throw Error("Unexpected error in SHA-2 implementation");for(a=15+(t+65>>>9<<4),i=16;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,t+=n,e[a]=4294967295&t,e[a-1]=t/4294967296|0,n=e.length,t=0;t>>3)/4-1,oe/8){for(;t.length<=n;)t.push(0);t[n]&=4294967040}for(e=0;e<=n;e+=1)T[e]=909522486^t[e],U[e]=1549556828^t[e];c=h(T,c),w=l,H=!0},this.update=function(r){var e,t,n,o=0,a=l>>>5;for(r=(e=d(r,g,E)).binLen,t=e.value,e=r>>>5,n=0;n>>5),E=r%l,S=!0},this.getHash=function(e,t){var u,f,d,l;if(!0===H)throw Error("Cannot call getHash after setting HMAC key");switch(d=s(t),e){case"HEX":u=function(r){return n(r,p,d)};break;case"B64":u=function(r){return o(r,p,d)};break;case"BYTES":u=function(r){return a(r,p)};break;case"ARRAYBUFFER":try{f=new ArrayBuffer(0)}catch(r){throw Error("ARRAYBUFFER not supported by this environment")}u=function(r){return i(r,p)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(l=m(g.slice(),E,w,b(c)),f=1;f>>2]>>>8*(3+n%4*-1),a+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return t.outputUpper?a.toUpperCase():a}function o(r,e,t){var n,o,a,i="",s=e/8;for(n=0;n>>2]:0,a=n+2>>2]:0,a=(r[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|a>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)i+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6*(3-o)&63):t.b64Pad;return i}function a(r,e){var t,n,o="",a=e/8;for(t=0;t>>2]>>>8*(3+t%4*-1)&255,o+=String.fromCharCode(n);return o}function i(r,e){var t,n,o=e/8,a=new ArrayBuffer(o);for(n=new Uint8Array(a),t=0;t>>2]>>>8*(3+t%4*-1)&255;return a}function s(r){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(r=r||{},e.outputUpper=r.outputUpper||!1,!0===r.hasOwnProperty("b64Pad")&&(e.b64Pad=r.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function u(r,e){var t;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(r){case"HEX":t=function(r,e,t){var n,o,a,i,s,u=r.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(t=t||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=a;)e.push(0);e[a]|=o<<8*(3+i%4*-1)}return{value:e,binLen:4*u+t}};break;case"TEXT":t=function(r,t,n){var o,a,i,s,u,f,c,d,p=0;if(t=t||[0],u=(n=n||0)>>>3,"UTF8"===e)for(d=3,i=0;i(o=r.charCodeAt(i))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(i+=1,o=65536+((1023&o)<<10|1023&r.charCodeAt(i)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;t.length<=f;)t.push(0);t[f]|=a[s]<<8*(d+c%4*-1),p+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(d=2,a="UTF16LE"===e||"UTF16LE"!==e&&!1,i=0;i>>8),f=(c=p+u)>>>2;t.length<=f;)t.push(0);t[f]|=o<<8*(d+c%4*-1),p+=2}return{value:t,binLen:8*p+n}};break;case"B64":t=function(r,e,t){var n,o,a,i,s,u,f,c=0;if(-1===r.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=r.indexOf("="),r=r.replace(/\=/g,""),-1!==o&&o>>3,o=0;o>>2;e.length<=n;)e.push(0);e[n]|=(i>>>16-8*a&255)<<8*(3+f%4*-1),d+=1}}return{value:e,binLen:8*d+t}};break;case"BYTES":t=function(r,e,t){var n,o,a,i,s;for(e=e||[0],a=(t=t||0)>>>3,o=0;o>>2,e.length<=i&&e.push(0),e[i]|=n<<8*(3+s%4*-1);return{value:e,binLen:8*r.length+t}};break;case"ARRAYBUFFER":try{t=new ArrayBuffer(0)}catch(r){throw Error("ARRAYBUFFER not supported by this environment")}t=function(r,e,t){var n,o,a,i,s;for(e=e||[0],o=(t=t||0)>>>3,s=new Uint8Array(r),n=0;n>>2,e.length<=a&&e.push(0),e[a]|=s[n]<<8*(3+i%4*-1);return{value:e,binLen:8*r.byteLength+t}};break;default:throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER")}return t}function f(r,e){return r>>>e|r<<32-e}function d(r,e,t){return r&e^~r&t}function c(r,e,t){return r&e^r&t^e&t}function p(r){return f(r,2)^f(r,13)^f(r,22)}function l(r){return f(r,6)^f(r,11)^f(r,25)}function h(r){return f(r,7)^f(r,18)^r>>>3}function m(r){return f(r,17)^f(r,19)^r>>>10}function b(r,e){var t=(65535&r)+(65535&e);return((r>>>16)+(e>>>16)+(t>>>16)&65535)<<16|65535&t}function y(r,e,t,n){var o=(65535&r)+(65535&e)+(65535&t)+(65535&n);return((r>>>16)+(e>>>16)+(t>>>16)+(n>>>16)+(o>>>16)&65535)<<16|65535&o}function A(r,e,t,n,o){var a=(65535&r)+(65535&e)+(65535&t)+(65535&n)+(65535&o);return((r>>>16)+(e>>>16)+(t>>>16)+(n>>>16)+(o>>>16)+(a>>>16)&65535)<<16|65535&a}function w(r){var e,n=[];if(0!==r.lastIndexOf("SHA-",0))throw Error("No SHA variants supported");switch(n=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],e=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],r){case"SHA-224":break;case"SHA-256":n=e;break;case"SHA-384":case"SHA-512":n=[new t,new t,new t,new t,new t,new t,new t,new t];break;default:throw Error("Unknown SHA variant")}return n}function v(r,e,t){var n,o,a,i,s,u,f,w,v,E,H,T,U,S,F,B,R,x,k,C,L,Y,X,_=[];if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(E=64,T=1,Y=Number,U=b,S=y,F=A,B=h,R=m,x=p,k=l,L=c,C=d,X=g,t=e[0],n=e[1],o=e[2],a=e[3],i=e[4],s=e[5],u=e[6],f=e[7],H=0;HH?(v=H*T,w=r.length<=v?0:r[v],v=r.length<=v+1?0:r[v+1],_[H]=new Y(w,v)):_[H]=S(R(_[H-2]),_[H-7],B(_[H-15]),_[H-16]),w=F(f,k(i),C(i,s,u),X[H],_[H]),v=U(x(t),L(t,n,o)),f=u,u=s,s=i,i=U(a,w),a=o,o=n,n=t,t=U(w,v);return e[0]=U(t,e[0]),e[1]=U(n,e[1]),e[2]=U(o,e[2]),e[3]=U(a,e[3]),e[4]=U(i,e[4]),e[5]=U(s,e[5]),e[6]=U(u,e[6]),e[7]=U(f,e[7]),e}var g;g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],"function"==typeof define&&define.amd?define(function(){return e}):"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(module.exports=e),exports=e):r.jsSHA=e}(this),function(r){for(var e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",t={},n=0;n>8,a[n]&=255;for(;s;)a.push(255&s),s>>=8}for(e=0;"1"===r[e]&&e=0}};r?module.exports=a:window.WAValidator=a}("undefined"!=typeof module&&void 0!==module.exports); \ No newline at end of file +"use strict";!function(e){function r(e,r,t){var c,d,f,l,h,p,m,b,y,w=0,g=[],E=0,H=!1,T=[],k=[],U=!1;if(c=(t=t||{}).encoding||"UTF8",(y=t.numRounds||1)!==parseInt(y,10)||1>y)throw Error("numRounds must a integer >= 1");if(0!==e.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(p=function(r,t){return v(r,t,e)},m=function(r,t,n,o){var a,s;if("SHA-224"!==e&&"SHA-256"!==e)throw Error("Unexpected error in SHA-2 implementation");for(a=15+(t+65>>>9<<4),s=16;r.length<=a;)r.push(0);for(r[t>>>5]|=128<<24-t%32,t+=n,r[a]=4294967295&t,r[a-1]=t/4294967296|0,n=r.length,t=0;t>>3)/4-1,or/8){for(;t.length<=n;)t.push(0);t[n]&=4294967040}for(r=0;r<=n;r+=1)T[r]=909522486^t[r],k[r]=1549556828^t[r];d=p(T,d),w=h,H=!0},this.update=function(e){var r,t,n,o=0,a=h>>>5;for(e=(r=f(e,g,E)).binLen,t=r.value,r=e>>>5,n=0;n>>5),E=e%h,U=!0},this.getHash=function(r,t){var u,c,f,h;if(!0===H)throw Error("Cannot call getHash after setting HMAC key");switch(f=i(t),r){case"HEX":u=function(e){return n(e,l,f)};break;case"B64":u=function(e){return o(e,l,f)};break;case"BYTES":u=function(e){return a(e,l)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}u=function(e){return s(e,l)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(h=m(g.slice(),E,w,b(d)),c=1;c>>2]>>>8*(3+n%4*-1),a+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return t.outputUpper?a.toUpperCase():a}function o(e,r,t){var n,o,a,s="",i=r/8;for(n=0;n>>2]:0,a=n+2>>2]:0,a=(e[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|a>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6*(3-o)&63):t.b64Pad;return s}function a(e,r){var t,n,o="",a=r/8;for(t=0;t>>2]>>>8*(3+t%4*-1)&255,o+=String.fromCharCode(n);return o}function s(e,r){var t,n,o=r/8,a=new ArrayBuffer(o);for(n=new Uint8Array(a),t=0;t>>2]>>>8*(3+t%4*-1)&255;return a}function i(e){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(e=e||{},r.outputUpper=e.outputUpper||!1,!0===e.hasOwnProperty("b64Pad")&&(r.b64Pad=e.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function u(e,r){var t;switch(r){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":t=function(e,r,t){var n,o,a,s,i,u=e.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],i=(t=t||0)>>>3,n=0;n>>1)+i)>>>2;r.length<=a;)r.push(0);r[a]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+t}};break;case"TEXT":t=function(e,t,n){var o,a,s,i,u,c,d,f,l=0;if(t=t||[0],u=(n=n||0)>>>3,"UTF8"===r)for(f=3,s=0;s(o=e.charCodeAt(s))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(s)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),i=0;i>>2;t.length<=c;)t.push(0);t[c]|=a[i]<<8*(f+d%4*-1),l+=1}else if("UTF16BE"===r||"UTF16LE"===r)for(f=2,a="UTF16LE"===r||"UTF16LE"!==r&&!1,s=0;s>>8),c=(d=l+u)>>>2;t.length<=c;)t.push(0);t[c]|=o<<8*(f+d%4*-1),l+=2}return{value:t,binLen:8*l+n}};break;case"B64":t=function(e,r,t){var n,o,a,s,i,u,c,d=0;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=e.indexOf("="),e=e.replace(/\=/g,""),-1!==o&&o Date: Sun, 4 Mar 2018 05:45:15 +0200 Subject: [PATCH 009/108] Browserify package --- Gruntfile.js | 16 +++++++++++++++- package.json | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index e0343423..b4ae83de 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,9 +1,23 @@ module.exports = function(grunt) { + grunt.loadNpmTasks('grunt-browserify'); grunt.loadNpmTasks('grunt-simple-mocha'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-mocha'); grunt.initConfig({ + browserify: { + dist: { + files: { + 'dist/address-validator.min.js': [ + 'node_modules/jssha/src/sha256.js', + 'src/base58.js', + 'src/crypto_utils.js', + 'src/currencies.js', + 'src/wallet_address_validator.js' + ] + } + } + }, uglify: { dist: { files: { @@ -39,4 +53,4 @@ module.exports = function(grunt) { }); grunt.registerTask('default', ['simplemocha', 'uglify', 'mocha']); -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 0100b296..54a4961c 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "devDependencies": { "chai": "latest", "grunt": "latest", + "grunt-browserify": "^5.2.0", "grunt-contrib-uglify": "latest", "grunt-mocha": "latest", "grunt-simple-mocha": "latest", From 6348fa33e02300d8a343b8f8dfbf71a8c6ae02ac Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Thu, 8 Mar 2018 20:36:25 +0900 Subject: [PATCH 010/108] Blake256 fix for browser. Dropped Grunt, added Karma test runner and moved to Browserify. --- Gruntfile.js | 56 - README.md | 3 +- dist/wallet-address-validator.js | 2423 ++++++++++++++++++++++++++ dist/wallet-address-validator.min.js | 2 +- karma.conf.js | 27 + package.json | 24 +- src/base58.js | 81 +- src/blake256.js | 188 ++ src/crypto_utils.js | 72 +- src/currencies.js | 168 +- src/wallet_address_validator.js | 120 +- test/runner.html | 30 - test/wallet_address_validator.js | 4 +- 13 files changed, 2857 insertions(+), 341 deletions(-) delete mode 100644 Gruntfile.js create mode 100644 dist/wallet-address-validator.js create mode 100644 karma.conf.js create mode 100644 src/blake256.js delete mode 100644 test/runner.html diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index b4ae83de..00000000 --- a/Gruntfile.js +++ /dev/null @@ -1,56 +0,0 @@ -module.exports = function(grunt) { - grunt.loadNpmTasks('grunt-browserify'); - grunt.loadNpmTasks('grunt-simple-mocha'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-mocha'); - - grunt.initConfig({ - browserify: { - dist: { - files: { - 'dist/address-validator.min.js': [ - 'node_modules/jssha/src/sha256.js', - 'src/base58.js', - 'src/crypto_utils.js', - 'src/currencies.js', - 'src/wallet_address_validator.js' - ] - } - } - }, - uglify: { - dist: { - files: { - 'dist/wallet-address-validator.min.js': [ - 'node_modules/jssha/src/sha256.js', - 'src/base58.js', - 'src/crypto_utils.js', - 'src/currencies.js', - 'src/wallet_address_validator.js' - ] - } - } - }, - // running tests in node - simplemocha: { - options: { - timeout: 3000, - ignoreLeaks: false, - ui: 'bdd', - reporter: 'spec' - }, - all: { src: ['test/**/*.js'] } - }, - // running tests in browser - mocha: { - all: { - src: ['test/runner.html'], - }, - options: { - run: true - } - } - }); - - grunt.registerTask('default', ['simplemocha', 'uglify', 'mocha']); -}; diff --git a/README.md b/README.md index f7b0cf2e..c83940c1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Simple wallet address validator for validating Bitcoin and other altcoins addres Forked from [ryanralph/altcoin-address](https://github.com/ryanralph/altcoin-address). -I forked it to remove all Node.js dependencies (crypro, Buffer etc.) to make it usable in the browser as well. I didn't use browserify to achieve smaller footprint, **file size is 4.0 kB (minifed and gzipped)**. +**File size is ~15 kB (minifed and gzipped)**. ## Installation @@ -52,6 +52,7 @@ npm install wallet-address-validator * Garlicoin/GRLC, `'garlicoin'` or `'GRLC'` * Vertcoin/VTC, `'vertcoin'` or `'VTC'` * BitcoinGold/BTG, `'bitcoingold'` or `'BTG'` +* Decred/DCR, `'decred'` or `'DCR'` ### Usage example diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js new file mode 100644 index 00000000..ef1ce981 --- /dev/null +++ b/dist/wallet-address-validator.js @@ -0,0 +1,2423 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} + +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return (b64.length * 3 / 4) - placeHoldersCount(b64) +} + +function toByteArray (b64) { + var i, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) + + arr = new Arr((len * 3 / 4) - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0; i < l; i += 4) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } + + parts.push(output) + + return parts.join('') +} + +},{}],2:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + +'use strict' + +var base64 = require('base64-js') +var ieee754 = require('ieee754') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} + +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 + } catch (e) { + return false + } +} + +Object.defineProperty(Buffer.prototype, 'parent', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined + } + return this.buffer + } +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined + } + return this.byteOffset + } +}) + +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('Invalid typed array length') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} + +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) +} + +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + return fromObject(value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf +} + +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} + +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf +} + +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj) { + if (ArrayBuffer.isView(obj) || 'length' in obj) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } + } + + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') +} + +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (ArrayBuffer.isView(buf)) { + buf = Buffer.from(buf) + } + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.toLocaleString = Buffer.prototype.toString + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : new Buffer(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check +// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 +function isArrayBuffer (obj) { + return obj instanceof ArrayBuffer || + (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && + typeof obj.byteLength === 'number') +} + +function numberIsNaN (obj) { + return obj !== obj // eslint-disable-line no-self-compare +} + +},{"base64-js":1,"ieee754":3}],3:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + +},{}],4:[function(require,module,exports){ +/* + A JavaScript implementation of the SHA family of hashes, as + defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding + HMAC implementation as defined in FIPS PUB 198a + + Copyright Brian Turek 2008-2017 + Distributed under the BSD License + See http://caligatio.github.com/jsSHA/ for more information + + Several functions taken from Paul Johnston +*/ +'use strict';(function(Y){function C(c,a,b){var e=0,h=[],n=0,g,l,d,f,m,q,u,r,I=!1,v=[],w=[],t,y=!1,z=!1,x=-1;b=b||{};g=b.encoding||"UTF8";t=b.numRounds||1;if(t!==parseInt(t,10)||1>t)throw Error("numRounds must a integer >= 1");if("SHA-1"===c)m=512,q=K,u=Z,f=160,r=function(a){return a.slice()};else if(0===c.lastIndexOf("SHA-",0))if(q=function(a,b){return L(a,b,c)},u=function(a,b,h,e){var k,f;if("SHA-224"===c||"SHA-256"===c)k=(b+65>>>9<<4)+15,f=16;else if("SHA-384"===c||"SHA-512"===c)k=(b+129>>>10<< +5)+31,f=32;else throw Error("Unexpected error in SHA-2 implementation");for(;a.length<=k;)a.push(0);a[b>>>5]|=128<<24-b%32;b=b+h;a[k]=b&4294967295;a[k-1]=b/4294967296|0;h=a.length;for(b=0;be;e+=1)c[e]=a[e].slice();return c};x=1;if("SHA3-224"=== +c)m=1152,f=224;else if("SHA3-256"===c)m=1088,f=256;else if("SHA3-384"===c)m=832,f=384;else if("SHA3-512"===c)m=576,f=512;else if("SHAKE128"===c)m=1344,f=-1,F=31,z=!0;else if("SHAKE256"===c)m=1088,f=-1,F=31,z=!0;else throw Error("Chosen SHA variant is not supported");u=function(a,c,e,b,h){e=m;var k=F,f,g=[],n=e>>>5,l=0,d=c>>>5;for(f=0;f=e;f+=n)b=D(a.slice(f,f+n),b),c-=e;a=a.slice(f);for(c%=e;a.length>>3;a[f>>2]^=k<=h)break;g.push(a.a);l+=1;0===64*l%e&&D(null,b)}return g}}else throw Error("Chosen SHA variant is not supported");d=M(a,g,x);l=A(c);this.setHMACKey=function(a,b,h){var k;if(!0===I)throw Error("HMAC key already set");if(!0===y)throw Error("Cannot set HMAC key after calling update");if(!0===z)throw Error("SHAKE is not supported for HMAC");g=(h||{}).encoding||"UTF8";b=M(b,g,x)(a);a=b.binLen;b=b.value;k=m>>>3;h=k/4-1;if(ka/8){for(;b.length<=h;)b.push(0);b[h]&=4294967040}for(a=0;a<=h;a+=1)v[a]=b[a]^909522486,w[a]=b[a]^1549556828;l=q(v,l);e=m;I=!0};this.update=function(a){var c,b,k,f=0,g=m>>>5;c=d(a,h,n);a=c.binLen;b=c.value;c=a>>>5;for(k=0;k>>5);n=a%m;y=!0};this.getHash=function(a,b){var k,g,d,m;if(!0===I)throw Error("Cannot call getHash after setting HMAC key");d=N(b);if(!0===z){if(-1===d.shakeLen)throw Error("shakeLen must be specified in options"); +f=d.shakeLen}switch(a){case "HEX":k=function(a){return O(a,f,x,d)};break;case "B64":k=function(a){return P(a,f,x,d)};break;case "BYTES":k=function(a){return Q(a,f,x)};break;case "ARRAYBUFFER":try{g=new ArrayBuffer(0)}catch(p){throw Error("ARRAYBUFFER not supported by this environment");}k=function(a){return R(a,f,x)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");}m=u(h.slice(),n,e,r(l),f);for(g=1;g>>24-f%32),m=u(m,f, +0,A(c),f);return k(m)};this.getHMAC=function(a,b){var k,g,d,p;if(!1===I)throw Error("Cannot call getHMAC without first setting HMAC key");d=N(b);switch(a){case "HEX":k=function(a){return O(a,f,x,d)};break;case "B64":k=function(a){return P(a,f,x,d)};break;case "BYTES":k=function(a){return Q(a,f,x)};break;case "ARRAYBUFFER":try{k=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}k=function(a){return R(a,f,x)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER"); +}g=u(h.slice(),n,e,r(l),f);p=q(w,A(c));p=u(g,f,m,p,f);return k(p)}}function b(c,a){this.a=c;this.b=a}function O(c,a,b,e){var h="";a/=8;var n,g,d;d=-1===b?3:0;for(n=0;n>>2]>>>8*(d+n%4*b),h+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return e.outputUpper?h.toUpperCase():h}function P(c,a,b,e){var h="",n=a/8,g,d,p,f;f=-1===b?3:0;for(g=0;g>>2]:0,p=g+2>>2]:0,p=(c[g>>>2]>>>8*(f+g%4*b)&255)<<16|(d>>>8*(f+(g+1)%4*b)&255)<<8|p>>>8*(f+ +(g+2)%4*b)&255,d=0;4>d;d+=1)8*g+6*d<=a?h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(p>>>6*(3-d)&63):h+=e.b64Pad;return h}function Q(c,a,b){var e="";a/=8;var h,d,g;g=-1===b?3:0;for(h=0;h>>2]>>>8*(g+h%4*b)&255,e+=String.fromCharCode(d);return e}function R(c,a,b){a/=8;var e,h=new ArrayBuffer(a),d,g;g=new Uint8Array(h);d=-1===b?3:0;for(e=0;e>>2]>>>8*(d+e%4*b)&255;return h}function N(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{}; +a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if(!0===c.hasOwnProperty("shakeLen")){if(0!==c.shakeLen%8)throw Error("shakeLen must be a multiple of 8");a.shakeLen=c.shakeLen}if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function M(c,a,b){switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE"); +}switch(c){case "HEX":c=function(a,c,d){var g=a.length,l,p,f,m,q,u;if(0!==g%2)throw Error("String of HEX type must be in byte increments");c=c||[0];d=d||0;q=d>>>3;u=-1===b?3:0;for(l=0;l>>1)+q;for(f=m>>>2;c.length<=f;)c.push(0);c[f]|=p<<8*(u+m%4*b)}return{value:c,binLen:4*g+d}};break;case "TEXT":c=function(c,h,d){var g,l,p=0,f,m,q,u,r,t;h=h||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(t=-1=== +b?3:0,f=0;fg?l.push(g):2048>g?(l.push(192|g>>>6),l.push(128|g&63)):55296>g||57344<=g?l.push(224|g>>>12,128|g>>>6&63,128|g&63):(f+=1,g=65536+((g&1023)<<10|c.charCodeAt(f)&1023),l.push(240|g>>>18,128|g>>>12&63,128|g>>>6&63,128|g&63)),m=0;m>>2;h.length<=u;)h.push(0);h[u]|=l[m]<<8*(t+r%4*b);p+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(t=-1===b?2:0,l="UTF16LE"===a&&1!==b||"UTF16LE"!==a&&1===b,f=0;f>>8);r=p+q;for(u=r>>>2;h.length<=u;)h.push(0);h[u]|=g<<8*(t+r%4*b);p+=2}return{value:h,binLen:8*p+d}};break;case "B64":c=function(a,c,d){var g=0,l,p,f,m,q,u,r,t;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");p=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==p&&p> 8 + bytes[j] &= 0xff + } + + while (carry) { + bytes.push(carry & 0xff) + carry >>= 8 + } + } + // deal with leading zeros + for (i = 0; string[i] === '1' && i < string.length - 1; ++i) bytes.push(0) + + return bytes.reverse() + } +}; + +module.exports = base58; + + +},{}],6:[function(require,module,exports){ +(function (Buffer){ +'use strict'; + +/** + * Credits to https://github.com/cryptocoinjs/blake-hash + */ +Blake256.sigma = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] +] + +Blake256.u256 = [ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 +] + +Blake256.padding = new Buffer([ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +]) + +Blake256.prototype._length_carry = function (arr) { + for (var j = 0; j < arr.length; ++j) { + if (arr[j] < 0x0100000000) break + arr[j] -= 0x0100000000 + arr[j + 1] += 1 + } +} + +Blake256.prototype.update = function (data, encoding) { + data = new Buffer(data, encoding); + var block = this._block + var offset = 0 + + while (this._blockOffset + data.length - offset >= block.length) { + for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] + + this._length[0] += block.length * 8 + this._length_carry(this._length) + + this._compress() + this._blockOffset = 0 + } + + while (offset < data.length) block[this._blockOffset++] = data[offset++] + return this; +} + +var zo = new Buffer([0x01]) +var oo = new Buffer([0x81]) + +function rot (x, n) { + return ((x << (32 - n)) | (x >>> n)) >>> 0 +} + +function g (v, m, i, a, b, c, d, e) { + var sigma = Blake256.sigma + var u256 = Blake256.u256 + + v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 16) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 12) + v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 8) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 7) +} + +function Blake256 () { + this._h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ] + + this._s = [0, 0, 0, 0] + + this._block = new Buffer(64) + this._blockOffset = 0 + this._length = [0, 0] + + this._nullt = false + + this._zo = zo + this._oo = oo +} + +Blake256.prototype._compress = function () { + var u256 = Blake256.u256 + var v = new Array(16) + var m = new Array(16) + var i + + for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) + for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 + for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 + for (i = 12; i < 16; ++i) v[i] = u256[i - 8] + + if (!this._nullt) { + v[12] = (v[12] ^ this._length[0]) >>> 0 + v[13] = (v[13] ^ this._length[0]) >>> 0 + v[14] = (v[14] ^ this._length[1]) >>> 0 + v[15] = (v[15] ^ this._length[1]) >>> 0 + } + + for (i = 0; i < 14; ++i) { + /* column step */ + g(v, m, i, 0, 4, 8, 12, 0) + g(v, m, i, 1, 5, 9, 13, 2) + g(v, m, i, 2, 6, 10, 14, 4) + g(v, m, i, 3, 7, 11, 15, 6) + /* diagonal step */ + g(v, m, i, 0, 5, 10, 15, 8) + g(v, m, i, 1, 6, 11, 12, 10) + g(v, m, i, 2, 7, 8, 13, 12) + g(v, m, i, 3, 4, 9, 14, 14) + } + + for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 + for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 +} + +Blake256.prototype._padding = function () { + var lo = this._length[0] + this._blockOffset * 8 + var hi = this._length[1] + if (lo >= 0x0100000000) { + lo -= 0x0100000000 + hi += 1 + } + + var msglen = new Buffer(8) + msglen.writeUInt32BE(hi, 0) + msglen.writeUInt32BE(lo, 4) + + if (this._blockOffset === 55) { + this._length[0] -= 8 + this.update(this._oo) + } else { + if (this._blockOffset < 55) { + if (this._blockOffset === 0) this._nullt = true + this._length[0] -= (55 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) + } else { + this._length[0] -= (64 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) + this._length[0] -= 55 * 8 + this.update(Blake256.padding.slice(1, 1 + 55)) + this._nullt = true + } + + this.update(this._zo) + this._length[0] -= 8 + } + + this._length[0] -= 64 + this.update(msglen) +} + +Blake256.prototype.digest = function (encoding) { + this._padding() + + var buffer = new Buffer(32) + for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) + return buffer.toString(encoding); +} + +module.exports = Blake256; +}).call(this,require("buffer").Buffer) +},{"buffer":2}],7:[function(require,module,exports){ +var jsSHA = require('jssha'); +var Blake256 = require('./blake256'); + +function numberToHex (number) { + var hex = Math.round(number).toString(16); + if(hex.length === 1) { + hex = '0' + hex; + } + return hex; +} + +var cryptoUtils = { + toHex: function (arrayOfBytes) { + var hex = ''; + for(var i = 0; i < arrayOfBytes.length; i++) { + hex += numberToHex(arrayOfBytes[i]); + } + return hex; + }, + sha256: function (hexString) { + var sha = new jsSHA('SHA-256', 'HEX'); + sha.update(hexString); + return sha.getHash('HEX'); + }, + sha256Checksum: function (payload) { + return this.sha256(this.sha256(payload)).substr(0, 8); + }, + blake256: function (hexString) { + return new Blake256().update(hexString, 'hex').digest('hex'); + }, + blake256Checksum: function (payload) { + return this.blake256(this.blake256(payload)).substr(0, 8); + } +}; + +module.exports = cryptoUtils; + +},{"./blake256":6,"jssha":4}],8:[function(require,module,exports){ +// defines P2PKH and P2SH address types for standard (prod) and testnet networks +var CURRENCIES = [{ + name: 'bitcoin', + symbol: 'btc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'litecoin', + symbol: 'ltc', + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} +},{ + name: 'peercoin', + symbol: 'ppc', + addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} +},{ + name: 'dogecoin', + symbol: 'doge', + addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} +},{ + name: 'beavercoin', + symbol: 'bvc', + addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} +},{ + name: 'freicoin', + symbol: 'frc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'protoshares', + symbol: 'pts', + addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} +},{ + name: 'megacoin', + symbol: 'mec', + addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} +},{ + name: 'primecoin', + symbol: 'xpm', + addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} +},{ + name: 'auroracoin', + symbol: 'aur', + addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} +},{ + name: 'namecoin', + symbol: 'nmc', + addressTypes: {prod: ['34'], testnet: []} +},{ + name: 'biocoin', + symbol: 'bio', + addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} +},{ + name: 'garlicoin', + symbol: 'grlc', + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} +},{ + name: 'vertcoin', + symbol: 'vtc', + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} +},{ + name: 'bitcoingold', + symbol: 'btg', + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} +},{ + name: 'decred', + symbol: 'dcr', + addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, + hashFunction: 'blake256', + expectedLength: 26 +}]; + + +var currencies = { + getByNameOrSymbol: function (currencyNameOrSymbol) { + var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); + for (var i = 0; i < CURRENCIES.length; i++) { + var currency = CURRENCIES[i]; + if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { + return currency; + } + } + return null; + } +}; + +module.exports = currencies; + +},{}],9:[function(require,module,exports){ +var base58 = require('./base58'); +var cryptoUtils = require('./crypto_utils'); +var currencies = require('./currencies'); + +var DEFAULT_CURRENCY_NAME = 'bitcoin', + DEFAULT_NETWORK_TYPE = 'prod'; + +var WAValidator = { + getAddressType: function (address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded; + + try { + decoded = base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } + + var length = decoded.length; + + if (length !== expectedLength) { + return null; + } + + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = this.checksum(hashFunction, body); + + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + }, + + // Each currency may implement different hashing algorithm + checksum: function (hashFunction, payload) { + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); + } + }, + + validate: function (address, currencyNameOrSymbol, networkType) { + currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; + networkType = networkType || DEFAULT_NETWORK_TYPE; + + var correctAddressTypes, + currency = currencies.getByNameOrSymbol(currencyNameOrSymbol), + addressType = this.getAddressType(address, currency); + + if(networkType === 'prod' || networkType === 'testnet'){ + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + } + + return correctAddressTypes.indexOf(addressType) >= 0; + } +}; + +module.exports = WAValidator; + +},{"./base58":5,"./crypto_utils":7,"./currencies":8}]},{},[9])(9) +}); \ No newline at end of file diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 1eee780d..97039722 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -"use strict";!function(e){function r(e,r,t){var c,d,f,l,h,p,m,b,y,w=0,g=[],E=0,H=!1,T=[],k=[],U=!1;if(c=(t=t||{}).encoding||"UTF8",(y=t.numRounds||1)!==parseInt(y,10)||1>y)throw Error("numRounds must a integer >= 1");if(0!==e.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(p=function(r,t){return v(r,t,e)},m=function(r,t,n,o){var a,s;if("SHA-224"!==e&&"SHA-256"!==e)throw Error("Unexpected error in SHA-2 implementation");for(a=15+(t+65>>>9<<4),s=16;r.length<=a;)r.push(0);for(r[t>>>5]|=128<<24-t%32,t+=n,r[a]=4294967295&t,r[a-1]=t/4294967296|0,n=r.length,t=0;t>>3)/4-1,or/8){for(;t.length<=n;)t.push(0);t[n]&=4294967040}for(r=0;r<=n;r+=1)T[r]=909522486^t[r],k[r]=1549556828^t[r];d=p(T,d),w=h,H=!0},this.update=function(e){var r,t,n,o=0,a=h>>>5;for(e=(r=f(e,g,E)).binLen,t=r.value,r=e>>>5,n=0;n>>5),E=e%h,U=!0},this.getHash=function(r,t){var u,c,f,h;if(!0===H)throw Error("Cannot call getHash after setting HMAC key");switch(f=i(t),r){case"HEX":u=function(e){return n(e,l,f)};break;case"B64":u=function(e){return o(e,l,f)};break;case"BYTES":u=function(e){return a(e,l)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}u=function(e){return s(e,l)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(h=m(g.slice(),E,w,b(d)),c=1;c>>2]>>>8*(3+n%4*-1),a+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return t.outputUpper?a.toUpperCase():a}function o(e,r,t){var n,o,a,s="",i=r/8;for(n=0;n>>2]:0,a=n+2>>2]:0,a=(e[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|a>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6*(3-o)&63):t.b64Pad;return s}function a(e,r){var t,n,o="",a=r/8;for(t=0;t>>2]>>>8*(3+t%4*-1)&255,o+=String.fromCharCode(n);return o}function s(e,r){var t,n,o=r/8,a=new ArrayBuffer(o);for(n=new Uint8Array(a),t=0;t>>2]>>>8*(3+t%4*-1)&255;return a}function i(e){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(e=e||{},r.outputUpper=e.outputUpper||!1,!0===e.hasOwnProperty("b64Pad")&&(r.b64Pad=e.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function u(e,r){var t;switch(r){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":t=function(e,r,t){var n,o,a,s,i,u=e.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],i=(t=t||0)>>>3,n=0;n>>1)+i)>>>2;r.length<=a;)r.push(0);r[a]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+t}};break;case"TEXT":t=function(e,t,n){var o,a,s,i,u,c,d,f,l=0;if(t=t||[0],u=(n=n||0)>>>3,"UTF8"===r)for(f=3,s=0;s(o=e.charCodeAt(s))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(s)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),i=0;i>>2;t.length<=c;)t.push(0);t[c]|=a[i]<<8*(f+d%4*-1),l+=1}else if("UTF16BE"===r||"UTF16LE"===r)for(f=2,a="UTF16LE"===r||"UTF16LE"!==r&&!1,s=0;s>>8),c=(d=l+u)>>>2;t.length<=c;)t.push(0);t[c]|=o<<8*(f+d%4*-1),l+=2}return{value:t,binLen:8*l+n}};break;case"B64":t=function(e,r,t){var n,o,a,s,i,u,c,d=0;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=e.indexOf("="),e=e.replace(/\=/g,""),-1!==o&&o>16&255,i[a++]=n>>8&255,i[a++]=255&n;2===o?(n=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,i[a++]=255&n):1===o&&(n=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,i[a++]=n>>8&255,i[a++]=255&n);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o="",i=[],s=16383,a=0,f=r-n;a>2],o+=u[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=u[e>>10],o+=u[e>>4&63],o+=u[e<<2&63],o+="=");return i.push(o),i.join("")};for(var u=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],2:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=c,r.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return R(t).length;default:if(n)return I(t).length;e=(""+e).toLowerCase(),n=!0}}function w(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:d(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):d(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function d(t,e,r,n,o){var i,s=1,a=t.length,f=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,f/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=E)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},c.prototype.compare=function(t,e,r,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),f=this.slice(n,o),u=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,f,u,h,c,l,p,w=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,O(I(t,(c=this).length-l),c,l,p);case"ascii":return y(this,t,e,r);case"latin1":case"binary":return y(this,t,e,r);case"base64":return f=this,u=e,h=r,O(R(t),f,u,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,O(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(w)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),w=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function T(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(t,e,r,n,o){return e=+e,r>>>=0,o||T(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,o){return e=+e,r>>>=0,o||T(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||U(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||U(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||U(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||U(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||U(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||U(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||U(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||U(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||k(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||k(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);k(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);k(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return H(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return H(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function R(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":1,ieee754:3}],3:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,f=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,w=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(e+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(e*f-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&a,p+=w,a/=256,o-=8);for(s=s<= 1");if("SHA-1"===s)c=512,h=J,l=G,u=160,p=function(t){return t.slice()};else if(0===s.lastIndexOf("SHA-",0))if(h=function(t,e){return Q(t,e,s)},l=function(t,e,r,n){var o,i;if("SHA-224"===s||"SHA-256"===s)o=15+(e+65>>>9<<4),i=16;else{if("SHA-384"!==s&&"SHA-512"!==s)throw Error("Unexpected error in SHA-2 implementation");o=31+(e+129>>>10<<5),i=32}for(;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>5,u=0,h=e>>>5;for(i=0;i>>3)>>2]^=s<=o));)a.push(t.a),0==64*(u+=1)%r&&$(null,n);return a}}f=C(t,o,A),a=Z(s),this.setHMACKey=function(t,e,r){var n;if(!0===y)throw Error("HMAC key already set");if(!0===m)throw Error("Cannot set HMAC key after calling update");if(!0===E)throw Error("SHAKE is not supported for HMAC");if(t=(e=C(e,o=(r||{}).encoding||"UTF8",A)(t)).binLen,e=e.value,r=(n=c>>>3)/4-1,n>>5;for(t=(e=f(t,d,b)).binLen,r=e.value,e=t>>>5,n=0;n>>5),b=t%c,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===y)throw Error("Cannot call getHash after setting HMAC key");if(o=H(e),!0===E){if(-1===o.shakeLen)throw Error("shakeLen must be specified in options");u=o.shakeLen}switch(t){case"HEX":r=function(t){return _(t,u,A,o)};break;case"B64":r=function(t){return S(t,u,A,o)};break;case"BYTES":r=function(t){return U(t,u,A)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return T(t,u,A)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(d.slice(),b,g,p(a),u),n=1;n>>24-u%32),i=l(i,u,0,Z(s),u);return r(i)},this.getHMAC=function(t,e){var r,n,o,i;if(!1===y)throw Error("Cannot call getHMAC without first setting HMAC key");switch(o=H(e),t){case"HEX":r=function(t){return _(t,u,A,o)};break;case"B64":r=function(t){return S(t,u,A,o)};break;case"BYTES":r=function(t){return U(t,u,A)};break;case"ARRAYBUFFER":try{r=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return T(t,u,A)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")}return n=l(d.slice(),b,g,p(a),u),i=h(v,Z(s)),r(i=l(n,u,c,i,u))}}function k(t,e){this.a=t,this.b=e}function _(t,e,r,n){var o,i,s,a="";for(e/=8,s=-1===r?3:0,o=0;o>>2]>>>8*(s+o%4*r),a+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return n.outputUpper?a.toUpperCase():a}function S(t,e,r,n){var o,i,s,a,f="",u=e/8;for(a=-1===r?3:0,o=0;o>>2]:0,s=o+2>>2]:0,s=(t[o>>>2]>>>8*(a+o%4*r)&255)<<16|(i>>>8*(a+(o+1)%4*r)&255)<<8|s>>>8*(a+(o+2)%4*r)&255,i=0;i<4;i+=1)f+=8*o+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(s>>>6*(3-i)&63):n.b64Pad;return f}function U(t,e,r){var n,o,i,s="";for(e/=8,i=-1===r?3:0,n=0;n>>2]>>>8*(i+n%4*r)&255,s+=String.fromCharCode(o);return s}function T(t,e,r){e/=8;var n,o,i,s=new ArrayBuffer(e);for(i=new Uint8Array(s),o=-1===r?3:0,n=0;n>>2]>>>8*(o+n%4*r)&255;return s}function H(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),!0===t.hasOwnProperty("shakeLen")){if(0!=t.shakeLen%8)throw Error("shakeLen must be a multiple of 8");e.shakeLen=t.shakeLen}if("boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function C(t,l,p){switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":t=function(t,e,r){var n,o,i,s,a,f,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,f=-1===p?3:0,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(f+s%4*p)}return{value:e,binLen:4*u+r}};break;case"TEXT":t=function(t,e,r){var n,o,i,s,a,f,u,h,c=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(h=-1===p?3:0,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=f;)e.push(0);e[f]|=o[s]<<8*(h+u%4*p),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=-1===p?2:0,o="UTF16LE"===l&&1!==p||"UTF16LE"!==l&&1===p,i=0;i>>8),f=(u=c+a)>>>2;e.length<=f;)e.push(0);e[f]|=n<<8*(h+u%4*p),c+=2}return{value:e,binLen:8*c+r}};break;case"B64":t=function(t,e,r){var n,o,i,s,a,f,u,h,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o> 8 - bytes[j] &= 0xff - } - - while (carry) { - bytes.push(carry & 0xff) - carry >>= 8 - } + +var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' +var ALPHABET_MAP = {} +for(var i = 0; i < ALPHABET.length; ++i) { + ALPHABET_MAP[ALPHABET.charAt(i)] = i +} +var BASE = ALPHABET.length + +var base58 = { + decode: function(string) { + if (string.length === 0) return [] + + var i, j, bytes = [0] + for (i = 0; i < string.length; ++i) { + var c = string[i] + if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character') + + for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE + bytes[0] += ALPHABET_MAP[c] + + var carry = 0 + for (j = 0; j < bytes.length; ++j) { + bytes[j] += carry + carry = bytes[j] >> 8 + bytes[j] &= 0xff } - // deal with leading zeros - for (i = 0; string[i] === '1' && i < string.length - 1; ++i) bytes.push(0) - return bytes.reverse() - } - }; - - // export base58 module - if(isNode) { - module.exports = base58; - } else { - if(typeof window.WAValidator === 'undefined'){ - window.WAValidator = {__imports: {}}; + while (carry) { + bytes.push(carry & 0xff) + carry >>= 8 + } } - window.WAValidator.__imports.base58 = base58; + // deal with leading zeros + for (i = 0; string[i] === '1' && i < string.length - 1; ++i) bytes.push(0) + + return bytes.reverse() } -})(typeof module !== 'undefined' && typeof module.exports !== 'undefined'); +}; + +module.exports = base58; diff --git a/src/blake256.js b/src/blake256.js new file mode 100644 index 00000000..8136fcf6 --- /dev/null +++ b/src/blake256.js @@ -0,0 +1,188 @@ +'use strict'; + +/** + * Credits to https://github.com/cryptocoinjs/blake-hash + */ +Blake256.sigma = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] +] + +Blake256.u256 = [ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 +] + +Blake256.padding = new Buffer([ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +]) + +Blake256.prototype._length_carry = function (arr) { + for (var j = 0; j < arr.length; ++j) { + if (arr[j] < 0x0100000000) break + arr[j] -= 0x0100000000 + arr[j + 1] += 1 + } +} + +Blake256.prototype.update = function (data, encoding) { + data = new Buffer(data, encoding); + var block = this._block + var offset = 0 + + while (this._blockOffset + data.length - offset >= block.length) { + for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] + + this._length[0] += block.length * 8 + this._length_carry(this._length) + + this._compress() + this._blockOffset = 0 + } + + while (offset < data.length) block[this._blockOffset++] = data[offset++] + return this; +} + +var zo = new Buffer([0x01]) +var oo = new Buffer([0x81]) + +function rot (x, n) { + return ((x << (32 - n)) | (x >>> n)) >>> 0 +} + +function g (v, m, i, a, b, c, d, e) { + var sigma = Blake256.sigma + var u256 = Blake256.u256 + + v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 16) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 12) + v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 8) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 7) +} + +function Blake256 () { + this._h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ] + + this._s = [0, 0, 0, 0] + + this._block = new Buffer(64) + this._blockOffset = 0 + this._length = [0, 0] + + this._nullt = false + + this._zo = zo + this._oo = oo +} + +Blake256.prototype._compress = function () { + var u256 = Blake256.u256 + var v = new Array(16) + var m = new Array(16) + var i + + for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) + for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 + for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 + for (i = 12; i < 16; ++i) v[i] = u256[i - 8] + + if (!this._nullt) { + v[12] = (v[12] ^ this._length[0]) >>> 0 + v[13] = (v[13] ^ this._length[0]) >>> 0 + v[14] = (v[14] ^ this._length[1]) >>> 0 + v[15] = (v[15] ^ this._length[1]) >>> 0 + } + + for (i = 0; i < 14; ++i) { + /* column step */ + g(v, m, i, 0, 4, 8, 12, 0) + g(v, m, i, 1, 5, 9, 13, 2) + g(v, m, i, 2, 6, 10, 14, 4) + g(v, m, i, 3, 7, 11, 15, 6) + /* diagonal step */ + g(v, m, i, 0, 5, 10, 15, 8) + g(v, m, i, 1, 6, 11, 12, 10) + g(v, m, i, 2, 7, 8, 13, 12) + g(v, m, i, 3, 4, 9, 14, 14) + } + + for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 + for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 +} + +Blake256.prototype._padding = function () { + var lo = this._length[0] + this._blockOffset * 8 + var hi = this._length[1] + if (lo >= 0x0100000000) { + lo -= 0x0100000000 + hi += 1 + } + + var msglen = new Buffer(8) + msglen.writeUInt32BE(hi, 0) + msglen.writeUInt32BE(lo, 4) + + if (this._blockOffset === 55) { + this._length[0] -= 8 + this.update(this._oo) + } else { + if (this._blockOffset < 55) { + if (this._blockOffset === 0) this._nullt = true + this._length[0] -= (55 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) + } else { + this._length[0] -= (64 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) + this._length[0] -= 55 * 8 + this.update(Blake256.padding.slice(1, 1 + 55)) + this._nullt = true + } + + this.update(this._zo) + this._length[0] -= 8 + } + + this._length[0] -= 64 + this.update(msglen) +} + +Blake256.prototype.digest = function (encoding) { + this._padding() + + var buffer = new Buffer(32) + for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) + return buffer.toString(encoding); +} + +module.exports = Blake256; \ No newline at end of file diff --git a/src/crypto_utils.js b/src/crypto_utils.js index 4dc533ba..2afdc1bb 100644 --- a/src/crypto_utils.js +++ b/src/crypto_utils.js @@ -1,46 +1,36 @@ -(function (isNode) { - var jsSHA = isNode ? require('jssha') : window.jsSHA; - var blakeHash = require('blake-hash'); +var jsSHA = require('jssha'); +var Blake256 = require('./blake256'); - function numberToHex (number) { - var hex = Math.round(number).toString(16); - if(hex.length == 1) { - hex = '0' + hex; - } - return hex; +function numberToHex (number) { + var hex = Math.round(number).toString(16); + if(hex.length === 1) { + hex = '0' + hex; } + return hex; +} - var cryptoUtils = { - toHex: function (arrayOfBytes) { - var hex = ''; - for(var i = 0; i < arrayOfBytes.length; i++) { - hex += numberToHex(arrayOfBytes[i]); - } - return hex; - }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX'); - sha.update(hexString) - return sha.getHash('HEX'); - }, - sha256Checksum: function (payload) { - return this.sha256(this.sha256(payload)).substr(0, 8); - }, - blake256: function (hexString) { - return blakeHash('blake256').update(hexString, 'hex').digest('hex'); - }, - blake256Checksum: function (payload) { - return this.blake256(this.blake256(payload)).substr(0, 8); - } - }; - - // export cryptoUtils module - if(isNode) { - module.exports = cryptoUtils; - } else { - if(typeof window.WAValidator === 'undefined'){ - window.WAValidator = {__imports: {}}; +var cryptoUtils = { + toHex: function (arrayOfBytes) { + var hex = ''; + for(var i = 0; i < arrayOfBytes.length; i++) { + hex += numberToHex(arrayOfBytes[i]); } - window.WAValidator.__imports.cryptoUtils = cryptoUtils; + return hex; + }, + sha256: function (hexString) { + var sha = new jsSHA('SHA-256', 'HEX'); + sha.update(hexString); + return sha.getHash('HEX'); + }, + sha256Checksum: function (payload) { + return this.sha256(this.sha256(payload)).substr(0, 8); + }, + blake256: function (hexString) { + return new Blake256().update(hexString, 'hex').digest('hex'); + }, + blake256Checksum: function (payload) { + return this.blake256(this.blake256(payload)).substr(0, 8); } -})(typeof module !== 'undefined' && typeof module.exports !== 'undefined'); +}; + +module.exports = cryptoUtils; diff --git a/src/currencies.js b/src/currencies.js index c9f4930b..cf885579 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -1,94 +1,84 @@ -(function (isNode) { - // defines P2PKH and P2SH address types for standard (prod) and testnet networks - var CURRENCIES = [{ - name: 'bitcoin', - symbol: 'btc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} - },{ - name: 'litecoin', - symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} - },{ - name: 'peercoin', - symbol: 'ppc', - addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} - },{ - name: 'dogecoin', - symbol: 'doge', - addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} - },{ - name: 'beavercoin', - symbol: 'bvc', - addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} - },{ - name: 'freicoin', - symbol: 'frc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} - },{ - name: 'protoshares', - symbol: 'pts', - addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} - },{ - name: 'megacoin', - symbol: 'mec', - addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} - },{ - name: 'primecoin', - symbol: 'xpm', - addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} - },{ - name: 'auroracoin', - symbol: 'aur', - addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} - },{ - name: 'namecoin', - symbol: 'nmc', - addressTypes: {prod: ['34'], testnet: []} - },{ - name: 'biocoin', - symbol: 'bio', - addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} - },{ - name: 'garlicoin', - symbol: 'grlc', - addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} - },{ - name: 'vertcoin', - symbol: 'vtc', - addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} - },{ - name: 'bitcoingold', - symbol: 'btg', - addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} - },{ - name: 'decred', - symbol: 'dcr', - addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, - hashFunction: 'blake256', - expectedLength: 26 - }]; +// defines P2PKH and P2SH address types for standard (prod) and testnet networks +var CURRENCIES = [{ + name: 'bitcoin', + symbol: 'btc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'litecoin', + symbol: 'ltc', + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} +},{ + name: 'peercoin', + symbol: 'ppc', + addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} +},{ + name: 'dogecoin', + symbol: 'doge', + addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} +},{ + name: 'beavercoin', + symbol: 'bvc', + addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} +},{ + name: 'freicoin', + symbol: 'frc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'protoshares', + symbol: 'pts', + addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} +},{ + name: 'megacoin', + symbol: 'mec', + addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} +},{ + name: 'primecoin', + symbol: 'xpm', + addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} +},{ + name: 'auroracoin', + symbol: 'aur', + addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} +},{ + name: 'namecoin', + symbol: 'nmc', + addressTypes: {prod: ['34'], testnet: []} +},{ + name: 'biocoin', + symbol: 'bio', + addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} +},{ + name: 'garlicoin', + symbol: 'grlc', + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} +},{ + name: 'vertcoin', + symbol: 'vtc', + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} +},{ + name: 'bitcoingold', + symbol: 'btg', + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} +},{ + name: 'decred', + symbol: 'dcr', + addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, + hashFunction: 'blake256', + expectedLength: 26 +}]; - var currencies = { - getByNameOrSymbol: function (currencyNameOrSymbol) { - var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); - for (var i = 0; i < CURRENCIES.length; i++) { - var currency = CURRENCIES[i]; - if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { - return currency; - } +var currencies = { + getByNameOrSymbol: function (currencyNameOrSymbol) { + var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); + for (var i = 0; i < CURRENCIES.length; i++) { + var currency = CURRENCIES[i]; + if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { + return currency; } - return null; } - }; - - // export currencies module - if(isNode) { - module.exports = currencies; - } else { - if(typeof window.WAValidator === 'undefined'){ - window.WAValidator = {__imports: {}}; - } - window.WAValidator.__imports.currencies = currencies; + return null; } -})(typeof module !== 'undefined' && typeof module.exports !== 'undefined'); +}; + +module.exports = currencies; diff --git a/src/wallet_address_validator.js b/src/wallet_address_validator.js index 4a560870..6e187167 100644 --- a/src/wallet_address_validator.js +++ b/src/wallet_address_validator.js @@ -1,82 +1,66 @@ -(function (isNode) { - var base58, cryptoUtils, currencies; +var base58 = require('./base58'); +var cryptoUtils = require('./crypto_utils'); +var currencies = require('./currencies'); - if(isNode) { - base58 = require('./base58'); - cryptoUtils = require('./crypto_utils'); - currencies = require('./currencies'); - } else { - var imports = window.WAValidator.__imports; - base58 = imports.base58; - cryptoUtils = imports.cryptoUtils; - currencies = imports.currencies; - } - - var DEFAULT_CURRENCY_NAME = 'bitcoin', - DEFAULT_NETWORK_TYPE = 'prod'; +var DEFAULT_CURRENCY_NAME = 'bitcoin', + DEFAULT_NETWORK_TYPE = 'prod'; - var WAValidator = { - getAddressType: function (address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded; +var WAValidator = { + getAddressType: function (address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded; - try { - decoded = base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } - - var length = decoded.length; + try { + decoded = base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } - if (length != expectedLength) { - return null; - } + var length = decoded.length; - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = this.checksum(hashFunction, body); + if (length !== expectedLength) { + return null; + } - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; - }, + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = this.checksum(hashFunction, body); - // Each currency may implement different hashing algorithm - checksum: function (hashFunction, payload) { - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); - } - }, + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + }, - validate: function (address, currencyNameOrSymbol, networkType) { - currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; - networkType = networkType || DEFAULT_NETWORK_TYPE; + // Each currency may implement different hashing algorithm + checksum: function (hashFunction, payload) { + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); + } + }, - var correctAddressTypes, - currency = currencies.getByNameOrSymbol(currencyNameOrSymbol), - addressType = this.getAddressType(address, currency); + validate: function (address, currencyNameOrSymbol, networkType) { + currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; + networkType = networkType || DEFAULT_NETWORK_TYPE; - if(networkType === 'prod' || networkType === 'testnet'){ - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); - } + var correctAddressTypes, + currency = currencies.getByNameOrSymbol(currencyNameOrSymbol), + addressType = this.getAddressType(address, currency); - return correctAddressTypes.indexOf(addressType) >= 0; + if(networkType === 'prod' || networkType === 'testnet'){ + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); } - }; - // export WAValidator module - if(isNode) { - module.exports = WAValidator; - } else { - window.WAValidator = WAValidator; + return correctAddressTypes.indexOf(addressType) >= 0; } -})(typeof module !== 'undefined' && typeof module.exports !== 'undefined'); +}; + +module.exports = WAValidator; diff --git a/test/runner.html b/test/runner.html deleted file mode 100644 index e791858d..00000000 --- a/test/runner.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - Mocha Tests - - - - -
- - - - - - - - - - - - - \ No newline at end of file diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index ef0508ac..01dd718d 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -1,4 +1,4 @@ -var isNode = typeof module !== 'undefined' && typeof module.exports !== 'undefined' +var isNode = typeof module !== 'undefined' && typeof module.exports !== 'undefined'; var chai = isNode ? require('chai') : window.chai, expect = chai.expect; @@ -189,7 +189,7 @@ describe('WAValidator.validate()', function () { }); it('should return true for correct Decred addresses', function () { - valid('Dsesax2GJnMN4wwmWo5rJGq73dDK217Rh85', 'dcr'); + valid('Dsesax2GJnMN4wwmWo5rJGq73dDK217Rh85', 'DCR'); valid('DsYuxtvGRfN8rncXAndtLUpJm55F77K17RA', 'decred'); valid('DsaXDG2NrJW8g4tFAb8n9MNx81Sn3Qc8AEV', 'decred'); valid('TsijUgejaRnLKF5WAbpUxNtwKGUiKVeXLr7', 'decred', 'testnet'); From 994f6306b3ffc6c5d03b9d952a66d00b6b66cc77 Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Thu, 8 Mar 2018 20:48:56 +0900 Subject: [PATCH 011/108] Travis CI workaround for Headless Chrome, https://github.com/travis-ci/travis-ci/issues/8836 --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0611ff21..b4451656 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ +sudo: required +addons: + chrome: stable language: node_js node_js: - "4" From 71e7cdf7b76eba2a88176a57224449aef021c13d Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Tue, 6 Mar 2018 20:20:11 +0900 Subject: [PATCH 012/108] Added Ethereum and Digibyte currencies --- README.md | 10 +- dist/wallet-address-validator.js | 1019 ++++++++++++++++++++-- dist/wallet-address-validator.min.js | 2 +- package.json | 3 + src/{ => crypto}/base58.js | 0 src/{ => crypto}/blake256.js | 0 src/crypto/sha3.js | 640 ++++++++++++++ src/{crypto_utils.js => crypto/utils.js} | 6 +- src/currencies.js | 21 + src/ethereum_validator.js | 34 + src/wallet_address_validator.js | 64 +- test/wallet_address_validator.js | 46 + 12 files changed, 1748 insertions(+), 97 deletions(-) rename src/{ => crypto}/base58.js (100%) rename src/{ => crypto}/blake256.js (100%) create mode 100644 src/crypto/sha3.js rename src/{crypto_utils.js => crypto/utils.js} (84%) create mode 100644 src/ethereum_validator.js diff --git a/README.md b/README.md index c83940c1..5df691b5 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Simple wallet address validator for validating Bitcoin and other altcoins addres Forked from [ryanralph/altcoin-address](https://github.com/ryanralph/altcoin-address). -**File size is ~15 kB (minifed and gzipped)**. +**File size is ~17 kB (minifed and gzipped)**. ## Installation @@ -53,6 +53,14 @@ npm install wallet-address-validator * Vertcoin/VTC, `'vertcoin'` or `'VTC'` * BitcoinGold/BTG, `'bitcoingold'` or `'BTG'` * Decred/DCR, `'decred'` or `'DCR'` +* Digibyte/DGB, `'digibyte'` or `'DGB'` + + +* Ethereum/ETH, `'ethereum'` or `'ETH'` +* EthereumClassic/ETH, `'ethereumclassic'` or `'ETC'` +* EthereumZero/ETZ, `'etherzero'` or `'ETZ'` +* Callisto/CLO, `'callisto'` or `'CLO'` + ### Usage example diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index ef1ce981..31cd56fe 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1952,42 +1952,212 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { Several functions taken from Paul Johnston */ -'use strict';(function(Y){function C(c,a,b){var e=0,h=[],n=0,g,l,d,f,m,q,u,r,I=!1,v=[],w=[],t,y=!1,z=!1,x=-1;b=b||{};g=b.encoding||"UTF8";t=b.numRounds||1;if(t!==parseInt(t,10)||1>t)throw Error("numRounds must a integer >= 1");if("SHA-1"===c)m=512,q=K,u=Z,f=160,r=function(a){return a.slice()};else if(0===c.lastIndexOf("SHA-",0))if(q=function(a,b){return L(a,b,c)},u=function(a,b,h,e){var k,f;if("SHA-224"===c||"SHA-256"===c)k=(b+65>>>9<<4)+15,f=16;else if("SHA-384"===c||"SHA-512"===c)k=(b+129>>>10<< -5)+31,f=32;else throw Error("Unexpected error in SHA-2 implementation");for(;a.length<=k;)a.push(0);a[b>>>5]|=128<<24-b%32;b=b+h;a[k]=b&4294967295;a[k-1]=b/4294967296|0;h=a.length;for(b=0;be;e+=1)c[e]=a[e].slice();return c};x=1;if("SHA3-224"=== -c)m=1152,f=224;else if("SHA3-256"===c)m=1088,f=256;else if("SHA3-384"===c)m=832,f=384;else if("SHA3-512"===c)m=576,f=512;else if("SHAKE128"===c)m=1344,f=-1,F=31,z=!0;else if("SHAKE256"===c)m=1088,f=-1,F=31,z=!0;else throw Error("Chosen SHA variant is not supported");u=function(a,c,e,b,h){e=m;var k=F,f,g=[],n=e>>>5,l=0,d=c>>>5;for(f=0;f=e;f+=n)b=D(a.slice(f,f+n),b),c-=e;a=a.slice(f);for(c%=e;a.length>>3;a[f>>2]^=k<=h)break;g.push(a.a);l+=1;0===64*l%e&&D(null,b)}return g}}else throw Error("Chosen SHA variant is not supported");d=M(a,g,x);l=A(c);this.setHMACKey=function(a,b,h){var k;if(!0===I)throw Error("HMAC key already set");if(!0===y)throw Error("Cannot set HMAC key after calling update");if(!0===z)throw Error("SHAKE is not supported for HMAC");g=(h||{}).encoding||"UTF8";b=M(b,g,x)(a);a=b.binLen;b=b.value;k=m>>>3;h=k/4-1;if(k
a/8){for(;b.length<=h;)b.push(0);b[h]&=4294967040}for(a=0;a<=h;a+=1)v[a]=b[a]^909522486,w[a]=b[a]^1549556828;l=q(v,l);e=m;I=!0};this.update=function(a){var c,b,k,f=0,g=m>>>5;c=d(a,h,n);a=c.binLen;b=c.value;c=a>>>5;for(k=0;k>>5);n=a%m;y=!0};this.getHash=function(a,b){var k,g,d,m;if(!0===I)throw Error("Cannot call getHash after setting HMAC key");d=N(b);if(!0===z){if(-1===d.shakeLen)throw Error("shakeLen must be specified in options"); -f=d.shakeLen}switch(a){case "HEX":k=function(a){return O(a,f,x,d)};break;case "B64":k=function(a){return P(a,f,x,d)};break;case "BYTES":k=function(a){return Q(a,f,x)};break;case "ARRAYBUFFER":try{g=new ArrayBuffer(0)}catch(p){throw Error("ARRAYBUFFER not supported by this environment");}k=function(a){return R(a,f,x)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");}m=u(h.slice(),n,e,r(l),f);for(g=1;g>>24-f%32),m=u(m,f, -0,A(c),f);return k(m)};this.getHMAC=function(a,b){var k,g,d,p;if(!1===I)throw Error("Cannot call getHMAC without first setting HMAC key");d=N(b);switch(a){case "HEX":k=function(a){return O(a,f,x,d)};break;case "B64":k=function(a){return P(a,f,x,d)};break;case "BYTES":k=function(a){return Q(a,f,x)};break;case "ARRAYBUFFER":try{k=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}k=function(a){return R(a,f,x)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER"); -}g=u(h.slice(),n,e,r(l),f);p=q(w,A(c));p=u(g,f,m,p,f);return k(p)}}function b(c,a){this.a=c;this.b=a}function O(c,a,b,e){var h="";a/=8;var n,g,d;d=-1===b?3:0;for(n=0;n>>2]>>>8*(d+n%4*b),h+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return e.outputUpper?h.toUpperCase():h}function P(c,a,b,e){var h="",n=a/8,g,d,p,f;f=-1===b?3:0;for(g=0;g>>2]:0,p=g+2>>2]:0,p=(c[g>>>2]>>>8*(f+g%4*b)&255)<<16|(d>>>8*(f+(g+1)%4*b)&255)<<8|p>>>8*(f+ -(g+2)%4*b)&255,d=0;4>d;d+=1)8*g+6*d<=a?h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(p>>>6*(3-d)&63):h+=e.b64Pad;return h}function Q(c,a,b){var e="";a/=8;var h,d,g;g=-1===b?3:0;for(h=0;h>>2]>>>8*(g+h%4*b)&255,e+=String.fromCharCode(d);return e}function R(c,a,b){a/=8;var e,h=new ArrayBuffer(a),d,g;g=new Uint8Array(h);d=-1===b?3:0;for(e=0;e>>2]>>>8*(d+e%4*b)&255;return h}function N(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{}; -a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if(!0===c.hasOwnProperty("shakeLen")){if(0!==c.shakeLen%8)throw Error("shakeLen must be a multiple of 8");a.shakeLen=c.shakeLen}if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function M(c,a,b){switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE"); -}switch(c){case "HEX":c=function(a,c,d){var g=a.length,l,p,f,m,q,u;if(0!==g%2)throw Error("String of HEX type must be in byte increments");c=c||[0];d=d||0;q=d>>>3;u=-1===b?3:0;for(l=0;l>>1)+q;for(f=m>>>2;c.length<=f;)c.push(0);c[f]|=p<<8*(u+m%4*b)}return{value:c,binLen:4*g+d}};break;case "TEXT":c=function(c,h,d){var g,l,p=0,f,m,q,u,r,t;h=h||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(t=-1=== -b?3:0,f=0;fg?l.push(g):2048>g?(l.push(192|g>>>6),l.push(128|g&63)):55296>g||57344<=g?l.push(224|g>>>12,128|g>>>6&63,128|g&63):(f+=1,g=65536+((g&1023)<<10|c.charCodeAt(f)&1023),l.push(240|g>>>18,128|g>>>12&63,128|g>>>6&63,128|g&63)),m=0;m>>2;h.length<=u;)h.push(0);h[u]|=l[m]<<8*(t+r%4*b);p+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(t=-1===b?2:0,l="UTF16LE"===a&&1!==b||"UTF16LE"!==a&&1===b,f=0;f>>8);r=p+q;for(u=r>>>2;h.length<=u;)h.push(0);h[u]|=g<<8*(t+r%4*b);p+=2}return{value:h,binLen:8*p+d}};break;case "B64":c=function(a,c,d){var g=0,l,p,f,m,q,u,r,t;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");p=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==p&&pu)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; +b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> +5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); +}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> +6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==k&&k 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],6:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -2036,7 +2206,7 @@ var base58 = { module.exports = base58; -},{}],6:[function(require,module,exports){ +},{}],7:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2227,9 +2397,654 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":2}],7:[function(require,module,exports){ -var jsSHA = require('jssha'); +},{"buffer":2}],8:[function(require,module,exports){ +(function (process,global){ +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.7.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2017 + * @license MIT + */ +/*jslint bitwise: true */ +'use strict'; + +var ERROR = 'input is invalid type'; +var WINDOW = typeof window === 'object'; +var root = WINDOW ? window : {}; +if (root.JS_SHA3_NO_WINDOW) { + WINDOW = false; +} +var WEB_WORKER = !WINDOW && typeof self === 'object'; +var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; +if (NODE_JS) { + root = global; +} else if (WEB_WORKER) { + root = self; +} +var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; +var HEX_CHARS = '0123456789abcdef'.split(''); +var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; +var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; +var KECCAK_PADDING = [1, 256, 65536, 16777216]; +var PADDING = [6, 1536, 393216, 100663296]; +var SHIFT = [0, 8, 16, 24]; +var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; +var BITS = [224, 256, 384, 512]; +var SHAKE_BITS = [128, 256]; +var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; +var CSHAKE_BYTEPAD = { + '128': 168, + '256': 136 +}; + +if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { + Array.isArray = function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; +} + +if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { + ArrayBuffer.isView = function (obj) { + return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; + }; +} + +var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; +}; + +var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; +}; + +var createCshakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits, n, s) { + return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); + }; +}; + +var createKmacOutputMethod = function (bits, padding, outputType) { + return function (key, message, outputBits, s) { + return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); + }; +}; + +var createOutputMethods = function (method, createMethod, bits, padding) { + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createMethod(bits, padding, type); + } + return method; +}; + +var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + return createOutputMethods(method, createOutputMethod, bits, padding); +}; + +var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + return createOutputMethods(method, createShakeOutputMethod, bits, padding); +}; + +var createCshakeMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createCshakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits, n, s) { + if (!n && !s) { + return methods['shake' + bits].create(outputBits); + } else { + return new Keccak(bits, padding, outputBits).bytepad([n, s], w); + } + }; + method.update = function (message, outputBits, n, s) { + return method.create(outputBits, n, s).update(message); + }; + return createOutputMethods(method, createCshakeOutputMethod, bits, padding); +}; + +var createKmacMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createKmacOutputMethod(bits, padding, 'hex'); + method.create = function (key, outputBits, s) { + return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); + }; + method.update = function (key, message, outputBits, s) { + return method.create(key, outputBits, s).update(message); + }; + return createOutputMethods(method, createKmacOutputMethod, bits, padding); +}; + +var algorithms = [ + { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, + { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, + { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, + { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, + { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } +]; + +var methods = {}, methodNames = []; + +for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name + '_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + if (algorithm.name !== 'sha3') { + var newMethodName = algorithm.name + bits[j]; + methodNames.push(newMethodName); + methods[newMethodName] = methods[methodName]; + } + } +} + +function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.finalized = false; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } +} + +Keccak.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString, type = typeof message; + if (type !== 'string') { + if (type === 'object') { + if (message === null) { + throw ERROR; + } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (!Array.isArray(message)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var blocks = this.blocks, byteCount = this.byteCount, length = message.length, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; +}; + +Keccak.prototype.encode = function (x, right) { + var o = x & 255, n = 1; + var bytes = [o]; + x = x >> 8; + o = x & 255; + while (o > 0) { + bytes.unshift(o); + x = x >> 8; + o = x & 255; + ++n; + } + if (right) { + bytes.push(n); + } else { + bytes.unshift(n); + } + this.update(bytes); + return bytes.length; +}; + +Keccak.prototype.encodeString = function (str) { + var notString, type = typeof str; + if (type !== 'string') { + if (type === 'object') { + if (str === null) { + throw ERROR; + } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { + str = new Uint8Array(str); + } else if (!Array.isArray(str)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var bytes = 0, length = str.length; + if (notString) { + bytes = length; + } else { + for (var i = 0; i < str.length; ++i) { + var code = str.charCodeAt(i); + if (code < 0x80) { + bytes += 1; + } else if (code < 0x800) { + bytes += 2; + } else if (code < 0xd800 || code >= 0xe000) { + bytes += 3; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); + bytes += 4; + } + } + } + bytes += this.encode(bytes * 8); + this.update(str); + return bytes; +}; + +Keccak.prototype.bytepad = function (strs, w) { + var bytes = this.encode(w); + for (var i = 0; i < strs.length; ++i) { + bytes += this.encodeString(strs[i]); + } + var paddingBytes = w - bytes % w; + var zeros = []; + zeros.length = paddingBytes; + this.update(zeros); + return this; +}; + +Keccak.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); +}; + +Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; +}; + +Keccak.prototype.arrayBuffer = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; +}; + +Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + +Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; +}; + +function Kmac(bits, padding, outputBits) { + Keccak.call(this, bits, padding, outputBits); +} + +Kmac.prototype = new Keccak(); + +Kmac.prototype.finalize = function () { + this.encode(this.outputBits, true); + return Keccak.prototype.finalize.call(this); +}; + +var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } +}; + +module.exports = methods; + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":5}],9:[function(require,module,exports){ +var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); +var keccak256 = require('./sha3')['keccak256']; function numberToHex (number) { var hex = Math.round(number).toString(16); @@ -2260,12 +3075,15 @@ var cryptoUtils = { }, blake256Checksum: function (payload) { return this.blake256(this.blake256(payload)).substr(0, 8); + }, + keccak256: function (hexString) { + return keccak256(hexString); } }; module.exports = cryptoUtils; -},{"./blake256":6,"jssha":4}],8:[function(require,module,exports){ +},{"./blake256":7,"./sha3":8,"jssha/src/sha256":4}],10:[function(require,module,exports){ // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ name: 'bitcoin', @@ -2333,6 +3151,27 @@ var CURRENCIES = [{ addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, hashFunction: 'blake256', expectedLength: 26 +},{ + name: 'digibyte', + symbol: 'dgb', + addressTypes: {prod: ['1e'], testnet: []}, + eip55: false +},{ + name: 'ethereum', + symbol: 'eth', + eip55: true +},{ + name: 'etherzero', + symbol: 'etz', + eip55: true +},{ + name: 'ethereumclassic', + symbol: 'etc', + eip55: true +},{ + name: 'callisto', + symbol: 'clo', + eip55: true }]; @@ -2351,40 +3190,83 @@ var currencies = { module.exports = currencies; -},{}],9:[function(require,module,exports){ -var base58 = require('./base58'); -var cryptoUtils = require('./crypto_utils'); +},{}],11:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); + +module.exports = { + isAddress: function (address) { + if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { + // Check if it has the basic requirements of an address + return false; + } + + if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { + // If it's all small caps or all all caps, return true + return true; + } + + // Otherwise check each case + return this.isChecksumAddress(address); + }, + isChecksumAddress: function (address) { + // Check each case + address = address.replace('0x',''); + + var addressHash = cryptoUtils.keccak256(address.toLowerCase()); + + for (var i = 0; i < 40; i++ ) { + // The nth letter should be uppercase if the nth digit of casemap is 1 + if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || + (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { + return false; + } + } + + return true; + } +}; + +},{"./crypto/utils":9}],12:[function(require,module,exports){ +var base58 = require('./crypto/base58'); +var cryptoUtils = require('./crypto/utils'); var currencies = require('./currencies'); +var ETHValidator = require('./ethereum_validator'); -var DEFAULT_CURRENCY_NAME = 'bitcoin', - DEFAULT_NETWORK_TYPE = 'prod'; +var DEFAULT_CURRENCY_NAME = 'bitcoin'; +var DEFAULT_NETWORK_TYPE = 'prod'; -var WAValidator = { +function getDecoded(address) { + try { + return base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } +} + +module.exports = { getAddressType: function (address, currency) { currency = currency || {}; // should be 25 bytes per btc address spec and 26 decred var expectedLength = currency.expectedLength || 25; var hashFunction = currency.hashFunction || 'sha256'; - var decoded; - - try { - decoded = base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } + var decoded = getDecoded(address); - var length = decoded.length; + if (decoded) { + var length = decoded.length; - if (length !== expectedLength) { - return null; - } + if (length !== expectedLength) { + return null; + } - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = this.checksum(hashFunction, body); + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = this.checksum(hashFunction, body); - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + } + + return null; }, // Each currency may implement different hashing algorithm @@ -2403,11 +3285,16 @@ var WAValidator = { currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; networkType = networkType || DEFAULT_NETWORK_TYPE; - var correctAddressTypes, - currency = currencies.getByNameOrSymbol(currencyNameOrSymbol), - addressType = this.getAddressType(address, currency); + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); - if(networkType === 'prod' || networkType === 'testnet'){ + if (currency.eip55) { + return ETHValidator.isAddress(address); + } + + var correctAddressTypes; + var addressType = this.getAddressType(address, currency); + + if (networkType === 'prod' || networkType === 'testnet'){ correctAddressTypes = currency.addressTypes[networkType] } else { correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); @@ -2417,7 +3304,5 @@ var WAValidator = { } }; -module.exports = WAValidator; - -},{"./base58":5,"./crypto_utils":7,"./currencies":8}]},{},[9])(9) +},{"./crypto/base58":6,"./crypto/utils":9,"./currencies":10,"./ethereum_validator":11}]},{},[12])(12) }); \ No newline at end of file diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 97039722..41b915e6 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,a,f){function u(r,t){if(!a[r]){if(!s[r]){var e="function"==typeof require&&require;if(!t&&e)return e(r,!0);if(h)return h(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[r]={exports:{}};s[r][0].call(o.exports,function(t){var e=s[r][1][t];return u(e||t)},o,o.exports,i,s,a,f)}return a[r].exports}for(var h="function"==typeof require&&require,t=0;t>16&255,i[a++]=n>>8&255,i[a++]=255&n;2===o?(n=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,i[a++]=255&n):1===o&&(n=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,i[a++]=n>>8&255,i[a++]=255&n);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o="",i=[],s=16383,a=0,f=r-n;a>2],o+=u[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=u[e>>10],o+=u[e>>4&63],o+=u[e<<2&63],o+="=");return i.push(o),i.join("")};for(var u=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],2:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=c,r.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return R(t).length;default:if(n)return I(t).length;e=(""+e).toLowerCase(),n=!0}}function w(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:d(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):d(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function d(t,e,r,n,o){var i,s=1,a=t.length,f=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,f/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=E)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},c.prototype.compare=function(t,e,r,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),f=this.slice(n,o),u=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,f,u,h,c,l,p,w=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,O(I(t,(c=this).length-l),c,l,p);case"ascii":return y(this,t,e,r);case"latin1":case"binary":return y(this,t,e,r);case"base64":return f=this,u=e,h=r,O(R(t),f,u,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,O(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(w)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),w=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function T(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(t,e,r,n,o){return e=+e,r>>>=0,o||T(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,o){return e=+e,r>>>=0,o||T(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||U(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||U(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||U(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||U(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||U(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||U(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||U(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||U(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||k(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||k(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);k(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);k(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return H(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return H(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function R(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":1,ieee754:3}],3:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,f=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,w=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(e+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(e*f-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&a,p+=w,a/=256,o-=8);for(s=s<= 1");if("SHA-1"===s)c=512,h=J,l=G,u=160,p=function(t){return t.slice()};else if(0===s.lastIndexOf("SHA-",0))if(h=function(t,e){return Q(t,e,s)},l=function(t,e,r,n){var o,i;if("SHA-224"===s||"SHA-256"===s)o=15+(e+65>>>9<<4),i=16;else{if("SHA-384"!==s&&"SHA-512"!==s)throw Error("Unexpected error in SHA-2 implementation");o=31+(e+129>>>10<<5),i=32}for(;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>5,u=0,h=e>>>5;for(i=0;i>>3)>>2]^=s<=o));)a.push(t.a),0==64*(u+=1)%r&&$(null,n);return a}}f=C(t,o,A),a=Z(s),this.setHMACKey=function(t,e,r){var n;if(!0===y)throw Error("HMAC key already set");if(!0===m)throw Error("Cannot set HMAC key after calling update");if(!0===E)throw Error("SHAKE is not supported for HMAC");if(t=(e=C(e,o=(r||{}).encoding||"UTF8",A)(t)).binLen,e=e.value,r=(n=c>>>3)/4-1,n>>5;for(t=(e=f(t,d,b)).binLen,r=e.value,e=t>>>5,n=0;n>>5),b=t%c,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===y)throw Error("Cannot call getHash after setting HMAC key");if(o=H(e),!0===E){if(-1===o.shakeLen)throw Error("shakeLen must be specified in options");u=o.shakeLen}switch(t){case"HEX":r=function(t){return _(t,u,A,o)};break;case"B64":r=function(t){return S(t,u,A,o)};break;case"BYTES":r=function(t){return U(t,u,A)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return T(t,u,A)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(d.slice(),b,g,p(a),u),n=1;n>>24-u%32),i=l(i,u,0,Z(s),u);return r(i)},this.getHMAC=function(t,e){var r,n,o,i;if(!1===y)throw Error("Cannot call getHMAC without first setting HMAC key");switch(o=H(e),t){case"HEX":r=function(t){return _(t,u,A,o)};break;case"B64":r=function(t){return S(t,u,A,o)};break;case"BYTES":r=function(t){return U(t,u,A)};break;case"ARRAYBUFFER":try{r=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return T(t,u,A)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")}return n=l(d.slice(),b,g,p(a),u),i=h(v,Z(s)),r(i=l(n,u,c,i,u))}}function k(t,e){this.a=t,this.b=e}function _(t,e,r,n){var o,i,s,a="";for(e/=8,s=-1===r?3:0,o=0;o>>2]>>>8*(s+o%4*r),a+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return n.outputUpper?a.toUpperCase():a}function S(t,e,r,n){var o,i,s,a,f="",u=e/8;for(a=-1===r?3:0,o=0;o>>2]:0,s=o+2>>2]:0,s=(t[o>>>2]>>>8*(a+o%4*r)&255)<<16|(i>>>8*(a+(o+1)%4*r)&255)<<8|s>>>8*(a+(o+2)%4*r)&255,i=0;i<4;i+=1)f+=8*o+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(s>>>6*(3-i)&63):n.b64Pad;return f}function U(t,e,r){var n,o,i,s="";for(e/=8,i=-1===r?3:0,n=0;n>>2]>>>8*(i+n%4*r)&255,s+=String.fromCharCode(o);return s}function T(t,e,r){e/=8;var n,o,i,s=new ArrayBuffer(e);for(i=new Uint8Array(s),o=-1===r?3:0,n=0;n>>2]>>>8*(o+n%4*r)&255;return s}function H(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),!0===t.hasOwnProperty("shakeLen")){if(0!=t.shakeLen%8)throw Error("shakeLen must be a multiple of 8");e.shakeLen=t.shakeLen}if("boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function C(t,l,p){switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":t=function(t,e,r){var n,o,i,s,a,f,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,f=-1===p?3:0,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(f+s%4*p)}return{value:e,binLen:4*u+r}};break;case"TEXT":t=function(t,e,r){var n,o,i,s,a,f,u,h,c=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(h=-1===p?3:0,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=f;)e.push(0);e[f]|=o[s]<<8*(h+u%4*p),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=-1===p?2:0,o="UTF16LE"===l&&1!==p||"UTF16LE"!==l&&1===p,i=0;i>>8),f=(u=c+a)>>>2;e.length<=f;)e.push(0);e[f]|=n<<8*(h+u%4*p),c+=2}return{value:e,binLen:8*c+r}};break;case"B64":t=function(t,e,r){var n,o,i,s,a,f,u,h,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=f[t.charCodeAt(r)]<<2|f[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=f[t.charCodeAt(r)]<<10|f[t.charCodeAt(r+1)]<<4|f[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=16383,u=0,f=e-n;u>2],o+=a[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=a[r>>10],o+=a[r>>4&63],o+=a[r<<2&63],o+="=");return i.push(o),i.join("")};for(var a=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],2:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return w(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":1,ieee754:3}],3:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,w)).binLen,e=r.value,r=t>>>5,n=0;n>>5),w=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),w,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } +} + +Keccak.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString, type = typeof message; + if (type !== 'string') { + if (type === 'object') { + if (message === null) { + throw ERROR; + } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (!Array.isArray(message)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var blocks = this.blocks, byteCount = this.byteCount, length = message.length, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; +}; + +Keccak.prototype.encode = function (x, right) { + var o = x & 255, n = 1; + var bytes = [o]; + x = x >> 8; + o = x & 255; + while (o > 0) { + bytes.unshift(o); + x = x >> 8; + o = x & 255; + ++n; + } + if (right) { + bytes.push(n); + } else { + bytes.unshift(n); + } + this.update(bytes); + return bytes.length; +}; + +Keccak.prototype.encodeString = function (str) { + var notString, type = typeof str; + if (type !== 'string') { + if (type === 'object') { + if (str === null) { + throw ERROR; + } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { + str = new Uint8Array(str); + } else if (!Array.isArray(str)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var bytes = 0, length = str.length; + if (notString) { + bytes = length; + } else { + for (var i = 0; i < str.length; ++i) { + var code = str.charCodeAt(i); + if (code < 0x80) { + bytes += 1; + } else if (code < 0x800) { + bytes += 2; + } else if (code < 0xd800 || code >= 0xe000) { + bytes += 3; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); + bytes += 4; + } + } + } + bytes += this.encode(bytes * 8); + this.update(str); + return bytes; +}; + +Keccak.prototype.bytepad = function (strs, w) { + var bytes = this.encode(w); + for (var i = 0; i < strs.length; ++i) { + bytes += this.encodeString(strs[i]); + } + var paddingBytes = w - bytes % w; + var zeros = []; + zeros.length = paddingBytes; + this.update(zeros); + return this; +}; + +Keccak.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); +}; + +Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; +}; + +Keccak.prototype.arrayBuffer = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; +}; + +Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + +Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; +}; + +function Kmac(bits, padding, outputBits) { + Keccak.call(this, bits, padding, outputBits); +} + +Kmac.prototype = new Keccak(); + +Kmac.prototype.finalize = function () { + this.encode(this.outputBits, true); + return Keccak.prototype.finalize.call(this); +}; + +var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } +}; + +module.exports = methods; diff --git a/src/crypto_utils.js b/src/crypto/utils.js similarity index 84% rename from src/crypto_utils.js rename to src/crypto/utils.js index 2afdc1bb..b8808ac3 100644 --- a/src/crypto_utils.js +++ b/src/crypto/utils.js @@ -1,5 +1,6 @@ -var jsSHA = require('jssha'); +var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); +var keccak256 = require('./sha3')['keccak256']; function numberToHex (number) { var hex = Math.round(number).toString(16); @@ -30,6 +31,9 @@ var cryptoUtils = { }, blake256Checksum: function (payload) { return this.blake256(this.blake256(payload)).substr(0, 8); + }, + keccak256: function (hexString) { + return keccak256(hexString); } }; diff --git a/src/currencies.js b/src/currencies.js index cf885579..0390da7b 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -65,6 +65,27 @@ var CURRENCIES = [{ addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, hashFunction: 'blake256', expectedLength: 26 +},{ + name: 'digibyte', + symbol: 'dgb', + addressTypes: {prod: ['1e'], testnet: []}, + eip55: false +},{ + name: 'ethereum', + symbol: 'eth', + eip55: true +},{ + name: 'etherzero', + symbol: 'etz', + eip55: true +},{ + name: 'ethereumclassic', + symbol: 'etc', + eip55: true +},{ + name: 'callisto', + symbol: 'clo', + eip55: true }]; diff --git a/src/ethereum_validator.js b/src/ethereum_validator.js new file mode 100644 index 00000000..f49138a8 --- /dev/null +++ b/src/ethereum_validator.js @@ -0,0 +1,34 @@ +var cryptoUtils = require('./crypto/utils'); + +module.exports = { + isAddress: function (address) { + if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { + // Check if it has the basic requirements of an address + return false; + } + + if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { + // If it's all small caps or all all caps, return true + return true; + } + + // Otherwise check each case + return this.isChecksumAddress(address); + }, + isChecksumAddress: function (address) { + // Check each case + address = address.replace('0x',''); + + var addressHash = cryptoUtils.keccak256(address.toLowerCase()); + + for (var i = 0; i < 40; i++ ) { + // The nth letter should be uppercase if the nth digit of casemap is 1 + if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || + (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { + return false; + } + } + + return true; + } +}; diff --git a/src/wallet_address_validator.js b/src/wallet_address_validator.js index 6e187167..0b5ee6a6 100644 --- a/src/wallet_address_validator.js +++ b/src/wallet_address_validator.js @@ -1,36 +1,43 @@ -var base58 = require('./base58'); -var cryptoUtils = require('./crypto_utils'); +var base58 = require('./crypto/base58'); +var cryptoUtils = require('./crypto/utils'); var currencies = require('./currencies'); +var ETHValidator = require('./ethereum_validator'); -var DEFAULT_CURRENCY_NAME = 'bitcoin', - DEFAULT_NETWORK_TYPE = 'prod'; +var DEFAULT_CURRENCY_NAME = 'bitcoin'; +var DEFAULT_NETWORK_TYPE = 'prod'; -var WAValidator = { +function getDecoded(address) { + try { + return base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } +} + +module.exports = { getAddressType: function (address, currency) { currency = currency || {}; // should be 25 bytes per btc address spec and 26 decred var expectedLength = currency.expectedLength || 25; var hashFunction = currency.hashFunction || 'sha256'; - var decoded; + var decoded = getDecoded(address); - try { - decoded = base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } + if (decoded) { + var length = decoded.length; - var length = decoded.length; - - if (length !== expectedLength) { - return null; - } + if (length !== expectedLength) { + return null; + } - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = this.checksum(hashFunction, body); + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = this.checksum(hashFunction, body); - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + } + + return null; }, // Each currency may implement different hashing algorithm @@ -49,11 +56,16 @@ var WAValidator = { currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; networkType = networkType || DEFAULT_NETWORK_TYPE; - var correctAddressTypes, - currency = currencies.getByNameOrSymbol(currencyNameOrSymbol), - addressType = this.getAddressType(address, currency); + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); + + if (currency.eip55) { + return ETHValidator.isAddress(address); + } + + var correctAddressTypes; + var addressType = this.getAddressType(address, currency); - if(networkType === 'prod' || networkType === 'testnet'){ + if (networkType === 'prod' || networkType === 'testnet'){ correctAddressTypes = currency.addressTypes[networkType] } else { correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); @@ -62,5 +74,3 @@ var WAValidator = { return correctAddressTypes.indexOf(addressType) >= 0; } }; - -module.exports = WAValidator; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 01dd718d..07aa263a 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -195,6 +195,36 @@ describe('WAValidator.validate()', function () { valid('TsijUgejaRnLKF5WAbpUxNtwKGUiKVeXLr7', 'decred', 'testnet'); valid('TsZ9QmAoadF12hGvyALp6qvaF4be3BmLqG9', 'dcr', 'testnet'); }); + + it('should return true for correct Digibyte addresses', function () { + valid('DG2rM2orU2JH5i4ACh3AKNpRTNESdv5xf8', 'DGB'); + valid('DBR2Lj1F17eHGHXgbpae2Wb4m39bDyA1qo', 'DGB'); + valid('D9TDZTR9Z9Mx2NoDJnhqhnYhDLKRAmsL9n', 'digibyte'); + valid('DHRzA1YHA1kFWpz2apRckZJy6KZRyGq4EV', 'digibyte'); + valid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'digibyte'); + }); + + it('should return true for correct Ethereum addresses', function () { + valid('0xE37c0D48d68da5c5b14E5c1a9f1CFE802776D9FF', 'ethereum'); + valid('0xa00354276d2fC74ee91e37D085d35748613f4748', 'ethereum'); + valid('0xAff4d6793F584a473348EbA058deb8caad77a288', 'ETH'); + valid('0xc6d9d2cd449a754c494264e1809c50e34d64562b', 'ETH'); + valid('0x52908400098527886E0F7030069857D2E4169EE7', 'ETH'); + valid('0x8617E340B3D01FA5F11F306F4090FD50E238070D', 'ETH'); + valid('0xde709f2102306220921060314715629080e2fb77', 'ETH'); + valid('0x27b1fdb04752bbc536007a920d24acb045561c26', 'ETH'); + valid('0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', 'ETH'); + valid('0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359', 'ETH'); + valid('0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB', 'ETH'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETH'); + + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ethereumclassic'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETC'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'etherzero'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETZ'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'callisto'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'CLO'); + }); }); describe('invalid results', function () { @@ -273,5 +303,21 @@ describe('WAValidator.validate()', function () { it('should return false for incorrect decred addresses', function () { commonTests('decred'); }); + + it('should return false for incorrect digibyte addresses', function () { + commonTests('digibyte'); + }); + + it('should return false for incorrect eip55 addresses', function () { + invalid('6xAff4d6793F584a473348EbA058deb8caad77a288', 'ethereum'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereum'); + invalid('0XD1220A0CF47C7B9BE7A2E6BA89F429762E7B9ADB', 'ethereum'); + invalid('aFf4d6793f584a473348ebA058deb8caad77a2885', 'ethereum'); + invalid('0xff4d6793F584a473', 'ethereum'); + + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereumclassic'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'etherzero'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'callisto'); + }); }); }); From 274edfbf04c89989f1e5d19d259654c06af47532 Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Fri, 9 Mar 2018 20:22:20 +0900 Subject: [PATCH 013/108] chore(release): 0.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 83a807ad..f9bad43a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "browser", "nodejs" ], - "version": "0.1.2", + "version": "0.1.3", "author": "Tomek Kolasa ", "homepage": "https://github.com/ognus/wallet-address-validator", "license": "MIT", From bb8030d30d7c337579dcb24f3c4b64a31f72b935 Mon Sep 17 00:00:00 2001 From: Dmitrii Pominov Date: Thu, 22 Mar 2018 12:20:44 +0300 Subject: [PATCH 014/108] Add ripple validator --- dist/wallet-address-validator.js | 5745 +++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- package.json | 1 + src/currencies.js | 7 + src/ripple_validator.js | 22 + src/wallet_address_validator.js | 4 + 6 files changed, 3004 insertions(+), 2777 deletions(-) create mode 100644 src/ripple_validator.js diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 31cd56fe..445b4fb9 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,3308 +1,3501 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { - throw new Error('Invalid string. Length must be a multiple of 4') + if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous') + ALPHABET_MAP[x] = z } - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 -} - -function byteLength (b64) { - // base64 is 4/3 + up to two characters of the original data - return (b64.length * 3 / 4) - placeHoldersCount(b64) -} + function encode (source) { + if (source.length === 0) return '' -function toByteArray (b64) { - var i, l, tmp, placeHolders, arr - var len = b64.length - placeHolders = placeHoldersCount(b64) + var digits = [0] + for (var i = 0; i < source.length; ++i) { + for (var j = 0, carry = source[i]; j < digits.length; ++j) { + carry += digits[j] << 8 + digits[j] = carry % BASE + carry = (carry / BASE) | 0 + } - arr = new Arr((len * 3 / 4) - placeHolders) + while (carry > 0) { + digits.push(carry % BASE) + carry = (carry / BASE) | 0 + } + } - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? len - 4 : len + var string = '' - var L = 0 + // deal with leading zeros + for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER + // convert digits to a string + for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] - for (i = 0; i < l; i += 4) { - tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] - arr[L++] = (tmp >> 16) & 0xFF - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF + return string } - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } + function decodeUnsafe (string) { + if (typeof string !== 'string') throw new TypeError('Expected String') + if (string.length === 0) return Buffer.allocUnsafe(0) - return arr -} + var bytes = [0] + for (var i = 0; i < string.length; i++) { + var value = ALPHABET_MAP[string[i]] + if (value === undefined) return -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] -} + for (var j = 0, carry = value; j < bytes.length; ++j) { + carry += bytes[j] * BASE + bytes[j] = carry & 0xff + carry >>= 8 + } -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} + while (carry > 0) { + bytes.push(carry & 0xff) + carry >>= 8 + } + } -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 + // deal with leading zeros + for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { + bytes.push(0) + } - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + return Buffer.from(bytes.reverse()) } - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' - } + function decode (string) { + var buffer = decodeUnsafe(string) + if (buffer) return buffer - parts.push(output) + throw new Error('Non-base' + BASE + ' character') + } - return parts.join('') + return { + encode: encode, + decodeUnsafe: decodeUnsafe, + decode: decode + } } -},{}],2:[function(require,module,exports){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' +},{"safe-buffer":3}],2:[function(require,module,exports){ +/* + A JavaScript implementation of the SHA family of hashes, as + defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding + HMAC implementation as defined in FIPS PUB 198a -var base64 = require('base64-js') -var ieee754 = require('ieee754') + Copyright Brian Turek 2008-2017 + Distributed under the BSD License + See http://caligatio.github.com/jsSHA/ for more information -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 + Several functions taken from Paul Johnston +*/ +'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; +b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> +5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); +}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> +6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==k&&k K_MAX_LENGTH) { - throw new RangeError('Invalid typed array length') + } else { + buf.fill(0) } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype return buf } -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' - ) - } - return allocUnsafe(arg) +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') } - return from(arg, encodingOrOffset, length) + return Buffer(size) } -// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) } -Buffer.poolSize = 8192 // not used by this implementation - -function from (value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') - } +},{"buffer":13}],4:[function(require,module,exports){ +// Base58 encoding/decoding +// Originally written by Mike Hearn for BitcoinJ +// Copyright (c) 2011 Google Inc +// Ported to JavaScript by Stefan Thomas +// Merged Buffer refactorings from base58-native by Stephen Pair +// Copyright (c) 2013 BitPay Inc - if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } +var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' +var ALPHABET_MAP = {} +for(var i = 0; i < ALPHABET.length; ++i) { + ALPHABET_MAP[ALPHABET.charAt(i)] = i +} +var BASE = ALPHABET.length - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } +var base58 = { + decode: function(string) { + if (string.length === 0) return [] - return fromObject(value) -} + var i, j, bytes = [0] + for (i = 0; i < string.length; ++i) { + var c = string[i] + if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character') -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) -} + for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE + bytes[0] += ALPHABET_MAP[c] -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array + var carry = 0 + for (j = 0; j < bytes.length; ++j) { + bytes[j] += carry + carry = bytes[j] >> 8 + bytes[j] &= 0xff + } -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') - } -} + while (carry) { + bytes.push(carry & 0xff) + carry >>= 8 + } + } + // deal with leading zeros + for (i = 0; string[i] === '1' && i < string.length - 1; ++i) bytes.push(0) -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) -} + return bytes.reverse() + } +}; -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) -} +module.exports = base58; -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) -} + +},{}],5:[function(require,module,exports){ +(function (Buffer){ +'use strict'; /** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + * Credits to https://github.com/cryptocoinjs/blake-hash */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) -} +Blake256.sigma = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] +] -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } +Blake256.u256 = [ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 +] - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } +Blake256.padding = new Buffer([ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +]) - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) +Blake256.prototype._length_carry = function (arr) { + for (var j = 0; j < arr.length; ++j) { + if (arr[j] < 0x0100000000) break + arr[j] -= 0x0100000000 + arr[j + 1] += 1 + } +} - var actual = buf.write(string, encoding) +Blake256.prototype.update = function (data, encoding) { + data = new Buffer(data, encoding); + var block = this._block + var offset = 0 - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } + while (this._blockOffset + data.length - offset >= block.length) { + for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] - return buf -} + this._length[0] += block.length * 8 + this._length_carry(this._length) -function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf + this._compress() + this._blockOffset = 0 + } + + while (offset < data.length) block[this._blockOffset++] = data[offset++] + return this; } -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } +var zo = new Buffer([0x01]) +var oo = new Buffer([0x81]) - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } +function rot (x, n) { + return ((x << (32 - n)) | (x >>> n)) >>> 0 +} - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } +function g (v, m, i, a, b, c, d, e) { + var sigma = Blake256.sigma + var u256 = Blake256.u256 - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf + v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 16) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 12) + v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 8) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 7) } -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } +function Blake256 () { + this._h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ] - obj.copy(buf, 0, 0, len) - return buf - } + this._s = [0, 0, 0, 0] - if (obj) { - if (ArrayBuffer.isView(obj) || 'length' in obj) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } + this._block = new Buffer(64) + this._blockOffset = 0 + this._length = [0, 0] - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } - } + this._nullt = false - throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') + this._zo = zo + this._oo = oo } -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 -} +Blake256.prototype._compress = function () { + var u256 = Blake256.u256 + var v = new Array(16) + var m = new Array(16) + var i -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} + for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) + for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 + for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 + for (i = 12; i < 16; ++i) v[i] = u256[i - 8] -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true + if (!this._nullt) { + v[12] = (v[12] ^ this._length[0]) >>> 0 + v[13] = (v[13] ^ this._length[0]) >>> 0 + v[14] = (v[14] ^ this._length[1]) >>> 0 + v[15] = (v[15] ^ this._length[1]) >>> 0 + } + + for (i = 0; i < 14; ++i) { + /* column step */ + g(v, m, i, 0, 4, 8, 12, 0) + g(v, m, i, 1, 5, 9, 13, 2) + g(v, m, i, 2, 6, 10, 14, 4) + g(v, m, i, 3, 7, 11, 15, 6) + /* diagonal step */ + g(v, m, i, 0, 5, 10, 15, 8) + g(v, m, i, 1, 6, 11, 12, 10) + g(v, m, i, 2, 7, 8, 13, 12) + g(v, m, i, 3, 4, 9, 14, 14) + } + + for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 + for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 } -Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } +Blake256.prototype._padding = function () { + var lo = this._length[0] + this._blockOffset * 8 + var hi = this._length[1] + if (lo >= 0x0100000000) { + lo -= 0x0100000000 + hi += 1 + } - if (a === b) return 0 + var msglen = new Buffer(8) + msglen.writeUInt32BE(hi, 0) + msglen.writeUInt32BE(lo, 4) - var x = a.length - var y = b.length + if (this._blockOffset === 55) { + this._length[0] -= 8 + this.update(this._oo) + } else { + if (this._blockOffset < 55) { + if (this._blockOffset === 0) this._nullt = true + this._length[0] -= (55 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) + } else { + this._length[0] -= (64 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) + this._length[0] -= 55 * 8 + this.update(Blake256.padding.slice(1, 1 + 55)) + this._nullt = true + } - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break + this.update(this._zo) + this._length[0] -= 8 } - } - if (x < y) return -1 - if (y < x) return 1 - return 0 + this._length[0] -= 64 + this.update(msglen) } -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } +Blake256.prototype.digest = function (encoding) { + this._padding() + + var buffer = new Buffer(32) + for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) + return buffer.toString(encoding); } -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } +module.exports = Blake256; +}).call(this,require("buffer").Buffer) +},{"buffer":13}],6:[function(require,module,exports){ +(function (process,global){ +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.7.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2017 + * @license MIT + */ +/*jslint bitwise: true */ +'use strict'; - if (list.length === 0) { - return Buffer.alloc(0) - } +var ERROR = 'input is invalid type'; +var WINDOW = typeof window === 'object'; +var root = WINDOW ? window : {}; +if (root.JS_SHA3_NO_WINDOW) { + WINDOW = false; +} +var WEB_WORKER = !WINDOW && typeof self === 'object'; +var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; +if (NODE_JS) { + root = global; +} else if (WEB_WORKER) { + root = self; +} +var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; +var HEX_CHARS = '0123456789abcdef'.split(''); +var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; +var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; +var KECCAK_PADDING = [1, 256, 65536, 16777216]; +var PADDING = [6, 1536, 393216, 100663296]; +var SHIFT = [0, 8, 16, 24]; +var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; +var BITS = [224, 256, 384, 512]; +var SHAKE_BITS = [128, 256]; +var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; +var CSHAKE_BYTEPAD = { + '128': 168, + '256': 136 +}; - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } +if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { + Array.isArray = function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; +} - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (ArrayBuffer.isView(buf)) { - buf = Buffer.from(buf) - } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer +if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { + ArrayBuffer.isView = function (obj) { + return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; + }; } -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { - return string.byteLength - } - if (typeof string !== 'string') { - string = '' + string - } +var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; +}; - var len = string.length - if (len === 0) return 0 +var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; +}; - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - case undefined: - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength +var createCshakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits, n, s) { + return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); + }; +}; -function slowToString (encoding, start, end) { - var loweredCase = false +var createKmacOutputMethod = function (bits, padding, outputType) { + return function (key, message, outputBits, s) { + return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); + }; +}; - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' +var createOutputMethods = function (method, createMethod, bits, padding) { + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createMethod(bits, padding, type); + } + return method; +}; - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) +var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + return createOutputMethods(method, createOutputMethod, bits, padding); +}; - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) +var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + return createOutputMethods(method, createShakeOutputMethod, bits, padding); +}; - case 'ascii': - return asciiSlice(this, start, end) +var createCshakeMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createCshakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits, n, s) { + if (!n && !s) { + return methods['shake' + bits].create(outputBits); + } else { + return new Keccak(bits, padding, outputBits).bytepad([n, s], w); + } + }; + method.update = function (message, outputBits, n, s) { + return method.create(outputBits, n, s).update(message); + }; + return createOutputMethods(method, createCshakeOutputMethod, bits, padding); +}; - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) +var createKmacMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createKmacOutputMethod(bits, padding, 'hex'); + method.create = function (key, outputBits, s) { + return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); + }; + method.update = function (key, message, outputBits, s) { + return method.create(key, outputBits, s).update(message); + }; + return createOutputMethods(method, createKmacOutputMethod, bits, padding); +}; - case 'base64': - return base64Slice(this, start, end) +var algorithms = [ + { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, + { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, + { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, + { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, + { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } +]; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) +var methods = {}, methodNames = []; - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true +for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name + '_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + if (algorithm.name !== 'sha3') { + var newMethodName = algorithm.name + bits[j]; + methodNames.push(newMethodName); + methods[newMethodName] = methods[methodName]; + } } - } } -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true +function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.finalized = false; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } } -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} +Keccak.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString, type = typeof message; + if (type !== 'string') { + if (type === 'object') { + if (message === null) { + throw ERROR; + } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (!Array.isArray(message)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var blocks = this.blocks, byteCount = this.byteCount, length = message.length, + blockCount = this.blockCount, index = 0, s = this.s, i, code; -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; +}; -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.toLocaleString = Buffer.prototype.toString - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} +Keccak.prototype.encode = function (x, right) { + var o = x & 255, n = 1; + var bytes = [o]; + x = x >> 8; + o = x & 255; + while (o > 0) { + bytes.unshift(o); + x = x >> 8; + o = x & 255; + ++n; + } + if (right) { + bytes.push(n); + } else { + bytes.unshift(n); + } + this.update(bytes); + return bytes.length; +}; -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' -} +Keccak.prototype.encodeString = function (str) { + var notString, type = typeof str; + if (type !== 'string') { + if (type === 'object') { + if (str === null) { + throw ERROR; + } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { + str = new Uint8Array(str); + } else if (!Array.isArray(str)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var bytes = 0, length = str.length; + if (notString) { + bytes = length; + } else { + for (var i = 0; i < str.length; ++i) { + var code = str.charCodeAt(i); + if (code < 0x80) { + bytes += 1; + } else if (code < 0x800) { + bytes += 2; + } else if (code < 0xd800 || code >= 0xe000) { + bytes += 3; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); + bytes += 4; + } + } + } + bytes += this.encode(bytes * 8); + this.update(str); + return bytes; +}; -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (!Buffer.isBuffer(target)) { - throw new TypeError('Argument must be a Buffer') - } +Keccak.prototype.bytepad = function (strs, w) { + var bytes = this.encode(w); + for (var i = 0; i < strs.length; ++i) { + bytes += this.encodeString(strs[i]); + } + var paddingBytes = w - bytes % w; + var zeros = []; + zeros.length = paddingBytes; + this.update(zeros); + return this; +}; - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } +Keccak.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); +}; - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } +Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; +}; - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 +Keccak.prototype.arrayBuffer = function () { + this.finalize(); - if (this === target) return 0 + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; +}; - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) +Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) +Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } } - } + if (extraBytes) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; +}; - if (x < y) return -1 - if (y < x) return 1 - return 0 +function Kmac(bits, padding, outputBits) { + Keccak.call(this, bits, padding, outputBits); } -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 +Kmac.prototype = new Keccak(); - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } +Kmac.prototype.finalize = function () { + this.encode(this.outputBits, true); + return Keccak.prototype.finalize.call(this); +}; - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } +var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } +}; - throw new TypeError('val must be string, number or Buffer') -} +module.exports = methods; -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":15}],7:[function(require,module,exports){ +var jsSHA = require('jssha/src/sha256'); +var Blake256 = require('./blake256'); +var keccak256 = require('./sha3')['keccak256']; - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 +function numberToHex (number) { + var hex = Math.round(number).toString(16); + if(hex.length === 1) { + hex = '0' + hex; } - } + return hex; +} - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) +var cryptoUtils = { + toHex: function (arrayOfBytes) { + var hex = ''; + for(var i = 0; i < arrayOfBytes.length; i++) { + hex += numberToHex(arrayOfBytes[i]); + } + return hex; + }, + sha256: function (hexString) { + var sha = new jsSHA('SHA-256', 'HEX'); + sha.update(hexString); + return sha.getHash('HEX'); + }, + sha256Checksum: function (payload) { + return this.sha256(this.sha256(payload)).substr(0, 8); + }, + blake256: function (hexString) { + return new Blake256().update(hexString, 'hex').digest('hex'); + }, + blake256Checksum: function (payload) { + return this.blake256(this.blake256(payload)).substr(0, 8); + }, + keccak256: function (hexString) { + return keccak256(hexString); } - } +}; - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break +module.exports = cryptoUtils; + +},{"./blake256":5,"./sha3":6,"jssha/src/sha256":2}],8:[function(require,module,exports){ +var XRPValidator = require('./ripple_validator'); + +// defines P2PKH and P2SH address types for standard (prod) and testnet networks +var CURRENCIES = [{ + name: 'bitcoin', + symbol: 'btc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'litecoin', + symbol: 'ltc', + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} +},{ + name: 'peercoin', + symbol: 'ppc', + addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} +},{ + name: 'dogecoin', + symbol: 'doge', + addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} +},{ + name: 'beavercoin', + symbol: 'bvc', + addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} +},{ + name: 'freicoin', + symbol: 'frc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'protoshares', + symbol: 'pts', + addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} +},{ + name: 'megacoin', + symbol: 'mec', + addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} +},{ + name: 'primecoin', + symbol: 'xpm', + addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} +},{ + name: 'auroracoin', + symbol: 'aur', + addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} +},{ + name: 'namecoin', + symbol: 'nmc', + addressTypes: {prod: ['34'], testnet: []} +},{ + name: 'biocoin', + symbol: 'bio', + addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} +},{ + name: 'garlicoin', + symbol: 'grlc', + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} +},{ + name: 'vertcoin', + symbol: 'vtc', + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} +},{ + name: 'bitcoingold', + symbol: 'btg', + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} +},{ + name: 'decred', + symbol: 'dcr', + addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, + hashFunction: 'blake256', + expectedLength: 26 +},{ + name: 'digibyte', + symbol: 'dgb', + addressTypes: {prod: ['1e'], testnet: []}, + eip55: false +},{ + name: 'ethereum', + symbol: 'eth', + eip55: true +},{ + name: 'etherzero', + symbol: 'etz', + eip55: true +},{ + name: 'ethereumclassic', + symbol: 'etc', + eip55: true +},{ + name: 'callisto', + symbol: 'clo', + eip55: true +},{ + name: 'ripple', + symbol: 'xrp', + validator: XRPValidator, + eip55: false +}]; + + +var currencies = { + getByNameOrSymbol: function (currencyNameOrSymbol) { + var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); + for (var i = 0; i < CURRENCIES.length; i++) { + var currency = CURRENCIES[i]; + if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { + return currency; + } } - } - if (found) return i + return null; } - } +}; - return -1 -} +module.exports = currencies; -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} +},{"./ripple_validator":10}],9:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} +module.exports = { + isAddress: function (address) { + if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { + // Check if it has the basic requirements of an address + return false; + } + + if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { + // If it's all small caps or all all caps, return true + return true; + } -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} + // Otherwise check each case + return this.isChecksumAddress(address); + }, + isChecksumAddress: function (address) { + // Check each case + address = address.replace('0x',''); -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining + var addressHash = cryptoUtils.keccak256(address.toLowerCase()); + + for (var i = 0; i < 40; i++ ) { + // The nth letter should be uppercase if the nth digit of casemap is 1 + if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || + (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { + return false; + } + } + + return true; } - } - - var strLen = string.length +}; - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} +},{"./crypto/utils":7}],10:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var baseX = require('base-x'); +var codec = baseX("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"); // for ripple -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} +module.exports = { + /** + * ripple address validation + */ + isValidAddress: function (address) { + if (/^r[rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz]{27,35}$/.test(address) === false) + return false; + return this.verifyChecksum(address); + }, + + verifyChecksum: function (address) { + var bytes = codec.decode(address); + var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); + var checksum = cryptoUtils.toHex(bytes.slice(-4)); + + return computedChecksum === checksum + } +}; -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} +},{"./crypto/utils":7,"base-x":1}],11:[function(require,module,exports){ +var base58 = require('./crypto/base58'); +var cryptoUtils = require('./crypto/utils'); +var currencies = require('./currencies'); +var ETHValidator = require('./ethereum_validator'); -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} +var DEFAULT_CURRENCY_NAME = 'bitcoin'; +var DEFAULT_NETWORK_TYPE = 'prod'; -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) +function getDecoded(address) { + try { + return base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } } -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} +module.exports = { + getAddressType: function (address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded = getDecoded(address); -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } + if (decoded) { + var length = decoded.length; - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining + if (length !== expectedLength) { + return null; + } - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = this.checksum(hashFunction, body); - if (!encoding) encoding = 'utf8' + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + } + + return null; + }, - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) + // Each currency may implement different hashing algorithm + checksum: function (hashFunction, payload) { + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); + } + }, - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) + validate: function (address, currencyNameOrSymbol, networkType) { + currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; + networkType = networkType || DEFAULT_NETWORK_TYPE; - case 'ascii': - return asciiWrite(this, string, offset, length) + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) + if (currency.validator) { + return currency.validator.isValidAddress(address); + } - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) + if (currency.eip55) { + return ETHValidator.isAddress(address); + } + + var correctAddressTypes; + var addressType = this.getAddressType(address, currency); - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) + if (networkType === 'prod' || networkType === 'testnet'){ + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + } - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true + return correctAddressTypes.indexOf(addressType) >= 0; } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} +}; -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] +},{"./crypto/base58":4,"./crypto/utils":7,"./currencies":8,"./ethereum_validator":9}],12:[function(require,module,exports){ +'use strict' - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 - res.push(codePoint) - i += bytesPerSequence +function placeHoldersCount (b64) { + var len = b64.length + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') } - return decodeCodePointsArray(res) + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} + +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return (b64.length * 3 / 4) - placeHoldersCount(b64) } -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 +function toByteArray (b64) { + var i, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + arr = new Arr((len * 3 / 4) - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0; i < l; i += 4) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF } - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF } - return res + + return arr } -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) } - return ret + return output.join('') } -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) } - return ret + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } + + parts.push(output) + + return parts.join('') } -function hexSlice (buf, start, end) { - var len = buf.length +},{}],13:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len +'use strict' - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out +var base64 = require('base64-js') +var ieee754 = require('ieee754') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) } -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 + } catch (e) { + return false } - return res } -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len +Object.defineProperty(Buffer.prototype, 'parent', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined + } + return this.buffer } +}) - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len +Object.defineProperty(Buffer.prototype, 'offset', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined + } + return this.byteOffset } +}) - if (end < start) end = start - - var newBuf = this.subarray(start, end) +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('Invalid typed array length') + } // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf } -/* - * Need to make sure that buffer isn't trying to write out of bounds. +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(arg) } + return from(arg, encodingOrOffset, length) +} - return val +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) } -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) } - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) } - return val + return fromObject(value) } -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) } -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } } -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) } -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) } -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' } - mul *= 0x80 - if (val >= mul) val -= Math.pow(2, 8 * byteLength) + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } - return val -} + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) + var actual = buf.write(string, encoding) - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - return val + return buf } -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf } -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf } -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} + if (buf.length === 0) { + return buf + } -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} + obj.copy(buf, 0, 0, len) + return buf + } -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) + if (obj) { + if (ArrayBuffer.isView(obj) || 'length' in obj) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } + } + + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') } -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 } -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) } -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true } -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') } - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } } - return offset + byteLength + if (x < y) return -1 + if (y < x) return 1 + return 0 } -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false } +} - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') } - return offset + byteLength -} + if (list.length === 0) { + return Buffer.alloc(0) + } -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 -} + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (ArrayBuffer.isView(buf)) { + buf = Buffer.from(buf) + } + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer } -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 -} + var len = string.length + if (len === 0) return 0 -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } } +Buffer.byteLength = byteLength -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) +function slowToString (encoding, start, end) { + var loweredCase = false - checkInt(this, value, offset, byteLength, limit - 1, -limit) + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' } - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + if (end === undefined || end > this.length) { + end = this.length } - return offset + byteLength -} + if (end <= 0) { + return '' + } -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 - checkInt(this, value, offset, byteLength, limit - 1, -limit) + if (end <= start) { + return '' } - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } - - return offset + byteLength } -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i } -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this } -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this } -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this } -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) } -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} +Buffer.prototype.toLocaleString = Buffer.prototype.toString -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 } -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' } -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') + if (this === target) return 0 - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) - var len = end - start + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) } - return len + if (x < y) return -1 + if (y < x) return 1 + return 0 } -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) } } - } else if (typeof val === 'number') { - val = val & 255 + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) } - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } + throw new TypeError('val must be string, number or Buffer') +} - if (end <= start) { - return this - } +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } - if (!val) val = 0 + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } } } else { - var bytes = Buffer.isBuffer(val) - ? val - : new Buffer(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i } } - return this + return -1 } -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 } -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) } -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining } } - return bytes -} + var strLen = string.length -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) + if (length > strLen / 2) { + length = strLen / 2 } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed } + return i +} - return byteArray +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) } -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) } -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) } -// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check -// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 -function isArrayBuffer (obj) { - return obj instanceof ArrayBuffer || - (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && - typeof obj.byteLength === 'number') +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) } -function numberIsNaN (obj) { - return obj !== obj // eslint-disable-line no-self-compare +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) } -},{"base64-js":1,"ieee754":3}],3:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } - i += d + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + if (!encoding) encoding = 'utf8' - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) - value = Math.abs(value) + case 'ascii': + return asciiWrite(this, string, offset, length) - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true } } +} - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} - buffer[offset + i - d] |= s * 128 +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } } -},{}],4:[function(require,module,exports){ -/* - A JavaScript implementation of the SHA family of hashes, as - defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding - HMAC implementation as defined in FIPS PUB 198a +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] - Copyright Brian Turek 2008-2017 - Distributed under the BSD License - See http://caligatio.github.com/jsSHA/ for more information + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 - Several functions taken from Paul Johnston -*/ -'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; -b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> -5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); -}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> -6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); -if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, -"");if(-1!==k&&k len) end = len + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out } -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res } -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf } -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; -function noop() {} +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } -process.listeners = function (name) { return [] } + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; + return val +} -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} -},{}],6:[function(require,module,exports){ -// Base58 encoding/decoding -// Originally written by Mike Hearn for BitcoinJ -// Copyright (c) 2011 Google Inc -// Ported to JavaScript by Stefan Thomas -// Merged Buffer refactorings from base58-native by Stephen Pair -// Copyright (c) 2013 BitPay Inc +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' -var ALPHABET_MAP = {} -for(var i = 0; i < ALPHABET.length; ++i) { - ALPHABET_MAP[ALPHABET.charAt(i)] = i +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] } -var BASE = ALPHABET.length -var base58 = { - decode: function(string) { - if (string.length === 0) return [] +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) - var i, j, bytes = [0] - for (i = 0; i < string.length; ++i) { - var c = string[i] - if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character') + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} - for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE - bytes[0] += ALPHABET_MAP[c] +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) - var carry = 0 - for (j = 0; j < bytes.length; ++j) { - bytes[j] += carry - carry = bytes[j] >> 8 - bytes[j] &= 0xff - } + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} - while (carry) { - bytes.push(carry & 0xff) - carry >>= 8 - } - } - // deal with leading zeros - for (i = 0; string[i] === '1' && i < string.length - 1; ++i) bytes.push(0) +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) - return bytes.reverse() - } -}; + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 -module.exports = base58; + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + return val +} -},{}],7:[function(require,module,exports){ -(function (Buffer){ -'use strict'; +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) -/** - * Credits to https://github.com/cryptocoinjs/blake-hash - */ -Blake256.sigma = [ - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], - [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], - [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], - [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], - [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] -] + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 -Blake256.u256 = [ - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 -] + if (val >= mul) val -= Math.pow(2, 8 * byteLength) -Blake256.padding = new Buffer([ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -]) + return val +} -Blake256.prototype._length_carry = function (arr) { - for (var j = 0; j < arr.length; ++j) { - if (arr[j] < 0x0100000000) break - arr[j] -= 0x0100000000 - arr[j + 1] += 1 - } +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) } -Blake256.prototype.update = function (data, encoding) { - data = new Buffer(data, encoding); - var block = this._block - var offset = 0 +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} - while (this._blockOffset + data.length - offset >= block.length) { - for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} - this._length[0] += block.length * 8 - this._length_carry(this._length) +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) - this._compress() - this._blockOffset = 0 - } + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} - while (offset < data.length) block[this._blockOffset++] = data[offset++] - return this; +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) } -var zo = new Buffer([0x01]) -var oo = new Buffer([0x81]) +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} -function rot (x, n) { - return ((x << (32 - n)) | (x >>> n)) >>> 0 +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) } -function g (v, m, i, a, b, c, d, e) { - var sigma = Blake256.sigma - var u256 = Blake256.u256 +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} - v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 16) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 12) - v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 8) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 7) +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) } -function Blake256 () { - this._h = [ - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 - ] +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } - this._s = [0, 0, 0, 0] + return offset + byteLength +} - this._block = new Buffer(64) - this._blockOffset = 0 - this._length = [0, 0] +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } - this._nullt = false + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } - this._zo = zo - this._oo = oo + return offset + byteLength } -Blake256.prototype._compress = function () { - var u256 = Blake256.u256 - var v = new Array(16) - var m = new Array(16) - var i - - for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) - for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 - for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 - for (i = 12; i < 16; ++i) v[i] = u256[i - 8] +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} - if (!this._nullt) { - v[12] = (v[12] ^ this._length[0]) >>> 0 - v[13] = (v[13] ^ this._length[0]) >>> 0 - v[14] = (v[14] ^ this._length[1]) >>> 0 - v[15] = (v[15] ^ this._length[1]) >>> 0 - } +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} - for (i = 0; i < 14; ++i) { - /* column step */ - g(v, m, i, 0, 4, 8, 12, 0) - g(v, m, i, 1, 5, 9, 13, 2) - g(v, m, i, 2, 6, 10, 14, 4) - g(v, m, i, 3, 7, 11, 15, 6) - /* diagonal step */ - g(v, m, i, 0, 5, 10, 15, 8) - g(v, m, i, 1, 6, 11, 12, 10) - g(v, m, i, 2, 7, 8, 13, 12) - g(v, m, i, 3, 4, 9, 14, 14) - } +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} - for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 - for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 } -Blake256.prototype._padding = function () { - var lo = this._length[0] + this._blockOffset * 8 - var hi = this._length[1] - if (lo >= 0x0100000000) { - lo -= 0x0100000000 - hi += 1 - } +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} - var msglen = new Buffer(8) - msglen.writeUInt32BE(hi, 0) - msglen.writeUInt32BE(lo, 4) +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) - if (this._blockOffset === 55) { - this._length[0] -= 8 - this.update(this._oo) - } else { - if (this._blockOffset < 55) { - if (this._blockOffset === 0) this._nullt = true - this._length[0] -= (55 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) - } else { - this._length[0] -= (64 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) - this._length[0] -= 55 * 8 - this.update(Blake256.padding.slice(1, 1 + 55)) - this._nullt = true - } + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } - this.update(this._zo) - this._length[0] -= 8 + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } - this._length[0] -= 64 - this.update(msglen) + return offset + byteLength } -Blake256.prototype.digest = function (encoding) { - this._padding() - - var buffer = new Buffer(32) - for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) - return buffer.toString(encoding); -} +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) -module.exports = Blake256; -}).call(this,require("buffer").Buffer) -},{"buffer":2}],8:[function(require,module,exports){ -(function (process,global){ -/** - * [js-sha3]{@link https://github.com/emn178/js-sha3} - * - * @version 0.7.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2015-2017 - * @license MIT - */ -/*jslint bitwise: true */ -'use strict'; + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } -var ERROR = 'input is invalid type'; -var WINDOW = typeof window === 'object'; -var root = WINDOW ? window : {}; -if (root.JS_SHA3_NO_WINDOW) { - WINDOW = false; -} -var WEB_WORKER = !WINDOW && typeof self === 'object'; -var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; -if (NODE_JS) { - root = global; -} else if (WEB_WORKER) { - root = self; -} -var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; -var HEX_CHARS = '0123456789abcdef'.split(''); -var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; -var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; -var KECCAK_PADDING = [1, 256, 65536, 16777216]; -var PADDING = [6, 1536, 393216, 100663296]; -var SHIFT = [0, 8, 16, 24]; -var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, - 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, - 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, - 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, - 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; -var BITS = [224, 256, 384, 512]; -var SHAKE_BITS = [128, 256]; -var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; -var CSHAKE_BYTEPAD = { - '128': 168, - '256': 136 -}; + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } -if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { - Array.isArray = function (obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; - }; + return offset + byteLength } -if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { - ArrayBuffer.isView = function (obj) { - return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; - }; +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 } -var createOutputMethod = function (bits, padding, outputType) { - return function (message) { - return new Keccak(bits, padding, bits).update(message)[outputType](); - }; -}; - -var createShakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits) { - return new Keccak(bits, padding, outputBits).update(message)[outputType](); - }; -}; - -var createCshakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits, n, s) { - return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); - }; -}; - -var createKmacOutputMethod = function (bits, padding, outputType) { - return function (key, message, outputBits, s) { - return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); - }; -}; +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} -var createOutputMethods = function (method, createMethod, bits, padding) { - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createMethod(bits, padding, type); - } - return method; -}; +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} -var createMethod = function (bits, padding) { - var method = createOutputMethod(bits, padding, 'hex'); - method.create = function () { - return new Keccak(bits, padding, bits); - }; - method.update = function (message) { - return method.create().update(message); - }; - return createOutputMethods(method, createOutputMethod, bits, padding); -}; +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} -var createShakeMethod = function (bits, padding) { - var method = createShakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits) { - return new Keccak(bits, padding, outputBits); - }; - method.update = function (message, outputBits) { - return method.create(outputBits).update(message); - }; - return createOutputMethods(method, createShakeOutputMethod, bits, padding); -}; +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} -var createCshakeMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createCshakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits, n, s) { - if (!n && !s) { - return methods['shake' + bits].create(outputBits); - } else { - return new Keccak(bits, padding, outputBits).bytepad([n, s], w); - } - }; - method.update = function (message, outputBits, n, s) { - return method.create(outputBits, n, s).update(message); - }; - return createOutputMethods(method, createCshakeOutputMethod, bits, padding); -}; +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} -var createKmacMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createKmacOutputMethod(bits, padding, 'hex'); - method.create = function (key, outputBits, s) { - return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); - }; - method.update = function (key, message, outputBits, s) { - return method.create(key, outputBits, s).update(message); - }; - return createOutputMethods(method, createKmacOutputMethod, bits, padding); -}; +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} -var algorithms = [ - { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, - { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, - { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, - { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, - { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } -]; +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} -var methods = {}, methodNames = []; +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} -for (var i = 0; i < algorithms.length; ++i) { - var algorithm = algorithms[i]; - var bits = algorithm.bits; - for (var j = 0; j < bits.length; ++j) { - var methodName = algorithm.name + '_' + bits[j]; - methodNames.push(methodName); - methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); - if (algorithm.name !== 'sha3') { - var newMethodName = algorithm.name + bits[j]; - methodNames.push(newMethodName); - methods[newMethodName] = methods[methodName]; - } - } +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 } -function Keccak(bits, padding, outputBits) { - this.blocks = []; - this.s = []; - this.padding = padding; - this.outputBits = outputBits; - this.reset = true; - this.finalized = false; - this.block = 0; - this.start = 0; - this.blockCount = (1600 - (bits << 1)) >> 5; - this.byteCount = this.blockCount << 2; - this.outputBlocks = outputBits >> 5; - this.extraBytes = (outputBits & 31) >> 3; +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} - for (var i = 0; i < 50; ++i) { - this.s[i] = 0; - } +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) } -Keccak.prototype.update = function (message) { - if (this.finalized) { - return; - } - var notString, type = typeof message; - if (type !== 'string') { - if (type === 'object') { - if (message === null) { - throw ERROR; - } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } else if (!Array.isArray(message)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var blocks = this.blocks, byteCount = this.byteCount, length = message.length, - blockCount = this.blockCount, index = 0, s = this.s, i, code; +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start - while (index < length) { - if (this.reset) { - this.reset = false; - blocks[0] = this.block; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - if (notString) { - for (i = this.start; index < length && i < byteCount; ++index) { - blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; - } - } else { - for (i = this.start; index < length && i < byteCount; ++index) { - code = message.charCodeAt(index); - if (code < 0x80) { - blocks[i >> 2] |= code << SHIFT[i++ & 3]; - } else if (code < 0x800) { - blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else if (code < 0xd800 || code >= 0xe000) { - blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); - blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - } - } - this.lastByteIndex = i; - if (i >= byteCount) { - this.start = i - byteCount; - this.block = blocks[blockCount]; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); - this.reset = true; - } else { - this.start = i; - } - } - return this; -}; + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start -Keccak.prototype.encode = function (x, right) { - var o = x & 255, n = 1; - var bytes = [o]; - x = x >> 8; - o = x & 255; - while (o > 0) { - bytes.unshift(o); - x = x >> 8; - o = x & 255; - ++n; - } - if (right) { - bytes.push(n); - } else { - bytes.unshift(n); + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] } - this.update(bytes); - return bytes.length; -}; + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } -Keccak.prototype.encodeString = function (str) { - var notString, type = typeof str; - if (type !== 'string') { - if (type === 'object') { - if (str === null) { - throw ERROR; - } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { - str = new Uint8Array(str); - } else if (!Array.isArray(str)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var bytes = 0, length = str.length; - if (notString) { - bytes = length; - } else { - for (var i = 0; i < str.length; ++i) { - var code = str.charCodeAt(i); - if (code < 0x80) { - bytes += 1; - } else if (code < 0x800) { - bytes += 2; - } else if (code < 0xd800 || code >= 0xe000) { - bytes += 3; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); - bytes += 4; - } - } - } - bytes += this.encode(bytes * 8); - this.update(str); - return bytes; -}; + return len +} -Keccak.prototype.bytepad = function (strs, w) { - var bytes = this.encode(w); - for (var i = 0; i < strs.length; ++i) { - bytes += this.encodeString(strs[i]); +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length } - var paddingBytes = w - bytes % w; - var zeros = []; - zeros.length = paddingBytes; - this.update(zeros); - return this; -}; - -Keccak.prototype.finalize = function () { - if (this.finalized) { - return; + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') } - this.finalized = true; - var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; - blocks[i >> 2] |= this.padding[i & 3]; - if (this.lastByteIndex === this.byteCount) { - blocks[0] = blocks[blockCount]; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) } - blocks[blockCount - 1] |= 0x80000000; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } } - f(s); -}; + } else if (typeof val === 'number') { + val = val & 255 + } -Keccak.prototype.toString = Keccak.prototype.hex = function () { - this.finalize(); + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var hex = '', block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + - HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + - HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + - HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; - } - if (j % blockCount === 0) { - f(s); - i = 0; - } - } - if (extraBytes) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; - if (extraBytes > 1) { - hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; - } - if (extraBytes > 2) { - hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; - } - } - return hex; -}; + if (end <= start) { + return this + } -Keccak.prototype.arrayBuffer = function () { - this.finalize(); + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var bytes = this.outputBits >> 3; - var buffer; - if (extraBytes) { - buffer = new ArrayBuffer((outputBlocks + 1) << 2); - } else { - buffer = new ArrayBuffer(bytes); + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val } - var array = new Uint32Array(buffer); - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - array[j] = s[i]; - } - if (j % blockCount === 0) { - f(s); - } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : new Buffer(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') } - if (extraBytes) { - array[i] = s[i]; - buffer = buffer.slice(0, bytes); + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] } - return buffer; -}; + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } -Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + // valid lead + leadSurrogate = codePoint -Keccak.prototype.digest = Keccak.prototype.array = function () { - this.finalize(); + continue + } - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var array = [], offset, block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - array[offset + 1] = (block >> 8) & 0xFF; - array[offset + 2] = (block >> 16) & 0xFF; - array[offset + 3] = (block >> 24) & 0xFF; - } - if (j % blockCount === 0) { - f(s); - } + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) } - if (extraBytes) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - if (extraBytes > 1) { - array[offset + 1] = (block >> 8) & 0xFF; - } - if (extraBytes > 2) { - array[offset + 2] = (block >> 16) & 0xFF; - } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') } - return array; -}; + } -function Kmac(bits, padding, outputBits) { - Keccak.call(this, bits, padding, outputBits); + return bytes } -Kmac.prototype = new Keccak(); +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} -Kmac.prototype.finalize = function () { - this.encode(this.outputBits, true); - return Keccak.prototype.finalize.call(this); -}; +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break -var f = function (s) { - var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, - b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, - b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, - b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; - for (n = 0; n < 48; n += 2) { - c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; - c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; - c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; - c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; - c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; - c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; - c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; - c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; - c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; - c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } - h = c8 ^ ((c2 << 1) | (c3 >>> 31)); - l = c9 ^ ((c3 << 1) | (c2 >>> 31)); - s[0] ^= h; - s[1] ^= l; - s[10] ^= h; - s[11] ^= l; - s[20] ^= h; - s[21] ^= l; - s[30] ^= h; - s[31] ^= l; - s[40] ^= h; - s[41] ^= l; - h = c0 ^ ((c4 << 1) | (c5 >>> 31)); - l = c1 ^ ((c5 << 1) | (c4 >>> 31)); - s[2] ^= h; - s[3] ^= l; - s[12] ^= h; - s[13] ^= l; - s[22] ^= h; - s[23] ^= l; - s[32] ^= h; - s[33] ^= l; - s[42] ^= h; - s[43] ^= l; - h = c2 ^ ((c6 << 1) | (c7 >>> 31)); - l = c3 ^ ((c7 << 1) | (c6 >>> 31)); - s[4] ^= h; - s[5] ^= l; - s[14] ^= h; - s[15] ^= l; - s[24] ^= h; - s[25] ^= l; - s[34] ^= h; - s[35] ^= l; - s[44] ^= h; - s[45] ^= l; - h = c4 ^ ((c8 << 1) | (c9 >>> 31)); - l = c5 ^ ((c9 << 1) | (c8 >>> 31)); - s[6] ^= h; - s[7] ^= l; - s[16] ^= h; - s[17] ^= l; - s[26] ^= h; - s[27] ^= l; - s[36] ^= h; - s[37] ^= l; - s[46] ^= h; - s[47] ^= l; - h = c6 ^ ((c0 << 1) | (c1 >>> 31)); - l = c7 ^ ((c1 << 1) | (c0 >>> 31)); - s[8] ^= h; - s[9] ^= l; - s[18] ^= h; - s[19] ^= l; - s[28] ^= h; - s[29] ^= l; - s[38] ^= h; - s[39] ^= l; - s[48] ^= h; - s[49] ^= l; + return byteArray +} - b0 = s[0]; - b1 = s[1]; - b32 = (s[11] << 4) | (s[10] >>> 28); - b33 = (s[10] << 4) | (s[11] >>> 28); - b14 = (s[20] << 3) | (s[21] >>> 29); - b15 = (s[21] << 3) | (s[20] >>> 29); - b46 = (s[31] << 9) | (s[30] >>> 23); - b47 = (s[30] << 9) | (s[31] >>> 23); - b28 = (s[40] << 18) | (s[41] >>> 14); - b29 = (s[41] << 18) | (s[40] >>> 14); - b20 = (s[2] << 1) | (s[3] >>> 31); - b21 = (s[3] << 1) | (s[2] >>> 31); - b2 = (s[13] << 12) | (s[12] >>> 20); - b3 = (s[12] << 12) | (s[13] >>> 20); - b34 = (s[22] << 10) | (s[23] >>> 22); - b35 = (s[23] << 10) | (s[22] >>> 22); - b16 = (s[33] << 13) | (s[32] >>> 19); - b17 = (s[32] << 13) | (s[33] >>> 19); - b48 = (s[42] << 2) | (s[43] >>> 30); - b49 = (s[43] << 2) | (s[42] >>> 30); - b40 = (s[5] << 30) | (s[4] >>> 2); - b41 = (s[4] << 30) | (s[5] >>> 2); - b22 = (s[14] << 6) | (s[15] >>> 26); - b23 = (s[15] << 6) | (s[14] >>> 26); - b4 = (s[25] << 11) | (s[24] >>> 21); - b5 = (s[24] << 11) | (s[25] >>> 21); - b36 = (s[34] << 15) | (s[35] >>> 17); - b37 = (s[35] << 15) | (s[34] >>> 17); - b18 = (s[45] << 29) | (s[44] >>> 3); - b19 = (s[44] << 29) | (s[45] >>> 3); - b10 = (s[6] << 28) | (s[7] >>> 4); - b11 = (s[7] << 28) | (s[6] >>> 4); - b42 = (s[17] << 23) | (s[16] >>> 9); - b43 = (s[16] << 23) | (s[17] >>> 9); - b24 = (s[26] << 25) | (s[27] >>> 7); - b25 = (s[27] << 25) | (s[26] >>> 7); - b6 = (s[36] << 21) | (s[37] >>> 11); - b7 = (s[37] << 21) | (s[36] >>> 11); - b38 = (s[47] << 24) | (s[46] >>> 8); - b39 = (s[46] << 24) | (s[47] >>> 8); - b30 = (s[8] << 27) | (s[9] >>> 5); - b31 = (s[9] << 27) | (s[8] >>> 5); - b12 = (s[18] << 20) | (s[19] >>> 12); - b13 = (s[19] << 20) | (s[18] >>> 12); - b44 = (s[29] << 7) | (s[28] >>> 25); - b45 = (s[28] << 7) | (s[29] >>> 25); - b26 = (s[38] << 8) | (s[39] >>> 24); - b27 = (s[39] << 8) | (s[38] >>> 24); - b8 = (s[48] << 14) | (s[49] >>> 18); - b9 = (s[49] << 14) | (s[48] >>> 18); +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check +// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 +function isArrayBuffer (obj) { + return obj instanceof ArrayBuffer || + (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && + typeof obj.byteLength === 'number') +} + +function numberIsNaN (obj) { + return obj !== obj // eslint-disable-line no-self-compare +} - s[0] = b0 ^ (~b2 & b4); - s[1] = b1 ^ (~b3 & b5); - s[10] = b10 ^ (~b12 & b14); - s[11] = b11 ^ (~b13 & b15); - s[20] = b20 ^ (~b22 & b24); - s[21] = b21 ^ (~b23 & b25); - s[30] = b30 ^ (~b32 & b34); - s[31] = b31 ^ (~b33 & b35); - s[40] = b40 ^ (~b42 & b44); - s[41] = b41 ^ (~b43 & b45); - s[2] = b2 ^ (~b4 & b6); - s[3] = b3 ^ (~b5 & b7); - s[12] = b12 ^ (~b14 & b16); - s[13] = b13 ^ (~b15 & b17); - s[22] = b22 ^ (~b24 & b26); - s[23] = b23 ^ (~b25 & b27); - s[32] = b32 ^ (~b34 & b36); - s[33] = b33 ^ (~b35 & b37); - s[42] = b42 ^ (~b44 & b46); - s[43] = b43 ^ (~b45 & b47); - s[4] = b4 ^ (~b6 & b8); - s[5] = b5 ^ (~b7 & b9); - s[14] = b14 ^ (~b16 & b18); - s[15] = b15 ^ (~b17 & b19); - s[24] = b24 ^ (~b26 & b28); - s[25] = b25 ^ (~b27 & b29); - s[34] = b34 ^ (~b36 & b38); - s[35] = b35 ^ (~b37 & b39); - s[44] = b44 ^ (~b46 & b48); - s[45] = b45 ^ (~b47 & b49); - s[6] = b6 ^ (~b8 & b0); - s[7] = b7 ^ (~b9 & b1); - s[16] = b16 ^ (~b18 & b10); - s[17] = b17 ^ (~b19 & b11); - s[26] = b26 ^ (~b28 & b20); - s[27] = b27 ^ (~b29 & b21); - s[36] = b36 ^ (~b38 & b30); - s[37] = b37 ^ (~b39 & b31); - s[46] = b46 ^ (~b48 & b40); - s[47] = b47 ^ (~b49 & b41); - s[8] = b8 ^ (~b0 & b2); - s[9] = b9 ^ (~b1 & b3); - s[18] = b18 ^ (~b10 & b12); - s[19] = b19 ^ (~b11 & b13); - s[28] = b28 ^ (~b20 & b22); - s[29] = b29 ^ (~b21 & b23); - s[38] = b38 ^ (~b30 & b32); - s[39] = b39 ^ (~b31 & b33); - s[48] = b48 ^ (~b40 & b42); - s[49] = b49 ^ (~b41 & b43); +},{"base64-js":12,"ieee754":14}],14:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] - s[0] ^= RC[n]; - s[1] ^= RC[n + 1]; - } -}; + i += d -module.exports = methods; + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":5}],9:[function(require,module,exports){ -var jsSHA = require('jssha/src/sha256'); -var Blake256 = require('./blake256'); -var keccak256 = require('./sha3')['keccak256']; + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} -function numberToHex (number) { - var hex = Math.round(number).toString(16); - if(hex.length === 1) { - hex = '0' + hex; - } - return hex; + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) } -var cryptoUtils = { - toHex: function (arrayOfBytes) { - var hex = ''; - for(var i = 0; i < arrayOfBytes.length; i++) { - hex += numberToHex(arrayOfBytes[i]); - } - return hex; - }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX'); - sha.update(hexString); - return sha.getHash('HEX'); - }, - sha256Checksum: function (payload) { - return this.sha256(this.sha256(payload)).substr(0, 8); - }, - blake256: function (hexString) { - return new Blake256().update(hexString, 'hex').digest('hex'); - }, - blake256Checksum: function (payload) { - return this.blake256(this.blake256(payload)).substr(0, 8); - }, - keccak256: function (hexString) { - return keccak256(hexString); +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 } -}; -module.exports = cryptoUtils; + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } -},{"./blake256":7,"./sha3":8,"jssha/src/sha256":4}],10:[function(require,module,exports){ -// defines P2PKH and P2SH address types for standard (prod) and testnet networks -var CURRENCIES = [{ - name: 'bitcoin', - symbol: 'btc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'litecoin', - symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} -},{ - name: 'peercoin', - symbol: 'ppc', - addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} -},{ - name: 'dogecoin', - symbol: 'doge', - addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} -},{ - name: 'beavercoin', - symbol: 'bvc', - addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} -},{ - name: 'freicoin', - symbol: 'frc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'protoshares', - symbol: 'pts', - addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} -},{ - name: 'megacoin', - symbol: 'mec', - addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} -},{ - name: 'primecoin', - symbol: 'xpm', - addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} -},{ - name: 'auroracoin', - symbol: 'aur', - addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} -},{ - name: 'namecoin', - symbol: 'nmc', - addressTypes: {prod: ['34'], testnet: []} -},{ - name: 'biocoin', - symbol: 'bio', - addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} -},{ - name: 'garlicoin', - symbol: 'grlc', - addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} -},{ - name: 'vertcoin', - symbol: 'vtc', - addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} -},{ - name: 'bitcoingold', - symbol: 'btg', - addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} -},{ - name: 'decred', - symbol: 'dcr', - addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, - hashFunction: 'blake256', - expectedLength: 26 -},{ - name: 'digibyte', - symbol: 'dgb', - addressTypes: {prod: ['1e'], testnet: []}, - eip55: false -},{ - name: 'ethereum', - symbol: 'eth', - eip55: true -},{ - name: 'etherzero', - symbol: 'etz', - eip55: true -},{ - name: 'ethereumclassic', - symbol: 'etc', - eip55: true -},{ - name: 'callisto', - symbol: 'clo', - eip55: true -}]; + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + +},{}],15:[function(require,module,exports){ +// shim for using process in browser +var process = module.exports = {}; +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. -var currencies = { - getByNameOrSymbol: function (currencyNameOrSymbol) { - var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); - for (var i = 0; i < CURRENCIES.length; i++) { - var currency = CURRENCIES[i]; - if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { - return currency; - } +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; } - return null; + } catch (e) { + cachedSetTimeout = defaultSetTimout; } -}; - -module.exports = currencies; - -},{}],11:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); - -module.exports = { - isAddress: function (address) { - if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { - // Check if it has the basic requirements of an address - return false; + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; } - - if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { - // If it's all small caps or all all caps, return true - return true; + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); } + } - // Otherwise check each case - return this.isChecksumAddress(address); - }, - isChecksumAddress: function (address) { - // Check each case - address = address.replace('0x',''); - - var addressHash = cryptoUtils.keccak256(address.toLowerCase()); - for (var i = 0; i < 40; i++ ) { - // The nth letter should be uppercase if the nth digit of casemap is 1 - if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || - (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { - return false; - } +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); } - - return true; } -}; -},{"./crypto/utils":9}],12:[function(require,module,exports){ -var base58 = require('./crypto/base58'); -var cryptoUtils = require('./crypto/utils'); -var currencies = require('./currencies'); -var ETHValidator = require('./ethereum_validator'); -var DEFAULT_CURRENCY_NAME = 'bitcoin'; -var DEFAULT_NETWORK_TYPE = 'prod'; -function getDecoded(address) { - try { - return base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } } +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; -module.exports = { - getAddressType: function (address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded = getDecoded(address); +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} - if (decoded) { - var length = decoded.length; +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; - if (length !== expectedLength) { - return null; + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); } - - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = this.checksum(hashFunction, body); - - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; } - - return null; - }, + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} - // Each currency may implement different hashing algorithm - checksum: function (hashFunction, payload) { - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; } - }, + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; - validate: function (address, currencyNameOrSymbol, networkType) { - currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; - networkType = networkType || DEFAULT_NETWORK_TYPE; +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); +function noop() {} - if (currency.eip55) { - return ETHValidator.isAddress(address); - } - - var correctAddressTypes; - var addressType = this.getAddressType(address, currency); +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; - if (networkType === 'prod' || networkType === 'testnet'){ - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); - } +process.listeners = function (name) { return [] } - return correctAddressTypes.indexOf(addressType) >= 0; - } +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); }; +process.umask = function() { return 0; }; -},{"./crypto/base58":6,"./crypto/utils":9,"./currencies":10,"./ethereum_validator":11}]},{},[12])(12) -}); \ No newline at end of file +},{}]},{},[11])(11) +}); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 41b915e6..55818aca 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,u,f){function a(e,t){if(!u[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(h)return h(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=u[e]={exports:{}};s[e][0].call(o.exports,function(t){var r=s[e][1][t];return a(r||t)},o,o.exports,i,s,u,f)}return u[e].exports}for(var h="function"==typeof require&&require,t=0;t>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=f[t.charCodeAt(r)]<<2|f[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=f[t.charCodeAt(r)]<<10|f[t.charCodeAt(r+1)]<<4|f[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=16383,u=0,f=e-n;u>2],o+=a[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=a[r>>10],o+=a[r>>4&63],o+=a[r<<2&63],o+="=");return i.push(o),i.join("")};for(var a=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],2:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return w(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":1,ieee754:3}],3:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,w)).binLen,e=r.value,r=t>>>5,n=0;n>>5),w=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),w,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,w)).binLen,e=r.value,r=t>>>5,n=0;n>>5),w=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),w,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return w(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":12,ieee754:14}],14:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s< Date: Fri, 23 Mar 2018 09:51:51 +0300 Subject: [PATCH 015/108] add test for ripple --- test/wallet_address_validator.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 07aa263a..38942d15 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -225,6 +225,14 @@ describe('WAValidator.validate()', function () { valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'callisto'); valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'CLO'); }); + + it('should return true for correct Ripple addresses', function () { + valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'ripple'); + valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'XRP'); + valid('r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV', 'XRP'); + valid('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', 'XRP'); + valid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN', 'XRP'); + }); }); describe('invalid results', function () { @@ -319,5 +327,12 @@ describe('WAValidator.validate()', function () { invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'etherzero'); invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'callisto'); }); + + it('should return false for incorrect ripple addresses', function () { + invalid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCN', 'ripple'); + invalid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhMN', 'XRP'); + invalid('6xAff4d6793F584a473348EbA058deb8ca', 'ripple'); + invalid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'ripple'); + }); }); }); From 11cc42392e794fb19cc57af2607e33e2c43dbe23 Mon Sep 17 00:00:00 2001 From: Dmitrii Pominov Date: Fri, 23 Mar 2018 17:16:29 +0300 Subject: [PATCH 016/108] Add Ripple to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5df691b5..100eb623 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ npm install wallet-address-validator * EthereumZero/ETZ, `'etherzero'` or `'ETZ'` * Callisto/CLO, `'callisto'` or `'CLO'` +* Ripple/XRP, `'ripple'` or `'XRP'` + ### Usage example From 6847561171c33e3de40cdb66dc1c9e7424b688d5 Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Mon, 26 Mar 2018 14:29:05 +0900 Subject: [PATCH 017/108] Added .editorconfig and fixed whitespaces --- .editorconfig | 10 +++++++++ karma.conf.js | 50 ++++++++++++++++++++--------------------- src/ripple_validator.js | 28 +++++++++++------------ 3 files changed, 49 insertions(+), 39 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..8f960391 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/karma.conf.js b/karma.conf.js index 0fded0c9..dfc8dcb0 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,27 +1,27 @@ // Karma configuration -module.exports = function(config) { - config.set({ - basePath: '', - - frameworks: ['mocha', 'chai'], - - files: [ - 'dist/wallet-address-validator.min.js', - 'test/**/*.js' - ], - - reporters: ['progress'], - - port: 9876, - - colors: true, - - logLevel: config.LOG_INFO, - - browsers: ['ChromeHeadless'], - - singleRun: true, - - concurrency: Infinity - }) +module.exports = function (config) { + config.set({ + basePath: '', + + frameworks: ['mocha', 'chai'], + + files: [ + 'dist/wallet-address-validator.min.js', + 'test/**/*.js' + ], + + reporters: ['progress'], + + port: 9876, + + colors: true, + + logLevel: config.LOG_INFO, + + browsers: ['ChromeHeadless'], + + singleRun: true, + + concurrency: Infinity + }) }; diff --git a/src/ripple_validator.js b/src/ripple_validator.js index b34948f2..bdea3a44 100644 --- a/src/ripple_validator.js +++ b/src/ripple_validator.js @@ -3,20 +3,20 @@ var baseX = require('base-x'); var codec = baseX("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"); // for ripple module.exports = { - /** - * ripple address validation - */ - isValidAddress: function (address) { - if (/^r[rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz]{27,35}$/.test(address) === false) - return false; - return this.verifyChecksum(address); - }, + /** + * ripple address validation + */ + isValidAddress: function (address) { + if (/^r[rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz]{27,35}$/.test(address) === false) + return false; + return this.verifyChecksum(address); + }, - verifyChecksum: function (address) { - var bytes = codec.decode(address); - var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); - var checksum = cryptoUtils.toHex(bytes.slice(-4)); + verifyChecksum: function (address) { + var bytes = codec.decode(address); + var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); + var checksum = cryptoUtils.toHex(bytes.slice(-4)); - return computedChecksum === checksum - } + return computedChecksum === checksum + } }; From f55d5c05284ffdb49616c0dc66daa96c0a8919cf Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Mon, 26 Mar 2018 14:46:53 +0900 Subject: [PATCH 018/108] Small code refactor --- dist/wallet-address-validator.js | 5760 +++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- src/currencies.js | 11 +- src/ethereum_validator.js | 10 +- src/ripple_validator.js | 14 +- src/wallet_address_validator.js | 7 +- 6 files changed, 2902 insertions(+), 2902 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 445b4fb9..1dd892b2 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -92,3410 +92,3410 @@ module.exports = function base (ALPHABET) { } } -},{"safe-buffer":3}],2:[function(require,module,exports){ -/* - A JavaScript implementation of the SHA family of hashes, as - defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding - HMAC implementation as defined in FIPS PUB 198a +},{"safe-buffer":7}],2:[function(require,module,exports){ +'use strict' - Copyright Brian Turek 2008-2017 - Distributed under the BSD License - See http://caligatio.github.com/jsSHA/ for more information +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray - Several functions taken from Paul Johnston -*/ -'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; -b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> -5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); -}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> -6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); -if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, -"");if(-1!==k&&k 0) { + throw new Error('Invalid string. Length must be a multiple of 4') } -} -if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer -} else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 } -function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return (b64.length * 3 / 4) - placeHoldersCount(b64) } -// Copy static methods from Buffer -copyProps(Buffer, SafeBuffer) +function toByteArray (b64) { + var i, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) -SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) -} + arr = new Arr((len * 3 / 4) - placeHolders) -SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0; i < l; i += 4) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF } - return buf + + return arr } -SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] } -SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) } - return buffer.SlowBuffer(size) + return output.join('') } -},{"buffer":13}],4:[function(require,module,exports){ -// Base58 encoding/decoding -// Originally written by Mike Hearn for BitcoinJ -// Copyright (c) 2011 Google Inc -// Ported to JavaScript by Stefan Thomas -// Merged Buffer refactorings from base58-native by Stephen Pair -// Copyright (c) 2013 BitPay Inc - -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' -var ALPHABET_MAP = {} -for(var i = 0; i < ALPHABET.length; ++i) { - ALPHABET_MAP[ALPHABET.charAt(i)] = i -} -var BASE = ALPHABET.length +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 -var base58 = { - decode: function(string) { - if (string.length === 0) return [] + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } - var i, j, bytes = [0] - for (i = 0; i < string.length; ++i) { - var c = string[i] - if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character') + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } - for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE - bytes[0] += ALPHABET_MAP[c] + parts.push(output) - var carry = 0 - for (j = 0; j < bytes.length; ++j) { - bytes[j] += carry - carry = bytes[j] >> 8 - bytes[j] &= 0xff - } + return parts.join('') +} - while (carry) { - bytes.push(carry & 0xff) - carry >>= 8 - } - } - // deal with leading zeros - for (i = 0; string[i] === '1' && i < string.length - 1; ++i) bytes.push(0) +},{}],3:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ - return bytes.reverse() - } -}; +'use strict' -module.exports = base58; +var base64 = require('base64-js') +var ieee754 = require('ieee754') +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 -},{}],5:[function(require,module,exports){ -(function (Buffer){ -'use strict'; +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH /** - * Credits to https://github.com/cryptocoinjs/blake-hash + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. */ -Blake256.sigma = [ - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], - [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], - [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], - [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], - [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] -] +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() -Blake256.u256 = [ - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 -] +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} -Blake256.padding = new Buffer([ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -]) +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 + } catch (e) { + return false + } +} -Blake256.prototype._length_carry = function (arr) { - for (var j = 0; j < arr.length; ++j) { - if (arr[j] < 0x0100000000) break - arr[j] -= 0x0100000000 - arr[j + 1] += 1 +Object.defineProperty(Buffer.prototype, 'parent', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined } -} + return this.buffer + } +}) -Blake256.prototype.update = function (data, encoding) { - data = new Buffer(data, encoding); - var block = this._block - var offset = 0 +Object.defineProperty(Buffer.prototype, 'offset', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined + } + return this.byteOffset + } +}) - while (this._blockOffset + data.length - offset >= block.length) { - for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('Invalid typed array length') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf +} - this._length[0] += block.length * 8 - this._length_carry(this._length) +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ - this._compress() - this._blockOffset = 0 +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} - while (offset < data.length) block[this._blockOffset++] = data[offset++] - return this; +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) } -var zo = new Buffer([0x01]) -var oo = new Buffer([0x81]) +Buffer.poolSize = 8192 // not used by this implementation -function rot (x, n) { - return ((x << (32 - n)) | (x >>> n)) >>> 0 -} +function from (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } -function g (v, m, i, a, b, c, d, e) { - var sigma = Blake256.sigma - var u256 = Blake256.u256 + if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } - v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 16) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 12) - v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 8) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 7) -} + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } -function Blake256 () { - this._h = [ - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 - ] + return fromObject(value) +} - this._s = [0, 0, 0, 0] +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} - this._block = new Buffer(64) - this._blockOffset = 0 - this._length = [0, 0] +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array - this._nullt = false +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} - this._zo = zo - this._oo = oo +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) } -Blake256.prototype._compress = function () { - var u256 = Blake256.u256 - var v = new Array(16) - var m = new Array(16) - var i +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} - for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) - for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 - for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 - for (i = 12; i < 16; ++i) v[i] = u256[i - 8] +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} - if (!this._nullt) { - v[12] = (v[12] ^ this._length[0]) >>> 0 - v[13] = (v[13] ^ this._length[0]) >>> 0 - v[14] = (v[14] ^ this._length[1]) >>> 0 - v[15] = (v[15] ^ this._length[1]) >>> 0 - } +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} - for (i = 0; i < 14; ++i) { - /* column step */ - g(v, m, i, 0, 4, 8, 12, 0) - g(v, m, i, 1, 5, 9, 13, 2) - g(v, m, i, 2, 6, 10, 14, 4) - g(v, m, i, 3, 7, 11, 15, 6) - /* diagonal step */ - g(v, m, i, 0, 5, 10, 15, 8) - g(v, m, i, 1, 6, 11, 12, 10) - g(v, m, i, 2, 7, 8, 13, 12) - g(v, m, i, 3, 4, 9, 14, 14) - } +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } - for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 - for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 -} + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } -Blake256.prototype._padding = function () { - var lo = this._length[0] + this._blockOffset * 8 - var hi = this._length[1] - if (lo >= 0x0100000000) { - lo -= 0x0100000000 - hi += 1 - } + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) - var msglen = new Buffer(8) - msglen.writeUInt32BE(hi, 0) - msglen.writeUInt32BE(lo, 4) + var actual = buf.write(string, encoding) - if (this._blockOffset === 55) { - this._length[0] -= 8 - this.update(this._oo) - } else { - if (this._blockOffset < 55) { - if (this._blockOffset === 0) this._nullt = true - this._length[0] -= (55 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) - } else { - this._length[0] -= (64 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) - this._length[0] -= 55 * 8 - this.update(Blake256.padding.slice(1, 1 + 55)) - this._nullt = true - } - - this.update(this._zo) - this._length[0] -= 8 - } + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } - this._length[0] -= 64 - this.update(msglen) + return buf } -Blake256.prototype.digest = function (encoding) { - this._padding() - - var buffer = new Buffer(32) - for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) - return buffer.toString(encoding); +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf } -module.exports = Blake256; -}).call(this,require("buffer").Buffer) -},{"buffer":13}],6:[function(require,module,exports){ -(function (process,global){ -/** - * [js-sha3]{@link https://github.com/emn178/js-sha3} - * - * @version 0.7.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2015-2017 - * @license MIT - */ -/*jslint bitwise: true */ -'use strict'; +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } -var ERROR = 'input is invalid type'; -var WINDOW = typeof window === 'object'; -var root = WINDOW ? window : {}; -if (root.JS_SHA3_NO_WINDOW) { - WINDOW = false; -} -var WEB_WORKER = !WINDOW && typeof self === 'object'; -var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; -if (NODE_JS) { - root = global; -} else if (WEB_WORKER) { - root = self; -} -var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; -var HEX_CHARS = '0123456789abcdef'.split(''); -var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; -var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; -var KECCAK_PADDING = [1, 256, 65536, 16777216]; -var PADDING = [6, 1536, 393216, 100663296]; -var SHIFT = [0, 8, 16, 24]; -var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, - 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, - 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, - 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, - 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; -var BITS = [224, 256, 384, 512]; -var SHAKE_BITS = [128, 256]; -var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; -var CSHAKE_BYTEPAD = { - '128': 168, - '256': 136 -}; + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } -if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { - Array.isArray = function (obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; - }; -} + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } -if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { - ArrayBuffer.isView = function (obj) { - return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; - }; + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf } -var createOutputMethod = function (bits, padding, outputType) { - return function (message) { - return new Keccak(bits, padding, bits).update(message)[outputType](); - }; -}; +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) -var createShakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits) { - return new Keccak(bits, padding, outputBits).update(message)[outputType](); - }; -}; + if (buf.length === 0) { + return buf + } -var createCshakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits, n, s) { - return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); - }; -}; + obj.copy(buf, 0, 0, len) + return buf + } -var createKmacOutputMethod = function (bits, padding, outputType) { - return function (key, message, outputBits, s) { - return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); - }; -}; + if (obj) { + if (ArrayBuffer.isView(obj) || 'length' in obj) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } -var createOutputMethods = function (method, createMethod, bits, padding) { - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createMethod(bits, padding, type); + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) } - return method; -}; + } -var createMethod = function (bits, padding) { - var method = createOutputMethod(bits, padding, 'hex'); - method.create = function () { - return new Keccak(bits, padding, bits); - }; - method.update = function (message) { - return method.create().update(message); - }; - return createOutputMethods(method, createOutputMethod, bits, padding); -}; + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') +} -var createShakeMethod = function (bits, padding) { - var method = createShakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits) { - return new Keccak(bits, padding, outputBits); - }; - method.update = function (message, outputBits) { - return method.create(outputBits).update(message); - }; - return createOutputMethods(method, createShakeOutputMethod, bits, padding); -}; +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 +} -var createCshakeMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createCshakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits, n, s) { - if (!n && !s) { - return methods['shake' + bits].create(outputBits); - } else { - return new Keccak(bits, padding, outputBits).bytepad([n, s], w); - } - }; - method.update = function (message, outputBits, n, s) { - return method.create(outputBits, n, s).update(message); - }; - return createOutputMethods(method, createCshakeOutputMethod, bits, padding); -}; +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} -var createKmacMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createKmacOutputMethod(bits, padding, 'hex'); - method.create = function (key, outputBits, s) { - return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); - }; - method.update = function (key, message, outputBits, s) { - return method.create(key, outputBits, s).update(message); - }; - return createOutputMethods(method, createKmacOutputMethod, bits, padding); -}; +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true +} -var algorithms = [ - { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, - { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, - { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, - { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, - { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } -]; +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } -var methods = {}, methodNames = []; + if (a === b) return 0 -for (var i = 0; i < algorithms.length; ++i) { - var algorithm = algorithms[i]; - var bits = algorithm.bits; - for (var j = 0; j < bits.length; ++j) { - var methodName = algorithm.name + '_' + bits[j]; - methodNames.push(methodName); - methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); - if (algorithm.name !== 'sha3') { - var newMethodName = algorithm.name + bits[j]; - methodNames.push(newMethodName); - methods[newMethodName] = methods[methodName]; - } - } -} + var x = a.length + var y = b.length -function Keccak(bits, padding, outputBits) { - this.blocks = []; - this.s = []; - this.padding = padding; - this.outputBits = outputBits; - this.reset = true; - this.finalized = false; - this.block = 0; - this.start = 0; - this.blockCount = (1600 - (bits << 1)) >> 5; - this.byteCount = this.blockCount << 2; - this.outputBlocks = outputBits >> 5; - this.extraBytes = (outputBits & 31) >> 3; - - for (var i = 0; i < 50; ++i) { - this.s[i] = 0; + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break } -} + } -Keccak.prototype.update = function (message) { - if (this.finalized) { - return; - } - var notString, type = typeof message; - if (type !== 'string') { - if (type === 'object') { - if (message === null) { - throw ERROR; - } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } else if (!Array.isArray(message)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var blocks = this.blocks, byteCount = this.byteCount, length = message.length, - blockCount = this.blockCount, index = 0, s = this.s, i, code; + if (x < y) return -1 + if (y < x) return 1 + return 0 +} - while (index < length) { - if (this.reset) { - this.reset = false; - blocks[0] = this.block; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - if (notString) { - for (i = this.start; index < length && i < byteCount; ++index) { - blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; - } - } else { - for (i = this.start; index < length && i < byteCount; ++index) { - code = message.charCodeAt(index); - if (code < 0x80) { - blocks[i >> 2] |= code << SHIFT[i++ & 3]; - } else if (code < 0x800) { - blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else if (code < 0xd800 || code >= 0xe000) { - blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); - blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - } - } - this.lastByteIndex = i; - if (i >= byteCount) { - this.start = i - byteCount; - this.block = blocks[blockCount]; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); - this.reset = true; - } else { - this.start = i; - } - } - return this; -}; +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} -Keccak.prototype.encode = function (x, right) { - var o = x & 255, n = 1; - var bytes = [o]; - x = x >> 8; - o = x & 255; - while (o > 0) { - bytes.unshift(o); - x = x >> 8; - o = x & 255; - ++n; - } - if (right) { - bytes.push(n); - } else { - bytes.unshift(n); - } - this.update(bytes); - return bytes.length; -}; +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } -Keccak.prototype.encodeString = function (str) { - var notString, type = typeof str; - if (type !== 'string') { - if (type === 'object') { - if (str === null) { - throw ERROR; - } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { - str = new Uint8Array(str); - } else if (!Array.isArray(str)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var bytes = 0, length = str.length; - if (notString) { - bytes = length; - } else { - for (var i = 0; i < str.length; ++i) { - var code = str.charCodeAt(i); - if (code < 0x80) { - bytes += 1; - } else if (code < 0x800) { - bytes += 2; - } else if (code < 0xd800 || code >= 0xe000) { - bytes += 3; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); - bytes += 4; - } - } - } - bytes += this.encode(bytes * 8); - this.update(str); - return bytes; -}; + if (list.length === 0) { + return Buffer.alloc(0) + } -Keccak.prototype.bytepad = function (strs, w) { - var bytes = this.encode(w); - for (var i = 0; i < strs.length; ++i) { - bytes += this.encodeString(strs[i]); + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length } - var paddingBytes = w - bytes % w; - var zeros = []; - zeros.length = paddingBytes; - this.update(zeros); - return this; -}; + } -Keccak.prototype.finalize = function () { - if (this.finalized) { - return; - } - this.finalized = true; - var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; - blocks[i >> 2] |= this.padding[i & 3]; - if (this.lastByteIndex === this.byteCount) { - blocks[0] = blocks[blockCount]; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (ArrayBuffer.isView(buf)) { + buf = Buffer.from(buf) } - blocks[blockCount - 1] |= 0x80000000; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') } - f(s); -}; + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} -Keccak.prototype.toString = Keccak.prototype.hex = function () { - this.finalize(); +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var hex = '', block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + - HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + - HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + - HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; - } - if (j % blockCount === 0) { - f(s); - i = 0; - } - } - if (extraBytes) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; - if (extraBytes > 1) { - hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; - } - if (extraBytes > 2) { - hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; - } + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true } - return hex; -}; + } +} +Buffer.byteLength = byteLength -Keccak.prototype.arrayBuffer = function () { - this.finalize(); +function slowToString (encoding, start, end) { + var loweredCase = false - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var bytes = this.outputBits >> 3; - var buffer; - if (extraBytes) { - buffer = new ArrayBuffer((outputBlocks + 1) << 2); - } else { - buffer = new ArrayBuffer(bytes); - } - var array = new Uint32Array(buffer); - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - array[j] = s[i]; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - array[i] = s[i]; - buffer = buffer.slice(0, bytes); - } - return buffer; -}; + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. -Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } -Keccak.prototype.digest = Keccak.prototype.array = function () { - this.finalize(); + if (end === undefined || end > this.length) { + end = this.length + } - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var array = [], offset, block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - array[offset + 1] = (block >> 8) & 0xFF; - array[offset + 2] = (block >> 16) & 0xFF; - array[offset + 3] = (block >> 24) & 0xFF; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - if (extraBytes > 1) { - array[offset + 1] = (block >> 8) & 0xFF; - } - if (extraBytes > 2) { - array[offset + 2] = (block >> 16) & 0xFF; - } + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true } - return array; -}; + } +} -function Kmac(bits, padding, outputBits) { - Keccak.call(this, bits, padding, outputBits); +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i } -Kmac.prototype = new Keccak(); +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} -Kmac.prototype.finalize = function () { - this.encode(this.outputBits, true); - return Keccak.prototype.finalize.call(this); -}; +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} -var f = function (s) { - var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, - b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, - b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, - b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; - for (n = 0; n < 48; n += 2) { - c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; - c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; - c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; - c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; - c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; - c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; - c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; - c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; - c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; - c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} - h = c8 ^ ((c2 << 1) | (c3 >>> 31)); - l = c9 ^ ((c3 << 1) | (c2 >>> 31)); - s[0] ^= h; - s[1] ^= l; - s[10] ^= h; - s[11] ^= l; - s[20] ^= h; - s[21] ^= l; - s[30] ^= h; - s[31] ^= l; - s[40] ^= h; - s[41] ^= l; - h = c0 ^ ((c4 << 1) | (c5 >>> 31)); - l = c1 ^ ((c5 << 1) | (c4 >>> 31)); - s[2] ^= h; - s[3] ^= l; - s[12] ^= h; - s[13] ^= l; - s[22] ^= h; - s[23] ^= l; - s[32] ^= h; - s[33] ^= l; - s[42] ^= h; - s[43] ^= l; - h = c2 ^ ((c6 << 1) | (c7 >>> 31)); - l = c3 ^ ((c7 << 1) | (c6 >>> 31)); - s[4] ^= h; - s[5] ^= l; - s[14] ^= h; - s[15] ^= l; - s[24] ^= h; - s[25] ^= l; - s[34] ^= h; - s[35] ^= l; - s[44] ^= h; - s[45] ^= l; - h = c4 ^ ((c8 << 1) | (c9 >>> 31)); - l = c5 ^ ((c9 << 1) | (c8 >>> 31)); - s[6] ^= h; - s[7] ^= l; - s[16] ^= h; - s[17] ^= l; - s[26] ^= h; - s[27] ^= l; - s[36] ^= h; - s[37] ^= l; - s[46] ^= h; - s[47] ^= l; - h = c6 ^ ((c0 << 1) | (c1 >>> 31)); - l = c7 ^ ((c1 << 1) | (c0 >>> 31)); - s[8] ^= h; - s[9] ^= l; - s[18] ^= h; - s[19] ^= l; - s[28] ^= h; - s[29] ^= l; - s[38] ^= h; - s[39] ^= l; - s[48] ^= h; - s[49] ^= l; - - b0 = s[0]; - b1 = s[1]; - b32 = (s[11] << 4) | (s[10] >>> 28); - b33 = (s[10] << 4) | (s[11] >>> 28); - b14 = (s[20] << 3) | (s[21] >>> 29); - b15 = (s[21] << 3) | (s[20] >>> 29); - b46 = (s[31] << 9) | (s[30] >>> 23); - b47 = (s[30] << 9) | (s[31] >>> 23); - b28 = (s[40] << 18) | (s[41] >>> 14); - b29 = (s[41] << 18) | (s[40] >>> 14); - b20 = (s[2] << 1) | (s[3] >>> 31); - b21 = (s[3] << 1) | (s[2] >>> 31); - b2 = (s[13] << 12) | (s[12] >>> 20); - b3 = (s[12] << 12) | (s[13] >>> 20); - b34 = (s[22] << 10) | (s[23] >>> 22); - b35 = (s[23] << 10) | (s[22] >>> 22); - b16 = (s[33] << 13) | (s[32] >>> 19); - b17 = (s[32] << 13) | (s[33] >>> 19); - b48 = (s[42] << 2) | (s[43] >>> 30); - b49 = (s[43] << 2) | (s[42] >>> 30); - b40 = (s[5] << 30) | (s[4] >>> 2); - b41 = (s[4] << 30) | (s[5] >>> 2); - b22 = (s[14] << 6) | (s[15] >>> 26); - b23 = (s[15] << 6) | (s[14] >>> 26); - b4 = (s[25] << 11) | (s[24] >>> 21); - b5 = (s[24] << 11) | (s[25] >>> 21); - b36 = (s[34] << 15) | (s[35] >>> 17); - b37 = (s[35] << 15) | (s[34] >>> 17); - b18 = (s[45] << 29) | (s[44] >>> 3); - b19 = (s[44] << 29) | (s[45] >>> 3); - b10 = (s[6] << 28) | (s[7] >>> 4); - b11 = (s[7] << 28) | (s[6] >>> 4); - b42 = (s[17] << 23) | (s[16] >>> 9); - b43 = (s[16] << 23) | (s[17] >>> 9); - b24 = (s[26] << 25) | (s[27] >>> 7); - b25 = (s[27] << 25) | (s[26] >>> 7); - b6 = (s[36] << 21) | (s[37] >>> 11); - b7 = (s[37] << 21) | (s[36] >>> 11); - b38 = (s[47] << 24) | (s[46] >>> 8); - b39 = (s[46] << 24) | (s[47] >>> 8); - b30 = (s[8] << 27) | (s[9] >>> 5); - b31 = (s[9] << 27) | (s[8] >>> 5); - b12 = (s[18] << 20) | (s[19] >>> 12); - b13 = (s[19] << 20) | (s[18] >>> 12); - b44 = (s[29] << 7) | (s[28] >>> 25); - b45 = (s[28] << 7) | (s[29] >>> 25); - b26 = (s[38] << 8) | (s[39] >>> 24); - b27 = (s[39] << 8) | (s[38] >>> 24); - b8 = (s[48] << 14) | (s[49] >>> 18); - b9 = (s[49] << 14) | (s[48] >>> 18); - - s[0] = b0 ^ (~b2 & b4); - s[1] = b1 ^ (~b3 & b5); - s[10] = b10 ^ (~b12 & b14); - s[11] = b11 ^ (~b13 & b15); - s[20] = b20 ^ (~b22 & b24); - s[21] = b21 ^ (~b23 & b25); - s[30] = b30 ^ (~b32 & b34); - s[31] = b31 ^ (~b33 & b35); - s[40] = b40 ^ (~b42 & b44); - s[41] = b41 ^ (~b43 & b45); - s[2] = b2 ^ (~b4 & b6); - s[3] = b3 ^ (~b5 & b7); - s[12] = b12 ^ (~b14 & b16); - s[13] = b13 ^ (~b15 & b17); - s[22] = b22 ^ (~b24 & b26); - s[23] = b23 ^ (~b25 & b27); - s[32] = b32 ^ (~b34 & b36); - s[33] = b33 ^ (~b35 & b37); - s[42] = b42 ^ (~b44 & b46); - s[43] = b43 ^ (~b45 & b47); - s[4] = b4 ^ (~b6 & b8); - s[5] = b5 ^ (~b7 & b9); - s[14] = b14 ^ (~b16 & b18); - s[15] = b15 ^ (~b17 & b19); - s[24] = b24 ^ (~b26 & b28); - s[25] = b25 ^ (~b27 & b29); - s[34] = b34 ^ (~b36 & b38); - s[35] = b35 ^ (~b37 & b39); - s[44] = b44 ^ (~b46 & b48); - s[45] = b45 ^ (~b47 & b49); - s[6] = b6 ^ (~b8 & b0); - s[7] = b7 ^ (~b9 & b1); - s[16] = b16 ^ (~b18 & b10); - s[17] = b17 ^ (~b19 & b11); - s[26] = b26 ^ (~b28 & b20); - s[27] = b27 ^ (~b29 & b21); - s[36] = b36 ^ (~b38 & b30); - s[37] = b37 ^ (~b39 & b31); - s[46] = b46 ^ (~b48 & b40); - s[47] = b47 ^ (~b49 & b41); - s[8] = b8 ^ (~b0 & b2); - s[9] = b9 ^ (~b1 & b3); - s[18] = b18 ^ (~b10 & b12); - s[19] = b19 ^ (~b11 & b13); - s[28] = b28 ^ (~b20 & b22); - s[29] = b29 ^ (~b21 & b23); - s[38] = b38 ^ (~b30 & b32); - s[39] = b39 ^ (~b31 & b33); - s[48] = b48 ^ (~b40 & b42); - s[49] = b49 ^ (~b41 & b43); - - s[0] ^= RC[n]; - s[1] ^= RC[n + 1]; - } -}; - -module.exports = methods; - -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":15}],7:[function(require,module,exports){ -var jsSHA = require('jssha/src/sha256'); -var Blake256 = require('./blake256'); -var keccak256 = require('./sha3')['keccak256']; - -function numberToHex (number) { - var hex = Math.round(number).toString(16); - if(hex.length === 1) { - hex = '0' + hex; - } - return hex; +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) } -var cryptoUtils = { - toHex: function (arrayOfBytes) { - var hex = ''; - for(var i = 0; i < arrayOfBytes.length; i++) { - hex += numberToHex(arrayOfBytes[i]); - } - return hex; - }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX'); - sha.update(hexString); - return sha.getHash('HEX'); - }, - sha256Checksum: function (payload) { - return this.sha256(this.sha256(payload)).substr(0, 8); - }, - blake256: function (hexString) { - return new Blake256().update(hexString, 'hex').digest('hex'); - }, - blake256Checksum: function (payload) { - return this.blake256(this.blake256(payload)).substr(0, 8); - }, - keccak256: function (hexString) { - return keccak256(hexString); - } -}; - -module.exports = cryptoUtils; - -},{"./blake256":5,"./sha3":6,"jssha/src/sha256":2}],8:[function(require,module,exports){ -var XRPValidator = require('./ripple_validator'); - -// defines P2PKH and P2SH address types for standard (prod) and testnet networks -var CURRENCIES = [{ - name: 'bitcoin', - symbol: 'btc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'litecoin', - symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} -},{ - name: 'peercoin', - symbol: 'ppc', - addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} -},{ - name: 'dogecoin', - symbol: 'doge', - addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} -},{ - name: 'beavercoin', - symbol: 'bvc', - addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} -},{ - name: 'freicoin', - symbol: 'frc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'protoshares', - symbol: 'pts', - addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} -},{ - name: 'megacoin', - symbol: 'mec', - addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} -},{ - name: 'primecoin', - symbol: 'xpm', - addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} -},{ - name: 'auroracoin', - symbol: 'aur', - addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} -},{ - name: 'namecoin', - symbol: 'nmc', - addressTypes: {prod: ['34'], testnet: []} -},{ - name: 'biocoin', - symbol: 'bio', - addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} -},{ - name: 'garlicoin', - symbol: 'grlc', - addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} -},{ - name: 'vertcoin', - symbol: 'vtc', - addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} -},{ - name: 'bitcoingold', - symbol: 'btg', - addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} -},{ - name: 'decred', - symbol: 'dcr', - addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, - hashFunction: 'blake256', - expectedLength: 26 -},{ - name: 'digibyte', - symbol: 'dgb', - addressTypes: {prod: ['1e'], testnet: []}, - eip55: false -},{ - name: 'ethereum', - symbol: 'eth', - eip55: true -},{ - name: 'etherzero', - symbol: 'etz', - eip55: true -},{ - name: 'ethereumclassic', - symbol: 'etc', - eip55: true -},{ - name: 'callisto', - symbol: 'clo', - eip55: true -},{ - name: 'ripple', - symbol: 'xrp', - validator: XRPValidator, - eip55: false -}]; - - -var currencies = { - getByNameOrSymbol: function (currencyNameOrSymbol) { - var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); - for (var i = 0; i < CURRENCIES.length; i++) { - var currency = CURRENCIES[i]; - if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { - return currency; - } - } - return null; - } -}; +Buffer.prototype.toLocaleString = Buffer.prototype.toString -module.exports = currencies; +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} -},{"./ripple_validator":10}],9:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} -module.exports = { - isAddress: function (address) { - if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { - // Check if it has the basic requirements of an address - return false; - } - - if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { - // If it's all small caps or all all caps, return true - return true; - } +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } - // Otherwise check each case - return this.isChecksumAddress(address); - }, - isChecksumAddress: function (address) { - // Check each case - address = address.replace('0x',''); + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } - var addressHash = cryptoUtils.keccak256(address.toLowerCase()); + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } - for (var i = 0; i < 40; i++ ) { - // The nth letter should be uppercase if the nth digit of casemap is 1 - if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || - (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { - return false; - } - } - - return true; - } -}; + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } -},{"./crypto/utils":7}],10:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); -var baseX = require('base-x'); -var codec = baseX("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"); // for ripple + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 -module.exports = { - /** - * ripple address validation - */ - isValidAddress: function (address) { - if (/^r[rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz]{27,35}$/.test(address) === false) - return false; - return this.verifyChecksum(address); - }, - - verifyChecksum: function (address) { - var bytes = codec.decode(address); - var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); - var checksum = cryptoUtils.toHex(bytes.slice(-4)); - - return computedChecksum === checksum - } -}; + if (this === target) return 0 -},{"./crypto/utils":7,"base-x":1}],11:[function(require,module,exports){ -var base58 = require('./crypto/base58'); -var cryptoUtils = require('./crypto/utils'); -var currencies = require('./currencies'); -var ETHValidator = require('./ethereum_validator'); + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) -var DEFAULT_CURRENCY_NAME = 'bitcoin'; -var DEFAULT_NETWORK_TYPE = 'prod'; + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) -function getDecoded(address) { - try { - return base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break } -} + } -module.exports = { - getAddressType: function (address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded = getDecoded(address); + if (x < y) return -1 + if (y < x) return 1 + return 0 +} - if (decoded) { - var length = decoded.length; +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 - if (length !== expectedLength) { - return null; - } + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = this.checksum(hashFunction, body); + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; - } - - return null; - }, + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } - // Each currency may implement different hashing algorithm - checksum: function (hashFunction, payload) { - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); - } - }, + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } - validate: function (address, currencyNameOrSymbol, networkType) { - currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; - networkType = networkType || DEFAULT_NETWORK_TYPE; + throw new TypeError('val must be string, number or Buffer') +} - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length - if (currency.validator) { - return currency.validator.isValidAddress(address); - } + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } - if (currency.eip55) { - return ETHValidator.isAddress(address); - } - - var correctAddressTypes; - var addressType = this.getAddressType(address, currency); + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } - if (networkType === 'prod' || networkType === 'testnet'){ - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break } - - return correctAddressTypes.indexOf(addressType) >= 0; + } + if (found) return i } -}; - -},{"./crypto/base58":4,"./crypto/utils":7,"./currencies":8,"./ethereum_validator":9}],12:[function(require,module,exports){ -'use strict' + } -exports.byteLength = byteLength -exports.toByteArray = toByteArray -exports.fromByteArray = fromByteArray + return -1 +} -var lookup = [] -var revLookup = [] -var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} -var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) } -// Support decoding URL-safe base64 strings, as Node.js does. -// See: https://en.wikipedia.org/wiki/Base64#URL_applications -revLookup['-'.charCodeAt(0)] = 62 -revLookup['_'.charCodeAt(0)] = 63 +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} -function placeHoldersCount (b64) { - var len = b64.length - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } } - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i } -function byteLength (b64) { - // base64 is 4/3 + up to two characters of the original data - return (b64.length * 3 / 4) - placeHoldersCount(b64) +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) } -function toByteArray (b64) { - var i, l, tmp, placeHolders, arr - var len = b64.length - placeHolders = placeHoldersCount(b64) +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} - arr = new Arr((len * 3 / 4) - placeHolders) +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? len - 4 : len +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} - var L = 0 +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} - for (i = 0; i < l; i += 4) { - tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] - arr[L++] = (tmp >> 16) & 0xFF - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) } - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') } - return arr + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } } -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } } -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) } - return output.join('') } -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) - } + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' + res.push(codePoint) + i += bytesPerSequence } - parts.push(output) - - return parts.join('') + return decodeCodePointsArray(res) } -},{}],13:[function(require,module,exports){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' - -var base64 = require('base64-js') -var ieee754 = require('ieee754') - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -var K_MAX_LENGTH = 0x7fffffff -exports.kMaxLength = K_MAX_LENGTH - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ -Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 -if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) -} +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } -function typedArraySupport () { - // Can typed array instances can be augmented? - try { - var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} - return arr.foo() === 42 - } catch (e) { - return false + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) } + return res } -Object.defineProperty(Buffer.prototype, 'parent', { - get: function () { - if (!(this instanceof Buffer)) { - return undefined - } - return this.buffer - } -}) +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) -Object.defineProperty(Buffer.prototype, 'offset', { - get: function () { - if (!(this instanceof Buffer)) { - return undefined - } - return this.byteOffset + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) } -}) + return ret +} -function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('Invalid typed array length') +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype - return buf + return ret } -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ +function hexSlice (buf, start, end) { + var len = buf.length -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' - ) - } - return allocUnsafe(arg) + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) } - return from(arg, encodingOrOffset, length) + return out } -// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res } -Buffer.poolSize = 8192 // not used by this implementation +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end -function from (value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len } - if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len } - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } + if (end < start) end = start - return fromObject(value) + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf } -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') } -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul } + + return val } -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul } - return createBuffer(size) -} -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) + return val } -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] } -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) } -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] } -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) - var actual = buf.write(string, encoding) + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul } + mul *= 0x80 - return buf -} + if (val >= mul) val -= Math.pow(2, 8 * byteLength) -function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf + return val } -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul } + mul *= 0x80 - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } + if (val >= mul) val -= Math.pow(2, 8 * byteLength) - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf + return val } -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} - obj.copy(buf, 0, 0, len) - return buf - } +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} - if (obj) { - if (ArrayBuffer.isView(obj) || 'length' in obj) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } - } +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) - throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) } -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) } -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) } -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) } -Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} - if (a === b) return 0 +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} - var x = a.length - var y = b.length +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) } - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF } + + return offset + byteLength } -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) } - if (list.length === 0) { - return Buffer.alloc(0) + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF } - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } + return offset + byteLength +} - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (ArrayBuffer.isView(buf)) { - buf = Buffer.from(buf) - } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 } -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { - return string.byteLength - } - if (typeof string !== 'string') { - string = '' + string - } +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} - var len = string.length - if (len === 0) return 0 +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - case undefined: - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 } -Buffer.byteLength = byteLength -function slowToString (encoding, start, end) { - var loweredCase = false +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' + checkInt(this, value, offset, byteLength, limit - 1, -limit) } - if (end === undefined || end > this.length) { - end = this.length + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } - if (end <= 0) { - return '' - } + return offset + byteLength +} - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) - if (end <= start) { - return '' + checkInt(this, value, offset, byteLength, limit - 1, -limit) } - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) + return offset + byteLength +} - case 'base64': - return base64Slice(this, start, end) +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 } -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 } -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') } -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) } - return this + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 } -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) } -Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) } -Buffer.prototype.toLocaleString = Buffer.prototype.toString +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) } -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) } -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (!Buffer.isBuffer(target)) { - throw new TypeError('Argument must be a Buffer') - } +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start } - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) + var len = end - start - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) } - if (x < y) return -1 - if (y < x) return 1 - return 0 + return len } -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 } + } else if (typeof val === 'number') { + val = val & 255 } - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this } + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val } } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i + var bytes = Buffer.isBuffer(val) + ? val + : new Buffer(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] } } - return -1 + return this } -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} +// HELPER FUNCTIONS +// ================ -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str } -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) } -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') } } - var strLen = string.length + return bytes +} - if (length > strLen / 2) { - length = strLen / 2 +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] } return i } -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check +// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 +function isArrayBuffer (obj) { + return obj instanceof ArrayBuffer || + (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && + typeof obj.byteLength === 'number') } -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) +function numberIsNaN (obj) { + return obj !== obj // eslint-disable-line no-self-compare +} + +},{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) } -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} + value = Math.abs(value) -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias } else { - encoding = length - length = undefined + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) } - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - if (!encoding) encoding = 'utf8' + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) + buffer[offset + i - d] |= s * 128 +} - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) +},{}],5:[function(require,module,exports){ +/* + A JavaScript implementation of the SHA family of hashes, as + defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding + HMAC implementation as defined in FIPS PUB 198a - case 'ascii': - return asciiWrite(this, string, offset, length) + Copyright Brian Turek 2008-2017 + Distributed under the BSD License + See http://caligatio.github.com/jsSHA/ for more information - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) + Several functions taken from Paul Johnston +*/ +'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; +b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> +5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); +}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> +6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==k&&k 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } } - res.push(codePoint) - i += bytesPerSequence - } - return decodeCodePointsArray(res) } +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res } +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } } -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); } -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out -} +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) - } - return res +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; } +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf -} +function noop() {} -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) +process.listeners = function (name) { return [] } - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; - return val -} +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } +},{}],7:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] } - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer } -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) } -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) } -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf } -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val + return Buffer(size) } -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) } -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} +},{"buffer":3}],8:[function(require,module,exports){ +// Base58 encoding/decoding +// Originally written by Mike Hearn for BitcoinJ +// Copyright (c) 2011 Google Inc +// Ported to JavaScript by Stefan Thomas +// Merged Buffer refactorings from base58-native by Stephen Pair +// Copyright (c) 2013 BitPay Inc -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val +var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' +var ALPHABET_MAP = {} +for(var i = 0; i < ALPHABET.length; ++i) { + ALPHABET_MAP[ALPHABET.charAt(i)] = i } +var BASE = ALPHABET.length -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) +var base58 = { + decode: function(string) { + if (string.length === 0) return [] - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} + var i, j, bytes = [0] + for (i = 0; i < string.length; ++i) { + var c = string[i] + if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character') -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) + for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE + bytes[0] += ALPHABET_MAP[c] - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} + var carry = 0 + for (j = 0; j < bytes.length; ++j) { + bytes[j] += carry + carry = bytes[j] >> 8 + bytes[j] &= 0xff + } -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} + while (carry) { + bytes.push(carry & 0xff) + carry >>= 8 + } + } + // deal with leading zeros + for (i = 0; string[i] === '1' && i < string.length - 1; ++i) bytes.push(0) -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} + return bytes.reverse() + } +}; -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} +module.exports = base58; -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} +},{}],9:[function(require,module,exports){ +(function (Buffer){ +'use strict'; -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } +/** + * Credits to https://github.com/cryptocoinjs/blake-hash + */ +Blake256.sigma = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] +] - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } +Blake256.u256 = [ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 +] - return offset + byteLength +Blake256.padding = new Buffer([ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +]) + +Blake256.prototype._length_carry = function (arr) { + for (var j = 0; j < arr.length; ++j) { + if (arr[j] < 0x0100000000) break + arr[j] -= 0x0100000000 + arr[j + 1] += 1 + } } -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } +Blake256.prototype.update = function (data, encoding) { + data = new Buffer(data, encoding); + var block = this._block + var offset = 0 - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } + while (this._blockOffset + data.length - offset >= block.length) { + for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] + + this._length[0] += block.length * 8 + this._length_carry(this._length) - return offset + byteLength -} + this._compress() + this._blockOffset = 0 + } -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 + while (offset < data.length) block[this._blockOffset++] = data[offset++] + return this; } -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} +var zo = new Buffer([0x01]) +var oo = new Buffer([0x81]) -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 +function rot (x, n) { + return ((x << (32 - n)) | (x >>> n)) >>> 0 } -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 +function g (v, m, i, a, b, c, d, e) { + var sigma = Blake256.sigma + var u256 = Blake256.u256 + + v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 16) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 12) + v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 8) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 7) } -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 +function Blake256 () { + this._h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ] + + this._s = [0, 0, 0, 0] + + this._block = new Buffer(64) + this._blockOffset = 0 + this._length = [0, 0] + + this._nullt = false + + this._zo = zo + this._oo = oo } -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) +Blake256.prototype._compress = function () { + var u256 = Blake256.u256 + var v = new Array(16) + var m = new Array(16) + var i - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } + for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) + for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 + for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 + for (i = 12; i < 16; ++i) v[i] = u256[i - 8] - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 + if (!this._nullt) { + v[12] = (v[12] ^ this._length[0]) >>> 0 + v[13] = (v[13] ^ this._length[0]) >>> 0 + v[14] = (v[14] ^ this._length[1]) >>> 0 + v[15] = (v[15] ^ this._length[1]) >>> 0 } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - return offset + byteLength + for (i = 0; i < 14; ++i) { + /* column step */ + g(v, m, i, 0, 4, 8, 12, 0) + g(v, m, i, 1, 5, 9, 13, 2) + g(v, m, i, 2, 6, 10, 14, 4) + g(v, m, i, 3, 7, 11, 15, 6) + /* diagonal step */ + g(v, m, i, 0, 5, 10, 15, 8) + g(v, m, i, 1, 6, 11, 12, 10) + g(v, m, i, 2, 7, 8, 13, 12) + g(v, m, i, 3, 4, 9, 14, 14) + } + + for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 + for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 } -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) +Blake256.prototype._padding = function () { + var lo = this._length[0] + this._blockOffset * 8 + var hi = this._length[1] + if (lo >= 0x0100000000) { + lo -= 0x0100000000 + hi += 1 + } - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } + var msglen = new Buffer(8) + msglen.writeUInt32BE(hi, 0) + msglen.writeUInt32BE(lo, 4) - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 + if (this._blockOffset === 55) { + this._length[0] -= 8 + this.update(this._oo) + } else { + if (this._blockOffset < 55) { + if (this._blockOffset === 0) this._nullt = true + this._length[0] -= (55 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) + } else { + this._length[0] -= (64 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) + this._length[0] -= 55 * 8 + this.update(Blake256.padding.slice(1, 1 + 55)) + this._nullt = true + } + + this.update(this._zo) + this._length[0] -= 8 } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - return offset + byteLength + this._length[0] -= 64 + this.update(msglen) } -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} +Blake256.prototype.digest = function (encoding) { + this._padding() -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 + var buffer = new Buffer(32) + for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) + return buffer.toString(encoding); } -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 +module.exports = Blake256; +}).call(this,require("buffer").Buffer) +},{"buffer":3}],10:[function(require,module,exports){ +(function (process,global){ +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.7.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2017 + * @license MIT + */ +/*jslint bitwise: true */ +'use strict'; + +var ERROR = 'input is invalid type'; +var WINDOW = typeof window === 'object'; +var root = WINDOW ? window : {}; +if (root.JS_SHA3_NO_WINDOW) { + WINDOW = false; +} +var WEB_WORKER = !WINDOW && typeof self === 'object'; +var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; +if (NODE_JS) { + root = global; +} else if (WEB_WORKER) { + root = self; } +var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; +var HEX_CHARS = '0123456789abcdef'.split(''); +var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; +var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; +var KECCAK_PADDING = [1, 256, 65536, 16777216]; +var PADDING = [6, 1536, 393216, 100663296]; +var SHIFT = [0, 8, 16, 24]; +var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; +var BITS = [224, 256, 384, 512]; +var SHAKE_BITS = [128, 256]; +var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; +var CSHAKE_BYTEPAD = { + '128': 168, + '256': 136 +}; -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 +if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { + Array.isArray = function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; } -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 +if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { + ArrayBuffer.isView = function (obj) { + return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; + }; } -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} +var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; +}; -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} +var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; +}; -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} +var createCshakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits, n, s) { + return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); + }; +}; -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} +var createKmacOutputMethod = function (bits, padding, outputType) { + return function (key, message, outputBits, s) { + return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); + }; +}; -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} +var createOutputMethods = function (method, createMethod, bits, padding) { + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createMethod(bits, padding, type); + } + return method; +}; -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} +var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + return createOutputMethods(method, createOutputMethod, bits, padding); +}; -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} +var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + return createOutputMethods(method, createShakeOutputMethod, bits, padding); +}; -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start +var createCshakeMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createCshakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits, n, s) { + if (!n && !s) { + return methods['shake' + bits].create(outputBits); + } else { + return new Keccak(bits, padding, outputBits).bytepad([n, s], w); + } + }; + method.update = function (message, outputBits, n, s) { + return method.create(outputBits, n, s).update(message); + }; + return createOutputMethods(method, createCshakeOutputMethod, bits, padding); +}; - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 +var createKmacMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createKmacOutputMethod(bits, padding, 'hex'); + method.create = function (key, outputBits, s) { + return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); + }; + method.update = function (key, message, outputBits, s) { + return method.create(key, outputBits, s).update(message); + }; + return createOutputMethods(method, createKmacOutputMethod, bits, padding); +}; - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') +var algorithms = [ + { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, + { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, + { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, + { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, + { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } +]; - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } +var methods = {}, methodNames = []; - var len = end - start +for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name + '_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + if (algorithm.name !== 'sha3') { + var newMethodName = algorithm.name + bits[j]; + methodNames.push(newMethodName); + methods[newMethodName] = methods[methodName]; + } + } +} - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] +function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.finalized = false; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } +} + +Keccak.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString, type = typeof message; + if (type !== 'string') { + if (type === 'object') { + if (message === null) { + throw ERROR; + } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (!Array.isArray(message)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var blocks = this.blocks, byteCount = this.byteCount, length = message.length, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) - } - - return len -} + return this; +}; -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length +Keccak.prototype.encode = function (x, right) { + var o = x & 255, n = 1; + var bytes = [o]; + x = x >> 8; + o = x & 255; + while (o > 0) { + bytes.unshift(o); + x = x >> 8; + o = x & 255; + ++n; } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') + if (right) { + bytes.push(n); + } else { + bytes.unshift(n); } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) + this.update(bytes); + return bytes.length; +}; + +Keccak.prototype.encodeString = function (str) { + var notString, type = typeof str; + if (type !== 'string') { + if (type === 'object') { + if (str === null) { + throw ERROR; + } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { + str = new Uint8Array(str); + } else if (!Array.isArray(str)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code - } + var bytes = 0, length = str.length; + if (notString) { + bytes = length; + } else { + for (var i = 0; i < str.length; ++i) { + var code = str.charCodeAt(i); + if (code < 0x80) { + bytes += 1; + } else if (code < 0x800) { + bytes += 2; + } else if (code < 0xd800 || code >= 0xe000) { + bytes += 3; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); + bytes += 4; + } + } } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 + bytes += this.encode(bytes * 8); + this.update(str); + return bytes; +}; - if (!val) val = 0 +Keccak.prototype.bytepad = function (strs, w) { + var bytes = this.encode(w); + for (var i = 0; i < strs.length; ++i) { + bytes += this.encodeString(strs[i]); + } + var paddingBytes = w - bytes % w; + var zeros = []; + zeros.length = paddingBytes; + this.update(zeros); + return this; +}; - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val +Keccak.prototype.finalize = function () { + if (this.finalized) { + return; } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : new Buffer(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; } - } - - return this -} - -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} + f(s); +}; -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} +Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; +}; - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) +Keccak.prototype.arrayBuffer = function () { + this.finalize(); - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; +}; - // valid lead - leadSurrogate = codePoint - - continue - } +Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } +Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') + if (extraBytes) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } } - } + return array; +}; - return bytes +function Kmac(bits, padding, outputBits) { + Keccak.call(this, bits, padding, outputBits); } -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} +Kmac.prototype = new Keccak(); -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break +Kmac.prototype.finalize = function () { + this.encode(this.outputBits, true); + return Keccak.prototype.finalize.call(this); +}; - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } +var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; - return byteArray -} + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } +}; -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} +module.exports = methods; -// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check -// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 -function isArrayBuffer (obj) { - return obj instanceof ArrayBuffer || - (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && - typeof obj.byteLength === 'number') -} +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":6}],11:[function(require,module,exports){ +var jsSHA = require('jssha/src/sha256'); +var Blake256 = require('./blake256'); +var keccak256 = require('./sha3')['keccak256']; -function numberIsNaN (obj) { - return obj !== obj // eslint-disable-line no-self-compare +function numberToHex (number) { + var hex = Math.round(number).toString(16); + if(hex.length === 1) { + hex = '0' + hex; + } + return hex; } -},{"base64-js":12,"ieee754":14}],14:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} +var cryptoUtils = { + toHex: function (arrayOfBytes) { + var hex = ''; + for(var i = 0; i < arrayOfBytes.length; i++) { + hex += numberToHex(arrayOfBytes[i]); + } + return hex; + }, + sha256: function (hexString) { + var sha = new jsSHA('SHA-256', 'HEX'); + sha.update(hexString); + return sha.getHash('HEX'); + }, + sha256Checksum: function (payload) { + return this.sha256(this.sha256(payload)).substr(0, 8); + }, + blake256: function (hexString) { + return new Blake256().update(hexString, 'hex').digest('hex'); + }, + blake256Checksum: function (payload) { + return this.blake256(this.blake256(payload)).substr(0, 8); + }, + keccak256: function (hexString) { + return keccak256(hexString); + } +}; - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} +module.exports = cryptoUtils; -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 +},{"./blake256":9,"./sha3":10,"jssha/src/sha256":5}],12:[function(require,module,exports){ +var XRPValidator = require('./ripple_validator'); +var ETHValidator = require('./ethereum_validator'); - value = Math.abs(value) +// defines P2PKH and P2SH address types for standard (prod) and testnet networks +var CURRENCIES = [{ + name: 'bitcoin', + symbol: 'btc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'litecoin', + symbol: 'ltc', + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} +},{ + name: 'peercoin', + symbol: 'ppc', + addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} +},{ + name: 'dogecoin', + symbol: 'doge', + addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} +},{ + name: 'beavercoin', + symbol: 'bvc', + addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} +},{ + name: 'freicoin', + symbol: 'frc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'protoshares', + symbol: 'pts', + addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} +},{ + name: 'megacoin', + symbol: 'mec', + addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} +},{ + name: 'primecoin', + symbol: 'xpm', + addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} +},{ + name: 'auroracoin', + symbol: 'aur', + addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} +},{ + name: 'namecoin', + symbol: 'nmc', + addressTypes: {prod: ['34'], testnet: []} +},{ + name: 'biocoin', + symbol: 'bio', + addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} +},{ + name: 'garlicoin', + symbol: 'grlc', + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} +},{ + name: 'vertcoin', + symbol: 'vtc', + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} +},{ + name: 'bitcoingold', + symbol: 'btg', + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} +},{ + name: 'decred', + symbol: 'dcr', + addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, + hashFunction: 'blake256', + expectedLength: 26 +},{ + name: 'digibyte', + symbol: 'dgb', + addressTypes: {prod: ['1e'], testnet: []}, +},{ + name: 'ethereum', + symbol: 'eth', + validator: ETHValidator, +},{ + name: 'etherzero', + symbol: 'etz', + validator: ETHValidator, +},{ + name: 'ethereumclassic', + symbol: 'etc', + validator: ETHValidator, +},{ + name: 'callisto', + symbol: 'clo', + validator: ETHValidator, +},{ + name: 'ripple', + symbol: 'xrp', + validator: XRPValidator, +}]; - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 +var currencies = { + getByNameOrSymbol: function (currencyNameOrSymbol) { + var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); + for (var i = 0; i < CURRENCIES.length; i++) { + var currency = CURRENCIES[i]; + if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { + return currency; + } + } + return null; } - } +}; - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} +module.exports = currencies; - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} +},{"./ethereum_validator":13,"./ripple_validator":14}],13:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); - buffer[offset + i - d] |= s * 128 -} +module.exports = { + isValidAddress: function (address) { + if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { + // Check if it has the basic requirements of an address + return false; + } -},{}],15:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; + if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { + // If it's all small caps or all all caps, return true + return true; + } -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. + // Otherwise check each case + return this.verifyChecksum(address); + }, + verifyChecksum: function (address) { + // Check each case + address = address.replace('0x',''); -var cachedSetTimeout; -var cachedClearTimeout; + var addressHash = cryptoUtils.keccak256(address.toLowerCase()); -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); + for (var i = 0; i < 40; i++ ) { + // The nth letter should be uppercase if the nth digit of casemap is 1 + if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || + (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { + return false; + } } + + return true; } +}; +},{"./crypto/utils":11}],14:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var baseX = require('base-x'); -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } +var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; +var codec = baseX(ALLOWED_CHARS); +var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); +module.exports = { + /** + * ripple address validation + */ + isValidAddress: function (address) { + if (regexp.test(address)) { + return this.verifyChecksum(address); + } -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; + return false; + }, -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; + verifyChecksum: function (address) { + var bytes = codec.decode(address); + var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); + var checksum = cryptoUtils.toHex(bytes.slice(-4)); + + return computedChecksum === checksum } - if (queue.length) { - drainQueue(); +}; + +},{"./crypto/utils":11,"base-x":1}],15:[function(require,module,exports){ +var base58 = require('./crypto/base58'); +var cryptoUtils = require('./crypto/utils'); +var currencies = require('./currencies'); + +var DEFAULT_CURRENCY_NAME = 'bitcoin'; +var DEFAULT_NETWORK_TYPE = 'prod'; + +function getDecoded(address) { + try { + return base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; } } -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; +module.exports = { + getAddressType: function (address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded = getDecoded(address); - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); + if (decoded) { + var length = decoded.length; + + if (length !== expectedLength) { + return null; } + + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = this.checksum(hashFunction, body); + + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; + return null; + }, + + // Each currency may implement different hashing algorithm + checksum: function (hashFunction, payload) { + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; + }, -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; + validate: function (address, currencyNameOrSymbol, networkType) { + currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; + networkType = networkType || DEFAULT_NETWORK_TYPE; -function noop() {} + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; + if (currency.validator) { + return currency.validator.isValidAddress(address); + } -process.listeners = function (name) { return [] } + var correctAddressTypes; + var addressType = this.getAddressType(address, currency); -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; + if (networkType === 'prod' || networkType === 'testnet'){ + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + } -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); + return correctAddressTypes.indexOf(addressType) >= 0; + } }; -process.umask = function() { return 0; }; -},{}]},{},[11])(11) -}); +},{"./crypto/base58":8,"./crypto/utils":11,"./currencies":12}]},{},[15])(15) +}); \ No newline at end of file diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 55818aca..f4dc9fdb 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,u,f){function a(e,t){if(!u[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(h)return h(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=u[e]={exports:{}};s[e][0].call(o.exports,function(t){var r=s[e][1][t];return a(r||t)},o,o.exports,i,s,u,f)}return u[e].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,w)).binLen,e=r.value,r=t>>>5,n=0;n>>5),w=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),w,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return w(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":12,ieee754:14}],14:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return w(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,w)).binLen,e=r.value,r=t>>>5,n=0;n>>5),w=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),w,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Mon, 26 Mar 2018 15:10:37 +0900 Subject: [PATCH 019/108] Added Dash and listed coins alphabetically in README.md --- README.md | 38 ++++++++++++++++++---------- dist/wallet-address-validator.js | 4 +++ dist/wallet-address-validator.min.js | 2 +- package.json | 2 ++ src/currencies.js | 4 +++ test/wallet_address_validator.js | 11 ++++++++ 6 files changed, 46 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 100eb623..5152cfd9 100644 --- a/README.md +++ b/README.md @@ -37,32 +37,42 @@ npm install wallet-address-validator ### Supported crypto currencies -* Bitcoin/BTC, `'bitcoin'` or `'BTC'` -* Litecoin/LTC, `'litecoin'` or `'LTC'` -* Peercoin/PPCoin/PPC, `'peercoin'` or `'PPC'` -* Dogecoin/DOGE, `'dogecoin'` or `'DOGE'` -* BeaverCoin/BVC, `'beavercoin'` or `'BVC'` -* Freicoin/FRC, `'freicoin'` or `'FRC'` -* Protoshares/PTS, `'protoshares'` or `'PTS'` -* Megacoin/MEC, `'megacoin'` or `'MEC'` -* Primecoin/XPM, `'primecoin'` or `'XPM'` * Auroracoin/AUR, `'auroracoin'` or `'AUR'` -* Namecoin/NMC, `'namecoin'` or `'NMC'` + +* BeaverCoin/BVC, `'beavercoin'` or `'BVC'` * Biocoin/BIO, `'biocoin'` or `'BIO'` -* Garlicoin/GRLC, `'garlicoin'` or `'GRLC'` -* Vertcoin/VTC, `'vertcoin'` or `'VTC'` +* Bitcoin/BTC, `'bitcoin'` or `'BTC'` * BitcoinGold/BTG, `'bitcoingold'` or `'BTG'` + +* Callisto/CLO, `'callisto'` or `'CLO'` + +* Dash, `'dash'` or `'DASH'` * Decred/DCR, `'decred'` or `'DCR'` * Digibyte/DGB, `'digibyte'` or `'DGB'` - +* Dogecoin/DOGE, `'dogecoin'` or `'DOGE'` * Ethereum/ETH, `'ethereum'` or `'ETH'` * EthereumClassic/ETH, `'ethereumclassic'` or `'ETC'` * EthereumZero/ETZ, `'etherzero'` or `'ETZ'` -* Callisto/CLO, `'callisto'` or `'CLO'` + +* Freicoin/FRC, `'freicoin'` or `'FRC'` + +* Garlicoin/GRLC, `'garlicoin'` or `'GRLC'` + +* Litecoin/LTC, `'litecoin'` or `'LTC'` + +* Megacoin/MEC, `'megacoin'` or `'MEC'` + +* Namecoin/NMC, `'namecoin'` or `'NMC'` + +* Peercoin/PPCoin/PPC, `'peercoin'` or `'PPC'` +* Primecoin/XPM, `'primecoin'` or `'XPM'` +* Protoshares/PTS, `'protoshares'` or `'PTS'` * Ripple/XRP, `'ripple'` or `'XRP'` +* Vertcoin/VTC, `'vertcoin'` or `'VTC'` + ### Usage example diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 1dd892b2..77e793cf 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -3336,6 +3336,10 @@ var CURRENCIES = [{ name: 'ripple', symbol: 'xrp', validator: XRPValidator, +},{ + name: 'dash', + symbol: 'dash', + addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']} }]; diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index f4dc9fdb..23a051bc 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,u,f){function a(e,t){if(!u[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(h)return h(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=u[e]={exports:{}};s[e][0].call(o.exports,function(t){var r=s[e][1][t];return a(r||t)},o,o.exports,i,s,u,f)}return u[e].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return w(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,w)).binLen,e=r.value,r=t>>>5,n=0;n>>5),w=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),w,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return w(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,w)).binLen,e=r.value,r=t>>>5,n=0;n>>5),w=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),w,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Mon, 26 Mar 2018 15:17:55 +0900 Subject: [PATCH 020/108] chore(release): 0.1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5fa5cbf8..bd0bc7ab 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "browser", "nodejs" ], - "version": "0.1.3", + "version": "0.1.4", "author": "Tomek Kolasa ", "homepage": "https://github.com/ognus/wallet-address-validator", "license": "MIT", From b468f4471fcdda1a23baf2cd98605f98390bb570 Mon Sep 17 00:00:00 2001 From: Gabor Babicz Date: Tue, 3 Apr 2018 12:06:26 +0200 Subject: [PATCH 021/108] Add Bitcoin Cash --- README.md | 1 + dist/wallet-address-validator.js | 4 ++++ dist/wallet-address-validator.min.js | 2 +- src/currencies.js | 4 ++++ test/wallet_address_validator.js | 21 +++++++++++++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5152cfd9..5afb38f3 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ npm install wallet-address-validator * BeaverCoin/BVC, `'beavercoin'` or `'BVC'` * Biocoin/BIO, `'biocoin'` or `'BIO'` * Bitcoin/BTC, `'bitcoin'` or `'BTC'` +* BitcoinCash/BCH, `'bitcoincash'` or `'BCH'` * BitcoinGold/BTG, `'bitcoingold'` or `'BTG'` * Callisto/CLO, `'callisto'` or `'CLO'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 77e793cf..2dfd76e7 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -3250,6 +3250,10 @@ var CURRENCIES = [{ name: 'bitcoin', symbol: 'btc', addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'bitcoincash', + symbol: 'bch', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} },{ name: 'litecoin', symbol: 'ltc', diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 23a051bc..805811b0 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,u,f){function a(e,t){if(!u[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(h)return h(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=u[e]={exports:{}};s[e][0].call(o.exports,function(t){var r=s[e][1][t];return a(r||t)},o,o.exports,i,s,u,f)}return u[e].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return w(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,w)).binLen,e=r.value,r=t>>>5,n=0;n>>5),w=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),w,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,b)).binLen,e=r.value,r=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Tue, 3 Apr 2018 15:05:34 +0200 Subject: [PATCH 022/108] Add support for validating NEO addresses --- src/currencies.js | 4 ++++ test/wallet_address_validator.js | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/currencies.js b/src/currencies.js index 74a9d2f7..08e86900 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -100,6 +100,10 @@ var CURRENCIES = [{ name: 'dash', symbol: 'dash', addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']} +},{ + name: 'neo', + symbol: 'neo', + addressTypes: {prod: ['17'], testnet: []} }]; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index f3120086..92a9110f 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -257,6 +257,11 @@ describe('WAValidator.validate()', function () { valid('XqMkVUZnqe3w4xvgdZRtZoe7gMitDudGs4', 'dash'); valid('yPv7h2i8v3dJjfSH4L3x91JSJszjdbsJJA', 'dash', 'testnet'); }); + + it('should return true for correct neo addresses', function () { + valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neo'); + valid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X', 'NEO'); + }); }); describe('invalid results', function () { @@ -366,5 +371,11 @@ describe('WAValidator.validate()', function () { it('should return false for incorrect dash addresses', function () { commonTests('dash'); }); + + it('should return false for incorrect neo addresses', function () { + commonTests('neo'); + invalid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTa', 'neo'); + invalid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ10', 'NEO'); + }); }); }); From b45d4b8cdf49c373a0f8244c000d026313b27306 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Tue, 3 Apr 2018 15:13:16 +0200 Subject: [PATCH 023/108] Update README about NEO addition --- README.md | 1 + dist/wallet-address-validator.js | 4 ++++ dist/wallet-address-validator.min.js | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5afb38f3..ad18f1d8 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ npm install wallet-address-validator * Megacoin/MEC, `'megacoin'` or `'MEC'` * Namecoin/NMC, `'namecoin'` or `'NMC'` +* NEO/NEO, `'NEO'` or `'NEO'` * Peercoin/PPCoin/PPC, `'peercoin'` or `'PPC'` * Primecoin/XPM, `'primecoin'` or `'XPM'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 2dfd76e7..16d9519c 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -3344,6 +3344,10 @@ var CURRENCIES = [{ name: 'dash', symbol: 'dash', addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']} +},{ + name: 'neo', + symbol: 'neo', + addressTypes: {prod: ['17'], testnet: []} }]; diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 805811b0..83e8cada 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,u,f){function a(r,t){if(!u[r]){if(!s[r]){var e="function"==typeof require&&require;if(!t&&e)return e(r,!0);if(h)return h(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var o=u[r]={exports:{}};s[r][0].call(o.exports,function(t){return a(s[r][1][t]||t)},o,o.exports,i,s,u,f)}return u[r].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,b)).binLen,e=r.value,r=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,b)).binLen,e=r.value,r=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o> 8 + bytes[j] += carry; + carry = bytes[j] >> 8; bytes[j] &= 0xff } while (carry) { - bytes.push(carry & 0xff) - carry >>= 8 + bytes.push(carry & 0xff); + carry >>= 8; } } // deal with leading zeros - for (i = 0; string[i] === '1' && i < string.length - 1; ++i) bytes.push(0) + for (i = 0; string[i] === '1' && i < string.length - 1; ++i){ + bytes.push(0); + } - return bytes.reverse() + return bytes.reverse(); } }; -module.exports = base58; - - },{}],9:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -3212,7 +3211,7 @@ function numberToHex (number) { return hex; } -var cryptoUtils = { +module.exports = { toHex: function (arrayOfBytes) { var hex = ''; for(var i = 0; i < arrayOfBytes.length; i++) { @@ -3239,8 +3238,6 @@ var cryptoUtils = { } }; -module.exports = cryptoUtils; - },{"./blake256":9,"./sha3":10,"jssha/src/sha256":5}],12:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); @@ -3351,7 +3348,7 @@ var CURRENCIES = [{ }]; -var currencies = { +module.exports = { getByNameOrSymbol: function (currencyNameOrSymbol) { var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); for (var i = 0; i < CURRENCIES.length; i++) { @@ -3364,8 +3361,6 @@ var currencies = { } }; -module.exports = currencies; - },{"./ethereum_validator":13,"./ripple_validator":14}],13:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); @@ -3449,64 +3444,68 @@ function getDecoded(address) { } } -module.exports = { - getAddressType: function (address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded = getDecoded(address); - - if (decoded) { - var length = decoded.length; - - if (length !== expectedLength) { - return null; - } +function getChecksum(hashFunction, payload) { + // Each currency may implement different hashing algorithm + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); + } +} + +function getAddressType(address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded = getDecoded(address); - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = this.checksum(hashFunction, body); + if (decoded) { + var length = decoded.length; - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + if (length !== expectedLength) { + return null; } - return null; - }, + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = getChecksum(hashFunction, body); - // Each currency may implement different hashing algorithm - checksum: function (hashFunction, payload) { - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); - } - }, + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + } - validate: function (address, currencyNameOrSymbol, networkType) { - currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; - networkType = networkType || DEFAULT_NETWORK_TYPE; + return null; +} - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); +function validate(address, currencyNameOrSymbol, networkType) { + currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; + networkType = networkType || DEFAULT_NETWORK_TYPE; - if (currency.validator) { - return currency.validator.isValidAddress(address); - } + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); - var correctAddressTypes; - var addressType = this.getAddressType(address, currency); + if (currency.validator) { + return currency.validator.isValidAddress(address); + } - if (networkType === 'prod' || networkType === 'testnet'){ - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); - } + var correctAddressTypes; + var addressType = getAddressType(address, currency); - return correctAddressTypes.indexOf(addressType) >= 0; + if (networkType === 'prod' || networkType === 'testnet'){ + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); } + + return correctAddressTypes.indexOf(addressType) >= 0; +} + +module.exports = { + getAddressType: getAddressType, + checksum: getChecksum, + validate: validate, }; },{"./crypto/base58":8,"./crypto/utils":11,"./currencies":12}]},{},[15])(15) diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 83e8cada..d3486b8a 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,u,f){function a(e,t){if(!u[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(h)return h(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=u[e]={exports:{}};s[e][0].call(o.exports,function(t){var r=s[e][1][t];return a(r||t)},o,o.exports,i,s,u,f)}return u[e].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,b)).binLen,e=r.value,r=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,b)).binLen,e=r.value,r=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o> 8 + bytes[j] += carry; + carry = bytes[j] >> 8; bytes[j] &= 0xff } while (carry) { - bytes.push(carry & 0xff) - carry >>= 8 + bytes.push(carry & 0xff); + carry >>= 8; } } // deal with leading zeros - for (i = 0; string[i] === '1' && i < string.length - 1; ++i) bytes.push(0) + for (i = 0; string[i] === '1' && i < string.length - 1; ++i){ + bytes.push(0); + } - return bytes.reverse() + return bytes.reverse(); } }; - -module.exports = base58; - diff --git a/src/crypto/utils.js b/src/crypto/utils.js index b8808ac3..0d824c99 100644 --- a/src/crypto/utils.js +++ b/src/crypto/utils.js @@ -10,7 +10,7 @@ function numberToHex (number) { return hex; } -var cryptoUtils = { +module.exports = { toHex: function (arrayOfBytes) { var hex = ''; for(var i = 0; i < arrayOfBytes.length; i++) { @@ -36,5 +36,3 @@ var cryptoUtils = { return keccak256(hexString); } }; - -module.exports = cryptoUtils; diff --git a/src/currencies.js b/src/currencies.js index 08e86900..49d905c2 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -107,7 +107,7 @@ var CURRENCIES = [{ }]; -var currencies = { +module.exports = { getByNameOrSymbol: function (currencyNameOrSymbol) { var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); for (var i = 0; i < CURRENCIES.length; i++) { @@ -119,5 +119,3 @@ var currencies = { return null; } }; - -module.exports = currencies; diff --git a/src/wallet_address_validator.js b/src/wallet_address_validator.js index 07b027eb..19ce9eda 100644 --- a/src/wallet_address_validator.js +++ b/src/wallet_address_validator.js @@ -14,62 +14,66 @@ function getDecoded(address) { } } -module.exports = { - getAddressType: function (address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded = getDecoded(address); - - if (decoded) { - var length = decoded.length; +function getChecksum(hashFunction, payload) { + // Each currency may implement different hashing algorithm + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); + } +} - if (length !== expectedLength) { - return null; - } +function getAddressType(address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded = getDecoded(address); - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = this.checksum(hashFunction, body); + if (decoded) { + var length = decoded.length; - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + if (length !== expectedLength) { + return null; } - return null; - }, + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = getChecksum(hashFunction, body); - // Each currency may implement different hashing algorithm - checksum: function (hashFunction, payload) { - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); - } - }, + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + } - validate: function (address, currencyNameOrSymbol, networkType) { - currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; - networkType = networkType || DEFAULT_NETWORK_TYPE; + return null; +} - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); +function validate(address, currencyNameOrSymbol, networkType) { + currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; + networkType = networkType || DEFAULT_NETWORK_TYPE; - if (currency.validator) { - return currency.validator.isValidAddress(address); - } + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); - var correctAddressTypes; - var addressType = this.getAddressType(address, currency); + if (currency.validator) { + return currency.validator.isValidAddress(address); + } - if (networkType === 'prod' || networkType === 'testnet'){ - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); - } + var correctAddressTypes; + var addressType = getAddressType(address, currency); - return correctAddressTypes.indexOf(addressType) >= 0; + if (networkType === 'prod' || networkType === 'testnet'){ + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); } + + return correctAddressTypes.indexOf(addressType) >= 0; +} + +module.exports = { + getAddressType: getAddressType, + checksum: getChecksum, + validate: validate, }; From 4799be5b9079c14a26e6386cc6c5ccfc2a056140 Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Mon, 9 Apr 2018 21:55:59 +0900 Subject: [PATCH 026/108] Added Qtum validation --- README.md | 2 ++ dist/wallet-address-validator.js | 4 ++++ dist/wallet-address-validator.min.js | 2 +- package.json | 1 + src/currencies.js | 4 ++++ test/wallet_address_validator.js | 12 ++++++++++++ 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad18f1d8..ab026e37 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,8 @@ npm install wallet-address-validator * Primecoin/XPM, `'primecoin'` or `'XPM'` * Protoshares/PTS, `'protoshares'` or `'PTS'` +* Qtum/QTUM, `'qtum'` or `'QTUM'` + * Ripple/XRP, `'ripple'` or `'XRP'` * Vertcoin/VTC, `'vertcoin'` or `'VTC'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 6b712964..64f63d36 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -3345,6 +3345,10 @@ var CURRENCIES = [{ name: 'neo', symbol: 'neo', addressTypes: {prod: ['17'], testnet: []} +},{ + name: 'qtum', + symbol: 'qtum', + addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']} }]; diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index d3486b8a..ccae051c 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,u,f){function a(e,t){if(!u[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(h)return h(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=u[e]={exports:{}};s[e][0].call(o.exports,function(t){var r=s[e][1][t];return a(r||t)},o,o.exports,i,s,u,f)}return u[e].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,b)).binLen,e=r.value,r=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,b)).binLen,e=r.value,r=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Mon, 9 Apr 2018 22:02:41 +0900 Subject: [PATCH 027/108] chore(release): 0.1.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 077efa5e..a26c9407 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "browser", "nodejs" ], - "version": "0.1.5", + "version": "0.1.6", "author": "Tomek Kolasa ", "homepage": "https://github.com/ognus/wallet-address-validator", "license": "MIT", From 664215ddfe67714eb7692a8afc0fef3caf2f868b Mon Sep 17 00:00:00 2001 From: hellcatz Date: Tue, 10 Apr 2018 19:49:06 -0700 Subject: [PATCH 028/108] Update currencies.js Add votecoin, zencash, zclassic, zcash, snowgem, hush, bitcoinprivate, bitcoinz, komodo --- src/currencies.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/currencies.js b/src/currencies.js index 0304f5bb..14a5e672 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -66,6 +66,50 @@ var CURRENCIES = [{ name: 'bitcoingold', symbol: 'btg', addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} +},{ + name: 'komodo', + symbol: 'kmd', + addressTypes: {prod: ['3c', '55'], testnet: ['0','5']} +},{ + name: 'bitcoinz', + symbol: 'btcz', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'bitcoinprivate', + symbol: 'btcp', + expectedLength: 26, + addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']} +},{ + name: 'hush', + symbol: 'hush', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'snowgem', + symbol: 'sng', + expectedLength: 26, + addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']} +},{ + name: 'zcash', + symbol: 'zec', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'zclassic', + symbol: 'zcl', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'zencash', + symbol: 'zen', + expectedLength: 26, + addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']} +},{ + name: 'votecoin', + symbol: 'vot', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} },{ name: 'decred', symbol: 'dcr', From 6b880ca29991990bb07b5ddbd067247930c4aaee Mon Sep 17 00:00:00 2001 From: hellcatz Date: Tue, 10 Apr 2018 19:55:49 -0700 Subject: [PATCH 029/108] Update wallet_address_validator.js Small optimization --- src/wallet_address_validator.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wallet_address_validator.js b/src/wallet_address_validator.js index 19ce9eda..b77e7646 100644 --- a/src/wallet_address_validator.js +++ b/src/wallet_address_validator.js @@ -62,6 +62,9 @@ function validate(address, currencyNameOrSymbol, networkType) { var correctAddressTypes; var addressType = getAddressType(address, currency); + if (addressType == null) { + return false; + } if (networkType === 'prod' || networkType === 'testnet'){ correctAddressTypes = currency.addressTypes[networkType] From bfb4051d14819895582440cbf040b0c4595ee2a9 Mon Sep 17 00:00:00 2001 From: hellcatz Date: Wed, 18 Apr 2018 10:42:43 -0700 Subject: [PATCH 030/108] Update wallet_address_validator.js Add tests for VOTE, BTCZ, ZCl, HUSH, ZEC, BTCP, SNG, ZEN, KMD --- test/wallet_address_validator.js | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 77861753..8a1232fd 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -268,6 +268,60 @@ describe('WAValidator.validate()', function () { valid('QVZnSrMwKp6AL4FjUPPnfFgsma6j1DXQXu', 'QTUM'); valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'qtum', 'testnet'); }); + + it('should return true for correct votecoin addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); + }); + + it('should return true for correct bitcoinz addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); + }); + + it('should return true for correct zclassic addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); + }); + + it('should return true for correct hush addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); + }); + + it('should return true for correct zcash addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); + }); + + it('should return true for correct bitcoinprivate addresses', function () { + valid('b1M4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); + //valid('bx....', 'BTCP'); + //valid('nx....', 'bitcoinprivate', 'testnet'); + }); + + it('should return true for correct snowgem addresses', function () { + valid('s1fx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); + valid('s3d27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); + }); + + it('should return true for correct zencash addresses', function () { + valid('znhiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); + valid('zssEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); + valid('ztmWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); + }); + + it('should return true for correct komodo addresses', function () { + valid('R9R5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); + valid('RAvj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); + //valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + }); }); describe('invalid results', function () { From 8688e1e3a32ff89f59c0e2081d5e0b6a6cdca26d Mon Sep 17 00:00:00 2001 From: hellcatz Date: Wed, 18 Apr 2018 16:49:51 -0700 Subject: [PATCH 031/108] Add files via upload Add equihash coins to browser files --- dist/wallet-address-validator.js | 7074 +++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- 2 files changed, 3560 insertions(+), 3516 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 64f63d36..f96877f0 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,3516 +1,3560 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { - digits.push(carry % BASE) - carry = (carry / BASE) | 0 - } - } - - var string = '' - - // deal with leading zeros - for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER - // convert digits to a string - for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] - - return string - } - - function decodeUnsafe (string) { - if (typeof string !== 'string') throw new TypeError('Expected String') - if (string.length === 0) return Buffer.allocUnsafe(0) - - var bytes = [0] - for (var i = 0; i < string.length; i++) { - var value = ALPHABET_MAP[string[i]] - if (value === undefined) return - - for (var j = 0, carry = value; j < bytes.length; ++j) { - carry += bytes[j] * BASE - bytes[j] = carry & 0xff - carry >>= 8 - } - - while (carry > 0) { - bytes.push(carry & 0xff) - carry >>= 8 - } - } - - // deal with leading zeros - for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { - bytes.push(0) - } - - return Buffer.from(bytes.reverse()) - } - - function decode (string) { - var buffer = decodeUnsafe(string) - if (buffer) return buffer - - throw new Error('Non-base' + BASE + ' character') - } - - return { - encode: encode, - decodeUnsafe: decodeUnsafe, - decode: decode - } -} - -},{"safe-buffer":7}],2:[function(require,module,exports){ -'use strict' - -exports.byteLength = byteLength -exports.toByteArray = toByteArray -exports.fromByteArray = fromByteArray - -var lookup = [] -var revLookup = [] -var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - -var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i -} - -// Support decoding URL-safe base64 strings, as Node.js does. -// See: https://en.wikipedia.org/wiki/Base64#URL_applications -revLookup['-'.charCodeAt(0)] = 62 -revLookup['_'.charCodeAt(0)] = 63 - -function placeHoldersCount (b64) { - var len = b64.length - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 -} - -function byteLength (b64) { - // base64 is 4/3 + up to two characters of the original data - return (b64.length * 3 / 4) - placeHoldersCount(b64) -} - -function toByteArray (b64) { - var i, l, tmp, placeHolders, arr - var len = b64.length - placeHolders = placeHoldersCount(b64) - - arr = new Arr((len * 3 / 4) - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? len - 4 : len - - var L = 0 - - for (i = 0; i < l; i += 4) { - tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] - arr[L++] = (tmp >> 16) & 0xFF - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } - - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' - } - - parts.push(output) - - return parts.join('') -} - -},{}],3:[function(require,module,exports){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' - -var base64 = require('base64-js') -var ieee754 = require('ieee754') - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -var K_MAX_LENGTH = 0x7fffffff -exports.kMaxLength = K_MAX_LENGTH - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ -Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - -if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) -} - -function typedArraySupport () { - // Can typed array instances can be augmented? - try { - var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} - return arr.foo() === 42 - } catch (e) { - return false - } -} - -Object.defineProperty(Buffer.prototype, 'parent', { - get: function () { - if (!(this instanceof Buffer)) { - return undefined - } - return this.buffer - } -}) - -Object.defineProperty(Buffer.prototype, 'offset', { - get: function () { - if (!(this instanceof Buffer)) { - return undefined - } - return this.byteOffset - } -}) - -function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('Invalid typed array length') - } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype - return buf -} - -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' - ) - } - return allocUnsafe(arg) - } - return from(arg, encodingOrOffset, length) -} - -// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) -} - -Buffer.poolSize = 8192 // not used by this implementation - -function from (value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') - } - - if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } - - return fromObject(value) -} - -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) -} - -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array - -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') - } -} - -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) -} - -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) -} - -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) -} - -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) -} - -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) - - var actual = buf.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } - - return buf -} - -function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf -} - -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } - - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } - - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf -} - -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } - - obj.copy(buf, 0, 0, len) - return buf - } - - if (obj) { - if (ArrayBuffer.isView(obj) || 'length' in obj) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } - - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } - } - - throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') -} - -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} - -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true -} - -Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (ArrayBuffer.isView(buf)) { - buf = Buffer.from(buf) - } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer -} - -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { - return string.byteLength - } - if (typeof string !== 'string') { - string = '' + string - } - - var len = string.length - if (len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - case undefined: - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true - -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i -} - -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} - -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} - -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.toLocaleString = Buffer.prototype.toString - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' -} - -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (!Buffer.isBuffer(target)) { - throw new TypeError('Argument must be a Buffer') - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 -} - -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} - -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - var strLen = string.length - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) - } - - return len -} - -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code - } - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : new Buffer(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this -} - -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check -// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 -function isArrayBuffer (obj) { - return obj instanceof ArrayBuffer || - (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && - typeof obj.byteLength === 'number') -} - -function numberIsNaN (obj) { - return obj !== obj // eslint-disable-line no-self-compare -} - -},{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} - -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} - -},{}],5:[function(require,module,exports){ -/* - A JavaScript implementation of the SHA family of hashes, as - defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding - HMAC implementation as defined in FIPS PUB 198a - - Copyright Brian Turek 2008-2017 - Distributed under the BSD License - See http://caligatio.github.com/jsSHA/ for more information - - Several functions taken from Paul Johnston -*/ -'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; -b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> -5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); -}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> -6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); -if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, -"");if(-1!==k&&k 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],7:[function(require,module,exports){ -/* eslint-disable node/no-deprecated-api */ -var buffer = require('buffer') -var Buffer = buffer.Buffer - -// alternative to using Object.keys for old browsers -function copyProps (src, dst) { - for (var key in src) { - dst[key] = src[key] - } -} -if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer -} else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer -} - -function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) -} - -// Copy static methods from Buffer -copyProps(Buffer, SafeBuffer) - -SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) -} - -SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) - } - return buf -} - -SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) -} - -SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return buffer.SlowBuffer(size) -} - -},{"buffer":3}],8:[function(require,module,exports){ -// Base58 encoding/decoding -// Originally written by Mike Hearn for BitcoinJ -// Copyright (c) 2011 Google Inc -// Ported to JavaScript by Stefan Thomas -// Merged Buffer refactorings from base58-native by Stephen Pair -// Copyright (c) 2013 BitPay Inc - -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; -var ALPHABET_MAP = {}; -for (var i = 0; i < ALPHABET.length; ++i) { - ALPHABET_MAP[ALPHABET.charAt(i)] = i; -} -var BASE = ALPHABET.length; - -module.exports = { - decode: function(string) { - if (string.length === 0) return []; - - var i, j, bytes = [0]; - for (i = 0; i < string.length; ++i) { - var c = string[i]; - if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character'); - - for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE - bytes[0] += ALPHABET_MAP[c]; - - var carry = 0; - for (j = 0; j < bytes.length; ++j) { - bytes[j] += carry; - carry = bytes[j] >> 8; - bytes[j] &= 0xff - } - - while (carry) { - bytes.push(carry & 0xff); - carry >>= 8; - } - } - // deal with leading zeros - for (i = 0; string[i] === '1' && i < string.length - 1; ++i){ - bytes.push(0); - } - - return bytes.reverse(); - } -}; - -},{}],9:[function(require,module,exports){ -(function (Buffer){ -'use strict'; - -/** - * Credits to https://github.com/cryptocoinjs/blake-hash - */ -Blake256.sigma = [ - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], - [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], - [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], - [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], - [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] -] - -Blake256.u256 = [ - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 -] - -Blake256.padding = new Buffer([ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -]) - -Blake256.prototype._length_carry = function (arr) { - for (var j = 0; j < arr.length; ++j) { - if (arr[j] < 0x0100000000) break - arr[j] -= 0x0100000000 - arr[j + 1] += 1 - } -} - -Blake256.prototype.update = function (data, encoding) { - data = new Buffer(data, encoding); - var block = this._block - var offset = 0 - - while (this._blockOffset + data.length - offset >= block.length) { - for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] - - this._length[0] += block.length * 8 - this._length_carry(this._length) - - this._compress() - this._blockOffset = 0 - } - - while (offset < data.length) block[this._blockOffset++] = data[offset++] - return this; -} - -var zo = new Buffer([0x01]) -var oo = new Buffer([0x81]) - -function rot (x, n) { - return ((x << (32 - n)) | (x >>> n)) >>> 0 -} - -function g (v, m, i, a, b, c, d, e) { - var sigma = Blake256.sigma - var u256 = Blake256.u256 - - v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 16) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 12) - v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 8) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 7) -} - -function Blake256 () { - this._h = [ - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 - ] - - this._s = [0, 0, 0, 0] - - this._block = new Buffer(64) - this._blockOffset = 0 - this._length = [0, 0] - - this._nullt = false - - this._zo = zo - this._oo = oo -} - -Blake256.prototype._compress = function () { - var u256 = Blake256.u256 - var v = new Array(16) - var m = new Array(16) - var i - - for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) - for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 - for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 - for (i = 12; i < 16; ++i) v[i] = u256[i - 8] - - if (!this._nullt) { - v[12] = (v[12] ^ this._length[0]) >>> 0 - v[13] = (v[13] ^ this._length[0]) >>> 0 - v[14] = (v[14] ^ this._length[1]) >>> 0 - v[15] = (v[15] ^ this._length[1]) >>> 0 - } - - for (i = 0; i < 14; ++i) { - /* column step */ - g(v, m, i, 0, 4, 8, 12, 0) - g(v, m, i, 1, 5, 9, 13, 2) - g(v, m, i, 2, 6, 10, 14, 4) - g(v, m, i, 3, 7, 11, 15, 6) - /* diagonal step */ - g(v, m, i, 0, 5, 10, 15, 8) - g(v, m, i, 1, 6, 11, 12, 10) - g(v, m, i, 2, 7, 8, 13, 12) - g(v, m, i, 3, 4, 9, 14, 14) - } - - for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 - for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 -} - -Blake256.prototype._padding = function () { - var lo = this._length[0] + this._blockOffset * 8 - var hi = this._length[1] - if (lo >= 0x0100000000) { - lo -= 0x0100000000 - hi += 1 - } - - var msglen = new Buffer(8) - msglen.writeUInt32BE(hi, 0) - msglen.writeUInt32BE(lo, 4) - - if (this._blockOffset === 55) { - this._length[0] -= 8 - this.update(this._oo) - } else { - if (this._blockOffset < 55) { - if (this._blockOffset === 0) this._nullt = true - this._length[0] -= (55 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) - } else { - this._length[0] -= (64 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) - this._length[0] -= 55 * 8 - this.update(Blake256.padding.slice(1, 1 + 55)) - this._nullt = true - } - - this.update(this._zo) - this._length[0] -= 8 - } - - this._length[0] -= 64 - this.update(msglen) -} - -Blake256.prototype.digest = function (encoding) { - this._padding() - - var buffer = new Buffer(32) - for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) - return buffer.toString(encoding); -} - -module.exports = Blake256; -}).call(this,require("buffer").Buffer) -},{"buffer":3}],10:[function(require,module,exports){ -(function (process,global){ -/** - * [js-sha3]{@link https://github.com/emn178/js-sha3} - * - * @version 0.7.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2015-2017 - * @license MIT - */ -/*jslint bitwise: true */ -'use strict'; - -var ERROR = 'input is invalid type'; -var WINDOW = typeof window === 'object'; -var root = WINDOW ? window : {}; -if (root.JS_SHA3_NO_WINDOW) { - WINDOW = false; -} -var WEB_WORKER = !WINDOW && typeof self === 'object'; -var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; -if (NODE_JS) { - root = global; -} else if (WEB_WORKER) { - root = self; -} -var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; -var HEX_CHARS = '0123456789abcdef'.split(''); -var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; -var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; -var KECCAK_PADDING = [1, 256, 65536, 16777216]; -var PADDING = [6, 1536, 393216, 100663296]; -var SHIFT = [0, 8, 16, 24]; -var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, - 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, - 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, - 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, - 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; -var BITS = [224, 256, 384, 512]; -var SHAKE_BITS = [128, 256]; -var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; -var CSHAKE_BYTEPAD = { - '128': 168, - '256': 136 -}; - -if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { - Array.isArray = function (obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; - }; -} - -if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { - ArrayBuffer.isView = function (obj) { - return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; - }; -} - -var createOutputMethod = function (bits, padding, outputType) { - return function (message) { - return new Keccak(bits, padding, bits).update(message)[outputType](); - }; -}; - -var createShakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits) { - return new Keccak(bits, padding, outputBits).update(message)[outputType](); - }; -}; - -var createCshakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits, n, s) { - return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); - }; -}; - -var createKmacOutputMethod = function (bits, padding, outputType) { - return function (key, message, outputBits, s) { - return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); - }; -}; - -var createOutputMethods = function (method, createMethod, bits, padding) { - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createMethod(bits, padding, type); - } - return method; -}; - -var createMethod = function (bits, padding) { - var method = createOutputMethod(bits, padding, 'hex'); - method.create = function () { - return new Keccak(bits, padding, bits); - }; - method.update = function (message) { - return method.create().update(message); - }; - return createOutputMethods(method, createOutputMethod, bits, padding); -}; - -var createShakeMethod = function (bits, padding) { - var method = createShakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits) { - return new Keccak(bits, padding, outputBits); - }; - method.update = function (message, outputBits) { - return method.create(outputBits).update(message); - }; - return createOutputMethods(method, createShakeOutputMethod, bits, padding); -}; - -var createCshakeMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createCshakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits, n, s) { - if (!n && !s) { - return methods['shake' + bits].create(outputBits); - } else { - return new Keccak(bits, padding, outputBits).bytepad([n, s], w); - } - }; - method.update = function (message, outputBits, n, s) { - return method.create(outputBits, n, s).update(message); - }; - return createOutputMethods(method, createCshakeOutputMethod, bits, padding); -}; - -var createKmacMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createKmacOutputMethod(bits, padding, 'hex'); - method.create = function (key, outputBits, s) { - return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); - }; - method.update = function (key, message, outputBits, s) { - return method.create(key, outputBits, s).update(message); - }; - return createOutputMethods(method, createKmacOutputMethod, bits, padding); -}; - -var algorithms = [ - { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, - { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, - { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, - { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, - { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } -]; - -var methods = {}, methodNames = []; - -for (var i = 0; i < algorithms.length; ++i) { - var algorithm = algorithms[i]; - var bits = algorithm.bits; - for (var j = 0; j < bits.length; ++j) { - var methodName = algorithm.name + '_' + bits[j]; - methodNames.push(methodName); - methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); - if (algorithm.name !== 'sha3') { - var newMethodName = algorithm.name + bits[j]; - methodNames.push(newMethodName); - methods[newMethodName] = methods[methodName]; - } - } -} - -function Keccak(bits, padding, outputBits) { - this.blocks = []; - this.s = []; - this.padding = padding; - this.outputBits = outputBits; - this.reset = true; - this.finalized = false; - this.block = 0; - this.start = 0; - this.blockCount = (1600 - (bits << 1)) >> 5; - this.byteCount = this.blockCount << 2; - this.outputBlocks = outputBits >> 5; - this.extraBytes = (outputBits & 31) >> 3; - - for (var i = 0; i < 50; ++i) { - this.s[i] = 0; - } -} - -Keccak.prototype.update = function (message) { - if (this.finalized) { - return; - } - var notString, type = typeof message; - if (type !== 'string') { - if (type === 'object') { - if (message === null) { - throw ERROR; - } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } else if (!Array.isArray(message)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var blocks = this.blocks, byteCount = this.byteCount, length = message.length, - blockCount = this.blockCount, index = 0, s = this.s, i, code; - - while (index < length) { - if (this.reset) { - this.reset = false; - blocks[0] = this.block; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - if (notString) { - for (i = this.start; index < length && i < byteCount; ++index) { - blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; - } - } else { - for (i = this.start; index < length && i < byteCount; ++index) { - code = message.charCodeAt(index); - if (code < 0x80) { - blocks[i >> 2] |= code << SHIFT[i++ & 3]; - } else if (code < 0x800) { - blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else if (code < 0xd800 || code >= 0xe000) { - blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); - blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - } - } - this.lastByteIndex = i; - if (i >= byteCount) { - this.start = i - byteCount; - this.block = blocks[blockCount]; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); - this.reset = true; - } else { - this.start = i; - } - } - return this; -}; - -Keccak.prototype.encode = function (x, right) { - var o = x & 255, n = 1; - var bytes = [o]; - x = x >> 8; - o = x & 255; - while (o > 0) { - bytes.unshift(o); - x = x >> 8; - o = x & 255; - ++n; - } - if (right) { - bytes.push(n); - } else { - bytes.unshift(n); - } - this.update(bytes); - return bytes.length; -}; - -Keccak.prototype.encodeString = function (str) { - var notString, type = typeof str; - if (type !== 'string') { - if (type === 'object') { - if (str === null) { - throw ERROR; - } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { - str = new Uint8Array(str); - } else if (!Array.isArray(str)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var bytes = 0, length = str.length; - if (notString) { - bytes = length; - } else { - for (var i = 0; i < str.length; ++i) { - var code = str.charCodeAt(i); - if (code < 0x80) { - bytes += 1; - } else if (code < 0x800) { - bytes += 2; - } else if (code < 0xd800 || code >= 0xe000) { - bytes += 3; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); - bytes += 4; - } - } - } - bytes += this.encode(bytes * 8); - this.update(str); - return bytes; -}; - -Keccak.prototype.bytepad = function (strs, w) { - var bytes = this.encode(w); - for (var i = 0; i < strs.length; ++i) { - bytes += this.encodeString(strs[i]); - } - var paddingBytes = w - bytes % w; - var zeros = []; - zeros.length = paddingBytes; - this.update(zeros); - return this; -}; - -Keccak.prototype.finalize = function () { - if (this.finalized) { - return; - } - this.finalized = true; - var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; - blocks[i >> 2] |= this.padding[i & 3]; - if (this.lastByteIndex === this.byteCount) { - blocks[0] = blocks[blockCount]; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - blocks[blockCount - 1] |= 0x80000000; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); -}; - -Keccak.prototype.toString = Keccak.prototype.hex = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var hex = '', block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + - HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + - HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + - HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; - } - if (j % blockCount === 0) { - f(s); - i = 0; - } - } - if (extraBytes) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; - if (extraBytes > 1) { - hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; - } - if (extraBytes > 2) { - hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; - } - } - return hex; -}; - -Keccak.prototype.arrayBuffer = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var bytes = this.outputBits >> 3; - var buffer; - if (extraBytes) { - buffer = new ArrayBuffer((outputBlocks + 1) << 2); - } else { - buffer = new ArrayBuffer(bytes); - } - var array = new Uint32Array(buffer); - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - array[j] = s[i]; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - array[i] = s[i]; - buffer = buffer.slice(0, bytes); - } - return buffer; -}; - -Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; - -Keccak.prototype.digest = Keccak.prototype.array = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var array = [], offset, block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - array[offset + 1] = (block >> 8) & 0xFF; - array[offset + 2] = (block >> 16) & 0xFF; - array[offset + 3] = (block >> 24) & 0xFF; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - if (extraBytes > 1) { - array[offset + 1] = (block >> 8) & 0xFF; - } - if (extraBytes > 2) { - array[offset + 2] = (block >> 16) & 0xFF; - } - } - return array; -}; - -function Kmac(bits, padding, outputBits) { - Keccak.call(this, bits, padding, outputBits); -} - -Kmac.prototype = new Keccak(); - -Kmac.prototype.finalize = function () { - this.encode(this.outputBits, true); - return Keccak.prototype.finalize.call(this); -}; - -var f = function (s) { - var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, - b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, - b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, - b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; - for (n = 0; n < 48; n += 2) { - c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; - c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; - c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; - c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; - c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; - c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; - c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; - c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; - c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; - c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; - - h = c8 ^ ((c2 << 1) | (c3 >>> 31)); - l = c9 ^ ((c3 << 1) | (c2 >>> 31)); - s[0] ^= h; - s[1] ^= l; - s[10] ^= h; - s[11] ^= l; - s[20] ^= h; - s[21] ^= l; - s[30] ^= h; - s[31] ^= l; - s[40] ^= h; - s[41] ^= l; - h = c0 ^ ((c4 << 1) | (c5 >>> 31)); - l = c1 ^ ((c5 << 1) | (c4 >>> 31)); - s[2] ^= h; - s[3] ^= l; - s[12] ^= h; - s[13] ^= l; - s[22] ^= h; - s[23] ^= l; - s[32] ^= h; - s[33] ^= l; - s[42] ^= h; - s[43] ^= l; - h = c2 ^ ((c6 << 1) | (c7 >>> 31)); - l = c3 ^ ((c7 << 1) | (c6 >>> 31)); - s[4] ^= h; - s[5] ^= l; - s[14] ^= h; - s[15] ^= l; - s[24] ^= h; - s[25] ^= l; - s[34] ^= h; - s[35] ^= l; - s[44] ^= h; - s[45] ^= l; - h = c4 ^ ((c8 << 1) | (c9 >>> 31)); - l = c5 ^ ((c9 << 1) | (c8 >>> 31)); - s[6] ^= h; - s[7] ^= l; - s[16] ^= h; - s[17] ^= l; - s[26] ^= h; - s[27] ^= l; - s[36] ^= h; - s[37] ^= l; - s[46] ^= h; - s[47] ^= l; - h = c6 ^ ((c0 << 1) | (c1 >>> 31)); - l = c7 ^ ((c1 << 1) | (c0 >>> 31)); - s[8] ^= h; - s[9] ^= l; - s[18] ^= h; - s[19] ^= l; - s[28] ^= h; - s[29] ^= l; - s[38] ^= h; - s[39] ^= l; - s[48] ^= h; - s[49] ^= l; - - b0 = s[0]; - b1 = s[1]; - b32 = (s[11] << 4) | (s[10] >>> 28); - b33 = (s[10] << 4) | (s[11] >>> 28); - b14 = (s[20] << 3) | (s[21] >>> 29); - b15 = (s[21] << 3) | (s[20] >>> 29); - b46 = (s[31] << 9) | (s[30] >>> 23); - b47 = (s[30] << 9) | (s[31] >>> 23); - b28 = (s[40] << 18) | (s[41] >>> 14); - b29 = (s[41] << 18) | (s[40] >>> 14); - b20 = (s[2] << 1) | (s[3] >>> 31); - b21 = (s[3] << 1) | (s[2] >>> 31); - b2 = (s[13] << 12) | (s[12] >>> 20); - b3 = (s[12] << 12) | (s[13] >>> 20); - b34 = (s[22] << 10) | (s[23] >>> 22); - b35 = (s[23] << 10) | (s[22] >>> 22); - b16 = (s[33] << 13) | (s[32] >>> 19); - b17 = (s[32] << 13) | (s[33] >>> 19); - b48 = (s[42] << 2) | (s[43] >>> 30); - b49 = (s[43] << 2) | (s[42] >>> 30); - b40 = (s[5] << 30) | (s[4] >>> 2); - b41 = (s[4] << 30) | (s[5] >>> 2); - b22 = (s[14] << 6) | (s[15] >>> 26); - b23 = (s[15] << 6) | (s[14] >>> 26); - b4 = (s[25] << 11) | (s[24] >>> 21); - b5 = (s[24] << 11) | (s[25] >>> 21); - b36 = (s[34] << 15) | (s[35] >>> 17); - b37 = (s[35] << 15) | (s[34] >>> 17); - b18 = (s[45] << 29) | (s[44] >>> 3); - b19 = (s[44] << 29) | (s[45] >>> 3); - b10 = (s[6] << 28) | (s[7] >>> 4); - b11 = (s[7] << 28) | (s[6] >>> 4); - b42 = (s[17] << 23) | (s[16] >>> 9); - b43 = (s[16] << 23) | (s[17] >>> 9); - b24 = (s[26] << 25) | (s[27] >>> 7); - b25 = (s[27] << 25) | (s[26] >>> 7); - b6 = (s[36] << 21) | (s[37] >>> 11); - b7 = (s[37] << 21) | (s[36] >>> 11); - b38 = (s[47] << 24) | (s[46] >>> 8); - b39 = (s[46] << 24) | (s[47] >>> 8); - b30 = (s[8] << 27) | (s[9] >>> 5); - b31 = (s[9] << 27) | (s[8] >>> 5); - b12 = (s[18] << 20) | (s[19] >>> 12); - b13 = (s[19] << 20) | (s[18] >>> 12); - b44 = (s[29] << 7) | (s[28] >>> 25); - b45 = (s[28] << 7) | (s[29] >>> 25); - b26 = (s[38] << 8) | (s[39] >>> 24); - b27 = (s[39] << 8) | (s[38] >>> 24); - b8 = (s[48] << 14) | (s[49] >>> 18); - b9 = (s[49] << 14) | (s[48] >>> 18); - - s[0] = b0 ^ (~b2 & b4); - s[1] = b1 ^ (~b3 & b5); - s[10] = b10 ^ (~b12 & b14); - s[11] = b11 ^ (~b13 & b15); - s[20] = b20 ^ (~b22 & b24); - s[21] = b21 ^ (~b23 & b25); - s[30] = b30 ^ (~b32 & b34); - s[31] = b31 ^ (~b33 & b35); - s[40] = b40 ^ (~b42 & b44); - s[41] = b41 ^ (~b43 & b45); - s[2] = b2 ^ (~b4 & b6); - s[3] = b3 ^ (~b5 & b7); - s[12] = b12 ^ (~b14 & b16); - s[13] = b13 ^ (~b15 & b17); - s[22] = b22 ^ (~b24 & b26); - s[23] = b23 ^ (~b25 & b27); - s[32] = b32 ^ (~b34 & b36); - s[33] = b33 ^ (~b35 & b37); - s[42] = b42 ^ (~b44 & b46); - s[43] = b43 ^ (~b45 & b47); - s[4] = b4 ^ (~b6 & b8); - s[5] = b5 ^ (~b7 & b9); - s[14] = b14 ^ (~b16 & b18); - s[15] = b15 ^ (~b17 & b19); - s[24] = b24 ^ (~b26 & b28); - s[25] = b25 ^ (~b27 & b29); - s[34] = b34 ^ (~b36 & b38); - s[35] = b35 ^ (~b37 & b39); - s[44] = b44 ^ (~b46 & b48); - s[45] = b45 ^ (~b47 & b49); - s[6] = b6 ^ (~b8 & b0); - s[7] = b7 ^ (~b9 & b1); - s[16] = b16 ^ (~b18 & b10); - s[17] = b17 ^ (~b19 & b11); - s[26] = b26 ^ (~b28 & b20); - s[27] = b27 ^ (~b29 & b21); - s[36] = b36 ^ (~b38 & b30); - s[37] = b37 ^ (~b39 & b31); - s[46] = b46 ^ (~b48 & b40); - s[47] = b47 ^ (~b49 & b41); - s[8] = b8 ^ (~b0 & b2); - s[9] = b9 ^ (~b1 & b3); - s[18] = b18 ^ (~b10 & b12); - s[19] = b19 ^ (~b11 & b13); - s[28] = b28 ^ (~b20 & b22); - s[29] = b29 ^ (~b21 & b23); - s[38] = b38 ^ (~b30 & b32); - s[39] = b39 ^ (~b31 & b33); - s[48] = b48 ^ (~b40 & b42); - s[49] = b49 ^ (~b41 & b43); - - s[0] ^= RC[n]; - s[1] ^= RC[n + 1]; - } -}; - -module.exports = methods; - -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":6}],11:[function(require,module,exports){ -var jsSHA = require('jssha/src/sha256'); -var Blake256 = require('./blake256'); -var keccak256 = require('./sha3')['keccak256']; - -function numberToHex (number) { - var hex = Math.round(number).toString(16); - if(hex.length === 1) { - hex = '0' + hex; - } - return hex; -} - -module.exports = { - toHex: function (arrayOfBytes) { - var hex = ''; - for(var i = 0; i < arrayOfBytes.length; i++) { - hex += numberToHex(arrayOfBytes[i]); - } - return hex; - }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX'); - sha.update(hexString); - return sha.getHash('HEX'); - }, - sha256Checksum: function (payload) { - return this.sha256(this.sha256(payload)).substr(0, 8); - }, - blake256: function (hexString) { - return new Blake256().update(hexString, 'hex').digest('hex'); - }, - blake256Checksum: function (payload) { - return this.blake256(this.blake256(payload)).substr(0, 8); - }, - keccak256: function (hexString) { - return keccak256(hexString); - } -}; - -},{"./blake256":9,"./sha3":10,"jssha/src/sha256":5}],12:[function(require,module,exports){ -var XRPValidator = require('./ripple_validator'); -var ETHValidator = require('./ethereum_validator'); - -// defines P2PKH and P2SH address types for standard (prod) and testnet networks -var CURRENCIES = [{ - name: 'bitcoin', - symbol: 'btc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'bitcoincash', - symbol: 'bch', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'litecoin', - symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} -},{ - name: 'peercoin', - symbol: 'ppc', - addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} -},{ - name: 'dogecoin', - symbol: 'doge', - addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} -},{ - name: 'beavercoin', - symbol: 'bvc', - addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} -},{ - name: 'freicoin', - symbol: 'frc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'protoshares', - symbol: 'pts', - addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} -},{ - name: 'megacoin', - symbol: 'mec', - addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} -},{ - name: 'primecoin', - symbol: 'xpm', - addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} -},{ - name: 'auroracoin', - symbol: 'aur', - addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} -},{ - name: 'namecoin', - symbol: 'nmc', - addressTypes: {prod: ['34'], testnet: []} -},{ - name: 'biocoin', - symbol: 'bio', - addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} -},{ - name: 'garlicoin', - symbol: 'grlc', - addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} -},{ - name: 'vertcoin', - symbol: 'vtc', - addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} -},{ - name: 'bitcoingold', - symbol: 'btg', - addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} -},{ - name: 'decred', - symbol: 'dcr', - addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, - hashFunction: 'blake256', - expectedLength: 26 -},{ - name: 'digibyte', - symbol: 'dgb', - addressTypes: {prod: ['1e'], testnet: []}, -},{ - name: 'ethereum', - symbol: 'eth', - validator: ETHValidator, -},{ - name: 'etherzero', - symbol: 'etz', - validator: ETHValidator, -},{ - name: 'ethereumclassic', - symbol: 'etc', - validator: ETHValidator, -},{ - name: 'callisto', - symbol: 'clo', - validator: ETHValidator, -},{ - name: 'ripple', - symbol: 'xrp', - validator: XRPValidator, -},{ - name: 'dash', - symbol: 'dash', - addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']} -},{ - name: 'neo', - symbol: 'neo', - addressTypes: {prod: ['17'], testnet: []} -},{ - name: 'qtum', - symbol: 'qtum', - addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']} -}]; - - -module.exports = { - getByNameOrSymbol: function (currencyNameOrSymbol) { - var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); - for (var i = 0; i < CURRENCIES.length; i++) { - var currency = CURRENCIES[i]; - if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { - return currency; - } - } - return null; - } -}; - -},{"./ethereum_validator":13,"./ripple_validator":14}],13:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); - -module.exports = { - isValidAddress: function (address) { - if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { - // Check if it has the basic requirements of an address - return false; - } - - if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { - // If it's all small caps or all all caps, return true - return true; - } - - // Otherwise check each case - return this.verifyChecksum(address); - }, - verifyChecksum: function (address) { - // Check each case - address = address.replace('0x',''); - - var addressHash = cryptoUtils.keccak256(address.toLowerCase()); - - for (var i = 0; i < 40; i++ ) { - // The nth letter should be uppercase if the nth digit of casemap is 1 - if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || - (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { - return false; - } - } - - return true; - } -}; - -},{"./crypto/utils":11}],14:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); -var baseX = require('base-x'); - -var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; - -var codec = baseX(ALLOWED_CHARS); -var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); - -module.exports = { - /** - * ripple address validation - */ - isValidAddress: function (address) { - if (regexp.test(address)) { - return this.verifyChecksum(address); - } - - return false; - }, - - verifyChecksum: function (address) { - var bytes = codec.decode(address); - var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); - var checksum = cryptoUtils.toHex(bytes.slice(-4)); - - return computedChecksum === checksum - } -}; - -},{"./crypto/utils":11,"base-x":1}],15:[function(require,module,exports){ -var base58 = require('./crypto/base58'); -var cryptoUtils = require('./crypto/utils'); -var currencies = require('./currencies'); - -var DEFAULT_CURRENCY_NAME = 'bitcoin'; -var DEFAULT_NETWORK_TYPE = 'prod'; - -function getDecoded(address) { - try { - return base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } -} - -function getChecksum(hashFunction, payload) { - // Each currency may implement different hashing algorithm - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); - } -} - -function getAddressType(address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded = getDecoded(address); - - if (decoded) { - var length = decoded.length; - - if (length !== expectedLength) { - return null; - } - - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = getChecksum(hashFunction, body); - - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; - } - - return null; -} - -function validate(address, currencyNameOrSymbol, networkType) { - currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; - networkType = networkType || DEFAULT_NETWORK_TYPE; - - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); - - if (currency.validator) { - return currency.validator.isValidAddress(address); - } - - var correctAddressTypes; - var addressType = getAddressType(address, currency); - - if (networkType === 'prod' || networkType === 'testnet'){ - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); - } - - return correctAddressTypes.indexOf(addressType) >= 0; -} - -module.exports = { - getAddressType: getAddressType, - checksum: getChecksum, - validate: validate, -}; - -},{"./crypto/base58":8,"./crypto/utils":11,"./currencies":12}]},{},[15])(15) +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { + digits.push(carry % BASE) + carry = (carry / BASE) | 0 + } + } + + var string = '' + + // deal with leading zeros + for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER + // convert digits to a string + for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] + + return string + } + + function decodeUnsafe (string) { + if (typeof string !== 'string') throw new TypeError('Expected String') + if (string.length === 0) return Buffer.allocUnsafe(0) + + var bytes = [0] + for (var i = 0; i < string.length; i++) { + var value = ALPHABET_MAP[string[i]] + if (value === undefined) return + + for (var j = 0, carry = value; j < bytes.length; ++j) { + carry += bytes[j] * BASE + bytes[j] = carry & 0xff + carry >>= 8 + } + + while (carry > 0) { + bytes.push(carry & 0xff) + carry >>= 8 + } + } + + // deal with leading zeros + for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { + bytes.push(0) + } + + return Buffer.from(bytes.reverse()) + } + + function decode (string) { + var buffer = decodeUnsafe(string) + if (buffer) return buffer + + throw new Error('Non-base' + BASE + ' character') + } + + return { + encode: encode, + decodeUnsafe: decodeUnsafe, + decode: decode + } +} + +},{"safe-buffer":7}],2:[function(require,module,exports){ +'use strict' + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function placeHoldersCount (b64) { + var len = b64.length + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} + +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return (b64.length * 3 / 4) - placeHoldersCount(b64) +} + +function toByteArray (b64) { + var i, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) + + arr = new Arr((len * 3 / 4) - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0; i < l; i += 4) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } + + parts.push(output) + + return parts.join('') +} + +},{}],3:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + +'use strict' + +var base64 = require('base64-js') +var ieee754 = require('ieee754') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} + +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 + } catch (e) { + return false + } +} + +Object.defineProperty(Buffer.prototype, 'parent', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined + } + return this.buffer + } +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined + } + return this.byteOffset + } +}) + +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('Invalid typed array length') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} + +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) +} + +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + return fromObject(value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf +} + +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} + +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf +} + +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj) { + if (ArrayBuffer.isView(obj) || 'length' in obj) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } + } + + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') +} + +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (ArrayBuffer.isView(buf)) { + buf = Buffer.from(buf) + } + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.toLocaleString = Buffer.prototype.toString + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : new Buffer(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check +// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 +function isArrayBuffer (obj) { + return obj instanceof ArrayBuffer || + (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && + typeof obj.byteLength === 'number') +} + +function numberIsNaN (obj) { + return obj !== obj // eslint-disable-line no-self-compare +} + +},{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + +},{}],5:[function(require,module,exports){ +/* + A JavaScript implementation of the SHA family of hashes, as + defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding + HMAC implementation as defined in FIPS PUB 198a + + Copyright Brian Turek 2008-2017 + Distributed under the BSD License + See http://caligatio.github.com/jsSHA/ for more information + + Several functions taken from Paul Johnston +*/ +'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; +b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> +5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); +}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> +6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==k&&k 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],7:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} + +},{"buffer":3}],8:[function(require,module,exports){ +// Base58 encoding/decoding +// Originally written by Mike Hearn for BitcoinJ +// Copyright (c) 2011 Google Inc +// Ported to JavaScript by Stefan Thomas +// Merged Buffer refactorings from base58-native by Stephen Pair +// Copyright (c) 2013 BitPay Inc + +var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; +var ALPHABET_MAP = {}; +for (var i = 0; i < ALPHABET.length; ++i) { + ALPHABET_MAP[ALPHABET.charAt(i)] = i; +} +var BASE = ALPHABET.length; + +module.exports = { + decode: function(string) { + if (string.length === 0) return []; + + var i, j, bytes = [0]; + for (i = 0; i < string.length; ++i) { + var c = string[i]; + if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character'); + + for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE + bytes[0] += ALPHABET_MAP[c]; + + var carry = 0; + for (j = 0; j < bytes.length; ++j) { + bytes[j] += carry; + carry = bytes[j] >> 8; + bytes[j] &= 0xff + } + + while (carry) { + bytes.push(carry & 0xff); + carry >>= 8; + } + } + // deal with leading zeros + for (i = 0; string[i] === '1' && i < string.length - 1; ++i){ + bytes.push(0); + } + + return bytes.reverse(); + } +}; + +},{}],9:[function(require,module,exports){ +(function (Buffer){ +'use strict'; + +/** + * Credits to https://github.com/cryptocoinjs/blake-hash + */ +Blake256.sigma = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] +] + +Blake256.u256 = [ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 +] + +Blake256.padding = new Buffer([ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +]) + +Blake256.prototype._length_carry = function (arr) { + for (var j = 0; j < arr.length; ++j) { + if (arr[j] < 0x0100000000) break + arr[j] -= 0x0100000000 + arr[j + 1] += 1 + } +} + +Blake256.prototype.update = function (data, encoding) { + data = new Buffer(data, encoding); + var block = this._block + var offset = 0 + + while (this._blockOffset + data.length - offset >= block.length) { + for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] + + this._length[0] += block.length * 8 + this._length_carry(this._length) + + this._compress() + this._blockOffset = 0 + } + + while (offset < data.length) block[this._blockOffset++] = data[offset++] + return this; +} + +var zo = new Buffer([0x01]) +var oo = new Buffer([0x81]) + +function rot (x, n) { + return ((x << (32 - n)) | (x >>> n)) >>> 0 +} + +function g (v, m, i, a, b, c, d, e) { + var sigma = Blake256.sigma + var u256 = Blake256.u256 + + v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 16) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 12) + v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 8) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 7) +} + +function Blake256 () { + this._h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ] + + this._s = [0, 0, 0, 0] + + this._block = new Buffer(64) + this._blockOffset = 0 + this._length = [0, 0] + + this._nullt = false + + this._zo = zo + this._oo = oo +} + +Blake256.prototype._compress = function () { + var u256 = Blake256.u256 + var v = new Array(16) + var m = new Array(16) + var i + + for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) + for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 + for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 + for (i = 12; i < 16; ++i) v[i] = u256[i - 8] + + if (!this._nullt) { + v[12] = (v[12] ^ this._length[0]) >>> 0 + v[13] = (v[13] ^ this._length[0]) >>> 0 + v[14] = (v[14] ^ this._length[1]) >>> 0 + v[15] = (v[15] ^ this._length[1]) >>> 0 + } + + for (i = 0; i < 14; ++i) { + /* column step */ + g(v, m, i, 0, 4, 8, 12, 0) + g(v, m, i, 1, 5, 9, 13, 2) + g(v, m, i, 2, 6, 10, 14, 4) + g(v, m, i, 3, 7, 11, 15, 6) + /* diagonal step */ + g(v, m, i, 0, 5, 10, 15, 8) + g(v, m, i, 1, 6, 11, 12, 10) + g(v, m, i, 2, 7, 8, 13, 12) + g(v, m, i, 3, 4, 9, 14, 14) + } + + for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 + for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 +} + +Blake256.prototype._padding = function () { + var lo = this._length[0] + this._blockOffset * 8 + var hi = this._length[1] + if (lo >= 0x0100000000) { + lo -= 0x0100000000 + hi += 1 + } + + var msglen = new Buffer(8) + msglen.writeUInt32BE(hi, 0) + msglen.writeUInt32BE(lo, 4) + + if (this._blockOffset === 55) { + this._length[0] -= 8 + this.update(this._oo) + } else { + if (this._blockOffset < 55) { + if (this._blockOffset === 0) this._nullt = true + this._length[0] -= (55 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) + } else { + this._length[0] -= (64 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) + this._length[0] -= 55 * 8 + this.update(Blake256.padding.slice(1, 1 + 55)) + this._nullt = true + } + + this.update(this._zo) + this._length[0] -= 8 + } + + this._length[0] -= 64 + this.update(msglen) +} + +Blake256.prototype.digest = function (encoding) { + this._padding() + + var buffer = new Buffer(32) + for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) + return buffer.toString(encoding); +} + +module.exports = Blake256; +}).call(this,require("buffer").Buffer) +},{"buffer":3}],10:[function(require,module,exports){ +(function (process,global){ +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.7.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2017 + * @license MIT + */ +/*jslint bitwise: true */ +'use strict'; + +var ERROR = 'input is invalid type'; +var WINDOW = typeof window === 'object'; +var root = WINDOW ? window : {}; +if (root.JS_SHA3_NO_WINDOW) { + WINDOW = false; +} +var WEB_WORKER = !WINDOW && typeof self === 'object'; +var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; +if (NODE_JS) { + root = global; +} else if (WEB_WORKER) { + root = self; +} +var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; +var HEX_CHARS = '0123456789abcdef'.split(''); +var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; +var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; +var KECCAK_PADDING = [1, 256, 65536, 16777216]; +var PADDING = [6, 1536, 393216, 100663296]; +var SHIFT = [0, 8, 16, 24]; +var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; +var BITS = [224, 256, 384, 512]; +var SHAKE_BITS = [128, 256]; +var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; +var CSHAKE_BYTEPAD = { + '128': 168, + '256': 136 +}; + +if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { + Array.isArray = function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; +} + +if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { + ArrayBuffer.isView = function (obj) { + return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; + }; +} + +var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; +}; + +var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; +}; + +var createCshakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits, n, s) { + return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); + }; +}; + +var createKmacOutputMethod = function (bits, padding, outputType) { + return function (key, message, outputBits, s) { + return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); + }; +}; + +var createOutputMethods = function (method, createMethod, bits, padding) { + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createMethod(bits, padding, type); + } + return method; +}; + +var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + return createOutputMethods(method, createOutputMethod, bits, padding); +}; + +var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + return createOutputMethods(method, createShakeOutputMethod, bits, padding); +}; + +var createCshakeMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createCshakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits, n, s) { + if (!n && !s) { + return methods['shake' + bits].create(outputBits); + } else { + return new Keccak(bits, padding, outputBits).bytepad([n, s], w); + } + }; + method.update = function (message, outputBits, n, s) { + return method.create(outputBits, n, s).update(message); + }; + return createOutputMethods(method, createCshakeOutputMethod, bits, padding); +}; + +var createKmacMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createKmacOutputMethod(bits, padding, 'hex'); + method.create = function (key, outputBits, s) { + return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); + }; + method.update = function (key, message, outputBits, s) { + return method.create(key, outputBits, s).update(message); + }; + return createOutputMethods(method, createKmacOutputMethod, bits, padding); +}; + +var algorithms = [ + { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, + { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, + { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, + { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, + { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } +]; + +var methods = {}, methodNames = []; + +for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name + '_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + if (algorithm.name !== 'sha3') { + var newMethodName = algorithm.name + bits[j]; + methodNames.push(newMethodName); + methods[newMethodName] = methods[methodName]; + } + } +} + +function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.finalized = false; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } +} + +Keccak.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString, type = typeof message; + if (type !== 'string') { + if (type === 'object') { + if (message === null) { + throw ERROR; + } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (!Array.isArray(message)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var blocks = this.blocks, byteCount = this.byteCount, length = message.length, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; +}; + +Keccak.prototype.encode = function (x, right) { + var o = x & 255, n = 1; + var bytes = [o]; + x = x >> 8; + o = x & 255; + while (o > 0) { + bytes.unshift(o); + x = x >> 8; + o = x & 255; + ++n; + } + if (right) { + bytes.push(n); + } else { + bytes.unshift(n); + } + this.update(bytes); + return bytes.length; +}; + +Keccak.prototype.encodeString = function (str) { + var notString, type = typeof str; + if (type !== 'string') { + if (type === 'object') { + if (str === null) { + throw ERROR; + } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { + str = new Uint8Array(str); + } else if (!Array.isArray(str)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var bytes = 0, length = str.length; + if (notString) { + bytes = length; + } else { + for (var i = 0; i < str.length; ++i) { + var code = str.charCodeAt(i); + if (code < 0x80) { + bytes += 1; + } else if (code < 0x800) { + bytes += 2; + } else if (code < 0xd800 || code >= 0xe000) { + bytes += 3; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); + bytes += 4; + } + } + } + bytes += this.encode(bytes * 8); + this.update(str); + return bytes; +}; + +Keccak.prototype.bytepad = function (strs, w) { + var bytes = this.encode(w); + for (var i = 0; i < strs.length; ++i) { + bytes += this.encodeString(strs[i]); + } + var paddingBytes = w - bytes % w; + var zeros = []; + zeros.length = paddingBytes; + this.update(zeros); + return this; +}; + +Keccak.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); +}; + +Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; +}; + +Keccak.prototype.arrayBuffer = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; +}; + +Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + +Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; +}; + +function Kmac(bits, padding, outputBits) { + Keccak.call(this, bits, padding, outputBits); +} + +Kmac.prototype = new Keccak(); + +Kmac.prototype.finalize = function () { + this.encode(this.outputBits, true); + return Keccak.prototype.finalize.call(this); +}; + +var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } +}; + +module.exports = methods; + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":6}],11:[function(require,module,exports){ +var jsSHA = require('jssha/src/sha256'); +var Blake256 = require('./blake256'); +var keccak256 = require('./sha3')['keccak256']; + +function numberToHex (number) { + var hex = Math.round(number).toString(16); + if(hex.length === 1) { + hex = '0' + hex; + } + return hex; +} + +module.exports = { + toHex: function (arrayOfBytes) { + var hex = ''; + for(var i = 0; i < arrayOfBytes.length; i++) { + hex += numberToHex(arrayOfBytes[i]); + } + return hex; + }, + sha256: function (hexString) { + var sha = new jsSHA('SHA-256', 'HEX'); + sha.update(hexString); + return sha.getHash('HEX'); + }, + sha256Checksum: function (payload) { + return this.sha256(this.sha256(payload)).substr(0, 8); + }, + blake256: function (hexString) { + return new Blake256().update(hexString, 'hex').digest('hex'); + }, + blake256Checksum: function (payload) { + return this.blake256(this.blake256(payload)).substr(0, 8); + }, + keccak256: function (hexString) { + return keccak256(hexString); + } +}; + +},{"./blake256":9,"./sha3":10,"jssha/src/sha256":5}],12:[function(require,module,exports){ +var XRPValidator = require('./ripple_validator'); +var ETHValidator = require('./ethereum_validator'); + +// defines P2PKH and P2SH address types for standard (prod) and testnet networks +var CURRENCIES = [{ + name: 'bitcoin', + symbol: 'btc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'bitcoincash', + symbol: 'bch', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'litecoin', + symbol: 'ltc', + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} +},{ + name: 'peercoin', + symbol: 'ppc', + addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} +},{ + name: 'dogecoin', + symbol: 'doge', + addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} +},{ + name: 'beavercoin', + symbol: 'bvc', + addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} +},{ + name: 'freicoin', + symbol: 'frc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'protoshares', + symbol: 'pts', + addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} +},{ + name: 'megacoin', + symbol: 'mec', + addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} +},{ + name: 'primecoin', + symbol: 'xpm', + addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} +},{ + name: 'auroracoin', + symbol: 'aur', + addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} +},{ + name: 'namecoin', + symbol: 'nmc', + addressTypes: {prod: ['34'], testnet: []} +},{ + name: 'biocoin', + symbol: 'bio', + addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} +},{ + name: 'garlicoin', + symbol: 'grlc', + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} +},{ + name: 'vertcoin', + symbol: 'vtc', + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} +},{ + name: 'bitcoingold', + symbol: 'btg', + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} +},{ + name: 'komodo', + symbol: 'kmd', + addressTypes: {prod: ['3c', '55'], testnet: ['0','5']} +},{ + name: 'bitcoinz', + symbol: 'btcz', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'bitcoinprivate', + symbol: 'btcp', + expectedLength: 26, + addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']} +},{ + name: 'hush', + symbol: 'hush', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'snowgem', + symbol: 'sng', + expectedLength: 26, + addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']} +},{ + name: 'zcash', + symbol: 'zec', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'zclassic', + symbol: 'zcl', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'zencash', + symbol: 'zen', + expectedLength: 26, + addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']} +},{ + name: 'votecoin', + symbol: 'vot', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'decred', + symbol: 'dcr', + addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, + hashFunction: 'blake256', + expectedLength: 26 +},{ + name: 'digibyte', + symbol: 'dgb', + addressTypes: {prod: ['1e'], testnet: []}, +},{ + name: 'ethereum', + symbol: 'eth', + validator: ETHValidator, +},{ + name: 'etherzero', + symbol: 'etz', + validator: ETHValidator, +},{ + name: 'ethereumclassic', + symbol: 'etc', + validator: ETHValidator, +},{ + name: 'callisto', + symbol: 'clo', + validator: ETHValidator, +},{ + name: 'ripple', + symbol: 'xrp', + validator: XRPValidator, +},{ + name: 'dash', + symbol: 'dash', + addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']} +},{ + name: 'neo', + symbol: 'neo', + addressTypes: {prod: ['17'], testnet: []} +},{ + name: 'qtum', + symbol: 'qtum', + addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']} +}]; + + +module.exports = { + getByNameOrSymbol: function (currencyNameOrSymbol) { + var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); + for (var i = 0; i < CURRENCIES.length; i++) { + var currency = CURRENCIES[i]; + if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { + return currency; + } + } + return null; + } +}; + +},{"./ethereum_validator":13,"./ripple_validator":14}],13:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); + +module.exports = { + isValidAddress: function (address) { + if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { + // Check if it has the basic requirements of an address + return false; + } + + if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { + // If it's all small caps or all all caps, return true + return true; + } + + // Otherwise check each case + return this.verifyChecksum(address); + }, + verifyChecksum: function (address) { + // Check each case + address = address.replace('0x',''); + + var addressHash = cryptoUtils.keccak256(address.toLowerCase()); + + for (var i = 0; i < 40; i++ ) { + // The nth letter should be uppercase if the nth digit of casemap is 1 + if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || + (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { + return false; + } + } + + return true; + } +}; + +},{"./crypto/utils":11}],14:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var baseX = require('base-x'); + +var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; + +var codec = baseX(ALLOWED_CHARS); +var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); + +module.exports = { + /** + * ripple address validation + */ + isValidAddress: function (address) { + if (regexp.test(address)) { + return this.verifyChecksum(address); + } + + return false; + }, + + verifyChecksum: function (address) { + var bytes = codec.decode(address); + var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); + var checksum = cryptoUtils.toHex(bytes.slice(-4)); + + return computedChecksum === checksum + } +}; + +},{"./crypto/utils":11,"base-x":1}],15:[function(require,module,exports){ +var base58 = require('./crypto/base58'); +var cryptoUtils = require('./crypto/utils'); +var currencies = require('./currencies'); + +var DEFAULT_CURRENCY_NAME = 'bitcoin'; +var DEFAULT_NETWORK_TYPE = 'prod'; + +function getDecoded(address) { + try { + return base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } +} + +function getChecksum(hashFunction, payload) { + // Each currency may implement different hashing algorithm + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); + } +} + +function getAddressType(address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded = getDecoded(address); + + if (decoded) { + var length = decoded.length; + + if (length !== expectedLength) { + return null; + } + + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = getChecksum(hashFunction, body); + + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + } + + return null; +} + +function validate(address, currencyNameOrSymbol, networkType) { + currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; + networkType = networkType || DEFAULT_NETWORK_TYPE; + + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); + + if (currency.validator) { + return currency.validator.isValidAddress(address); + } + + var correctAddressTypes; + var addressType = getAddressType(address, currency); + + if (networkType === 'prod' || networkType === 'testnet'){ + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + } + + return correctAddressTypes.indexOf(addressType) >= 0; +} + +module.exports = { + getAddressType: getAddressType, + checksum: getChecksum, + validate: validate, +}; + +},{"./crypto/base58":8,"./crypto/utils":11,"./currencies":12}]},{},[15])(15) }); \ No newline at end of file diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index ccae051c..83d0520b 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,u,f){function a(e,t){if(!u[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(h)return h(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=u[e]={exports:{}};s[e][0].call(o.exports,function(t){var r=s[e][1][t];return a(r||t)},o,o.exports,i,s,u,f)}return u[e].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[u++]=n>>8&255,i[u++]=255&n;2===o?(n=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,i[u++]=255&n):1===o&&(n=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,u=e-n;s>2],o+=f[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=f[r>>10],o+=f[r>>4&63],o+=f[r<<2&63],o+="=");return i.push(o),i.join("")};for(var f=[],a=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return L(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u/=s=2,f/=2,e/=2}function a(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return v(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),u=Math.min(i,s),f=this.slice(n,o),a=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,u,f,a,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,F(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return f=this,a=r,h=e,F(H(t),f,a,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,u=e,F(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,u);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function S(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function x(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,o){return r=+r,e>>>=0,o||S(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||U(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=0,s=1,u=0;for(this[r]=255&t;++i>0)-u&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);U(this,t,r,e,o-1,-o)}var i=e-1,s=1,u=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/s>>0)-u&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||U(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return x(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return x(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,u=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),2<=(r+=1<=s+c?l/f:l*Math.pow(2,1-c))*f&&(s++,f/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(r*f-1)*Math.pow(2,o),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&u,p+=d,u/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=f(t,g,b)).binLen,e=r.value,r=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,a,o)};break;case"B64":e=function(t){return E(t,a,o)};break;case"BYTES":e=function(t){return B(t,a)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,a)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(u)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",u=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,u,f=t.length;if(0!=f%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],u=(e=e||0)>>>3,n=0;n>>1)+u)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*f+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,u,f,a,h,c=0;if(r=r||[0],u=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(h+a%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),f=(a=c+u)>>>2;r.length<=f;)r.push(0);r[f]|=n<<8*(h+a%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,u,f,a,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;f>0;)i.push(255&f),f>>=8}for(var h=0;t[h]===o&&h0;)n.push(a%r),a=a/r|0}for(var u="",f=0;0===e[f]&&f=0;--h)u+=t[n[h]];return u},decodeUnsafe:a,decode:function(t){var e=a(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":7}],2:[function(t,e,r){"use strict";r.byteLength=function(t){return 3*t.length/4-f(t)},r.toByteArray=function(t){var e,r,n,s,a,u=t.length;s=f(t),a=new i(3*u/4-s),r=s>0?u-4:u;var h=0;for(e=0;e>16&255,a[h++]=n>>8&255,a[h++]=255&n;2===s?(n=o[t.charCodeAt(e)]<<2|o[t.charCodeAt(e+1)]>>4,a[h++]=255&n):1===s&&(n=o[t.charCodeAt(e)]<<10|o[t.charCodeAt(e+1)]<<4|o[t.charCodeAt(e+2)]>>2,a[h++]=n>>8&255,a[h++]=255&n);return a},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i="",s=[],a=0,u=r-o;au?u:a+16383));1===o?(e=t[r-1],i+=n[e>>2],i+=n[e<<4&63],i+="=="):2===o&&(e=(t[r-2]<<8)+t[r-1],i+=n[e>>10],i+=n[e>>4&63],i+=n[e<<2&63],i+="=");return s.push(i),s.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function h(t,e,r){for(var o,i,s=[],a=e;a>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function s(t){if(t>i)throw new RangeError("Invalid typed array length");var e=new Uint8Array(t);return e.__proto__=a.prototype,e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return h(t)}return u(t,e,r)}function u(t,e,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return O(t)||t&&O(t.buffer)?function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||O(t))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return I(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(n)return I(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),M(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;ia&&(r=a-u),i=r;i>=0;i--){for(var c=!0,l=0;lo&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s239?4:f>223?3:f>191?2:1;if(o+c<=r)switch(c){case 1:f<128&&(h=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(h=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&f)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},a.prototype.compare=function(t,e,r,n,o){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,s=r-e,u=Math.min(i,s),f=this.slice(n,o),h=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,F(I(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return u=this,f=e,h=r,F(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,F(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function x(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,i){return e=+e,r>>>=0,i||x(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,i){return e=+e,r>>>=0,i||x(t,0,r,8),o.write(t,e,r,n,52,8),r+8}a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},a.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),o.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;h>0;i=256*i+t[e+c],c+=l,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+c],c+=l,h-=8);if(0===i)i=1-f;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var s,a,u,f=8*i-o-1,h=(1<>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=h?(a=0,s=h):s+c>=1?(a=(e*u-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,f-=8);t[r+p-d]|=128*y}},{}],5:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,c,l,p,d,y,g,b,w=0,v=[],m=0,B=!1,_=[],k=[],T=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return E(e,r,t)},y=function(e,r,n,o){var i,s;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),s=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,se/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)_[e]=909522486^r[e],k[e]=1549556828^r[e];o=d(_,o),w=p,B=!0},this.update=function(t){var e,r,n,i=0,s=p>>>5;for(t=(e=c(t,v,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,T=!0},this.getHash=function(e,r){var n,h,c,p;if(!0===B)throw Error("Cannot call getHash after setting HMAC key");switch(c=f(r),e){case"HEX":n=function(t){return i(t,l,c)};break;case"B64":n=function(t){return s(t,l,c)};break;case"BYTES":n=function(t){return a(t,l)};break;case"ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,l)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=y(v.slice(),m,w,g(o)),h=1;h>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function s(t,e,r){var n,o,i,s="",a=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)s+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return s}function a(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,s,a,u,f,h,c,l=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(c=3,s=0;so?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(s)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),a=0;a>>2;r.length<=f;)r.push(0);r[f]|=i[a]<<8*(c+h%4*-1),l+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(c=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,s=0;s>>8),f=(h=l+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(c+h%4*-1),l+=2}return{value:r,binLen:8*l+n}};break;case"B64":r=function(t,e,r){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Tue, 17 Apr 2018 20:50:16 +0300 Subject: [PATCH 033/108] add neogas --- src/currencies.js | 4 ++++ test/wallet_address_validator.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/currencies.js b/src/currencies.js index 14a5e672..6bbfb79e 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -148,6 +148,10 @@ var CURRENCIES = [{ name: 'neo', symbol: 'neo', addressTypes: {prod: ['17'], testnet: []} +},{ + name: 'neogas', + symbol: 'gas', + addressTypes: {prod: ['17'], testnet: []} },{ name: 'qtum', symbol: 'qtum', diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index db0ebd3d..06f27953 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -263,6 +263,11 @@ describe('WAValidator.validate()', function () { valid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X', 'NEO'); }); + it('should return true for correct neo gas addresses', function () { + valid('AXWGzmR7qkATA6ZNtDdViQRkotd6AmeZcD', 'neogas'); + + }); + it('should return true for correct qtum addresses', function () { valid('QNjUiD3bVVZwYTc5AhpeQbS1mfb2guyWhe', 'qtum'); valid('QVZnSrMwKp6AL4FjUPPnfFgsma6j1DXQXu', 'QTUM'); From 44fe097678a7c8502f63e07a8dc0eef0cd05d0be Mon Sep 17 00:00:00 2001 From: iddoberger Date: Wed, 18 Apr 2018 14:58:47 +0300 Subject: [PATCH 034/108] change test value --- test/wallet_address_validator.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 06f27953..fbc29183 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -264,8 +264,7 @@ describe('WAValidator.validate()', function () { }); it('should return true for correct neo gas addresses', function () { - valid('AXWGzmR7qkATA6ZNtDdViQRkotd6AmeZcD', 'neogas'); - + valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neogas'); }); it('should return true for correct qtum addresses', function () { From d7a0c8299e0208bf13011dd376f53dbd866ee8dc Mon Sep 17 00:00:00 2001 From: iddoberger Date: Wed, 18 Apr 2018 15:32:48 +0300 Subject: [PATCH 035/108] add gas to keywords in package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a26c9407..b6e49155 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "ripple", "dash", "neo", + "gas", "qtum", "altcoin", "crypto", @@ -37,7 +38,7 @@ "scripts": { "bundle": "browserify src/wallet_address_validator.js --standalone WAValidator --outfile dist/wallet-address-validator.js", "minify": "uglifyjs -c -m -o dist/wallet-address-validator.min.js -- dist/wallet-address-validator.js", - "test:node": "mocha test", + " ": "mocha test", "test:browser": "karma start", "test": "npm run test:node && npm run test:browser", "start": "npm run bundle && npm run minify && npm test" From beb8201b39d0b5834c3424dc7da6cb9561bf20ef Mon Sep 17 00:00:00 2001 From: iddoberger Date: Wed, 18 Apr 2018 15:34:18 +0300 Subject: [PATCH 036/108] add neogas to dist --- dist/wallet-address-validator.js | 7125 +++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- package.json | 2 +- 3 files changed, 3568 insertions(+), 3561 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index f96877f0..408eb388 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,3560 +1,3567 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { - digits.push(carry % BASE) - carry = (carry / BASE) | 0 - } - } - - var string = '' - - // deal with leading zeros - for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER - // convert digits to a string - for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] - - return string - } - - function decodeUnsafe (string) { - if (typeof string !== 'string') throw new TypeError('Expected String') - if (string.length === 0) return Buffer.allocUnsafe(0) - - var bytes = [0] - for (var i = 0; i < string.length; i++) { - var value = ALPHABET_MAP[string[i]] - if (value === undefined) return - - for (var j = 0, carry = value; j < bytes.length; ++j) { - carry += bytes[j] * BASE - bytes[j] = carry & 0xff - carry >>= 8 - } - - while (carry > 0) { - bytes.push(carry & 0xff) - carry >>= 8 - } - } - - // deal with leading zeros - for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { - bytes.push(0) - } - - return Buffer.from(bytes.reverse()) - } - - function decode (string) { - var buffer = decodeUnsafe(string) - if (buffer) return buffer - - throw new Error('Non-base' + BASE + ' character') - } - - return { - encode: encode, - decodeUnsafe: decodeUnsafe, - decode: decode - } -} - -},{"safe-buffer":7}],2:[function(require,module,exports){ -'use strict' - -exports.byteLength = byteLength -exports.toByteArray = toByteArray -exports.fromByteArray = fromByteArray - -var lookup = [] -var revLookup = [] -var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - -var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i -} - -// Support decoding URL-safe base64 strings, as Node.js does. -// See: https://en.wikipedia.org/wiki/Base64#URL_applications -revLookup['-'.charCodeAt(0)] = 62 -revLookup['_'.charCodeAt(0)] = 63 - -function placeHoldersCount (b64) { - var len = b64.length - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 -} - -function byteLength (b64) { - // base64 is 4/3 + up to two characters of the original data - return (b64.length * 3 / 4) - placeHoldersCount(b64) -} - -function toByteArray (b64) { - var i, l, tmp, placeHolders, arr - var len = b64.length - placeHolders = placeHoldersCount(b64) - - arr = new Arr((len * 3 / 4) - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? len - 4 : len - - var L = 0 - - for (i = 0; i < l; i += 4) { - tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] - arr[L++] = (tmp >> 16) & 0xFF - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } - - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' - } - - parts.push(output) - - return parts.join('') -} - -},{}],3:[function(require,module,exports){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' - -var base64 = require('base64-js') -var ieee754 = require('ieee754') - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -var K_MAX_LENGTH = 0x7fffffff -exports.kMaxLength = K_MAX_LENGTH - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ -Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - -if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) -} - -function typedArraySupport () { - // Can typed array instances can be augmented? - try { - var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} - return arr.foo() === 42 - } catch (e) { - return false - } -} - -Object.defineProperty(Buffer.prototype, 'parent', { - get: function () { - if (!(this instanceof Buffer)) { - return undefined - } - return this.buffer - } -}) - -Object.defineProperty(Buffer.prototype, 'offset', { - get: function () { - if (!(this instanceof Buffer)) { - return undefined - } - return this.byteOffset - } -}) - -function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('Invalid typed array length') - } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype - return buf -} - -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' - ) - } - return allocUnsafe(arg) - } - return from(arg, encodingOrOffset, length) -} - -// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) -} - -Buffer.poolSize = 8192 // not used by this implementation - -function from (value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') - } - - if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } - - return fromObject(value) -} - -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) -} - -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array - -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') - } -} - -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) -} - -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) -} - -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) -} - -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) -} - -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) - - var actual = buf.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } - - return buf -} - -function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf -} - -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } - - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } - - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf -} - -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } - - obj.copy(buf, 0, 0, len) - return buf - } - - if (obj) { - if (ArrayBuffer.isView(obj) || 'length' in obj) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } - - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } - } - - throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') -} - -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} - -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true -} - -Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (ArrayBuffer.isView(buf)) { - buf = Buffer.from(buf) - } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer -} - -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { - return string.byteLength - } - if (typeof string !== 'string') { - string = '' + string - } - - var len = string.length - if (len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - case undefined: - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true - -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i -} - -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} - -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} - -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.toLocaleString = Buffer.prototype.toString - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' -} - -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (!Buffer.isBuffer(target)) { - throw new TypeError('Argument must be a Buffer') - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 -} - -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} - -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - var strLen = string.length - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) - } - - return len -} - -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code - } - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : new Buffer(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this -} - -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check -// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 -function isArrayBuffer (obj) { - return obj instanceof ArrayBuffer || - (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && - typeof obj.byteLength === 'number') -} - -function numberIsNaN (obj) { - return obj !== obj // eslint-disable-line no-self-compare -} - -},{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} - -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} - -},{}],5:[function(require,module,exports){ -/* - A JavaScript implementation of the SHA family of hashes, as - defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding - HMAC implementation as defined in FIPS PUB 198a - - Copyright Brian Turek 2008-2017 - Distributed under the BSD License - See http://caligatio.github.com/jsSHA/ for more information - - Several functions taken from Paul Johnston -*/ -'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; -b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> -5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); -}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> -6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); -if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, -"");if(-1!==k&&k 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],7:[function(require,module,exports){ -/* eslint-disable node/no-deprecated-api */ -var buffer = require('buffer') -var Buffer = buffer.Buffer - -// alternative to using Object.keys for old browsers -function copyProps (src, dst) { - for (var key in src) { - dst[key] = src[key] - } -} -if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer -} else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer -} - -function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) -} - -// Copy static methods from Buffer -copyProps(Buffer, SafeBuffer) - -SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) -} - -SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) - } - return buf -} - -SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) -} - -SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return buffer.SlowBuffer(size) -} - -},{"buffer":3}],8:[function(require,module,exports){ -// Base58 encoding/decoding -// Originally written by Mike Hearn for BitcoinJ -// Copyright (c) 2011 Google Inc -// Ported to JavaScript by Stefan Thomas -// Merged Buffer refactorings from base58-native by Stephen Pair -// Copyright (c) 2013 BitPay Inc - -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; -var ALPHABET_MAP = {}; -for (var i = 0; i < ALPHABET.length; ++i) { - ALPHABET_MAP[ALPHABET.charAt(i)] = i; -} -var BASE = ALPHABET.length; - -module.exports = { - decode: function(string) { - if (string.length === 0) return []; - - var i, j, bytes = [0]; - for (i = 0; i < string.length; ++i) { - var c = string[i]; - if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character'); - - for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE - bytes[0] += ALPHABET_MAP[c]; - - var carry = 0; - for (j = 0; j < bytes.length; ++j) { - bytes[j] += carry; - carry = bytes[j] >> 8; - bytes[j] &= 0xff - } - - while (carry) { - bytes.push(carry & 0xff); - carry >>= 8; - } - } - // deal with leading zeros - for (i = 0; string[i] === '1' && i < string.length - 1; ++i){ - bytes.push(0); - } - - return bytes.reverse(); - } -}; - -},{}],9:[function(require,module,exports){ -(function (Buffer){ -'use strict'; - -/** - * Credits to https://github.com/cryptocoinjs/blake-hash - */ -Blake256.sigma = [ - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], - [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], - [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], - [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], - [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] -] - -Blake256.u256 = [ - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 -] - -Blake256.padding = new Buffer([ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -]) - -Blake256.prototype._length_carry = function (arr) { - for (var j = 0; j < arr.length; ++j) { - if (arr[j] < 0x0100000000) break - arr[j] -= 0x0100000000 - arr[j + 1] += 1 - } -} - -Blake256.prototype.update = function (data, encoding) { - data = new Buffer(data, encoding); - var block = this._block - var offset = 0 - - while (this._blockOffset + data.length - offset >= block.length) { - for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] - - this._length[0] += block.length * 8 - this._length_carry(this._length) - - this._compress() - this._blockOffset = 0 - } - - while (offset < data.length) block[this._blockOffset++] = data[offset++] - return this; -} - -var zo = new Buffer([0x01]) -var oo = new Buffer([0x81]) - -function rot (x, n) { - return ((x << (32 - n)) | (x >>> n)) >>> 0 -} - -function g (v, m, i, a, b, c, d, e) { - var sigma = Blake256.sigma - var u256 = Blake256.u256 - - v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 16) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 12) - v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 8) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 7) -} - -function Blake256 () { - this._h = [ - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 - ] - - this._s = [0, 0, 0, 0] - - this._block = new Buffer(64) - this._blockOffset = 0 - this._length = [0, 0] - - this._nullt = false - - this._zo = zo - this._oo = oo -} - -Blake256.prototype._compress = function () { - var u256 = Blake256.u256 - var v = new Array(16) - var m = new Array(16) - var i - - for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) - for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 - for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 - for (i = 12; i < 16; ++i) v[i] = u256[i - 8] - - if (!this._nullt) { - v[12] = (v[12] ^ this._length[0]) >>> 0 - v[13] = (v[13] ^ this._length[0]) >>> 0 - v[14] = (v[14] ^ this._length[1]) >>> 0 - v[15] = (v[15] ^ this._length[1]) >>> 0 - } - - for (i = 0; i < 14; ++i) { - /* column step */ - g(v, m, i, 0, 4, 8, 12, 0) - g(v, m, i, 1, 5, 9, 13, 2) - g(v, m, i, 2, 6, 10, 14, 4) - g(v, m, i, 3, 7, 11, 15, 6) - /* diagonal step */ - g(v, m, i, 0, 5, 10, 15, 8) - g(v, m, i, 1, 6, 11, 12, 10) - g(v, m, i, 2, 7, 8, 13, 12) - g(v, m, i, 3, 4, 9, 14, 14) - } - - for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 - for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 -} - -Blake256.prototype._padding = function () { - var lo = this._length[0] + this._blockOffset * 8 - var hi = this._length[1] - if (lo >= 0x0100000000) { - lo -= 0x0100000000 - hi += 1 - } - - var msglen = new Buffer(8) - msglen.writeUInt32BE(hi, 0) - msglen.writeUInt32BE(lo, 4) - - if (this._blockOffset === 55) { - this._length[0] -= 8 - this.update(this._oo) - } else { - if (this._blockOffset < 55) { - if (this._blockOffset === 0) this._nullt = true - this._length[0] -= (55 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) - } else { - this._length[0] -= (64 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) - this._length[0] -= 55 * 8 - this.update(Blake256.padding.slice(1, 1 + 55)) - this._nullt = true - } - - this.update(this._zo) - this._length[0] -= 8 - } - - this._length[0] -= 64 - this.update(msglen) -} - -Blake256.prototype.digest = function (encoding) { - this._padding() - - var buffer = new Buffer(32) - for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) - return buffer.toString(encoding); -} - -module.exports = Blake256; -}).call(this,require("buffer").Buffer) -},{"buffer":3}],10:[function(require,module,exports){ -(function (process,global){ -/** - * [js-sha3]{@link https://github.com/emn178/js-sha3} - * - * @version 0.7.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2015-2017 - * @license MIT - */ -/*jslint bitwise: true */ -'use strict'; - -var ERROR = 'input is invalid type'; -var WINDOW = typeof window === 'object'; -var root = WINDOW ? window : {}; -if (root.JS_SHA3_NO_WINDOW) { - WINDOW = false; -} -var WEB_WORKER = !WINDOW && typeof self === 'object'; -var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; -if (NODE_JS) { - root = global; -} else if (WEB_WORKER) { - root = self; -} -var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; -var HEX_CHARS = '0123456789abcdef'.split(''); -var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; -var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; -var KECCAK_PADDING = [1, 256, 65536, 16777216]; -var PADDING = [6, 1536, 393216, 100663296]; -var SHIFT = [0, 8, 16, 24]; -var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, - 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, - 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, - 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, - 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; -var BITS = [224, 256, 384, 512]; -var SHAKE_BITS = [128, 256]; -var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; -var CSHAKE_BYTEPAD = { - '128': 168, - '256': 136 -}; - -if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { - Array.isArray = function (obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; - }; -} - -if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { - ArrayBuffer.isView = function (obj) { - return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; - }; -} - -var createOutputMethod = function (bits, padding, outputType) { - return function (message) { - return new Keccak(bits, padding, bits).update(message)[outputType](); - }; -}; - -var createShakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits) { - return new Keccak(bits, padding, outputBits).update(message)[outputType](); - }; -}; - -var createCshakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits, n, s) { - return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); - }; -}; - -var createKmacOutputMethod = function (bits, padding, outputType) { - return function (key, message, outputBits, s) { - return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); - }; -}; - -var createOutputMethods = function (method, createMethod, bits, padding) { - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createMethod(bits, padding, type); - } - return method; -}; - -var createMethod = function (bits, padding) { - var method = createOutputMethod(bits, padding, 'hex'); - method.create = function () { - return new Keccak(bits, padding, bits); - }; - method.update = function (message) { - return method.create().update(message); - }; - return createOutputMethods(method, createOutputMethod, bits, padding); -}; - -var createShakeMethod = function (bits, padding) { - var method = createShakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits) { - return new Keccak(bits, padding, outputBits); - }; - method.update = function (message, outputBits) { - return method.create(outputBits).update(message); - }; - return createOutputMethods(method, createShakeOutputMethod, bits, padding); -}; - -var createCshakeMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createCshakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits, n, s) { - if (!n && !s) { - return methods['shake' + bits].create(outputBits); - } else { - return new Keccak(bits, padding, outputBits).bytepad([n, s], w); - } - }; - method.update = function (message, outputBits, n, s) { - return method.create(outputBits, n, s).update(message); - }; - return createOutputMethods(method, createCshakeOutputMethod, bits, padding); -}; - -var createKmacMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createKmacOutputMethod(bits, padding, 'hex'); - method.create = function (key, outputBits, s) { - return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); - }; - method.update = function (key, message, outputBits, s) { - return method.create(key, outputBits, s).update(message); - }; - return createOutputMethods(method, createKmacOutputMethod, bits, padding); -}; - -var algorithms = [ - { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, - { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, - { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, - { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, - { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } -]; - -var methods = {}, methodNames = []; - -for (var i = 0; i < algorithms.length; ++i) { - var algorithm = algorithms[i]; - var bits = algorithm.bits; - for (var j = 0; j < bits.length; ++j) { - var methodName = algorithm.name + '_' + bits[j]; - methodNames.push(methodName); - methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); - if (algorithm.name !== 'sha3') { - var newMethodName = algorithm.name + bits[j]; - methodNames.push(newMethodName); - methods[newMethodName] = methods[methodName]; - } - } -} - -function Keccak(bits, padding, outputBits) { - this.blocks = []; - this.s = []; - this.padding = padding; - this.outputBits = outputBits; - this.reset = true; - this.finalized = false; - this.block = 0; - this.start = 0; - this.blockCount = (1600 - (bits << 1)) >> 5; - this.byteCount = this.blockCount << 2; - this.outputBlocks = outputBits >> 5; - this.extraBytes = (outputBits & 31) >> 3; - - for (var i = 0; i < 50; ++i) { - this.s[i] = 0; - } -} - -Keccak.prototype.update = function (message) { - if (this.finalized) { - return; - } - var notString, type = typeof message; - if (type !== 'string') { - if (type === 'object') { - if (message === null) { - throw ERROR; - } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } else if (!Array.isArray(message)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var blocks = this.blocks, byteCount = this.byteCount, length = message.length, - blockCount = this.blockCount, index = 0, s = this.s, i, code; - - while (index < length) { - if (this.reset) { - this.reset = false; - blocks[0] = this.block; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - if (notString) { - for (i = this.start; index < length && i < byteCount; ++index) { - blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; - } - } else { - for (i = this.start; index < length && i < byteCount; ++index) { - code = message.charCodeAt(index); - if (code < 0x80) { - blocks[i >> 2] |= code << SHIFT[i++ & 3]; - } else if (code < 0x800) { - blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else if (code < 0xd800 || code >= 0xe000) { - blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); - blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - } - } - this.lastByteIndex = i; - if (i >= byteCount) { - this.start = i - byteCount; - this.block = blocks[blockCount]; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); - this.reset = true; - } else { - this.start = i; - } - } - return this; -}; - -Keccak.prototype.encode = function (x, right) { - var o = x & 255, n = 1; - var bytes = [o]; - x = x >> 8; - o = x & 255; - while (o > 0) { - bytes.unshift(o); - x = x >> 8; - o = x & 255; - ++n; - } - if (right) { - bytes.push(n); - } else { - bytes.unshift(n); - } - this.update(bytes); - return bytes.length; -}; - -Keccak.prototype.encodeString = function (str) { - var notString, type = typeof str; - if (type !== 'string') { - if (type === 'object') { - if (str === null) { - throw ERROR; - } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { - str = new Uint8Array(str); - } else if (!Array.isArray(str)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var bytes = 0, length = str.length; - if (notString) { - bytes = length; - } else { - for (var i = 0; i < str.length; ++i) { - var code = str.charCodeAt(i); - if (code < 0x80) { - bytes += 1; - } else if (code < 0x800) { - bytes += 2; - } else if (code < 0xd800 || code >= 0xe000) { - bytes += 3; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); - bytes += 4; - } - } - } - bytes += this.encode(bytes * 8); - this.update(str); - return bytes; -}; - -Keccak.prototype.bytepad = function (strs, w) { - var bytes = this.encode(w); - for (var i = 0; i < strs.length; ++i) { - bytes += this.encodeString(strs[i]); - } - var paddingBytes = w - bytes % w; - var zeros = []; - zeros.length = paddingBytes; - this.update(zeros); - return this; -}; - -Keccak.prototype.finalize = function () { - if (this.finalized) { - return; - } - this.finalized = true; - var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; - blocks[i >> 2] |= this.padding[i & 3]; - if (this.lastByteIndex === this.byteCount) { - blocks[0] = blocks[blockCount]; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - blocks[blockCount - 1] |= 0x80000000; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); -}; - -Keccak.prototype.toString = Keccak.prototype.hex = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var hex = '', block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + - HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + - HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + - HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; - } - if (j % blockCount === 0) { - f(s); - i = 0; - } - } - if (extraBytes) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; - if (extraBytes > 1) { - hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; - } - if (extraBytes > 2) { - hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; - } - } - return hex; -}; - -Keccak.prototype.arrayBuffer = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var bytes = this.outputBits >> 3; - var buffer; - if (extraBytes) { - buffer = new ArrayBuffer((outputBlocks + 1) << 2); - } else { - buffer = new ArrayBuffer(bytes); - } - var array = new Uint32Array(buffer); - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - array[j] = s[i]; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - array[i] = s[i]; - buffer = buffer.slice(0, bytes); - } - return buffer; -}; - -Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; - -Keccak.prototype.digest = Keccak.prototype.array = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var array = [], offset, block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - array[offset + 1] = (block >> 8) & 0xFF; - array[offset + 2] = (block >> 16) & 0xFF; - array[offset + 3] = (block >> 24) & 0xFF; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - if (extraBytes > 1) { - array[offset + 1] = (block >> 8) & 0xFF; - } - if (extraBytes > 2) { - array[offset + 2] = (block >> 16) & 0xFF; - } - } - return array; -}; - -function Kmac(bits, padding, outputBits) { - Keccak.call(this, bits, padding, outputBits); -} - -Kmac.prototype = new Keccak(); - -Kmac.prototype.finalize = function () { - this.encode(this.outputBits, true); - return Keccak.prototype.finalize.call(this); -}; - -var f = function (s) { - var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, - b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, - b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, - b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; - for (n = 0; n < 48; n += 2) { - c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; - c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; - c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; - c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; - c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; - c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; - c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; - c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; - c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; - c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; - - h = c8 ^ ((c2 << 1) | (c3 >>> 31)); - l = c9 ^ ((c3 << 1) | (c2 >>> 31)); - s[0] ^= h; - s[1] ^= l; - s[10] ^= h; - s[11] ^= l; - s[20] ^= h; - s[21] ^= l; - s[30] ^= h; - s[31] ^= l; - s[40] ^= h; - s[41] ^= l; - h = c0 ^ ((c4 << 1) | (c5 >>> 31)); - l = c1 ^ ((c5 << 1) | (c4 >>> 31)); - s[2] ^= h; - s[3] ^= l; - s[12] ^= h; - s[13] ^= l; - s[22] ^= h; - s[23] ^= l; - s[32] ^= h; - s[33] ^= l; - s[42] ^= h; - s[43] ^= l; - h = c2 ^ ((c6 << 1) | (c7 >>> 31)); - l = c3 ^ ((c7 << 1) | (c6 >>> 31)); - s[4] ^= h; - s[5] ^= l; - s[14] ^= h; - s[15] ^= l; - s[24] ^= h; - s[25] ^= l; - s[34] ^= h; - s[35] ^= l; - s[44] ^= h; - s[45] ^= l; - h = c4 ^ ((c8 << 1) | (c9 >>> 31)); - l = c5 ^ ((c9 << 1) | (c8 >>> 31)); - s[6] ^= h; - s[7] ^= l; - s[16] ^= h; - s[17] ^= l; - s[26] ^= h; - s[27] ^= l; - s[36] ^= h; - s[37] ^= l; - s[46] ^= h; - s[47] ^= l; - h = c6 ^ ((c0 << 1) | (c1 >>> 31)); - l = c7 ^ ((c1 << 1) | (c0 >>> 31)); - s[8] ^= h; - s[9] ^= l; - s[18] ^= h; - s[19] ^= l; - s[28] ^= h; - s[29] ^= l; - s[38] ^= h; - s[39] ^= l; - s[48] ^= h; - s[49] ^= l; - - b0 = s[0]; - b1 = s[1]; - b32 = (s[11] << 4) | (s[10] >>> 28); - b33 = (s[10] << 4) | (s[11] >>> 28); - b14 = (s[20] << 3) | (s[21] >>> 29); - b15 = (s[21] << 3) | (s[20] >>> 29); - b46 = (s[31] << 9) | (s[30] >>> 23); - b47 = (s[30] << 9) | (s[31] >>> 23); - b28 = (s[40] << 18) | (s[41] >>> 14); - b29 = (s[41] << 18) | (s[40] >>> 14); - b20 = (s[2] << 1) | (s[3] >>> 31); - b21 = (s[3] << 1) | (s[2] >>> 31); - b2 = (s[13] << 12) | (s[12] >>> 20); - b3 = (s[12] << 12) | (s[13] >>> 20); - b34 = (s[22] << 10) | (s[23] >>> 22); - b35 = (s[23] << 10) | (s[22] >>> 22); - b16 = (s[33] << 13) | (s[32] >>> 19); - b17 = (s[32] << 13) | (s[33] >>> 19); - b48 = (s[42] << 2) | (s[43] >>> 30); - b49 = (s[43] << 2) | (s[42] >>> 30); - b40 = (s[5] << 30) | (s[4] >>> 2); - b41 = (s[4] << 30) | (s[5] >>> 2); - b22 = (s[14] << 6) | (s[15] >>> 26); - b23 = (s[15] << 6) | (s[14] >>> 26); - b4 = (s[25] << 11) | (s[24] >>> 21); - b5 = (s[24] << 11) | (s[25] >>> 21); - b36 = (s[34] << 15) | (s[35] >>> 17); - b37 = (s[35] << 15) | (s[34] >>> 17); - b18 = (s[45] << 29) | (s[44] >>> 3); - b19 = (s[44] << 29) | (s[45] >>> 3); - b10 = (s[6] << 28) | (s[7] >>> 4); - b11 = (s[7] << 28) | (s[6] >>> 4); - b42 = (s[17] << 23) | (s[16] >>> 9); - b43 = (s[16] << 23) | (s[17] >>> 9); - b24 = (s[26] << 25) | (s[27] >>> 7); - b25 = (s[27] << 25) | (s[26] >>> 7); - b6 = (s[36] << 21) | (s[37] >>> 11); - b7 = (s[37] << 21) | (s[36] >>> 11); - b38 = (s[47] << 24) | (s[46] >>> 8); - b39 = (s[46] << 24) | (s[47] >>> 8); - b30 = (s[8] << 27) | (s[9] >>> 5); - b31 = (s[9] << 27) | (s[8] >>> 5); - b12 = (s[18] << 20) | (s[19] >>> 12); - b13 = (s[19] << 20) | (s[18] >>> 12); - b44 = (s[29] << 7) | (s[28] >>> 25); - b45 = (s[28] << 7) | (s[29] >>> 25); - b26 = (s[38] << 8) | (s[39] >>> 24); - b27 = (s[39] << 8) | (s[38] >>> 24); - b8 = (s[48] << 14) | (s[49] >>> 18); - b9 = (s[49] << 14) | (s[48] >>> 18); - - s[0] = b0 ^ (~b2 & b4); - s[1] = b1 ^ (~b3 & b5); - s[10] = b10 ^ (~b12 & b14); - s[11] = b11 ^ (~b13 & b15); - s[20] = b20 ^ (~b22 & b24); - s[21] = b21 ^ (~b23 & b25); - s[30] = b30 ^ (~b32 & b34); - s[31] = b31 ^ (~b33 & b35); - s[40] = b40 ^ (~b42 & b44); - s[41] = b41 ^ (~b43 & b45); - s[2] = b2 ^ (~b4 & b6); - s[3] = b3 ^ (~b5 & b7); - s[12] = b12 ^ (~b14 & b16); - s[13] = b13 ^ (~b15 & b17); - s[22] = b22 ^ (~b24 & b26); - s[23] = b23 ^ (~b25 & b27); - s[32] = b32 ^ (~b34 & b36); - s[33] = b33 ^ (~b35 & b37); - s[42] = b42 ^ (~b44 & b46); - s[43] = b43 ^ (~b45 & b47); - s[4] = b4 ^ (~b6 & b8); - s[5] = b5 ^ (~b7 & b9); - s[14] = b14 ^ (~b16 & b18); - s[15] = b15 ^ (~b17 & b19); - s[24] = b24 ^ (~b26 & b28); - s[25] = b25 ^ (~b27 & b29); - s[34] = b34 ^ (~b36 & b38); - s[35] = b35 ^ (~b37 & b39); - s[44] = b44 ^ (~b46 & b48); - s[45] = b45 ^ (~b47 & b49); - s[6] = b6 ^ (~b8 & b0); - s[7] = b7 ^ (~b9 & b1); - s[16] = b16 ^ (~b18 & b10); - s[17] = b17 ^ (~b19 & b11); - s[26] = b26 ^ (~b28 & b20); - s[27] = b27 ^ (~b29 & b21); - s[36] = b36 ^ (~b38 & b30); - s[37] = b37 ^ (~b39 & b31); - s[46] = b46 ^ (~b48 & b40); - s[47] = b47 ^ (~b49 & b41); - s[8] = b8 ^ (~b0 & b2); - s[9] = b9 ^ (~b1 & b3); - s[18] = b18 ^ (~b10 & b12); - s[19] = b19 ^ (~b11 & b13); - s[28] = b28 ^ (~b20 & b22); - s[29] = b29 ^ (~b21 & b23); - s[38] = b38 ^ (~b30 & b32); - s[39] = b39 ^ (~b31 & b33); - s[48] = b48 ^ (~b40 & b42); - s[49] = b49 ^ (~b41 & b43); - - s[0] ^= RC[n]; - s[1] ^= RC[n + 1]; - } -}; - -module.exports = methods; - -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":6}],11:[function(require,module,exports){ -var jsSHA = require('jssha/src/sha256'); -var Blake256 = require('./blake256'); -var keccak256 = require('./sha3')['keccak256']; - -function numberToHex (number) { - var hex = Math.round(number).toString(16); - if(hex.length === 1) { - hex = '0' + hex; - } - return hex; -} - -module.exports = { - toHex: function (arrayOfBytes) { - var hex = ''; - for(var i = 0; i < arrayOfBytes.length; i++) { - hex += numberToHex(arrayOfBytes[i]); - } - return hex; - }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX'); - sha.update(hexString); - return sha.getHash('HEX'); - }, - sha256Checksum: function (payload) { - return this.sha256(this.sha256(payload)).substr(0, 8); - }, - blake256: function (hexString) { - return new Blake256().update(hexString, 'hex').digest('hex'); - }, - blake256Checksum: function (payload) { - return this.blake256(this.blake256(payload)).substr(0, 8); - }, - keccak256: function (hexString) { - return keccak256(hexString); - } -}; - -},{"./blake256":9,"./sha3":10,"jssha/src/sha256":5}],12:[function(require,module,exports){ -var XRPValidator = require('./ripple_validator'); -var ETHValidator = require('./ethereum_validator'); - -// defines P2PKH and P2SH address types for standard (prod) and testnet networks -var CURRENCIES = [{ - name: 'bitcoin', - symbol: 'btc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'bitcoincash', - symbol: 'bch', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'litecoin', - symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} -},{ - name: 'peercoin', - symbol: 'ppc', - addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} -},{ - name: 'dogecoin', - symbol: 'doge', - addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} -},{ - name: 'beavercoin', - symbol: 'bvc', - addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} -},{ - name: 'freicoin', - symbol: 'frc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} -},{ - name: 'protoshares', - symbol: 'pts', - addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} -},{ - name: 'megacoin', - symbol: 'mec', - addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} -},{ - name: 'primecoin', - symbol: 'xpm', - addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} -},{ - name: 'auroracoin', - symbol: 'aur', - addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} -},{ - name: 'namecoin', - symbol: 'nmc', - addressTypes: {prod: ['34'], testnet: []} -},{ - name: 'biocoin', - symbol: 'bio', - addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} -},{ - name: 'garlicoin', - symbol: 'grlc', - addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} -},{ - name: 'vertcoin', - symbol: 'vtc', - addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} -},{ - name: 'bitcoingold', - symbol: 'btg', - addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} -},{ - name: 'komodo', - symbol: 'kmd', - addressTypes: {prod: ['3c', '55'], testnet: ['0','5']} -},{ - name: 'bitcoinz', - symbol: 'btcz', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} -},{ - name: 'bitcoinprivate', - symbol: 'btcp', - expectedLength: 26, - addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']} -},{ - name: 'hush', - symbol: 'hush', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} -},{ - name: 'snowgem', - symbol: 'sng', - expectedLength: 26, - addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']} -},{ - name: 'zcash', - symbol: 'zec', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} -},{ - name: 'zclassic', - symbol: 'zcl', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} -},{ - name: 'zencash', - symbol: 'zen', - expectedLength: 26, - addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']} -},{ - name: 'votecoin', - symbol: 'vot', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} -},{ - name: 'decred', - symbol: 'dcr', - addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, - hashFunction: 'blake256', - expectedLength: 26 -},{ - name: 'digibyte', - symbol: 'dgb', - addressTypes: {prod: ['1e'], testnet: []}, -},{ - name: 'ethereum', - symbol: 'eth', - validator: ETHValidator, -},{ - name: 'etherzero', - symbol: 'etz', - validator: ETHValidator, -},{ - name: 'ethereumclassic', - symbol: 'etc', - validator: ETHValidator, -},{ - name: 'callisto', - symbol: 'clo', - validator: ETHValidator, -},{ - name: 'ripple', - symbol: 'xrp', - validator: XRPValidator, -},{ - name: 'dash', - symbol: 'dash', - addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']} -},{ - name: 'neo', - symbol: 'neo', - addressTypes: {prod: ['17'], testnet: []} -},{ - name: 'qtum', - symbol: 'qtum', - addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']} -}]; - - -module.exports = { - getByNameOrSymbol: function (currencyNameOrSymbol) { - var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); - for (var i = 0; i < CURRENCIES.length; i++) { - var currency = CURRENCIES[i]; - if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { - return currency; - } - } - return null; - } -}; - -},{"./ethereum_validator":13,"./ripple_validator":14}],13:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); - -module.exports = { - isValidAddress: function (address) { - if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { - // Check if it has the basic requirements of an address - return false; - } - - if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { - // If it's all small caps or all all caps, return true - return true; - } - - // Otherwise check each case - return this.verifyChecksum(address); - }, - verifyChecksum: function (address) { - // Check each case - address = address.replace('0x',''); - - var addressHash = cryptoUtils.keccak256(address.toLowerCase()); - - for (var i = 0; i < 40; i++ ) { - // The nth letter should be uppercase if the nth digit of casemap is 1 - if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || - (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { - return false; - } - } - - return true; - } -}; - -},{"./crypto/utils":11}],14:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); -var baseX = require('base-x'); - -var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; - -var codec = baseX(ALLOWED_CHARS); -var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); - -module.exports = { - /** - * ripple address validation - */ - isValidAddress: function (address) { - if (regexp.test(address)) { - return this.verifyChecksum(address); - } - - return false; - }, - - verifyChecksum: function (address) { - var bytes = codec.decode(address); - var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); - var checksum = cryptoUtils.toHex(bytes.slice(-4)); - - return computedChecksum === checksum - } -}; - -},{"./crypto/utils":11,"base-x":1}],15:[function(require,module,exports){ -var base58 = require('./crypto/base58'); -var cryptoUtils = require('./crypto/utils'); -var currencies = require('./currencies'); - -var DEFAULT_CURRENCY_NAME = 'bitcoin'; -var DEFAULT_NETWORK_TYPE = 'prod'; - -function getDecoded(address) { - try { - return base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } -} - -function getChecksum(hashFunction, payload) { - // Each currency may implement different hashing algorithm - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); - } -} - -function getAddressType(address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded = getDecoded(address); - - if (decoded) { - var length = decoded.length; - - if (length !== expectedLength) { - return null; - } - - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = getChecksum(hashFunction, body); - - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; - } - - return null; -} - -function validate(address, currencyNameOrSymbol, networkType) { - currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; - networkType = networkType || DEFAULT_NETWORK_TYPE; - - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); - - if (currency.validator) { - return currency.validator.isValidAddress(address); - } - - var correctAddressTypes; - var addressType = getAddressType(address, currency); - - if (networkType === 'prod' || networkType === 'testnet'){ - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); - } - - return correctAddressTypes.indexOf(addressType) >= 0; -} - -module.exports = { - getAddressType: getAddressType, - checksum: getChecksum, - validate: validate, -}; - -},{"./crypto/base58":8,"./crypto/utils":11,"./currencies":12}]},{},[15])(15) +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { + digits.push(carry % BASE) + carry = (carry / BASE) | 0 + } + } + + var string = '' + + // deal with leading zeros + for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER + // convert digits to a string + for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] + + return string + } + + function decodeUnsafe (string) { + if (typeof string !== 'string') throw new TypeError('Expected String') + if (string.length === 0) return Buffer.allocUnsafe(0) + + var bytes = [0] + for (var i = 0; i < string.length; i++) { + var value = ALPHABET_MAP[string[i]] + if (value === undefined) return + + for (var j = 0, carry = value; j < bytes.length; ++j) { + carry += bytes[j] * BASE + bytes[j] = carry & 0xff + carry >>= 8 + } + + while (carry > 0) { + bytes.push(carry & 0xff) + carry >>= 8 + } + } + + // deal with leading zeros + for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { + bytes.push(0) + } + + return Buffer.from(bytes.reverse()) + } + + function decode (string) { + var buffer = decodeUnsafe(string) + if (buffer) return buffer + + throw new Error('Non-base' + BASE + ' character') + } + + return { + encode: encode, + decodeUnsafe: decodeUnsafe, + decode: decode + } +} + +},{"safe-buffer":7}],2:[function(require,module,exports){ +'use strict' + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function placeHoldersCount (b64) { + var len = b64.length + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} + +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return (b64.length * 3 / 4) - placeHoldersCount(b64) +} + +function toByteArray (b64) { + var i, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) + + arr = new Arr((len * 3 / 4) - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0; i < l; i += 4) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } + + parts.push(output) + + return parts.join('') +} + +},{}],3:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + +'use strict' + +var base64 = require('base64-js') +var ieee754 = require('ieee754') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} + +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 + } catch (e) { + return false + } +} + +Object.defineProperty(Buffer.prototype, 'parent', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined + } + return this.buffer + } +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + get: function () { + if (!(this instanceof Buffer)) { + return undefined + } + return this.byteOffset + } +}) + +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('Invalid typed array length') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} + +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) +} + +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + return fromObject(value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf +} + +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} + +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf +} + +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj) { + if (ArrayBuffer.isView(obj) || 'length' in obj) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } + } + + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') +} + +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (ArrayBuffer.isView(buf)) { + buf = Buffer.from(buf) + } + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.toLocaleString = Buffer.prototype.toString + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : new Buffer(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check +// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 +function isArrayBuffer (obj) { + return obj instanceof ArrayBuffer || + (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && + typeof obj.byteLength === 'number') +} + +function numberIsNaN (obj) { + return obj !== obj // eslint-disable-line no-self-compare +} + +},{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + +},{}],5:[function(require,module,exports){ +/* + A JavaScript implementation of the SHA family of hashes, as + defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding + HMAC implementation as defined in FIPS PUB 198a + + Copyright Brian Turek 2008-2017 + Distributed under the BSD License + See http://caligatio.github.com/jsSHA/ for more information + + Several functions taken from Paul Johnston +*/ +'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; +b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> +5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); +}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> +6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==k&&k 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],7:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} + +},{"buffer":3}],8:[function(require,module,exports){ +// Base58 encoding/decoding +// Originally written by Mike Hearn for BitcoinJ +// Copyright (c) 2011 Google Inc +// Ported to JavaScript by Stefan Thomas +// Merged Buffer refactorings from base58-native by Stephen Pair +// Copyright (c) 2013 BitPay Inc + +var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; +var ALPHABET_MAP = {}; +for (var i = 0; i < ALPHABET.length; ++i) { + ALPHABET_MAP[ALPHABET.charAt(i)] = i; +} +var BASE = ALPHABET.length; + +module.exports = { + decode: function(string) { + if (string.length === 0) return []; + + var i, j, bytes = [0]; + for (i = 0; i < string.length; ++i) { + var c = string[i]; + if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character'); + + for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE + bytes[0] += ALPHABET_MAP[c]; + + var carry = 0; + for (j = 0; j < bytes.length; ++j) { + bytes[j] += carry; + carry = bytes[j] >> 8; + bytes[j] &= 0xff + } + + while (carry) { + bytes.push(carry & 0xff); + carry >>= 8; + } + } + // deal with leading zeros + for (i = 0; string[i] === '1' && i < string.length - 1; ++i){ + bytes.push(0); + } + + return bytes.reverse(); + } +}; + +},{}],9:[function(require,module,exports){ +(function (Buffer){ +'use strict'; + +/** + * Credits to https://github.com/cryptocoinjs/blake-hash + */ +Blake256.sigma = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] +] + +Blake256.u256 = [ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 +] + +Blake256.padding = new Buffer([ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +]) + +Blake256.prototype._length_carry = function (arr) { + for (var j = 0; j < arr.length; ++j) { + if (arr[j] < 0x0100000000) break + arr[j] -= 0x0100000000 + arr[j + 1] += 1 + } +} + +Blake256.prototype.update = function (data, encoding) { + data = new Buffer(data, encoding); + var block = this._block + var offset = 0 + + while (this._blockOffset + data.length - offset >= block.length) { + for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] + + this._length[0] += block.length * 8 + this._length_carry(this._length) + + this._compress() + this._blockOffset = 0 + } + + while (offset < data.length) block[this._blockOffset++] = data[offset++] + return this; +} + +var zo = new Buffer([0x01]) +var oo = new Buffer([0x81]) + +function rot (x, n) { + return ((x << (32 - n)) | (x >>> n)) >>> 0 +} + +function g (v, m, i, a, b, c, d, e) { + var sigma = Blake256.sigma + var u256 = Blake256.u256 + + v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 16) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 12) + v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 8) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 7) +} + +function Blake256 () { + this._h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ] + + this._s = [0, 0, 0, 0] + + this._block = new Buffer(64) + this._blockOffset = 0 + this._length = [0, 0] + + this._nullt = false + + this._zo = zo + this._oo = oo +} + +Blake256.prototype._compress = function () { + var u256 = Blake256.u256 + var v = new Array(16) + var m = new Array(16) + var i + + for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) + for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 + for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 + for (i = 12; i < 16; ++i) v[i] = u256[i - 8] + + if (!this._nullt) { + v[12] = (v[12] ^ this._length[0]) >>> 0 + v[13] = (v[13] ^ this._length[0]) >>> 0 + v[14] = (v[14] ^ this._length[1]) >>> 0 + v[15] = (v[15] ^ this._length[1]) >>> 0 + } + + for (i = 0; i < 14; ++i) { + /* column step */ + g(v, m, i, 0, 4, 8, 12, 0) + g(v, m, i, 1, 5, 9, 13, 2) + g(v, m, i, 2, 6, 10, 14, 4) + g(v, m, i, 3, 7, 11, 15, 6) + /* diagonal step */ + g(v, m, i, 0, 5, 10, 15, 8) + g(v, m, i, 1, 6, 11, 12, 10) + g(v, m, i, 2, 7, 8, 13, 12) + g(v, m, i, 3, 4, 9, 14, 14) + } + + for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 + for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 +} + +Blake256.prototype._padding = function () { + var lo = this._length[0] + this._blockOffset * 8 + var hi = this._length[1] + if (lo >= 0x0100000000) { + lo -= 0x0100000000 + hi += 1 + } + + var msglen = new Buffer(8) + msglen.writeUInt32BE(hi, 0) + msglen.writeUInt32BE(lo, 4) + + if (this._blockOffset === 55) { + this._length[0] -= 8 + this.update(this._oo) + } else { + if (this._blockOffset < 55) { + if (this._blockOffset === 0) this._nullt = true + this._length[0] -= (55 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) + } else { + this._length[0] -= (64 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) + this._length[0] -= 55 * 8 + this.update(Blake256.padding.slice(1, 1 + 55)) + this._nullt = true + } + + this.update(this._zo) + this._length[0] -= 8 + } + + this._length[0] -= 64 + this.update(msglen) +} + +Blake256.prototype.digest = function (encoding) { + this._padding() + + var buffer = new Buffer(32) + for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) + return buffer.toString(encoding); +} + +module.exports = Blake256; +}).call(this,require("buffer").Buffer) +},{"buffer":3}],10:[function(require,module,exports){ +(function (process,global){ +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.7.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2017 + * @license MIT + */ +/*jslint bitwise: true */ +'use strict'; + +var ERROR = 'input is invalid type'; +var WINDOW = typeof window === 'object'; +var root = WINDOW ? window : {}; +if (root.JS_SHA3_NO_WINDOW) { + WINDOW = false; +} +var WEB_WORKER = !WINDOW && typeof self === 'object'; +var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; +if (NODE_JS) { + root = global; +} else if (WEB_WORKER) { + root = self; +} +var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; +var HEX_CHARS = '0123456789abcdef'.split(''); +var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; +var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; +var KECCAK_PADDING = [1, 256, 65536, 16777216]; +var PADDING = [6, 1536, 393216, 100663296]; +var SHIFT = [0, 8, 16, 24]; +var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; +var BITS = [224, 256, 384, 512]; +var SHAKE_BITS = [128, 256]; +var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; +var CSHAKE_BYTEPAD = { + '128': 168, + '256': 136 +}; + +if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { + Array.isArray = function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; +} + +if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { + ArrayBuffer.isView = function (obj) { + return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; + }; +} + +var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; +}; + +var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; +}; + +var createCshakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits, n, s) { + return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); + }; +}; + +var createKmacOutputMethod = function (bits, padding, outputType) { + return function (key, message, outputBits, s) { + return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); + }; +}; + +var createOutputMethods = function (method, createMethod, bits, padding) { + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createMethod(bits, padding, type); + } + return method; +}; + +var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + return createOutputMethods(method, createOutputMethod, bits, padding); +}; + +var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + return createOutputMethods(method, createShakeOutputMethod, bits, padding); +}; + +var createCshakeMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createCshakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits, n, s) { + if (!n && !s) { + return methods['shake' + bits].create(outputBits); + } else { + return new Keccak(bits, padding, outputBits).bytepad([n, s], w); + } + }; + method.update = function (message, outputBits, n, s) { + return method.create(outputBits, n, s).update(message); + }; + return createOutputMethods(method, createCshakeOutputMethod, bits, padding); +}; + +var createKmacMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createKmacOutputMethod(bits, padding, 'hex'); + method.create = function (key, outputBits, s) { + return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); + }; + method.update = function (key, message, outputBits, s) { + return method.create(key, outputBits, s).update(message); + }; + return createOutputMethods(method, createKmacOutputMethod, bits, padding); +}; + +var algorithms = [ + { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, + { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, + { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, + { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, + { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } +]; + +var methods = {}, methodNames = []; + +for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name + '_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + if (algorithm.name !== 'sha3') { + var newMethodName = algorithm.name + bits[j]; + methodNames.push(newMethodName); + methods[newMethodName] = methods[methodName]; + } + } +} + +function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.finalized = false; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } +} + +Keccak.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString, type = typeof message; + if (type !== 'string') { + if (type === 'object') { + if (message === null) { + throw ERROR; + } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (!Array.isArray(message)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var blocks = this.blocks, byteCount = this.byteCount, length = message.length, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; +}; + +Keccak.prototype.encode = function (x, right) { + var o = x & 255, n = 1; + var bytes = [o]; + x = x >> 8; + o = x & 255; + while (o > 0) { + bytes.unshift(o); + x = x >> 8; + o = x & 255; + ++n; + } + if (right) { + bytes.push(n); + } else { + bytes.unshift(n); + } + this.update(bytes); + return bytes.length; +}; + +Keccak.prototype.encodeString = function (str) { + var notString, type = typeof str; + if (type !== 'string') { + if (type === 'object') { + if (str === null) { + throw ERROR; + } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { + str = new Uint8Array(str); + } else if (!Array.isArray(str)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var bytes = 0, length = str.length; + if (notString) { + bytes = length; + } else { + for (var i = 0; i < str.length; ++i) { + var code = str.charCodeAt(i); + if (code < 0x80) { + bytes += 1; + } else if (code < 0x800) { + bytes += 2; + } else if (code < 0xd800 || code >= 0xe000) { + bytes += 3; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); + bytes += 4; + } + } + } + bytes += this.encode(bytes * 8); + this.update(str); + return bytes; +}; + +Keccak.prototype.bytepad = function (strs, w) { + var bytes = this.encode(w); + for (var i = 0; i < strs.length; ++i) { + bytes += this.encodeString(strs[i]); + } + var paddingBytes = w - bytes % w; + var zeros = []; + zeros.length = paddingBytes; + this.update(zeros); + return this; +}; + +Keccak.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); +}; + +Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; +}; + +Keccak.prototype.arrayBuffer = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; +}; + +Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + +Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; +}; + +function Kmac(bits, padding, outputBits) { + Keccak.call(this, bits, padding, outputBits); +} + +Kmac.prototype = new Keccak(); + +Kmac.prototype.finalize = function () { + this.encode(this.outputBits, true); + return Keccak.prototype.finalize.call(this); +}; + +var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } +}; + +module.exports = methods; + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":6}],11:[function(require,module,exports){ +var jsSHA = require('jssha/src/sha256'); +var Blake256 = require('./blake256'); +var keccak256 = require('./sha3')['keccak256']; + +function numberToHex (number) { + var hex = Math.round(number).toString(16); + if(hex.length === 1) { + hex = '0' + hex; + } + return hex; +} + +module.exports = { + toHex: function (arrayOfBytes) { + var hex = ''; + for(var i = 0; i < arrayOfBytes.length; i++) { + hex += numberToHex(arrayOfBytes[i]); + } + return hex; + }, + sha256: function (hexString) { + var sha = new jsSHA('SHA-256', 'HEX'); + sha.update(hexString); + return sha.getHash('HEX'); + }, + sha256Checksum: function (payload) { + return this.sha256(this.sha256(payload)).substr(0, 8); + }, + blake256: function (hexString) { + return new Blake256().update(hexString, 'hex').digest('hex'); + }, + blake256Checksum: function (payload) { + return this.blake256(this.blake256(payload)).substr(0, 8); + }, + keccak256: function (hexString) { + return keccak256(hexString); + } +}; + +},{"./blake256":9,"./sha3":10,"jssha/src/sha256":5}],12:[function(require,module,exports){ +var XRPValidator = require('./ripple_validator'); +var ETHValidator = require('./ethereum_validator'); + +// defines P2PKH and P2SH address types for standard (prod) and testnet networks +var CURRENCIES = [{ + name: 'bitcoin', + symbol: 'btc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'bitcoincash', + symbol: 'bch', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'litecoin', + symbol: 'ltc', + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} +},{ + name: 'peercoin', + symbol: 'ppc', + addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} +},{ + name: 'dogecoin', + symbol: 'doge', + addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} +},{ + name: 'beavercoin', + symbol: 'bvc', + addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} +},{ + name: 'freicoin', + symbol: 'frc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} +},{ + name: 'protoshares', + symbol: 'pts', + addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} +},{ + name: 'megacoin', + symbol: 'mec', + addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} +},{ + name: 'primecoin', + symbol: 'xpm', + addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} +},{ + name: 'auroracoin', + symbol: 'aur', + addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} +},{ + name: 'namecoin', + symbol: 'nmc', + addressTypes: {prod: ['34'], testnet: []} +},{ + name: 'biocoin', + symbol: 'bio', + addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} +},{ + name: 'garlicoin', + symbol: 'grlc', + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} +},{ + name: 'vertcoin', + symbol: 'vtc', + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} +},{ + name: 'bitcoingold', + symbol: 'btg', + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} +},{ + name: 'komodo', + symbol: 'kmd', + addressTypes: {prod: ['3c', '55'], testnet: ['0','5']} +},{ + name: 'bitcoinz', + symbol: 'btcz', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'bitcoinprivate', + symbol: 'btcp', + expectedLength: 26, + addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']} +},{ + name: 'hush', + symbol: 'hush', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'snowgem', + symbol: 'sng', + expectedLength: 26, + addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']} +},{ + name: 'zcash', + symbol: 'zec', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'zclassic', + symbol: 'zcl', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'zencash', + symbol: 'zen', + expectedLength: 26, + addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']} +},{ + name: 'votecoin', + symbol: 'vot', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} +},{ + name: 'decred', + symbol: 'dcr', + addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, + hashFunction: 'blake256', + expectedLength: 26 +},{ + name: 'digibyte', + symbol: 'dgb', + addressTypes: {prod: ['1e'], testnet: []}, +},{ + name: 'ethereum', + symbol: 'eth', + validator: ETHValidator, +},{ + name: 'etherzero', + symbol: 'etz', + validator: ETHValidator, +},{ + name: 'ethereumclassic', + symbol: 'etc', + validator: ETHValidator, +},{ + name: 'callisto', + symbol: 'clo', + validator: ETHValidator, +},{ + name: 'ripple', + symbol: 'xrp', + validator: XRPValidator, +},{ + name: 'dash', + symbol: 'dash', + addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']} +},{ + name: 'neo', + symbol: 'neo', + addressTypes: {prod: ['17'], testnet: []} +},{ + name: 'neogas', + symbol: 'gas', + addressTypes: {prod: ['17'], testnet: []} +},{ + name: 'qtum', + symbol: 'qtum', + addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']} +}]; + + +module.exports = { + getByNameOrSymbol: function (currencyNameOrSymbol) { + var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); + for (var i = 0; i < CURRENCIES.length; i++) { + var currency = CURRENCIES[i]; + if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { + return currency; + } + } + return null; + } +}; + +},{"./ethereum_validator":13,"./ripple_validator":14}],13:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); + +module.exports = { + isValidAddress: function (address) { + if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { + // Check if it has the basic requirements of an address + return false; + } + + if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { + // If it's all small caps or all all caps, return true + return true; + } + + // Otherwise check each case + return this.verifyChecksum(address); + }, + verifyChecksum: function (address) { + // Check each case + address = address.replace('0x',''); + + var addressHash = cryptoUtils.keccak256(address.toLowerCase()); + + for (var i = 0; i < 40; i++ ) { + // The nth letter should be uppercase if the nth digit of casemap is 1 + if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || + (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { + return false; + } + } + + return true; + } +}; + +},{"./crypto/utils":11}],14:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var baseX = require('base-x'); + +var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; + +var codec = baseX(ALLOWED_CHARS); +var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); + +module.exports = { + /** + * ripple address validation + */ + isValidAddress: function (address) { + if (regexp.test(address)) { + return this.verifyChecksum(address); + } + + return false; + }, + + verifyChecksum: function (address) { + var bytes = codec.decode(address); + var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); + var checksum = cryptoUtils.toHex(bytes.slice(-4)); + + return computedChecksum === checksum + } +}; + +},{"./crypto/utils":11,"base-x":1}],15:[function(require,module,exports){ +var base58 = require('./crypto/base58'); +var cryptoUtils = require('./crypto/utils'); +var currencies = require('./currencies'); + +var DEFAULT_CURRENCY_NAME = 'bitcoin'; +var DEFAULT_NETWORK_TYPE = 'prod'; + +function getDecoded(address) { + try { + return base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } +} + +function getChecksum(hashFunction, payload) { + // Each currency may implement different hashing algorithm + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); + } +} + +function getAddressType(address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded = getDecoded(address); + + if (decoded) { + var length = decoded.length; + + if (length !== expectedLength) { + return null; + } + + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = getChecksum(hashFunction, body); + + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + } + + return null; +} + +function validate(address, currencyNameOrSymbol, networkType) { + currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; + networkType = networkType || DEFAULT_NETWORK_TYPE; + + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); + + if (currency.validator) { + return currency.validator.isValidAddress(address); + } + + var correctAddressTypes; + var addressType = getAddressType(address, currency); + if (addressType == null) { + return false; + } + + if (networkType === 'prod' || networkType === 'testnet'){ + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + } + + return correctAddressTypes.indexOf(addressType) >= 0; +} + +module.exports = { + getAddressType: getAddressType, + checksum: getChecksum, + validate: validate, +}; + +},{"./crypto/base58":8,"./crypto/utils":11,"./currencies":12}]},{},[15])(15) }); \ No newline at end of file diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 83d0520b..128415bb 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var h=r[s]={exports:{}};e[s][0].call(h.exports,function(t){var r=e[s][1][t];return o(r||t)},h,h.exports,t,e,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s>=8;for(;f>0;)i.push(255&f),f>>=8}for(var h=0;t[h]===o&&h0;)n.push(a%r),a=a/r|0}for(var u="",f=0;0===e[f]&&f=0;--h)u+=t[n[h]];return u},decodeUnsafe:a,decode:function(t){var e=a(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":7}],2:[function(t,e,r){"use strict";r.byteLength=function(t){return 3*t.length/4-f(t)},r.toByteArray=function(t){var e,r,n,s,a,u=t.length;s=f(t),a=new i(3*u/4-s),r=s>0?u-4:u;var h=0;for(e=0;e>16&255,a[h++]=n>>8&255,a[h++]=255&n;2===s?(n=o[t.charCodeAt(e)]<<2|o[t.charCodeAt(e+1)]>>4,a[h++]=255&n):1===s&&(n=o[t.charCodeAt(e)]<<10|o[t.charCodeAt(e+1)]<<4|o[t.charCodeAt(e+2)]>>2,a[h++]=n>>8&255,a[h++]=255&n);return a},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i="",s=[],a=0,u=r-o;au?u:a+16383));1===o?(e=t[r-1],i+=n[e>>2],i+=n[e<<4&63],i+="=="):2===o&&(e=(t[r-2]<<8)+t[r-1],i+=n[e>>10],i+=n[e>>4&63],i+=n[e<<2&63],i+="=");return s.push(i),s.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function h(t,e,r){for(var o,i,s=[],a=e;a>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function s(t){if(t>i)throw new RangeError("Invalid typed array length");var e=new Uint8Array(t);return e.__proto__=a.prototype,e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return h(t)}return u(t,e,r)}function u(t,e,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return O(t)||t&&O(t.buffer)?function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||O(t))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return I(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(n)return I(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),M(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;ia&&(r=a-u),i=r;i>=0;i--){for(var c=!0,l=0;lo&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s239?4:f>223?3:f>191?2:1;if(o+c<=r)switch(c){case 1:f<128&&(h=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(h=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&f)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},a.prototype.compare=function(t,e,r,n,o){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,s=r-e,u=Math.min(i,s),f=this.slice(n,o),h=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,F(I(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return u=this,f=e,h=r,F(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,F(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function x(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,i){return e=+e,r>>>=0,i||x(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,i){return e=+e,r>>>=0,i||x(t,0,r,8),o.write(t,e,r,n,52,8),r+8}a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},a.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),o.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;h>0;i=256*i+t[e+c],c+=l,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+c],c+=l,h-=8);if(0===i)i=1-f;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var s,a,u,f=8*i-o-1,h=(1<>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=h?(a=0,s=h):s+c>=1?(a=(e*u-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,f-=8);t[r+p-d]|=128*y}},{}],5:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,c,l,p,d,y,g,b,w=0,v=[],m=0,B=!1,_=[],k=[],T=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return E(e,r,t)},y=function(e,r,n,o){var i,s;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),s=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,se/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)_[e]=909522486^r[e],k[e]=1549556828^r[e];o=d(_,o),w=p,B=!0},this.update=function(t){var e,r,n,i=0,s=p>>>5;for(t=(e=c(t,v,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,T=!0},this.getHash=function(e,r){var n,h,c,p;if(!0===B)throw Error("Cannot call getHash after setting HMAC key");switch(c=f(r),e){case"HEX":n=function(t){return i(t,l,c)};break;case"B64":n=function(t){return s(t,l,c)};break;case"BYTES":n=function(t){return a(t,l)};break;case"ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,l)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=y(v.slice(),m,w,g(o)),h=1;h>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function s(t,e,r){var n,o,i,s="",a=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)s+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return s}function a(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,s,a,u,f,h,c,l=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(c=3,s=0;so?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(s)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),a=0;a>>2;r.length<=f;)r.push(0);r[f]|=i[a]<<8*(c+h%4*-1),l+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(c=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,s=0;s>>8),f=(h=l+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(c+h%4*-1),l+=2}return{value:r,binLen:8*l+n}};break;case"B64":r=function(t,e,r){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[a++]=n>>8&255,i[a++]=255&n;2===o?(n=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,i[a++]=255&n):1===o&&(n=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,i[a++]=n>>8&255,i[a++]=255&n);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o="",i=[],s=0,a=r-n;s>2],o+=u[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=u[e>>10],o+=u[e>>4&63],o+=u[e<<2&63],o+="=");return i.push(o),i.join("")};for(var u=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=c,r.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},c.prototype.compare=function(t,e,r,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,F(R(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return u=this,f=e,h=r,F(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,F(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function x(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,o){return e=+e,r>>>=0,o||x(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,o){return e=+e,r>>>=0,o||x(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(e+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(e*u-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,e){return M(t,e,s)},l=function(t,e,r,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,b)).binLen,r=e.value,e=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(e),t){case"HEX":r=function(t){return A(t,f,o)};break;case"B64":r=function(t){return E(t,f,o)};break;case"BYTES":r=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function E(t,e,r){var n,o,i,s="",a=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return s}function B(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function k(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function T(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,s,a,u,f,h,c=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=u;)e.push(0);e[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(h+f%4*-1),c+=2}return{value:e,binLen:8*c+r}};break;case"B64":e=function(t,e,r){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Fri, 20 Apr 2018 20:45:01 +0900 Subject: [PATCH 038/108] chore(release): 0.1.7 --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4aef741a..35c3fd69 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,8 @@ "dash", "neo", "gas", + "komodo", + "zcash", "qtum", "altcoin", "crypto", @@ -23,7 +25,7 @@ "browser", "nodejs" ], - "version": "0.1.6", + "version": "0.1.7", "author": "Tomek Kolasa ", "homepage": "https://github.com/ognus/wallet-address-validator", "license": "MIT", From af2024cda36aa92a8438fd47f4b587f4f95a5731 Mon Sep 17 00:00:00 2001 From: Ignacio Baixas Date: Tue, 15 May 2018 16:53:41 -0400 Subject: [PATCH 039/108] chore(): add failing spec for P2SH testnet litecoin address Currently the library only supports legacy testnet P2SH addresses --- test/wallet_address_validator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index fbc29183..0cf857e9 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -65,6 +65,7 @@ describe('WAValidator.validate()', function () { // p2sh addresses valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'litecoin'); valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'litecoin', 'testnet'); + valid('QW2SvwjaJU8LD6GSmtm1PHnBG2xPuxwZFy', 'litecoin', 'testnet'); }); it('should return true for correct peercoin addresses', function () { From 0cb202e2d99ed432f39686a219a02dffea1fdefa Mon Sep 17 00:00:00 2001 From: Ignacio Baixas Date: Tue, 15 May 2018 16:55:17 -0400 Subject: [PATCH 040/108] feat(litecoin): adds support for new testnet P2SH addresses --- src/currencies.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/currencies.js b/src/currencies.js index 6bbfb79e..bed7bc64 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -13,7 +13,7 @@ var CURRENCIES = [{ },{ name: 'litecoin', symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']} },{ name: 'peercoin', symbol: 'ppc', From 42624453acf26a85e653deef84a604d3b2625407 Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Tue, 10 Jul 2018 21:10:03 +0900 Subject: [PATCH 041/108] chore(dist): rebuilt the bundle file --- dist/wallet-address-validator.js | 2 +- dist/wallet-address-validator.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 408eb388..35a3b5ac 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -3254,7 +3254,7 @@ var CURRENCIES = [{ },{ name: 'litecoin', symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']} },{ name: 'peercoin', symbol: 'ppc', diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 128415bb..0c70d667 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,a,u){function f(r,t){if(!a[r]){if(!s[r]){var e="function"==typeof require&&require;if(!t&&e)return e(r,!0);if(h)return h(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[r]={exports:{}};s[r][0].call(o.exports,function(t){var e=s[r][1][t];return f(e||t)},o,o.exports,i,s,a,u)}return a[r].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[a++]=n>>8&255,i[a++]=255&n;2===o?(n=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,i[a++]=255&n):1===o&&(n=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,i[a++]=n>>8&255,i[a++]=255&n);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o="",i=[],s=0,a=r-n;s>2],o+=u[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=u[e>>10],o+=u[e>>4&63],o+=u[e<<2&63],o+="=");return i.push(o),i.join("")};for(var u=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=c,r.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},c.prototype.compare=function(t,e,r,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,F(R(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return u=this,f=e,h=r,F(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,F(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function x(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,o){return e=+e,r>>>=0,o||x(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,o){return e=+e,r>>>=0,o||x(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(e+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(e*u-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,e){return M(t,e,s)},l=function(t,e,r,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,b)).binLen,r=e.value,e=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(e),t){case"HEX":r=function(t){return A(t,f,o)};break;case"B64":r=function(t){return E(t,f,o)};break;case"BYTES":r=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function E(t,e,r){var n,o,i,s="",a=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return s}function B(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function k(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function T(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,s,a,u,f,h,c=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=u;)e.push(0);e[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(h+f%4*-1),c+=2}return{value:e,binLen:8*c+r}};break;case"B64":e=function(t,e,r){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[a++]=n>>8&255,i[a++]=255&n;2===o?(n=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,i[a++]=255&n):1===o&&(n=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,i[a++]=n>>8&255,i[a++]=255&n);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o="",i=[],s=0,a=r-n;s>2],o+=u[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=u[e>>10],o+=u[e>>4&63],o+=u[e<<2&63],o+="=");return i.push(o),i.join("")};for(var u=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=c,r.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},c.prototype.compare=function(t,e,r,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,F(R(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return u=this,f=e,h=r,F(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,F(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function x(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,o){return e=+e,r>>>=0,o||x(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,o){return e=+e,r>>>=0,o||x(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(e+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(e*u-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,e){return M(t,e,s)},l=function(t,e,r,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,b)).binLen,r=e.value,e=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(e),t){case"HEX":r=function(t){return A(t,f,o)};break;case"B64":r=function(t){return E(t,f,o)};break;case"BYTES":r=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function E(t,e,r){var n,o,i,s="",a=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return s}function B(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function k(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function T(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,s,a,u,f,h,c=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=u;)e.push(0);e[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(h+f%4*-1),c+=2}return{value:e,binLen:8*c+r}};break;case"B64":e=function(t,e,r){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o 0) { throw new Error('Invalid string. Length must be a multiple of 4') } - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] } +// base64 is 4/3 + up to two characters of the original data function byteLength (b64) { - // base64 is 4/3 + up to two characters of the original data - return (b64.length * 3 / 4) - placeHoldersCount(b64) + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function toByteArray (b64) { - var i, l, tmp, placeHolders, arr - var len = b64.length - placeHolders = placeHoldersCount(b64) + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] - arr = new Arr((len * 3 / 4) - placeHolders) + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? len - 4 : len + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen - var L = 0 + for (var i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } - for (i = 0; i < l; i += 4) { - tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] - arr[L++] = (tmp >> 16) & 0xFF - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF } - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF } return arr } function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] } function encodeChunk (uint8, start, end) { var tmp var output = [] for (var i = start; i < end; i += 3) { - tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) output.push(tripletToBase64(tmp)) } return output.join('') @@ -182,31 +214,34 @@ function fromByteArray (uint8) { var tmp var len = uint8.length var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' var parts = [] var maxChunkLength = 16383 // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) } - parts.push(output) - return parts.join('') } @@ -1951,7 +1986,7 @@ function numberIsNaN (obj) { },{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m - var eLen = nBytes * 8 - mLen - 1 + var eLen = (nBytes * 8) - mLen - 1 var eMax = (1 << eLen) - 1 var eBias = eMax >> 1 var nBits = -7 @@ -1964,12 +1999,12 @@ exports.read = function (buffer, offset, isLE, mLen, nBytes) { e = s & ((1 << (-nBits)) - 1) s >>= (-nBits) nBits += eLen - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} m = e & ((1 << (-nBits)) - 1) e >>= (-nBits) nBits += mLen - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} if (e === 0) { e = 1 - eBias @@ -1984,7 +2019,7 @@ exports.read = function (buffer, offset, isLE, mLen, nBytes) { exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { var e, m, c - var eLen = nBytes * 8 - mLen - 1 + var eLen = (nBytes * 8) - mLen - 1 var eMax = (1 << eLen) - 1 var eBias = eMax >> 1 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) @@ -2017,7 +2052,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { m = 0 e = eMax } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen) + m = ((value * c) - 1) * Math.pow(2, mLen) e = e + eBias } else { m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) @@ -2316,6 +2351,56 @@ SafeBuffer.allocUnsafeSlow = function (size) { } },{"buffer":3}],8:[function(require,module,exports){ +var segwit_addr = require('./crypto/segwit_addr'); +var CURRENCY_NAME = 'bitcoin'; + +function isValidNetworkAddress(address, networkType) { + return isValidP2PKHandP2SHAddress(address, networkType) || isValidSegwitAddress(address) +} + +function isValidP2PKHandP2SHAddress(address, networkType) { + // These libs need to reqired in here. + var WAValidator = require('./wallet_address_validator.js'); + var currencies = require('./currencies.js'); + + var currency = currencies.getByNameOrSymbol(CURRENCY_NAME); + + var correctAddressTypes; + var addressType = WAValidator.getAddressType(address, currency); + if (addressType == null) { + return false; + } + + if (networkType === 'prod' || networkType === 'testnet'){ + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + } + + return correctAddressTypes.indexOf(addressType) >= 0; +} + +function isValidSegwitAddress(address) { + var hrp = "bc"; + var ret = segwit_addr.decode(hrp, address); + if (ret === null) { + hrp = "tb"; + ret = segwit_addr.decode(hrp, address); + } + var ok = ret !== null; + if (ok) { + var recreate = segwit_addr.encode(hrp, ret.version, ret.program); + ok = (recreate === address.toLowerCase()); + } + + return !!ok; +} + +module.exports = { + isValidNetworkAddress: isValidNetworkAddress +}; + +},{"./crypto/segwit_addr":12,"./currencies.js":15,"./wallet_address_validator.js":18}],9:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -2363,7 +2448,125 @@ module.exports = { } }; -},{}],9:[function(require,module,exports){ +},{}],10:[function(require,module,exports){ +// Copyright (c) 2017 Pieter Wuille +// +// 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. + +var CHARSET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'; +var GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]; + +module.exports = { + decode: decode, + encode: encode, +}; + + +function polymod (values) { + var chk = 1; + for (var p = 0; p < values.length; ++p) { + var top = chk >> 25; + chk = (chk & 0x1ffffff) << 5 ^ values[p]; + for (var i = 0; i < 5; ++i) { + if ((top >> i) & 1) { + chk ^= GENERATOR[i]; + } + } + } + return chk; +} + +function hrpExpand (hrp) { + var ret = []; + var p; + for (p = 0; p < hrp.length; ++p) { + ret.push(hrp.charCodeAt(p) >> 5); + } + ret.push(0); + for (p = 0; p < hrp.length; ++p) { + ret.push(hrp.charCodeAt(p) & 31); + } + return ret; +} + +function verifyChecksum (hrp, data) { + return polymod(hrpExpand(hrp).concat(data)) === 1; +} + +function createChecksum (hrp, data) { + var values = hrpExpand(hrp).concat(data).concat([0, 0, 0, 0, 0, 0]); + var mod = polymod(values) ^ 1; + var ret = []; + for (var p = 0; p < 6; ++p) { + ret.push((mod >> 5 * (5 - p)) & 31); + } + return ret; +} + +function encode (hrp, data) { + var combined = data.concat(createChecksum(hrp, data)); + var ret = hrp + '1'; + for (var p = 0; p < combined.length; ++p) { + ret += CHARSET.charAt(combined[p]); + } + return ret; +} + +function decode (bechString) { + var p; + var has_lower = false; + var has_upper = false; + for (p = 0; p < bechString.length; ++p) { + if (bechString.charCodeAt(p) < 33 || bechString.charCodeAt(p) > 126) { + return null; + } + if (bechString.charCodeAt(p) >= 97 && bechString.charCodeAt(p) <= 122) { + has_lower = true; + } + if (bechString.charCodeAt(p) >= 65 && bechString.charCodeAt(p) <= 90) { + has_upper = true; + } + } + if (has_lower && has_upper) { + return null; + } + bechString = bechString.toLowerCase(); + var pos = bechString.lastIndexOf('1'); + if (pos < 1 || pos + 7 > bechString.length || bechString.length > 90) { + return null; + } + var hrp = bechString.substring(0, pos); + var data = []; + for (p = pos + 1; p < bechString.length; ++p) { + var d = CHARSET.indexOf(bechString.charAt(p)); + if (d === -1) { + return null; + } + data.push(d); + } + if (!verifyChecksum(hrp, data)) { + return null; + } + return {hrp: hrp, data: data.slice(0, data.length - 6)}; +} + +},{}],11:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2554,7 +2757,85 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":3}],10:[function(require,module,exports){ +},{"buffer":3}],12:[function(require,module,exports){ +// Copyright (c) 2017 Pieter Wuille +// +// 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. + +var bech32 = require('./bech32'); + +module.exports = { + encode: encode, + decode: decode +}; + +function convertbits (data, frombits, tobits, pad) { + var acc = 0; + var bits = 0; + var ret = []; + var maxv = (1 << tobits) - 1; + for (var p = 0; p < data.length; ++p) { + var value = data[p]; + if (value < 0 || (value >> frombits) !== 0) { + return null; + } + acc = (acc << frombits) | value; + bits += frombits; + while (bits >= tobits) { + bits -= tobits; + ret.push((acc >> bits) & maxv); + } + } + if (pad) { + if (bits > 0) { + ret.push((acc << (tobits - bits)) & maxv); + } + } else if (bits >= frombits || ((acc << (tobits - bits)) & maxv)) { + return null; + } + return ret; +} + +function decode (hrp, addr) { + var dec = bech32.decode(addr); + if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) { + return null; + } + var res = convertbits(dec.data.slice(1), 5, 8, false); + if (res === null || res.length < 2 || res.length > 40) { + return null; + } + if (dec.data[0] === 0 && res.length !== 20 && res.length !== 32) { + return null; + } + return {version: dec.data[0], program: res}; +} + +function encode (hrp, version, program) { + var ret = bech32.encode(hrp, [version].concat(convertbits(program, 8, 5, true))); + if (decode(hrp, ret) === null) { + return null; + } + return ret; +} + +},{"./bech32":10}],13:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -3198,7 +3479,7 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":6}],11:[function(require,module,exports){ +},{"_process":6}],14:[function(require,module,exports){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; @@ -3238,15 +3519,17 @@ module.exports = { } }; -},{"./blake256":9,"./sha3":10,"jssha/src/sha256":5}],12:[function(require,module,exports){ +},{"./blake256":11,"./sha3":13,"jssha/src/sha256":5}],15:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); +var BTCValidator = require('./bitcoin_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ name: 'bitcoin', symbol: 'btc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + networkValidator: BTCValidator },{ name: 'bitcoincash', symbol: 'bch', @@ -3413,7 +3696,7 @@ module.exports = { } }; -},{"./ethereum_validator":13,"./ripple_validator":14}],13:[function(require,module,exports){ +},{"./bitcoin_validator":8,"./ethereum_validator":16,"./ripple_validator":17}],16:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -3449,7 +3732,7 @@ module.exports = { } }; -},{"./crypto/utils":11}],14:[function(require,module,exports){ +},{"./crypto/utils":14}],17:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -3479,7 +3762,7 @@ module.exports = { } }; -},{"./crypto/utils":11,"base-x":1}],15:[function(require,module,exports){ +},{"./crypto/utils":14,"base-x":1}],18:[function(require,module,exports){ var base58 = require('./crypto/base58'); var cryptoUtils = require('./crypto/utils'); var currencies = require('./currencies'); @@ -3542,13 +3825,17 @@ function validate(address, currencyNameOrSymbol, networkType) { return currency.validator.isValidAddress(address); } + if (currency.networkValidator) { + return currency.networkValidator.isValidNetworkAddress(address, networkType); + } + var correctAddressTypes; var addressType = getAddressType(address, currency); if (addressType == null) { return false; } - if (networkType === 'prod' || networkType === 'testnet'){ + if (networkType === 'prod' || networkType === 'testnet') { correctAddressTypes = currency.addressTypes[networkType] } else { correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); @@ -3563,5 +3850,5 @@ module.exports = { validate: validate, }; -},{"./crypto/base58":8,"./crypto/utils":11,"./currencies":12}]},{},[15])(15) -}); \ No newline at end of file +},{"./crypto/base58":9,"./crypto/utils":14,"./currencies":15}]},{},[18])(18) +}); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 0c70d667..d2cf6c87 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,a,u){function f(r,t){if(!a[r]){if(!s[r]){var e="function"==typeof require&&require;if(!t&&e)return e(r,!0);if(h)return h(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[r]={exports:{}};s[r][0].call(o.exports,function(t){var e=s[r][1][t];return f(e||t)},o,o.exports,i,s,a,u)}return a[r].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[a++]=n>>8&255,i[a++]=255&n;2===o?(n=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,i[a++]=255&n):1===o&&(n=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,i[a++]=n>>8&255,i[a++]=255&n);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o="",i=[],s=0,a=r-n;s>2],o+=u[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=u[e>>10],o+=u[e>>4&63],o+=u[e<<2&63],o+="=");return i.push(o),i.join("")};for(var u=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=c,r.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},c.prototype.compare=function(t,e,r,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,F(R(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return u=this,f=e,h=r,F(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,F(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function x(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,o){return e=+e,r>>>=0,o||x(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,o){return e=+e,r>>>=0,o||x(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function O(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(e+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(e*u-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,e){return M(t,e,s)},l=function(t,e,r,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,b)).binLen,r=e.value,e=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(e),t){case"HEX":r=function(t){return A(t,f,o)};break;case"B64":r=function(t){return E(t,f,o)};break;case"BYTES":r=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function E(t,e,r){var n,o,i,s="",a=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return s}function B(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function k(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function T(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,s,a,u,f,h,c=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=u;)e.push(0);e[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(h+f%4*-1),c+=2}return{value:e,binLen:8*c+r}};break;case"B64":e=function(t,e,r){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[s++]=e>>8&255,i[s++]=255&e;var f,h;2===o&&(e=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,i[s++]=255&e);1===o&&(e=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,i[s++]=e>>8&255,i[s++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,s=r-n;i>2]+a[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(a[e>>10]+a[e>>4&63]+a[e<<2&63]+"="));return o.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=c,r.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},c.prototype.compare=function(t,e,r,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,O(R(t,(c=this).length-l),c,l,p);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return u=this,f=e,h=r,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,O(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||x(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||x(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);x(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);x(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(e+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(e*u-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,e){return M(t,e,s)},l=function(t,e,r,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,b)).binLen,r=e.value,e=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===v)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(e),t){case"HEX":r=function(t){return A(t,f,o)};break;case"B64":r=function(t){return E(t,f,o)};break;case"BYTES":r=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function E(t,e,r){var n,o,i,s="",a=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return s}function B(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function k(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function T(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,s,a,u,f,h,c=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=u;)e.push(0);e[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(h+f%4*-1),c+=2}return{value:e,binLen:8*c+r}};break;case"B64":e=function(t,e,r){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o= 0; +} + +function isValidSegwitAddress(address) { + var hrp = "bc"; + var ret = segwit_addr.decode(hrp, address); + if (ret === null) { + hrp = "tb"; + ret = segwit_addr.decode(hrp, address); + } + var ok = ret !== null; + if (ok) { + var recreate = segwit_addr.encode(hrp, ret.version, ret.program); + ok = (recreate === address.toLowerCase()); + } + + return !!ok; +} + +module.exports = { + isValidNetworkAddress: isValidNetworkAddress +}; diff --git a/src/crypto/bech32.js b/src/crypto/bech32.js new file mode 100644 index 00000000..effe8002 --- /dev/null +++ b/src/crypto/bech32.js @@ -0,0 +1,116 @@ +// Copyright (c) 2017 Pieter Wuille +// +// 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. + +var CHARSET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'; +var GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]; + +module.exports = { + decode: decode, + encode: encode, +}; + + +function polymod (values) { + var chk = 1; + for (var p = 0; p < values.length; ++p) { + var top = chk >> 25; + chk = (chk & 0x1ffffff) << 5 ^ values[p]; + for (var i = 0; i < 5; ++i) { + if ((top >> i) & 1) { + chk ^= GENERATOR[i]; + } + } + } + return chk; +} + +function hrpExpand (hrp) { + var ret = []; + var p; + for (p = 0; p < hrp.length; ++p) { + ret.push(hrp.charCodeAt(p) >> 5); + } + ret.push(0); + for (p = 0; p < hrp.length; ++p) { + ret.push(hrp.charCodeAt(p) & 31); + } + return ret; +} + +function verifyChecksum (hrp, data) { + return polymod(hrpExpand(hrp).concat(data)) === 1; +} + +function createChecksum (hrp, data) { + var values = hrpExpand(hrp).concat(data).concat([0, 0, 0, 0, 0, 0]); + var mod = polymod(values) ^ 1; + var ret = []; + for (var p = 0; p < 6; ++p) { + ret.push((mod >> 5 * (5 - p)) & 31); + } + return ret; +} + +function encode (hrp, data) { + var combined = data.concat(createChecksum(hrp, data)); + var ret = hrp + '1'; + for (var p = 0; p < combined.length; ++p) { + ret += CHARSET.charAt(combined[p]); + } + return ret; +} + +function decode (bechString) { + var p; + var has_lower = false; + var has_upper = false; + for (p = 0; p < bechString.length; ++p) { + if (bechString.charCodeAt(p) < 33 || bechString.charCodeAt(p) > 126) { + return null; + } + if (bechString.charCodeAt(p) >= 97 && bechString.charCodeAt(p) <= 122) { + has_lower = true; + } + if (bechString.charCodeAt(p) >= 65 && bechString.charCodeAt(p) <= 90) { + has_upper = true; + } + } + if (has_lower && has_upper) { + return null; + } + bechString = bechString.toLowerCase(); + var pos = bechString.lastIndexOf('1'); + if (pos < 1 || pos + 7 > bechString.length || bechString.length > 90) { + return null; + } + var hrp = bechString.substring(0, pos); + var data = []; + for (p = pos + 1; p < bechString.length; ++p) { + var d = CHARSET.indexOf(bechString.charAt(p)); + if (d === -1) { + return null; + } + data.push(d); + } + if (!verifyChecksum(hrp, data)) { + return null; + } + return {hrp: hrp, data: data.slice(0, data.length - 6)}; +} diff --git a/src/crypto/segwit_addr.js b/src/crypto/segwit_addr.js new file mode 100644 index 00000000..9e7c9822 --- /dev/null +++ b/src/crypto/segwit_addr.js @@ -0,0 +1,76 @@ +// Copyright (c) 2017 Pieter Wuille +// +// 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. + +var bech32 = require('./bech32'); + +module.exports = { + encode: encode, + decode: decode +}; + +function convertbits (data, frombits, tobits, pad) { + var acc = 0; + var bits = 0; + var ret = []; + var maxv = (1 << tobits) - 1; + for (var p = 0; p < data.length; ++p) { + var value = data[p]; + if (value < 0 || (value >> frombits) !== 0) { + return null; + } + acc = (acc << frombits) | value; + bits += frombits; + while (bits >= tobits) { + bits -= tobits; + ret.push((acc >> bits) & maxv); + } + } + if (pad) { + if (bits > 0) { + ret.push((acc << (tobits - bits)) & maxv); + } + } else if (bits >= frombits || ((acc << (tobits - bits)) & maxv)) { + return null; + } + return ret; +} + +function decode (hrp, addr) { + var dec = bech32.decode(addr); + if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) { + return null; + } + var res = convertbits(dec.data.slice(1), 5, 8, false); + if (res === null || res.length < 2 || res.length > 40) { + return null; + } + if (dec.data[0] === 0 && res.length !== 20 && res.length !== 32) { + return null; + } + return {version: dec.data[0], program: res}; +} + +function encode (hrp, version, program) { + var ret = bech32.encode(hrp, [version].concat(convertbits(program, 8, 5, true))); + if (decode(hrp, ret) === null) { + return null; + } + return ret; +} diff --git a/src/currencies.js b/src/currencies.js index bed7bc64..a37a3d86 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -1,11 +1,13 @@ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); +var BTCValidator = require('./bitcoin_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ name: 'bitcoin', symbol: 'btc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + networkValidator: BTCValidator },{ name: 'bitcoincash', symbol: 'bch', diff --git a/src/wallet_address_validator.js b/src/wallet_address_validator.js index b77e7646..94acab4d 100644 --- a/src/wallet_address_validator.js +++ b/src/wallet_address_validator.js @@ -60,13 +60,17 @@ function validate(address, currencyNameOrSymbol, networkType) { return currency.validator.isValidAddress(address); } + if (currency.networkValidator) { + return currency.networkValidator.isValidNetworkAddress(address, networkType); + } + var correctAddressTypes; var addressType = getAddressType(address, currency); if (addressType == null) { return false; } - if (networkType === 'prod' || networkType === 'testnet'){ + if (networkType === 'prod' || networkType === 'testnet') { correctAddressTypes = currency.addressTypes[networkType] } else { correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 0cf857e9..9c705011 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -36,6 +36,25 @@ describe('WAValidator.validate()', function () { valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt'); valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoin'); valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoin', 'testnet'); + + // segwit addresses + valid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'bitcoin'); + valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 'bitcoin'); + valid('bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx', 'bitcoin'); + valid('BC1SW50QA3JX3S', 'bitcoin'); + valid('bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj', 'bitcoin'); + valid('tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy', 'bitcoin'); + + invalid("tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", 'bitcoin'), + invalid("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", 'bitcoin'), + invalid("BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", 'bitcoin'), + invalid("bc1rw5uspcuh", 'bitcoin'), + invalid("bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90", 'bitcoin'), + invalid("BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P", 'bitcoin'), + invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7", 'bitcoin'), + invalid("bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", 'bitcoin'), + invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv", 'bitcoin'), + invalid("bc1gmk9yu", 'bitcoin') }); it('should return true for correct bitcoincash addresses', function () { From 6019d4b3c5837da2f77fd164fc1897c6bc55807c Mon Sep 17 00:00:00 2001 From: Tomek Kolasa Date: Tue, 11 Sep 2018 21:03:02 +0900 Subject: [PATCH 043/108] refactored segwit support --- README.md | 7 - dist/wallet-address-validator.js | 433 +++++++++++++-------------- dist/wallet-address-validator.min.js | 2 +- package.json | 3 +- src/bitcoin_validator.js | 113 +++---- src/crypto/segwit_addr.js | 28 +- src/currencies.js | 90 ++++-- src/wallet_address_validator.js | 85 +----- test/wallet_address_validator.js | 41 +-- 9 files changed, 374 insertions(+), 428 deletions(-) diff --git a/README.md b/README.md index 56ecc07d..ece3f76f 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,6 @@ npm install wallet-address-validator > Returns true if the address (string) is a valid wallet address for the crypto currency specified, see below for supported currencies. -##### getAddressType (address) - -###### Parameters -* address - Wallet address. - -> Returns address type (as 2 character hex string) if valid base58 address, otherwise null. - ### Supported crypto currencies * Auroracoin/AUR, `'auroracoin'` or `'AUR'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 96735188..d3526e26 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,4 +1,4 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0) { throw new Error('Invalid string. Length must be a multiple of 4') } - // Trim off extra bytes after placeholder bytes are found - // See: https://github.com/beatgammit/base64-js/issues/42 - var validLen = b64.indexOf('=') - if (validLen === -1) validLen = len - - var placeHoldersLen = validLen === len - ? 0 - : 4 - (validLen % 4) - - return [validLen, placeHoldersLen] + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 } -// base64 is 4/3 + up to two characters of the original data function byteLength (b64) { - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function _byteLength (b64, validLen, placeHoldersLen) { - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen + // base64 is 4/3 + up to two characters of the original data + return (b64.length * 3 / 4) - placeHoldersCount(b64) } function toByteArray (b64) { - var tmp - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - - var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + var i, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) - var curByte = 0 + arr = new Arr((len * 3 / 4) - placeHolders) // if there are placeholders, only get up to the last complete 4 chars - var len = placeHoldersLen > 0 - ? validLen - 4 - : validLen + l = placeHolders > 0 ? len - 4 : len - for (var i = 0; i < len; i += 4) { - tmp = - (revLookup[b64.charCodeAt(i)] << 18) | - (revLookup[b64.charCodeAt(i + 1)] << 12) | - (revLookup[b64.charCodeAt(i + 2)] << 6) | - revLookup[b64.charCodeAt(i + 3)] - arr[curByte++] = (tmp >> 16) & 0xFF - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } + var L = 0 - if (placeHoldersLen === 2) { - tmp = - (revLookup[b64.charCodeAt(i)] << 2) | - (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[curByte++] = tmp & 0xFF + for (i = 0; i < l; i += 4) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF } - if (placeHoldersLen === 1) { - tmp = - (revLookup[b64.charCodeAt(i)] << 10) | - (revLookup[b64.charCodeAt(i + 1)] << 4) | - (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF } return arr } function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + - lookup[num >> 12 & 0x3F] + - lookup[num >> 6 & 0x3F] + - lookup[num & 0x3F] + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] } function encodeChunk (uint8, start, end) { var tmp var output = [] for (var i = start; i < end; i += 3) { - tmp = - ((uint8[i] << 16) & 0xFF0000) + - ((uint8[i + 1] << 8) & 0xFF00) + - (uint8[i + 2] & 0xFF) + tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) output.push(tripletToBase64(tmp)) } return output.join('') @@ -214,34 +182,31 @@ function fromByteArray (uint8) { var tmp var len = uint8.length var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' var parts = [] var maxChunkLength = 16383 // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk( - uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) - )) + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1] - parts.push( - lookup[tmp >> 2] + - lookup[(tmp << 4) & 0x3F] + - '==' - ) + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + uint8[len - 1] - parts.push( - lookup[tmp >> 10] + - lookup[(tmp >> 4) & 0x3F] + - lookup[(tmp << 2) & 0x3F] + - '=' - ) + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' } + parts.push(output) + return parts.join('') } @@ -1986,7 +1951,7 @@ function numberIsNaN (obj) { },{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m - var eLen = (nBytes * 8) - mLen - 1 + var eLen = nBytes * 8 - mLen - 1 var eMax = (1 << eLen) - 1 var eBias = eMax >> 1 var nBits = -7 @@ -1999,12 +1964,12 @@ exports.read = function (buffer, offset, isLE, mLen, nBytes) { e = s & ((1 << (-nBits)) - 1) s >>= (-nBits) nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} m = e & ((1 << (-nBits)) - 1) e >>= (-nBits) nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} if (e === 0) { e = 1 - eBias @@ -2019,7 +1984,7 @@ exports.read = function (buffer, offset, isLE, mLen, nBytes) { exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { var e, m, c - var eLen = (nBytes * 8) - mLen - 1 + var eLen = nBytes * 8 - mLen - 1 var eMax = (1 << eLen) - 1 var eBias = eMax >> 1 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) @@ -2052,7 +2017,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { m = 0 e = eMax } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) + m = (value * c - 1) * Math.pow(2, mLen) e = e + eBias } else { m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) @@ -2351,56 +2316,83 @@ SafeBuffer.allocUnsafeSlow = function (size) { } },{"buffer":3}],8:[function(require,module,exports){ -var segwit_addr = require('./crypto/segwit_addr'); -var CURRENCY_NAME = 'bitcoin'; - -function isValidNetworkAddress(address, networkType) { - return isValidP2PKHandP2SHAddress(address, networkType) || isValidSegwitAddress(address) -} +var base58 = require('./crypto/base58'); +var segwit = require('./crypto/segwit_addr'); +var cryptoUtils = require('./crypto/utils'); -function isValidP2PKHandP2SHAddress(address, networkType) { - // These libs need to reqired in here. - var WAValidator = require('./wallet_address_validator.js'); - var currencies = require('./currencies.js'); +var DEFAULT_NETWORK_TYPE = 'prod'; - var currency = currencies.getByNameOrSymbol(CURRENCY_NAME); - - var correctAddressTypes; - var addressType = WAValidator.getAddressType(address, currency); - if (addressType == null) { - return false; +function getDecoded(address) { + try { + return base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; } +} - if (networkType === 'prod' || networkType === 'testnet'){ - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); +function getChecksum(hashFunction, payload) { + // Each currency may implement different hashing algorithm + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); } - - return correctAddressTypes.indexOf(addressType) >= 0; } -function isValidSegwitAddress(address) { - var hrp = "bc"; - var ret = segwit_addr.decode(hrp, address); - if (ret === null) { - hrp = "tb"; - ret = segwit_addr.decode(hrp, address); +function getAddressType(address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded = getDecoded(address); + + if (decoded) { + var length = decoded.length; + + if (length !== expectedLength) { + return null; + } + + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = getChecksum(hashFunction, body); + + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; } - var ok = ret !== null; - if (ok) { - var recreate = segwit_addr.encode(hrp, ret.version, ret.program); - ok = (recreate === address.toLowerCase()); + + return null; +} + +function isValidP2PKHandP2SHAddress(address, currency, networkType) { + networkType = networkType || DEFAULT_NETWORK_TYPE; + + var correctAddressTypes; + var addressType = getAddressType(address, currency); + + if (addressType) { + if (networkType === 'prod' || networkType === 'testnet') { + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + } + + return correctAddressTypes.indexOf(addressType) >= 0; } - return !!ok; + return false; } module.exports = { - isValidNetworkAddress: isValidNetworkAddress + isValidAddress: function (address, currency, networkType) { + return isValidP2PKHandP2SHAddress(address, currency, networkType) || segwit.isValidAddress(address); + } }; -},{"./crypto/segwit_addr":12,"./currencies.js":15,"./wallet_address_validator.js":18}],9:[function(require,module,exports){ +},{"./crypto/base58":9,"./crypto/segwit_addr":12,"./crypto/utils":14}],9:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -2780,11 +2772,6 @@ module.exports = Blake256; var bech32 = require('./bech32'); -module.exports = { - encode: encode, - decode: decode -}; - function convertbits (data, frombits, tobits, pad) { var acc = 0; var bits = 0; @@ -2835,6 +2822,29 @@ function encode (hrp, version, program) { return ret; } +function isValidAddress(address) { + var hrp = 'bc'; + var ret = decode(hrp, address); + + if (ret === null) { + hrp = 'tb'; + ret = decode(hrp, address); + } + + if (ret === null) { + return false; + } + + var recreate = encode(hrp, ret.version, ret.program); + return recreate === address.toLowerCase(); +} + +module.exports = { + encode: encode, + decode: decode, + isValidAddress: isValidAddress, +}; + },{"./bech32":10}],13:[function(require,module,exports){ (function (process,global){ /** @@ -3529,121 +3539,147 @@ var CURRENCIES = [{ name: 'bitcoin', symbol: 'btc', addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, - networkValidator: BTCValidator + validator: BTCValidator },{ name: 'bitcoincash', symbol: 'bch', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'litecoin', symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']} + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']}, + validator: BTCValidator },{ name: 'peercoin', symbol: 'ppc', - addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'dogecoin', symbol: 'doge', - addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} + addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']}, + validator: BTCValidator },{ name: 'beavercoin', symbol: 'bvc', - addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator, },{ name: 'freicoin', symbol: 'frc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'protoshares', symbol: 'pts', - addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'megacoin', symbol: 'mec', - addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'primecoin', symbol: 'xpm', - addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'auroracoin', symbol: 'aur', - addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'namecoin', symbol: 'nmc', - addressTypes: {prod: ['34'], testnet: []} + addressTypes: {prod: ['34'], testnet: []}, + validator: BTCValidator },{ name: 'biocoin', symbol: 'bio', - addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'garlicoin', symbol: 'grlc', - addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'vertcoin', symbol: 'vtc', - addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'bitcoingold', symbol: 'btg', - addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'komodo', symbol: 'kmd', - addressTypes: {prod: ['3c', '55'], testnet: ['0','5']} + addressTypes: {prod: ['3c', '55'], testnet: ['0','5']}, + validator: BTCValidator },{ name: 'bitcoinz', symbol: 'btcz', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'bitcoinprivate', symbol: 'btcp', expectedLength: 26, - addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']} + addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']}, + validator: BTCValidator },{ name: 'hush', symbol: 'hush', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'snowgem', symbol: 'sng', expectedLength: 26, - addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'zcash', symbol: 'zec', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'zclassic', symbol: 'zcl', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'zencash', symbol: 'zen', expectedLength: 26, - addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']} + addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']}, + validator: BTCValidator },{ name: 'votecoin', symbol: 'vot', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'decred', symbol: 'dcr', addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, hashFunction: 'blake256', - expectedLength: 26 + expectedLength: 26, + validator: BTCValidator },{ name: 'digibyte', symbol: 'dgb', addressTypes: {prod: ['1e'], testnet: []}, + validator: BTCValidator },{ name: 'ethereum', symbol: 'eth', @@ -3667,19 +3703,23 @@ var CURRENCIES = [{ },{ name: 'dash', symbol: 'dash', - addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']} + addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']}, + validator: BTCValidator },{ name: 'neo', symbol: 'neo', - addressTypes: {prod: ['17'], testnet: []} + addressTypes: {prod: ['17'], testnet: []}, + validator: BTCValidator },{ name: 'neogas', symbol: 'gas', - addressTypes: {prod: ['17'], testnet: []} + addressTypes: {prod: ['17'], testnet: []}, + validator: BTCValidator },{ name: 'qtum', symbol: 'qtum', - addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, + validator: BTCValidator }]; @@ -3763,92 +3803,21 @@ module.exports = { }; },{"./crypto/utils":14,"base-x":1}],18:[function(require,module,exports){ -var base58 = require('./crypto/base58'); -var cryptoUtils = require('./crypto/utils'); var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; -var DEFAULT_NETWORK_TYPE = 'prod'; - -function getDecoded(address) { - try { - return base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } -} - -function getChecksum(hashFunction, payload) { - // Each currency may implement different hashing algorithm - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); - } -} - -function getAddressType(address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded = getDecoded(address); - if (decoded) { - var length = decoded.length; +module.exports = { + validate: function (address, currencyNameOrSymbol, networkType) { + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); - if (length !== expectedLength) { - return null; + if (currency.validator) { + return currency.validator.isValidAddress(address, currency, networkType); } - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = getChecksum(hashFunction, body); - - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; - } - - return null; -} - -function validate(address, currencyNameOrSymbol, networkType) { - currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; - networkType = networkType || DEFAULT_NETWORK_TYPE; - - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); - - if (currency.validator) { - return currency.validator.isValidAddress(address); - } - - if (currency.networkValidator) { - return currency.networkValidator.isValidNetworkAddress(address, networkType); - } - - var correctAddressTypes; - var addressType = getAddressType(address, currency); - if (addressType == null) { - return false; - } - - if (networkType === 'prod' || networkType === 'testnet') { - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); - } - - return correctAddressTypes.indexOf(addressType) >= 0; -} - -module.exports = { - getAddressType: getAddressType, - checksum: getChecksum, - validate: validate, + throw new Error('Missing validator for currency: ' + currencyNameOrSymbol); + }, }; -},{"./crypto/base58":9,"./crypto/utils":14,"./currencies":15}]},{},[18])(18) -}); +},{"./currencies":15}]},{},[18])(18) +}); \ No newline at end of file diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index d2cf6c87..361b2c38 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,a,u){function f(e,t){if(!a[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(h)return h(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[e]={exports:{}};s[e][0].call(o.exports,function(t){return f(s[e][1][t]||t)},o,o.exports,i,s,a,u)}return a[e].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[s++]=e>>8&255,i[s++]=255&e;var f,h;2===o&&(e=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,i[s++]=255&e);1===o&&(e=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,i[s++]=e>>8&255,i[s++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,s=r-n;i>2]+a[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(a[e>>10]+a[e>>4&63]+a[e<<2&63]+"="));return o.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=c,r.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},c.prototype.compare=function(t,e,r,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,O(R(t,(c=this).length-l),c,l,p);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return u=this,f=e,h=r,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,O(function(t,e){for(var r,n,o,i=[],s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||x(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||x(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);x(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);x(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(e+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(e*u-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,e){return M(t,e,s)},l=function(t,e,r,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,b)).binLen,r=e.value,e=t>>>5,n=0;n>>5),b=t%h,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===v)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(e),t){case"HEX":r=function(t){return A(t,f,o)};break;case"B64":r=function(t){return E(t,f,o)};break;case"BYTES":r=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),b,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function E(t,e,r){var n,o,i,s="",a=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return s}function B(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function k(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function T(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,s,a,u,f,h,c=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=u;)e.push(0);e[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(h+f%4*-1),c+=2}return{value:e,binLen:8*c+r}};break;case"B64":e=function(t,e,r){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[a++]=n>>8&255,i[a++]=255&n;2===o?(n=f[t.charCodeAt(r)]<<2|f[t.charCodeAt(r+1)]>>4,i[a++]=255&n):1===o&&(n=f[t.charCodeAt(r)]<<10|f[t.charCodeAt(r+1)]<<4|f[t.charCodeAt(r+2)]>>2,i[a++]=n>>8&255,i[a++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,a=e-n;s>2],o+=u[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=u[r>>10],o+=u[r>>4&63],o+=u[r<<2&63],o+="=");return i.push(o),i.join("")};for(var u=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return w(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,O(R(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return u=this,f=r,h=e,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,O(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function U(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function S(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=0,s=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,o),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,g,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,f,o)};break;case"B64":e=function(t){return E(t,f,o)};break;case"BYTES":e=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",a=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o= 0; + + return null; } -function isValidSegwitAddress(address) { - var hrp = "bc"; - var ret = segwit_addr.decode(hrp, address); - if (ret === null) { - hrp = "tb"; - ret = segwit_addr.decode(hrp, address); - } - var ok = ret !== null; - if (ok) { - var recreate = segwit_addr.encode(hrp, ret.version, ret.program); - ok = (recreate === address.toLowerCase()); +function isValidP2PKHandP2SHAddress(address, currency, networkType) { + networkType = networkType || DEFAULT_NETWORK_TYPE; + + var correctAddressTypes; + var addressType = getAddressType(address, currency); + + if (addressType) { + if (networkType === 'prod' || networkType === 'testnet') { + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + } + + return correctAddressTypes.indexOf(addressType) >= 0; } - return !!ok; + return false; } module.exports = { - isValidNetworkAddress: isValidNetworkAddress + isValidAddress: function (address, currency, networkType) { + return isValidP2PKHandP2SHAddress(address, currency, networkType) || segwit.isValidAddress(address); + } }; diff --git a/src/crypto/segwit_addr.js b/src/crypto/segwit_addr.js index 9e7c9822..a82fcc8e 100644 --- a/src/crypto/segwit_addr.js +++ b/src/crypto/segwit_addr.js @@ -20,11 +20,6 @@ var bech32 = require('./bech32'); -module.exports = { - encode: encode, - decode: decode -}; - function convertbits (data, frombits, tobits, pad) { var acc = 0; var bits = 0; @@ -74,3 +69,26 @@ function encode (hrp, version, program) { } return ret; } + +function isValidAddress(address) { + var hrp = 'bc'; + var ret = decode(hrp, address); + + if (ret === null) { + hrp = 'tb'; + ret = decode(hrp, address); + } + + if (ret === null) { + return false; + } + + var recreate = encode(hrp, ret.version, ret.program); + return recreate === address.toLowerCase(); +} + +module.exports = { + encode: encode, + decode: decode, + isValidAddress: isValidAddress, +}; diff --git a/src/currencies.js b/src/currencies.js index a37a3d86..47e644e8 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -7,121 +7,147 @@ var CURRENCIES = [{ name: 'bitcoin', symbol: 'btc', addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, - networkValidator: BTCValidator + validator: BTCValidator },{ name: 'bitcoincash', symbol: 'bch', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'litecoin', symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']} + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']}, + validator: BTCValidator },{ name: 'peercoin', symbol: 'ppc', - addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'dogecoin', symbol: 'doge', - addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']} + addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']}, + validator: BTCValidator },{ name: 'beavercoin', symbol: 'bvc', - addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator, },{ name: 'freicoin', symbol: 'frc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'protoshares', symbol: 'pts', - addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'megacoin', symbol: 'mec', - addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'primecoin', symbol: 'xpm', - addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'auroracoin', symbol: 'aur', - addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'namecoin', symbol: 'nmc', - addressTypes: {prod: ['34'], testnet: []} + addressTypes: {prod: ['34'], testnet: []}, + validator: BTCValidator },{ name: 'biocoin', symbol: 'bio', - addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'garlicoin', symbol: 'grlc', - addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'vertcoin', symbol: 'vtc', - addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'bitcoingold', symbol: 'btg', - addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'komodo', symbol: 'kmd', - addressTypes: {prod: ['3c', '55'], testnet: ['0','5']} + addressTypes: {prod: ['3c', '55'], testnet: ['0','5']}, + validator: BTCValidator },{ name: 'bitcoinz', symbol: 'btcz', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'bitcoinprivate', symbol: 'btcp', expectedLength: 26, - addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']} + addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']}, + validator: BTCValidator },{ name: 'hush', symbol: 'hush', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'snowgem', symbol: 'sng', expectedLength: 26, - addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'zcash', symbol: 'zec', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'zclassic', symbol: 'zcl', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'zencash', symbol: 'zen', expectedLength: 26, - addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']} + addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']}, + validator: BTCValidator },{ name: 'votecoin', symbol: 'vot', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']} + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator },{ name: 'decred', symbol: 'dcr', addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, hashFunction: 'blake256', - expectedLength: 26 + expectedLength: 26, + validator: BTCValidator },{ name: 'digibyte', symbol: 'dgb', addressTypes: {prod: ['1e'], testnet: []}, + validator: BTCValidator },{ name: 'ethereum', symbol: 'eth', @@ -145,19 +171,23 @@ var CURRENCIES = [{ },{ name: 'dash', symbol: 'dash', - addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']} + addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']}, + validator: BTCValidator },{ name: 'neo', symbol: 'neo', - addressTypes: {prod: ['17'], testnet: []} + addressTypes: {prod: ['17'], testnet: []}, + validator: BTCValidator },{ name: 'neogas', symbol: 'gas', - addressTypes: {prod: ['17'], testnet: []} + addressTypes: {prod: ['17'], testnet: []}, + validator: BTCValidator },{ name: 'qtum', symbol: 'qtum', - addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']} + addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, + validator: BTCValidator }]; diff --git a/src/wallet_address_validator.js b/src/wallet_address_validator.js index 94acab4d..7ffecf8d 100644 --- a/src/wallet_address_validator.js +++ b/src/wallet_address_validator.js @@ -1,86 +1,15 @@ -var base58 = require('./crypto/base58'); -var cryptoUtils = require('./crypto/utils'); var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; -var DEFAULT_NETWORK_TYPE = 'prod'; -function getDecoded(address) { - try { - return base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } -} - -function getChecksum(hashFunction, payload) { - // Each currency may implement different hashing algorithm - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); - } -} - -function getAddressType(address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded = getDecoded(address); - - if (decoded) { - var length = decoded.length; +module.exports = { + validate: function (address, currencyNameOrSymbol, networkType) { + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); - if (length !== expectedLength) { - return null; + if (currency.validator) { + return currency.validator.isValidAddress(address, currency, networkType); } - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = getChecksum(hashFunction, body); - - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; - } - - return null; -} - -function validate(address, currencyNameOrSymbol, networkType) { - currencyNameOrSymbol = currencyNameOrSymbol || DEFAULT_CURRENCY_NAME; - networkType = networkType || DEFAULT_NETWORK_TYPE; - - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol); - - if (currency.validator) { - return currency.validator.isValidAddress(address); - } - - if (currency.networkValidator) { - return currency.networkValidator.isValidNetworkAddress(address, networkType); - } - - var correctAddressTypes; - var addressType = getAddressType(address, currency); - if (addressType == null) { - return false; - } - - if (networkType === 'prod' || networkType === 'testnet') { - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); - } - - return correctAddressTypes.indexOf(addressType) >= 0; -} - -module.exports = { - getAddressType: getAddressType, - checksum: getChecksum, - validate: validate, + throw new Error('Missing validator for currency: ' + currencyNameOrSymbol); + }, }; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 9c705011..67c5d930 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -85,6 +85,7 @@ describe('WAValidator.validate()', function () { valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'litecoin'); valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'litecoin', 'testnet'); valid('QW2SvwjaJU8LD6GSmtm1PHnBG2xPuxwZFy', 'litecoin', 'testnet'); + valid('QjpzxpbLp5pCGsCczMbfh1uhC3P89QZavY', 'litecoin', 'testnet'); }); it('should return true for correct peercoin addresses', function () { @@ -123,7 +124,7 @@ describe('WAValidator.validate()', function () { valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'beavercoin', 'testnet'); }); - it('should return true for correct litecoin freicoin', function () { + it('should return true for correct freicoin addresses', function () { valid('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', 'freicoin'); valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'freicoin'); valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'freicoin'); @@ -292,55 +293,55 @@ describe('WAValidator.validate()', function () { valid('QVZnSrMwKp6AL4FjUPPnfFgsma6j1DXQXu', 'QTUM'); valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'qtum', 'testnet'); }); - + it('should return true for correct votecoin addresses', function () { valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); }); - + it('should return true for correct bitcoinz addresses', function () { valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); }); - + it('should return true for correct zclassic addresses', function () { valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); }); - + it('should return true for correct hush addresses', function () { valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); }); - + it('should return true for correct zcash addresses', function () { valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); }); - + it('should return true for correct bitcoinprivate addresses', function () { valid('b1M4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); //valid('bx....', 'BTCP'); //valid('nx....', 'bitcoinprivate', 'testnet'); }); - + it('should return true for correct snowgem addresses', function () { valid('s1fx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); valid('s3d27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); }); - + it('should return true for correct zencash addresses', function () { valid('znhiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); valid('zssEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); valid('ztmWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); }); - + it('should return true for correct komodo addresses', function () { valid('R9R5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); valid('RAvj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); @@ -467,68 +468,68 @@ describe('WAValidator.validate()', function () { invalid('QNPhBbVhDghASxcUh2vHotQUgNeLRFTcfb', 'qtum'); invalid('QOPhBbVhDghASxcUh2vHotQUgNeLRFTcfa', 'QTUM'); }); - + it('should return false for incorrect votecoin addresses', function () { commonTests('votecoin'); invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); }); - + it('should return false for incorrect bitcoinz addresses', function () { commonTests('bitcoinz'); invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); }); - + it('should return false for incorrect zclassic addresses', function () { commonTests('zclassic'); invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); }); - + it('should return false for incorrect hush addresses', function () { invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); }); - + it('should return false for incorrect zcash addresses', function () { commonTests('zcash'); invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); }); - + it('should return false for incorrect bitcoinprivate addresses', function () { commonTests('bitcoinprivate'); invalid('b1Y4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); //invalid('bx....', 'BTCP'); //invalid('nx....', 'bitcoinprivate', 'testnet'); }); - + it('should return false for incorrect snowgem addresses', function () { commonTests('snowgem'); invalid('s1Yx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); invalid('s3Y27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); }); - + it('should return false for incorrect zencash addresses', function () { commonTests('zencash'); invalid('znYiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); invalid('zsYEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); invalid('ztYWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); }); - + it('should return false for incorrect komodo addresses', function () { commonTests('komodo'); invalid('R9Y5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); invalid('RAYj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); }); - + }); }); From fb37bc5447e2378273ca8aac51f0487da2ffbb46 Mon Sep 17 00:00:00 2001 From: "UNIVERSE\\pvoronov" Date: Mon, 17 Sep 2018 17:29:33 +0300 Subject: [PATCH 044/108] added new currency bkx-bankex, tests attached --- README.md | 1 + dist/wallet-address-validator.js | 135 +++++++++++++++++---------- dist/wallet-address-validator.min.js | 2 +- package.json | 1 + src/currencies.js | 4 + test/wallet_address_validator.js | 14 +++ 6 files changed, 108 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index ece3f76f..ef22e425 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ npm install wallet-address-validator * Auroracoin/AUR, `'auroracoin'` or `'AUR'` +* Bankex/BKX, `'bankex'` or `'BKX'` * BeaverCoin/BVC, `'beavercoin'` or `'BVC'` * Biocoin/BIO, `'biocoin'` or `'BIO'` * Bitcoin/BTC, `'bitcoin'` or `'BTC'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index d3526e26..9eba6b47 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,4 +1,4 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { throw new Error('Invalid string. Length must be a multiple of 4') } - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] } +// base64 is 4/3 + up to two characters of the original data function byteLength (b64) { - // base64 is 4/3 + up to two characters of the original data - return (b64.length * 3 / 4) - placeHoldersCount(b64) + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function toByteArray (b64) { - var i, l, tmp, placeHolders, arr - var len = b64.length - placeHolders = placeHoldersCount(b64) + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] - arr = new Arr((len * 3 / 4) - placeHolders) + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? len - 4 : len + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen - var L = 0 + for (var i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } - for (i = 0; i < l; i += 4) { - tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] - arr[L++] = (tmp >> 16) & 0xFF - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF } - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF } return arr } function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] } function encodeChunk (uint8, start, end) { var tmp var output = [] for (var i = start; i < end; i += 3) { - tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) output.push(tripletToBase64(tmp)) } return output.join('') @@ -182,31 +214,34 @@ function fromByteArray (uint8) { var tmp var len = uint8.length var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' var parts = [] var maxChunkLength = 16383 // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) } - parts.push(output) - return parts.join('') } @@ -1951,7 +1986,7 @@ function numberIsNaN (obj) { },{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m - var eLen = nBytes * 8 - mLen - 1 + var eLen = (nBytes * 8) - mLen - 1 var eMax = (1 << eLen) - 1 var eBias = eMax >> 1 var nBits = -7 @@ -1964,12 +1999,12 @@ exports.read = function (buffer, offset, isLE, mLen, nBytes) { e = s & ((1 << (-nBits)) - 1) s >>= (-nBits) nBits += eLen - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} m = e & ((1 << (-nBits)) - 1) e >>= (-nBits) nBits += mLen - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} if (e === 0) { e = 1 - eBias @@ -1984,7 +2019,7 @@ exports.read = function (buffer, offset, isLE, mLen, nBytes) { exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { var e, m, c - var eLen = nBytes * 8 - mLen - 1 + var eLen = (nBytes * 8) - mLen - 1 var eMax = (1 << eLen) - 1 var eBias = eMax >> 1 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) @@ -2017,7 +2052,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { m = 0 e = eMax } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen) + m = ((value * c) - 1) * Math.pow(2, mLen) e = e + eBias } else { m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) @@ -3720,6 +3755,10 @@ var CURRENCIES = [{ symbol: 'qtum', addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, validator: BTCValidator +},{ + name: 'bankex', + symbol: 'bkx', + validator: ETHValidator }]; @@ -3820,4 +3859,4 @@ module.exports = { }; },{"./currencies":15}]},{},[18])(18) -}); \ No newline at end of file +}); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 361b2c38..ec0dbbbc 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,a,u){function f(e,t){if(!a[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(h)return h(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[e]={exports:{}};s[e][0].call(o.exports,function(t){var r=s[e][1][t];return f(r||t)},o,o.exports,i,s,a,u)}return a[e].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[a++]=n>>8&255,i[a++]=255&n;2===o?(n=f[t.charCodeAt(r)]<<2|f[t.charCodeAt(r+1)]>>4,i[a++]=255&n):1===o&&(n=f[t.charCodeAt(r)]<<10|f[t.charCodeAt(r+1)]<<4|f[t.charCodeAt(r+2)]>>2,i[a++]=n>>8&255,i[a++]=255&n);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o="",i=[],s=0,a=e-n;s>2],o+=u[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=u[r>>10],o+=u[r>>4&63],o+=u[r<<2&63],o+="=");return i.push(o),i.join("")};for(var u=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return w(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,O(R(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return u=this,f=r,h=e,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,O(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function U(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function S(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=0,s=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,o),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,g,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,f,o)};break;case"B64":e=function(t){return E(t,f,o)};break;case"BYTES":e=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",a=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[s++]=r>>8&255,i[s++]=255&r;var f,h;2===o&&(r=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,i[s++]=255&r);1===o&&(r=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,i[s++]=r>>8&255,i[s++]=255&r);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o=[],i=0,s=e-n;i>2]+a[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],o.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"="));return o.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return w(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,O(R(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return u=this,f=r,h=e,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,O(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function U(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function S(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=0,s=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,o),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,g,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,f,o)};break;case"B64":e=function(t){return E(t,f,o)};break;case"BYTES":e=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",a=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Fri, 28 Sep 2018 19:59:11 +0900 Subject: [PATCH 045/108] chore(release): 0.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a62eb68b..f49d89f0 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "browser", "nodejs" ], - "version": "0.2.0", + "version": "0.2.1", "author": "Tomek Kolasa ", "homepage": "https://github.com/ognus/wallet-address-validator", "license": "MIT", From 43efec548e91dd74eb9d9844183c28423294d089 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Fri, 28 Sep 2018 14:17:21 +0200 Subject: [PATCH 046/108] Add Blake2B support to crypto utils (taken from https://github.com/emilbayes/blake2b) --- src/crypto/blake2b.js | 276 ++++++++++++++++++++++++++++++++++++++++++ src/crypto/utils.js | 13 ++ 2 files changed, 289 insertions(+) create mode 100644 src/crypto/blake2b.js diff --git a/src/crypto/blake2b.js b/src/crypto/blake2b.js new file mode 100644 index 00000000..2b29a24f --- /dev/null +++ b/src/crypto/blake2b.js @@ -0,0 +1,276 @@ +'use strict'; + +/** + * Credits to https://github.com/emilbayes/blake2b + * + * Copyright (c) 2017, Emil Bay github@tixz.dk + * + * Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// 64-bit unsigned addition +// Sets v[a,a+1] += v[b,b+1] +// v should be a Uint32Array +function ADD64AA (v, a, b) { + var o0 = v[a] + v[b] + var o1 = v[a + 1] + v[b + 1] + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// 64-bit unsigned addition +// Sets v[a,a+1] += b +// b0 is the low 32 bits of b, b1 represents the high 32 bits +function ADD64AC (v, a, b0, b1) { + var o0 = v[a] + b0 + if (b0 < 0) { + o0 += 0x100000000 + } + var o1 = v[a + 1] + b1 + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// Little-endian byte access +function B2B_GET32 (arr, i) { + return (arr[i] ^ + (arr[i + 1] << 8) ^ + (arr[i + 2] << 16) ^ + (arr[i + 3] << 24)) +} + +// G Mixing function +// The ROTRs are inlined for speed +function B2B_G (a, b, c, d, ix, iy) { + var x0 = m[ix] + var x1 = m[ix + 1] + var y0 = m[iy] + var y1 = m[iy + 1] + + ADD64AA(v, a, b) // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s + ADD64AC(v, a, x0, x1) // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits + var xor0 = v[d] ^ v[a] + var xor1 = v[d + 1] ^ v[a + 1] + v[d] = xor1 + v[d + 1] = xor0 + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor0 >>> 24) ^ (xor1 << 8) + v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8) + + ADD64AA(v, a, b) + ADD64AC(v, a, y0, y1) + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits + xor0 = v[d] ^ v[a] + xor1 = v[d + 1] ^ v[a + 1] + v[d] = (xor0 >>> 16) ^ (xor1 << 16) + v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16) + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor1 >>> 31) ^ (xor0 << 1) + v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1) +} + +// Initialization Vector +var BLAKE2B_IV32 = new Uint32Array([ + 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, + 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, + 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, + 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 +]) + +var SIGMA8 = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 +] + +// These are offsets into a uint64 buffer. +// Multiply them all by 2 to make them offsets into a uint32 buffer, +// because this is Javascript and we don't have uint64s +var SIGMA82 = new Uint8Array(SIGMA8.map(function (x) { return x * 2 })) + +// Compression function. 'last' flag indicates last block. +// Note we're representing 16 uint64s as 32 uint32s +var v = new Uint32Array(32) +var m = new Uint32Array(32) +function blake2bCompress (ctx, last) { + var i = 0 + + // init work variables + for (i = 0; i < 16; i++) { + v[i] = ctx.h[i] + v[i + 16] = BLAKE2B_IV32[i] + } + + // low 64 bits of offset + v[24] = v[24] ^ ctx.t + v[25] = v[25] ^ (ctx.t / 0x100000000) + // high 64 bits not supported, offset may not be higher than 2**53-1 + + // last block flag set ? + if (last) { + v[28] = ~v[28] + v[29] = ~v[29] + } + + // get little-endian words + for (i = 0; i < 32; i++) { + m[i] = B2B_GET32(ctx.b, 4 * i) + } + + // twelve rounds of mixing + for (i = 0; i < 12; i++) { + B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]) + B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]) + B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]) + B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]) + B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]) + B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]) + B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]) + B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]) + } + + for (i = 0; i < 16; i++) { + ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16] + } +} + +// reusable parameter_block +var parameter_block = new Uint8Array([ + 0, 0, 0, 0, // 0: outlen, keylen, fanout, depth + 0, 0, 0, 0, // 4: leaf length, sequential mode + 0, 0, 0, 0, // 8: node offset + 0, 0, 0, 0, // 12: node offset + 0, 0, 0, 0, // 16: node depth, inner length, rfu + 0, 0, 0, 0, // 20: rfu + 0, 0, 0, 0, // 24: rfu + 0, 0, 0, 0, // 28: rfu + 0, 0, 0, 0, // 32: salt + 0, 0, 0, 0, // 36: salt + 0, 0, 0, 0, // 40: salt + 0, 0, 0, 0, // 44: salt + 0, 0, 0, 0, // 48: personal + 0, 0, 0, 0, // 52: personal + 0, 0, 0, 0, // 56: personal + 0, 0, 0, 0 // 60: personal +]) + +// Creates a BLAKE2b hashing context +// Requires an output length between 1 and 64 bytes +// Takes an optional Uint8Array key +function Blake2b (outlen, key, salt, personal) { + // zero out parameter_block before usage + parameter_block.fill(0) + // state, 'param block' + + this.b = new Uint8Array(128) + this.h = new Uint32Array(16) + this.t = 0 // input count + this.c = 0 // pointer within buffer + this.outlen = outlen // output length in bytes + + parameter_block[0] = outlen + if (key) parameter_block[1] = key.length + parameter_block[2] = 1 // fanout + parameter_block[3] = 1 // depth + + if (salt) parameter_block.set(salt, 32) + if (personal) parameter_block.set(personal, 48) + + // initialize hash state + for (var i = 0; i < 16; i++) { + this.h[i] = BLAKE2B_IV32[i] ^ B2B_GET32(parameter_block, i * 4) + } + + // key the hash, if applicable + if (key) { + blake2bUpdate(this, key) + // at the end + this.c = 128 + } +} + +Blake2b.prototype.update = function (input) { + blake2bUpdate(this, input) + return this +} + +Blake2b.prototype.digest = function (out) { + var buf = (!out || out === 'binary' || out === 'hex') ? new Uint8Array(this.outlen) : out + blake2bFinal(this, buf) + if (out === 'hex') return hexSlice(buf) + return buf +} + +Blake2b.prototype.final = Blake2b.prototype.digest + +// Updates a BLAKE2b streaming hash +// Requires hash context and Uint8Array (byte array) +function blake2bUpdate (ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 128) { // buffer full ? + ctx.t += ctx.c // add counters + blake2bCompress(ctx, false) // compress (not last) + ctx.c = 0 // counter to zero + } + ctx.b[ctx.c++] = input[i] + } +} + +// Completes a BLAKE2b streaming hash +// Returns a Uint8Array containing the message digest +function blake2bFinal (ctx, out) { + ctx.t += ctx.c // mark last block offset + + while (ctx.c < 128) { // fill up with zeros + ctx.b[ctx.c++] = 0 + } + blake2bCompress(ctx, true) // final block flag = 1 + + for (var i = 0; i < ctx.outlen; i++) { + out[i] = ctx.h[i >> 2] >> (8 * (i & 3)) + } + return out +} + +function hexSlice (buf) { + var str = '' + for (var i = 0; i < buf.length; i++) str += toHex(buf[i]) + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +module.exports = Blake2b; \ No newline at end of file diff --git a/src/crypto/utils.js b/src/crypto/utils.js index 0d824c99..5f4f3e15 100644 --- a/src/crypto/utils.js +++ b/src/crypto/utils.js @@ -1,6 +1,7 @@ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; +var Blake2B = require('./blake2b'); function numberToHex (number) { var hex = Math.round(number).toString(16); @@ -10,6 +11,15 @@ function numberToHex (number) { return hex; } +function hexToUint8(hexString) { + var arr = []; + for (var i = 0; i < hexString.length; i += 2) { + arr.push(parseInt(hexString.substr(i, 2), 16)); + } + + return new Uint8Array(arr); +} + module.exports = { toHex: function (arrayOfBytes) { var hex = ''; @@ -32,6 +42,9 @@ module.exports = { blake256Checksum: function (payload) { return this.blake256(this.blake256(payload)).substr(0, 8); }, + blake2b: function (hexString, outlen) { + return new Blake2B(outlen).update(hexToUint8(hexString)).digest('hex'); + }, keccak256: function (hexString) { return keccak256(hexString); } From e680b0e2a89038916fb264e98034e0b88776fa7b Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Fri, 28 Sep 2018 14:18:31 +0200 Subject: [PATCH 047/108] Add support for validating NANO/XRB addresses --- src/currencies.js | 9 +++++++++ src/nano_validator.js | 27 +++++++++++++++++++++++++++ test/wallet_address_validator.js | 20 ++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 src/nano_validator.js diff --git a/src/currencies.js b/src/currencies.js index c8483af1..6b824046 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -1,6 +1,7 @@ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); +var NANOValidator = require('./nano_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -192,6 +193,14 @@ var CURRENCIES = [{ name: 'bankex', symbol: 'bkx', validator: ETHValidator +},{ + name: 'nano', + symbol: 'nano', + validator: NANOValidator, +},{ + name: 'raiblocks', + symbol: 'xrb', + validator: NANOValidator, }]; diff --git a/src/nano_validator.js b/src/nano_validator.js new file mode 100644 index 00000000..8960ab4e --- /dev/null +++ b/src/nano_validator.js @@ -0,0 +1,27 @@ +var cryptoUtils = require('./crypto/utils'); +var baseX = require('base-x'); + +var ALLOWED_CHARS = '13456789abcdefghijkmnopqrstuwxyz'; + +var codec = baseX(ALLOWED_CHARS); +// https://github.com/nanocurrency/raiblocks/wiki/Accounts,-Keys,-Seeds,-and-Wallet-Identifiers +var regexp = new RegExp('^(xrb|nano)_([' + ALLOWED_CHARS + ']{60})$'); + +module.exports = { + isValidAddress: function (address) { + if (regexp.test(address)) { + return this.verifyChecksum(address); + } + + return false; + }, + + verifyChecksum: function (address) { + var bytes = codec.decode(regexp.exec(address)[2]).slice(-37); + // https://github.com/nanocurrency/raiblocks/blob/master/rai/lib/numbers.cpp#L73 + var computedChecksum = cryptoUtils.blake2b(cryptoUtils.toHex(bytes.slice(0, -5)), 5); + var checksum = cryptoUtils.toHex(bytes.slice(-5).reverse()); + + return computedChecksum === checksum + } +}; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 27eefa65..52de9d0e 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -354,6 +354,19 @@ describe('WAValidator.validate()', function () { valid('0xf40d80FCfa5cdEa0bB1E570c2D52132ac9bC6aEC', 'bankex', 'testnet'); valid('0x8A7395f281EeCf2B471B689E87Cf4C7fa8bb957d', 'BKX', 'testnet'); }); + + it('should return true for correct nano addresses', function () { + valid('xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3', 'nano'); + valid('xrb_13ezf4od79h1tgj9aiu4djzcmmguendtjfuhwfukhuucboua8cpoihmh8byo', 'nano'); + valid('xrb_35jjmmmh81kydepzeuf9oec8hzkay7msr6yxagzxpcht7thwa5bus5tomgz9', 'nano'); + valid('xrb_1111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); + valid('xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est', 'nano'); + valid('xrb_3wm37qz19zhei7nzscjcopbrbnnachs4p1gnwo5oroi3qonw6inwgoeuufdp', 'nano'); + valid('xrb_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4', 'nano'); + valid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjmgu', 'nano'); + valid('xrb_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); + valid('nano_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); + }); }); describe('invalid results', function () { @@ -545,5 +558,12 @@ describe('WAValidator.validate()', function () { //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); }); + it('should return false for incorrect nano addresses', function () { + commonTests('nano'); + invalid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); + invalid('nano_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nano'); + invalid('nano_111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); + }); }); }); From 47adbfe203378a2ca6404d999c34b3f00afbc7fb Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Fri, 28 Sep 2018 14:29:21 +0200 Subject: [PATCH 048/108] Update README about NANO addition --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ef22e425..bdca7da5 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ npm install wallet-address-validator * Megacoin/MEC, `'megacoin'` or `'MEC'` * Namecoin/NMC, `'namecoin'` or `'NMC'` +* Nano/NANO, `'nano'` or `'NANO'` * NEO/NEO, `'NEO'` or `'NEO'` * NeoGas/GAS, `'neogas'` or `'GAS'` @@ -74,6 +75,7 @@ npm install wallet-address-validator * Qtum/QTUM, `'qtum'` or `'QTUM'` +* Raiblocks/XRB, `'raiblocks'` or `'XRB'` * Ripple/XRP, `'ripple'` or `'XRP'` * Snowgem/SNG, `'snowgem'` or `'SNG'` From 72e9b37d31880730ecef26ec9d679a72132ffab2 Mon Sep 17 00:00:00 2001 From: maximumgame Date: Fri, 28 Sep 2018 09:59:21 -0700 Subject: [PATCH 049/108] Add monero/xmr validation --- README.md | 2 + dist/wallet-address-validator.js | 1915 +++++++++++++++++++++++++- dist/wallet-address-validator.min.js | 2 +- package.json | 1 + src/crypto/biginteger.js | 1450 +++++++++++++++++++ src/crypto/cnBase58.js | 226 +++ src/crypto/utils.js | 3 + src/currencies.js | 7 + src/monero_validator.js | 60 + test/wallet_address_validator.js | 20 + 10 files changed, 3623 insertions(+), 63 deletions(-) create mode 100644 src/crypto/biginteger.js create mode 100644 src/crypto/cnBase58.js create mode 100644 src/monero_validator.js diff --git a/README.md b/README.md index ef22e425..77d8e619 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ npm install wallet-address-validator * Megacoin/MEC, `'megacoin'` or `'MEC'` +* Monero/XMR, `'monero'` or `'XMR'` + * Namecoin/NMC, `'namecoin'` or `'NMC'` * NEO/NEO, `'NEO'` or `'NEO'` * NeoGas/GAS, `'neogas'` or `'GAS'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 9eba6b47..9a5d323d 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -294,7 +294,7 @@ function typedArraySupport () { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } return arr.foo() === 42 } catch (e) { return false @@ -302,26 +302,24 @@ function typedArraySupport () { } Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, get: function () { - if (!(this instanceof Buffer)) { - return undefined - } + if (!Buffer.isBuffer(this)) return undefined return this.buffer } }) Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, get: function () { - if (!(this instanceof Buffer)) { - return undefined - } + if (!Buffer.isBuffer(this)) return undefined return this.byteOffset } }) function createBuffer (length) { if (length > K_MAX_LENGTH) { - throw new RangeError('Invalid typed array length') + throw new RangeError('The value "' + length + '" is invalid for option "size"') } // Return an augmented `Uint8Array` instance var buf = new Uint8Array(length) @@ -343,8 +341,8 @@ function Buffer (arg, encodingOrOffset, length) { // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' + throw new TypeError( + 'The "string" argument must be of type string. Received type number' ) } return allocUnsafe(arg) @@ -353,7 +351,7 @@ function Buffer (arg, encodingOrOffset, length) { } // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species && +if (typeof Symbol !== 'undefined' && Symbol.species != null && Buffer[Symbol.species] === Buffer) { Object.defineProperty(Buffer, Symbol.species, { value: null, @@ -366,19 +364,51 @@ if (typeof Symbol !== 'undefined' && Symbol.species && Buffer.poolSize = 8192 // not used by this implementation function from (value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + if (ArrayBuffer.isView(value)) { + return fromArrayLike(value) + } + + if (value == null) { + throw TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) } - if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { + if (isInstance(value, ArrayBuffer) || + (value && isInstance(value.buffer, ArrayBuffer))) { return fromArrayBuffer(value, encodingOrOffset, length) } - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) + if (typeof value === 'number') { + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) + } + + var valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) + } + + var b = fromObject(value) + if (b) return b + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && + typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from( + value[Symbol.toPrimitive]('string'), encodingOrOffset, length + ) } - return fromObject(value) + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) } /** @@ -402,7 +432,7 @@ function assertSize (size) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be of type number') } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') + throw new RangeError('The value "' + size + '" is invalid for option "size"') } } @@ -517,20 +547,16 @@ function fromObject (obj) { return buf } - if (obj) { - if (ArrayBuffer.isView(obj) || 'length' in obj) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } - - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) } + return fromArrayLike(obj) } - throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } } function checked (length) { @@ -551,12 +577,17 @@ function SlowBuffer (length) { } Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true + return b != null && b._isBuffer === true && + b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false } Buffer.compare = function compare (a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) } if (a === b) return 0 @@ -617,7 +648,7 @@ Buffer.concat = function concat (list, length) { var pos = 0 for (i = 0; i < list.length; ++i) { var buf = list[i] - if (ArrayBuffer.isView(buf)) { + if (isInstance(buf, Uint8Array)) { buf = Buffer.from(buf) } if (!Buffer.isBuffer(buf)) { @@ -633,15 +664,19 @@ function byteLength (string, encoding) { if (Buffer.isBuffer(string)) { return string.length } - if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { return string.byteLength } if (typeof string !== 'string') { - string = '' + string + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) } var len = string.length - if (len === 0) return 0 + var mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 // Use a for loop to avoid recursion var loweredCase = false @@ -653,7 +688,6 @@ function byteLength (string, encoding) { return len case 'utf8': case 'utf-8': - case undefined: return utf8ToBytes(string).length case 'ucs2': case 'ucs-2': @@ -665,7 +699,9 @@ function byteLength (string, encoding) { case 'base64': return base64ToBytes(string).length default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } encoding = ('' + encoding).toLowerCase() loweredCase = true } @@ -812,16 +848,20 @@ Buffer.prototype.equals = function equals (b) { Buffer.prototype.inspect = function inspect () { var str = '' var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' return '' } Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength) + } if (!Buffer.isBuffer(target)) { - throw new TypeError('Argument must be a Buffer') + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) } if (start === undefined) { @@ -900,7 +940,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { } else if (byteOffset < -0x80000000) { byteOffset = -0x80000000 } - byteOffset = +byteOffset // Coerce to Number. + byteOffset = +byteOffset // Coerce to Number. if (numberIsNaN(byteOffset)) { // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer byteOffset = dir ? 0 : (buffer.length - 1) @@ -1152,8 +1192,8 @@ function utf8Slice (buf, start, end) { var codePoint = null var bytesPerSequence = (firstByte > 0xEF) ? 4 : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 + : (firstByte > 0xBF) ? 2 + : 1 if (i + bytesPerSequence <= end) { var secondByte, thirdByte, fourthByte, tempCodePoint @@ -1816,7 +1856,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) { } else { var bytes = Buffer.isBuffer(val) ? val - : new Buffer(val, encoding) + : Buffer.from(val, encoding) var len = bytes.length if (len === 0) { throw new TypeError('The value "' + val + @@ -1971,15 +2011,16 @@ function blitBuffer (src, dst, offset, length) { return i } -// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check -// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 -function isArrayBuffer (obj) { - return obj instanceof ArrayBuffer || - (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && - typeof obj.byteLength === 'number') +// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass +// the `instanceof` check but they should be treated as of that type. +// See: https://github.com/feross/buffer/issues/166 +function isInstance (obj, type) { + return obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && + obj.constructor.name === type.name) } - function numberIsNaN (obj) { + // For IE11 support return obj !== obj // eslint-disable-line no-self-compare } @@ -2427,7 +2468,7 @@ module.exports = { } }; -},{"./crypto/base58":9,"./crypto/segwit_addr":12,"./crypto/utils":14}],9:[function(require,module,exports){ +},{"./crypto/base58":9,"./crypto/segwit_addr":14,"./crypto/utils":16}],9:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -2594,6 +2635,1457 @@ function decode (bechString) { } },{}],11:[function(require,module,exports){ +/* + JavaScript BigInteger library version 0.9.1 + http://silentmatt.com/biginteger/ + Copyright (c) 2009 Matthew Crumley + Copyright (c) 2010,2011 by John Tobey + Licensed under the MIT license. + Support for arbitrary internal representation base was added by + Vitaly Magerya. +*/ + +/* + File: biginteger.js + Exports: + +*/ +(function(exports) { + "use strict"; + /* + Class: BigInteger + An arbitrarily-large integer. + objects should be considered immutable. None of the "built-in" + methods modify *this* or their arguments. All properties should be + considered private. + All the methods of instances can be called "statically". The + static versions are convenient if you don't already have a + object. + As an example, these calls are equivalent. + > BigInteger(4).multiply(5); // returns BigInteger(20); + > BigInteger.multiply(4, 5); // returns BigInteger(20); + > var a = 42; + > var a = BigInteger.toJSValue("0b101010"); // Not completely useless... + */ + + var CONSTRUCT = {}; // Unique token to call "private" version of constructor + + /* + Constructor: BigInteger() + Convert a value to a . + Although is the constructor for objects, it is + best not to call it as a constructor. If *n* is a object, it is + simply returned as-is. Otherwise, is equivalent to + without a radix argument. + > var n0 = BigInteger(); // Same as + > var n1 = BigInteger("123"); // Create a new with value 123 + > var n2 = BigInteger(123); // Create a new with value 123 + > var n3 = BigInteger(n2); // Return n2, unchanged + The constructor form only takes an array and a sign. *n* must be an + array of numbers in little-endian order, where each digit is between 0 + and BigInteger.base. The second parameter sets the sign: -1 for + negative, +1 for positive, or 0 for zero. The array is *not copied and + may be modified*. If the array contains only zeros, the sign parameter + is ignored and is forced to zero. + > new BigInteger([5], -1): create a new BigInteger with value -5 + Parameters: + n - Value to convert to a . + Returns: + A value. + See Also: + , + */ + function BigInteger(n, s, token) { + + if (token !== CONSTRUCT) { + if (n instanceof BigInteger) { + return n; + } + else if (typeof n === "undefined") { + return ZERO; + } + return BigInteger.parse(n); + } + + n = n || []; // Provide the nullary constructor for subclasses. + while (n.length && !n[n.length - 1]) { + --n.length; + } + this._d = n; + this._s = n.length ? (s || 1) : 0; + } + + BigInteger._construct = function(n, s) { + return new BigInteger(n, s, CONSTRUCT); + }; + + // Base-10 speedup hacks in parse, toString, exp10 and log functions + // require base to be a power of 10. 10^7 is the largest such power + // that won't cause a precision loss when digits are multiplied. + var BigInteger_base = 10000000; + var BigInteger_base_log10 = 7; + + BigInteger.base = BigInteger_base; + BigInteger.base_log10 = BigInteger_base_log10; + + var ZERO = new BigInteger([], 0, CONSTRUCT); + // Constant: ZERO + // 0. + BigInteger.ZERO = ZERO; + + var ONE = new BigInteger([1], 1, CONSTRUCT); + // Constant: ONE + // 1. + BigInteger.ONE = ONE; + + var M_ONE = new BigInteger(ONE._d, -1, CONSTRUCT); + // Constant: M_ONE + // -1. + BigInteger.M_ONE = M_ONE; + + // Constant: _0 + // Shortcut for . + BigInteger._0 = ZERO; + + // Constant: _1 + // Shortcut for . + BigInteger._1 = ONE; + + /* + Constant: small + Array of from 0 to 36. + These are used internally for parsing, but useful when you need a "small" + . + See Also: + , , <_0>, <_1> + */ + BigInteger.small = [ + ZERO, + ONE, + /* Assuming BigInteger_base > 36 */ + new BigInteger( [2], 1, CONSTRUCT), + new BigInteger( [3], 1, CONSTRUCT), + new BigInteger( [4], 1, CONSTRUCT), + new BigInteger( [5], 1, CONSTRUCT), + new BigInteger( [6], 1, CONSTRUCT), + new BigInteger( [7], 1, CONSTRUCT), + new BigInteger( [8], 1, CONSTRUCT), + new BigInteger( [9], 1, CONSTRUCT), + new BigInteger([10], 1, CONSTRUCT), + new BigInteger([11], 1, CONSTRUCT), + new BigInteger([12], 1, CONSTRUCT), + new BigInteger([13], 1, CONSTRUCT), + new BigInteger([14], 1, CONSTRUCT), + new BigInteger([15], 1, CONSTRUCT), + new BigInteger([16], 1, CONSTRUCT), + new BigInteger([17], 1, CONSTRUCT), + new BigInteger([18], 1, CONSTRUCT), + new BigInteger([19], 1, CONSTRUCT), + new BigInteger([20], 1, CONSTRUCT), + new BigInteger([21], 1, CONSTRUCT), + new BigInteger([22], 1, CONSTRUCT), + new BigInteger([23], 1, CONSTRUCT), + new BigInteger([24], 1, CONSTRUCT), + new BigInteger([25], 1, CONSTRUCT), + new BigInteger([26], 1, CONSTRUCT), + new BigInteger([27], 1, CONSTRUCT), + new BigInteger([28], 1, CONSTRUCT), + new BigInteger([29], 1, CONSTRUCT), + new BigInteger([30], 1, CONSTRUCT), + new BigInteger([31], 1, CONSTRUCT), + new BigInteger([32], 1, CONSTRUCT), + new BigInteger([33], 1, CONSTRUCT), + new BigInteger([34], 1, CONSTRUCT), + new BigInteger([35], 1, CONSTRUCT), + new BigInteger([36], 1, CONSTRUCT) + ]; + + // Used for parsing/radix conversion + BigInteger.digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""); + + /* + Method: toString + Convert a to a string. + When *base* is greater than 10, letters are upper case. + Parameters: + base - Optional base to represent the number in (default is base 10). + Must be between 2 and 36 inclusive, or an Error will be thrown. + Returns: + The string representation of the . + */ + BigInteger.prototype.toString = function(base) { + base = +base || 10; + if (base < 2 || base > 36) { + throw new Error("illegal radix " + base + "."); + } + if (this._s === 0) { + return "0"; + } + if (base === 10) { + var str = this._s < 0 ? "-" : ""; + str += this._d[this._d.length - 1].toString(); + for (var i = this._d.length - 2; i >= 0; i--) { + var group = this._d[i].toString(); + while (group.length < BigInteger_base_log10) group = '0' + group; + str += group; + } + return str; + } + else { + var numerals = BigInteger.digits; + base = BigInteger.small[base]; + var sign = this._s; + + var n = this.abs(); + var digits = []; + var digit; + + while (n._s !== 0) { + var divmod = n.divRem(base); + n = divmod[0]; + digit = divmod[1]; + // TODO: This could be changed to unshift instead of reversing at the end. + // Benchmark both to compare speeds. + digits.push(numerals[digit.valueOf()]); + } + return (sign < 0 ? "-" : "") + digits.reverse().join(""); + } + }; + + // Verify strings for parsing + BigInteger.radixRegex = [ + /^$/, + /^$/, + /^[01]*$/, + /^[012]*$/, + /^[0-3]*$/, + /^[0-4]*$/, + /^[0-5]*$/, + /^[0-6]*$/, + /^[0-7]*$/, + /^[0-8]*$/, + /^[0-9]*$/, + /^[0-9aA]*$/, + /^[0-9abAB]*$/, + /^[0-9abcABC]*$/, + /^[0-9a-dA-D]*$/, + /^[0-9a-eA-E]*$/, + /^[0-9a-fA-F]*$/, + /^[0-9a-gA-G]*$/, + /^[0-9a-hA-H]*$/, + /^[0-9a-iA-I]*$/, + /^[0-9a-jA-J]*$/, + /^[0-9a-kA-K]*$/, + /^[0-9a-lA-L]*$/, + /^[0-9a-mA-M]*$/, + /^[0-9a-nA-N]*$/, + /^[0-9a-oA-O]*$/, + /^[0-9a-pA-P]*$/, + /^[0-9a-qA-Q]*$/, + /^[0-9a-rA-R]*$/, + /^[0-9a-sA-S]*$/, + /^[0-9a-tA-T]*$/, + /^[0-9a-uA-U]*$/, + /^[0-9a-vA-V]*$/, + /^[0-9a-wA-W]*$/, + /^[0-9a-xA-X]*$/, + /^[0-9a-yA-Y]*$/, + /^[0-9a-zA-Z]*$/ + ]; + + /* + Function: parse + Parse a string into a . + *base* is optional but, if provided, must be from 2 to 36 inclusive. If + *base* is not provided, it will be guessed based on the leading characters + of *s* as follows: + - "0x" or "0X": *base* = 16 + - "0c" or "0C": *base* = 8 + - "0b" or "0B": *base* = 2 + - else: *base* = 10 + If no base is provided, or *base* is 10, the number can be in exponential + form. For example, these are all valid: + > BigInteger.parse("1e9"); // Same as "1000000000" + > BigInteger.parse("1.234*10^3"); // Same as 1234 + > BigInteger.parse("56789 * 10 ** -2"); // Same as 567 + If any characters fall outside the range defined by the radix, an exception + will be thrown. + Parameters: + s - The string to parse. + base - Optional radix (default is to guess based on *s*). + Returns: + a instance. + */ + BigInteger.parse = function(s, base) { + // Expands a number in exponential form to decimal form. + // expandExponential("-13.441*10^5") === "1344100"; + // expandExponential("1.12300e-1") === "0.112300"; + // expandExponential(1000000000000000000000000000000) === "1000000000000000000000000000000"; + function expandExponential(str) { + str = str.replace(/\s*[*xX]\s*10\s*(\^|\*\*)\s*/, "e"); + + return str.replace(/^([+\-])?(\d+)\.?(\d*)[eE]([+\-]?\d+)$/, function(x, s, n, f, c) { + c = +c; + var l = c < 0; + var i = n.length + c; + x = (l ? n : f).length; + c = ((c = Math.abs(c)) >= x ? c - x + l : 0); + var z = (new Array(c + 1)).join("0"); + var r = n + f; + return (s || "") + (l ? r = z + r : r += z).substr(0, i += l ? z.length : 0) + (i < r.length ? "." + r.substr(i) : ""); + }); + } + + s = s.toString(); + if (typeof base === "undefined" || +base === 10) { + s = expandExponential(s); + } + + var prefixRE; + if (typeof base === "undefined") { + prefixRE = '0[xcb]'; + } + else if (base == 16) { + prefixRE = '0x'; + } + else if (base == 8) { + prefixRE = '0c'; + } + else if (base == 2) { + prefixRE = '0b'; + } + else { + prefixRE = ''; + } + var parts = new RegExp('^([+\\-]?)(' + prefixRE + ')?([0-9a-z]*)(?:\\.\\d*)?$', 'i').exec(s); + if (parts) { + var sign = parts[1] || "+"; + var baseSection = parts[2] || ""; + var digits = parts[3] || ""; + + if (typeof base === "undefined") { + // Guess base + if (baseSection === "0x" || baseSection === "0X") { // Hex + base = 16; + } + else if (baseSection === "0c" || baseSection === "0C") { // Octal + base = 8; + } + else if (baseSection === "0b" || baseSection === "0B") { // Binary + base = 2; + } + else { + base = 10; + } + } + else if (base < 2 || base > 36) { + throw new Error("Illegal radix " + base + "."); + } + + base = +base; + + // Check for digits outside the range + if (!(BigInteger.radixRegex[base].test(digits))) { + throw new Error("Bad digit for radix " + base); + } + + // Strip leading zeros, and convert to array + digits = digits.replace(/^0+/, "").split(""); + if (digits.length === 0) { + return ZERO; + } + + // Get the sign (we know it's not zero) + sign = (sign === "-") ? -1 : 1; + + // Optimize 10 + if (base == 10) { + var d = []; + while (digits.length >= BigInteger_base_log10) { + d.push(parseInt(digits.splice(digits.length-BigInteger.base_log10, BigInteger.base_log10).join(''), 10)); + } + d.push(parseInt(digits.join(''), 10)); + return new BigInteger(d, sign, CONSTRUCT); + } + + // Do the conversion + var d = ZERO; + base = BigInteger.small[base]; + var small = BigInteger.small; + for (var i = 0; i < digits.length; i++) { + d = d.multiply(base).add(small[parseInt(digits[i], 36)]); + } + return new BigInteger(d._d, sign, CONSTRUCT); + } + else { + throw new Error("Invalid BigInteger format: " + s); + } + }; + + /* + Function: add + Add two . + Parameters: + n - The number to add to *this*. Will be converted to a . + Returns: + The numbers added together. + See Also: + , , , + */ + BigInteger.prototype.add = function(n) { + if (this._s === 0) { + return BigInteger(n); + } + + n = BigInteger(n); + if (n._s === 0) { + return this; + } + if (this._s !== n._s) { + n = n.negate(); + return this.subtract(n); + } + + var a = this._d; + var b = n._d; + var al = a.length; + var bl = b.length; + var sum = new Array(Math.max(al, bl) + 1); + var size = Math.min(al, bl); + var carry = 0; + var digit; + + for (var i = 0; i < size; i++) { + digit = a[i] + b[i] + carry; + sum[i] = digit % BigInteger_base; + carry = (digit / BigInteger_base) | 0; + } + if (bl > al) { + a = b; + al = bl; + } + for (i = size; carry && i < al; i++) { + digit = a[i] + carry; + sum[i] = digit % BigInteger_base; + carry = (digit / BigInteger_base) | 0; + } + if (carry) { + sum[i] = carry; + } + + for ( ; i < al; i++) { + sum[i] = a[i]; + } + + return new BigInteger(sum, this._s, CONSTRUCT); + }; + + /* + Function: negate + Get the additive inverse of a . + Returns: + A with the same magnatude, but with the opposite sign. + See Also: + + */ + BigInteger.prototype.negate = function() { + return new BigInteger(this._d, (-this._s) | 0, CONSTRUCT); + }; + + /* + Function: abs + Get the absolute value of a . + Returns: + A with the same magnatude, but always positive (or zero). + See Also: + + */ + BigInteger.prototype.abs = function() { + return (this._s < 0) ? this.negate() : this; + }; + + /* + Function: subtract + Subtract two . + Parameters: + n - The number to subtract from *this*. Will be converted to a . + Returns: + The *n* subtracted from *this*. + See Also: + , , , + */ + BigInteger.prototype.subtract = function(n) { + if (this._s === 0) { + return BigInteger(n).negate(); + } + + n = BigInteger(n); + if (n._s === 0) { + return this; + } + if (this._s !== n._s) { + n = n.negate(); + return this.add(n); + } + + var m = this; + // negative - negative => -|a| - -|b| => -|a| + |b| => |b| - |a| + if (this._s < 0) { + m = new BigInteger(n._d, 1, CONSTRUCT); + n = new BigInteger(this._d, 1, CONSTRUCT); + } + + // Both are positive => a - b + var sign = m.compareAbs(n); + if (sign === 0) { + return ZERO; + } + else if (sign < 0) { + // swap m and n + var t = n; + n = m; + m = t; + } + + // a > b + var a = m._d; + var b = n._d; + var al = a.length; + var bl = b.length; + var diff = new Array(al); // al >= bl since a > b + var borrow = 0; + var i; + var digit; + + for (i = 0; i < bl; i++) { + digit = a[i] - borrow - b[i]; + if (digit < 0) { + digit += BigInteger_base; + borrow = 1; + } + else { + borrow = 0; + } + diff[i] = digit; + } + for (i = bl; i < al; i++) { + digit = a[i] - borrow; + if (digit < 0) { + digit += BigInteger_base; + } + else { + diff[i++] = digit; + break; + } + diff[i] = digit; + } + for ( ; i < al; i++) { + diff[i] = a[i]; + } + + return new BigInteger(diff, sign, CONSTRUCT); + }; + + (function() { + function addOne(n, sign) { + var a = n._d; + var sum = a.slice(); + var carry = true; + var i = 0; + + while (true) { + var digit = (a[i] || 0) + 1; + sum[i] = digit % BigInteger_base; + if (digit <= BigInteger_base - 1) { + break; + } + ++i; + } + + return new BigInteger(sum, sign, CONSTRUCT); + } + + function subtractOne(n, sign) { + var a = n._d; + var sum = a.slice(); + var borrow = true; + var i = 0; + + while (true) { + var digit = (a[i] || 0) - 1; + if (digit < 0) { + sum[i] = digit + BigInteger_base; + } + else { + sum[i] = digit; + break; + } + ++i; + } + + return new BigInteger(sum, sign, CONSTRUCT); + } + + /* + Function: next + Get the next (add one). + Returns: + *this* + 1. + See Also: + , + */ + BigInteger.prototype.next = function() { + switch (this._s) { + case 0: + return ONE; + case -1: + return subtractOne(this, -1); + // case 1: + default: + return addOne(this, 1); + } + }; + + /* + Function: prev + Get the previous (subtract one). + Returns: + *this* - 1. + See Also: + , + */ + BigInteger.prototype.prev = function() { + switch (this._s) { + case 0: + return M_ONE; + case -1: + return addOne(this, -1); + // case 1: + default: + return subtractOne(this, 1); + } + }; + })(); + + /* + Function: compareAbs + Compare the absolute value of two . + Calling is faster than calling twice, then . + Parameters: + n - The number to compare to *this*. Will be converted to a . + Returns: + -1, 0, or +1 if *|this|* is less than, equal to, or greater than *|n|*. + See Also: + , + */ + BigInteger.prototype.compareAbs = function(n) { + if (this === n) { + return 0; + } + + if (!(n instanceof BigInteger)) { + if (!isFinite(n)) { + return(isNaN(n) ? n : -1); + } + n = BigInteger(n); + } + + if (this._s === 0) { + return (n._s !== 0) ? -1 : 0; + } + if (n._s === 0) { + return 1; + } + + var l = this._d.length; + var nl = n._d.length; + if (l < nl) { + return -1; + } + else if (l > nl) { + return 1; + } + + var a = this._d; + var b = n._d; + for (var i = l-1; i >= 0; i--) { + if (a[i] !== b[i]) { + return a[i] < b[i] ? -1 : 1; + } + } + + return 0; + }; + + /* + Function: compare + Compare two . + Parameters: + n - The number to compare to *this*. Will be converted to a . + Returns: + -1, 0, or +1 if *this* is less than, equal to, or greater than *n*. + See Also: + , , , + */ + BigInteger.prototype.compare = function(n) { + if (this === n) { + return 0; + } + + n = BigInteger(n); + + if (this._s === 0) { + return -n._s; + } + + if (this._s === n._s) { // both positive or both negative + var cmp = this.compareAbs(n); + return cmp * this._s; + } + else { + return this._s; + } + }; + + /* + Function: isUnit + Return true iff *this* is either 1 or -1. + Returns: + true if *this* compares equal to or . + See Also: + , , , , , + , + */ + BigInteger.prototype.isUnit = function() { + return this === ONE || + this === M_ONE || + (this._d.length === 1 && this._d[0] === 1); + }; + + /* + Function: multiply + Multiply two . + Parameters: + n - The number to multiply *this* by. Will be converted to a + . + Returns: + The numbers multiplied together. + See Also: + , , , + */ + BigInteger.prototype.multiply = function(n) { + // TODO: Consider adding Karatsuba multiplication for large numbers + if (this._s === 0) { + return ZERO; + } + + n = BigInteger(n); + if (n._s === 0) { + return ZERO; + } + if (this.isUnit()) { + if (this._s < 0) { + return n.negate(); + } + return n; + } + if (n.isUnit()) { + if (n._s < 0) { + return this.negate(); + } + return this; + } + if (this === n) { + return this.square(); + } + + var r = (this._d.length >= n._d.length); + var a = (r ? this : n)._d; // a will be longer than b + var b = (r ? n : this)._d; + var al = a.length; + var bl = b.length; + + var pl = al + bl; + var partial = new Array(pl); + var i; + for (i = 0; i < pl; i++) { + partial[i] = 0; + } + + for (i = 0; i < bl; i++) { + var carry = 0; + var bi = b[i]; + var jlimit = al + i; + var digit; + for (var j = i; j < jlimit; j++) { + digit = partial[j] + bi * a[j - i] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = (digit % BigInteger_base) | 0; + } + if (carry) { + digit = partial[j] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = digit % BigInteger_base; + } + } + return new BigInteger(partial, this._s * n._s, CONSTRUCT); + }; + + // Multiply a BigInteger by a single-digit native number + // Assumes that this and n are >= 0 + // This is not really intended to be used outside the library itself + BigInteger.prototype.multiplySingleDigit = function(n) { + if (n === 0 || this._s === 0) { + return ZERO; + } + if (n === 1) { + return this; + } + + var digit; + if (this._d.length === 1) { + digit = this._d[0] * n; + if (digit >= BigInteger_base) { + return new BigInteger([(digit % BigInteger_base)|0, + (digit / BigInteger_base)|0], 1, CONSTRUCT); + } + return new BigInteger([digit], 1, CONSTRUCT); + } + + if (n === 2) { + return this.add(this); + } + if (this.isUnit()) { + return new BigInteger([n], 1, CONSTRUCT); + } + + var a = this._d; + var al = a.length; + + var pl = al + 1; + var partial = new Array(pl); + for (var i = 0; i < pl; i++) { + partial[i] = 0; + } + + var carry = 0; + for (var j = 0; j < al; j++) { + digit = n * a[j] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = (digit % BigInteger_base) | 0; + } + if (carry) { + partial[j] = carry; + } + + return new BigInteger(partial, 1, CONSTRUCT); + }; + + /* + Function: square + Multiply a by itself. + This is slightly faster than regular multiplication, since it removes the + duplicated multiplcations. + Returns: + > this.multiply(this) + See Also: + + */ + BigInteger.prototype.square = function() { + // Normally, squaring a 10-digit number would take 100 multiplications. + // Of these 10 are unique diagonals, of the remaining 90 (100-10), 45 are repeated. + // This procedure saves (N*(N-1))/2 multiplications, (e.g., 45 of 100 multiplies). + // Based on code by Gary Darby, Intellitech Systems Inc., www.DelphiForFun.org + + if (this._s === 0) { + return ZERO; + } + if (this.isUnit()) { + return ONE; + } + + var digits = this._d; + var length = digits.length; + var imult1 = new Array(length + length + 1); + var product, carry, k; + var i; + + // Calculate diagonal + for (i = 0; i < length; i++) { + k = i * 2; + product = digits[i] * digits[i]; + carry = (product / BigInteger_base) | 0; + imult1[k] = product % BigInteger_base; + imult1[k + 1] = carry; + } + + // Calculate repeating part + for (i = 0; i < length; i++) { + carry = 0; + k = i * 2 + 1; + for (var j = i + 1; j < length; j++, k++) { + product = digits[j] * digits[i] * 2 + imult1[k] + carry; + carry = (product / BigInteger_base) | 0; + imult1[k] = product % BigInteger_base; + } + k = length + i; + var digit = carry + imult1[k]; + carry = (digit / BigInteger_base) | 0; + imult1[k] = digit % BigInteger_base; + imult1[k + 1] += carry; + } + + return new BigInteger(imult1, 1, CONSTRUCT); + }; + + /* + Function: quotient + Divide two and truncate towards zero. + throws an exception if *n* is zero. + Parameters: + n - The number to divide *this* by. Will be converted to a . + Returns: + The *this* / *n*, truncated to an integer. + See Also: + , , , , + */ + BigInteger.prototype.quotient = function(n) { + return this.divRem(n)[0]; + }; + + /* + Function: divide + Deprecated synonym for . + */ + BigInteger.prototype.divide = BigInteger.prototype.quotient; + + /* + Function: remainder + Calculate the remainder of two . + throws an exception if *n* is zero. + Parameters: + n - The remainder after *this* is divided *this* by *n*. Will be + converted to a . + Returns: + *this* % *n*. + See Also: + , + */ + BigInteger.prototype.remainder = function(n) { + return this.divRem(n)[1]; + }; + + /* + Function: divRem + Calculate the integer quotient and remainder of two . + throws an exception if *n* is zero. + Parameters: + n - The number to divide *this* by. Will be converted to a . + Returns: + A two-element array containing the quotient and the remainder. + > a.divRem(b) + is exactly equivalent to + > [a.quotient(b), a.remainder(b)] + except it is faster, because they are calculated at the same time. + See Also: + , + */ + BigInteger.prototype.divRem = function(n) { + n = BigInteger(n); + if (n._s === 0) { + throw new Error("Divide by zero"); + } + if (this._s === 0) { + return [ZERO, ZERO]; + } + if (n._d.length === 1) { + return this.divRemSmall(n._s * n._d[0]); + } + + // Test for easy cases -- |n1| <= |n2| + switch (this.compareAbs(n)) { + case 0: // n1 == n2 + return [this._s === n._s ? ONE : M_ONE, ZERO]; + case -1: // |n1| < |n2| + return [ZERO, this]; + } + + var sign = this._s * n._s; + var a = n.abs(); + var b_digits = this._d; + var b_index = b_digits.length; + var digits = n._d.length; + var quot = []; + var guess; + + var part = new BigInteger([], 0, CONSTRUCT); + + while (b_index) { + part._d.unshift(b_digits[--b_index]); + part = new BigInteger(part._d, 1, CONSTRUCT); + + if (part.compareAbs(n) < 0) { + quot.push(0); + continue; + } + if (part._s === 0) { + guess = 0; + } + else { + var xlen = part._d.length, ylen = a._d.length; + var highx = part._d[xlen-1]*BigInteger_base + part._d[xlen-2]; + var highy = a._d[ylen-1]*BigInteger_base + a._d[ylen-2]; + if (part._d.length > a._d.length) { + // The length of part._d can either match a._d length, + // or exceed it by one. + highx = (highx+1)*BigInteger_base; + } + guess = Math.ceil(highx/highy); + } + do { + var check = a.multiplySingleDigit(guess); + if (check.compareAbs(part) <= 0) { + break; + } + guess--; + } while (guess); + + quot.push(guess); + if (!guess) { + continue; + } + var diff = part.subtract(check); + part._d = diff._d.slice(); + } + + return [new BigInteger(quot.reverse(), sign, CONSTRUCT), + new BigInteger(part._d, this._s, CONSTRUCT)]; + }; + + // Throws an exception if n is outside of (-BigInteger.base, -1] or + // [1, BigInteger.base). It's not necessary to call this, since the + // other division functions will call it if they are able to. + BigInteger.prototype.divRemSmall = function(n) { + var r; + n = +n; + if (n === 0) { + throw new Error("Divide by zero"); + } + + var n_s = n < 0 ? -1 : 1; + var sign = this._s * n_s; + n = Math.abs(n); + + if (n < 1 || n >= BigInteger_base) { + throw new Error("Argument out of range"); + } + + if (this._s === 0) { + return [ZERO, ZERO]; + } + + if (n === 1 || n === -1) { + return [(sign === 1) ? this.abs() : new BigInteger(this._d, sign, CONSTRUCT), ZERO]; + } + + // 2 <= n < BigInteger_base + + // divide a single digit by a single digit + if (this._d.length === 1) { + var q = new BigInteger([(this._d[0] / n) | 0], 1, CONSTRUCT); + r = new BigInteger([(this._d[0] % n) | 0], 1, CONSTRUCT); + if (sign < 0) { + q = q.negate(); + } + if (this._s < 0) { + r = r.negate(); + } + return [q, r]; + } + + var digits = this._d.slice(); + var quot = new Array(digits.length); + var part = 0; + var diff = 0; + var i = 0; + var guess; + + while (digits.length) { + part = part * BigInteger_base + digits[digits.length - 1]; + if (part < n) { + quot[i++] = 0; + digits.pop(); + diff = BigInteger_base * diff + part; + continue; + } + if (part === 0) { + guess = 0; + } + else { + guess = (part / n) | 0; + } + + var check = n * guess; + diff = part - check; + quot[i++] = guess; + if (!guess) { + digits.pop(); + continue; + } + + digits.pop(); + part = diff; + } + + r = new BigInteger([diff], 1, CONSTRUCT); + if (this._s < 0) { + r = r.negate(); + } + return [new BigInteger(quot.reverse(), sign, CONSTRUCT), r]; + }; + + /* + Function: isEven + Return true iff *this* is divisible by two. + Note that is even. + Returns: + true if *this* is even, false otherwise. + See Also: + + */ + BigInteger.prototype.isEven = function() { + var digits = this._d; + return this._s === 0 || digits.length === 0 || (digits[0] % 2) === 0; + }; + + /* + Function: isOdd + Return true iff *this* is not divisible by two. + Returns: + true if *this* is odd, false otherwise. + See Also: + + */ + BigInteger.prototype.isOdd = function() { + return !this.isEven(); + }; + + /* + Function: sign + Get the sign of a . + Returns: + * -1 if *this* < 0 + * 0 if *this* == 0 + * +1 if *this* > 0 + See Also: + , , , , + */ + BigInteger.prototype.sign = function() { + return this._s; + }; + + /* + Function: isPositive + Return true iff *this* > 0. + Returns: + true if *this*.compare() == 1. + See Also: + , , , , , + */ + BigInteger.prototype.isPositive = function() { + return this._s > 0; + }; + + /* + Function: isNegative + Return true iff *this* < 0. + Returns: + true if *this*.compare() == -1. + See Also: + , , , , , + */ + BigInteger.prototype.isNegative = function() { + return this._s < 0; + }; + + /* + Function: isZero + Return true iff *this* == 0. + Returns: + true if *this*.compare() == 0. + See Also: + , , , , + */ + BigInteger.prototype.isZero = function() { + return this._s === 0; + }; + + /* + Function: exp10 + Multiply a by a power of 10. + This is equivalent to, but faster than + > if (n >= 0) { + > return this.multiply(BigInteger("1e" + n)); + > } + > else { // n <= 0 + > return this.quotient(BigInteger("1e" + -n)); + > } + Parameters: + n - The power of 10 to multiply *this* by. *n* is converted to a + javascipt number and must be no greater than + (0x7FFFFFFF), or an exception will be thrown. + Returns: + *this* * (10 ** *n*), truncated to an integer if necessary. + See Also: + , + */ + BigInteger.prototype.exp10 = function(n) { + n = +n; + if (n === 0) { + return this; + } + if (Math.abs(n) > Number(MAX_EXP)) { + throw new Error("exponent too large in BigInteger.exp10"); + } + // Optimization for this == 0. This also keeps us from having to trim zeros in the positive n case + if (this._s === 0) { + return ZERO; + } + if (n > 0) { + var k = new BigInteger(this._d.slice(), this._s, CONSTRUCT); + + for (; n >= BigInteger_base_log10; n -= BigInteger_base_log10) { + k._d.unshift(0); + } + if (n == 0) + return k; + k._s = 1; + k = k.multiplySingleDigit(Math.pow(10, n)); + return (this._s < 0 ? k.negate() : k); + } else if (-n >= this._d.length*BigInteger_base_log10) { + return ZERO; + } else { + var k = new BigInteger(this._d.slice(), this._s, CONSTRUCT); + + for (n = -n; n >= BigInteger_base_log10; n -= BigInteger_base_log10) { + k._d.shift(); + } + return (n == 0) ? k : k.divRemSmall(Math.pow(10, n))[0]; + } + }; + + /* + Function: pow + Raise a to a power. + In this implementation, 0**0 is 1. + Parameters: + n - The exponent to raise *this* by. *n* must be no greater than + (0x7FFFFFFF), or an exception will be thrown. + Returns: + *this* raised to the *nth* power. + See Also: + + */ + BigInteger.prototype.pow = function(n) { + if (this.isUnit()) { + if (this._s > 0) { + return this; + } + else { + return BigInteger(n).isOdd() ? this : this.negate(); + } + } + + n = BigInteger(n); + if (n._s === 0) { + return ONE; + } + else if (n._s < 0) { + if (this._s === 0) { + throw new Error("Divide by zero"); + } + else { + return ZERO; + } + } + if (this._s === 0) { + return ZERO; + } + if (n.isUnit()) { + return this; + } + + if (n.compareAbs(MAX_EXP) > 0) { + throw new Error("exponent too large in BigInteger.pow"); + } + var x = this; + var aux = ONE; + var two = BigInteger.small[2]; + + while (n.isPositive()) { + if (n.isOdd()) { + aux = aux.multiply(x); + if (n.isUnit()) { + return aux; + } + } + x = x.square(); + n = n.quotient(two); + } + + return aux; + }; + + /* + Function: modPow + Raise a to a power (mod m). + Because it is reduced by a modulus, is not limited by + like . + Parameters: + exponent - The exponent to raise *this* by. Must be positive. + modulus - The modulus. + Returns: + *this* ^ *exponent* (mod *modulus*). + See Also: + , + */ + BigInteger.prototype.modPow = function(exponent, modulus) { + var result = ONE; + var base = this; + + while (exponent.isPositive()) { + if (exponent.isOdd()) { + result = result.multiply(base).remainder(modulus); + } + + exponent = exponent.quotient(BigInteger.small[2]); + if (exponent.isPositive()) { + base = base.square().remainder(modulus); + } + } + + return result; + }; + + /* + Function: log + Get the natural logarithm of a as a native JavaScript number. + This is equivalent to + > Math.log(this.toJSValue()) + but handles values outside of the native number range. + Returns: + log( *this* ) + See Also: + + */ + BigInteger.prototype.log = function() { + switch (this._s) { + case 0: return -Infinity; + case -1: return NaN; + default: // Fall through. + } + + var l = this._d.length; + + if (l*BigInteger_base_log10 < 30) { + return Math.log(this.valueOf()); + } + + var N = Math.ceil(30/BigInteger_base_log10); + var firstNdigits = this._d.slice(l - N); + return Math.log((new BigInteger(firstNdigits, 1, CONSTRUCT)).valueOf()) + (l - N) * Math.log(BigInteger_base); + }; + + /* + Function: valueOf + Convert a to a native JavaScript integer. + This is called automatically by JavaScipt to convert a to a + native value. + Returns: + > parseInt(this.toString(), 10) + See Also: + , + */ + BigInteger.prototype.valueOf = function() { + return parseInt(this.toString(), 10); + }; + + /* + Function: toJSValue + Convert a to a native JavaScript integer. + This is the same as valueOf, but more explicitly named. + Returns: + > parseInt(this.toString(), 10) + See Also: + , + */ + BigInteger.prototype.toJSValue = function() { + return parseInt(this.toString(), 10); + }; + + + /* + Function: lowVal + Author: Lucas Jones + */ + BigInteger.prototype.lowVal = function () { + return this._d[0] || 0; + }; + + var MAX_EXP = BigInteger(0x7FFFFFFF); + // Constant: MAX_EXP + // The largest exponent allowed in and (0x7FFFFFFF or 2147483647). + BigInteger.MAX_EXP = MAX_EXP; + + (function() { + function makeUnary(fn) { + return function(a) { + return fn.call(BigInteger(a)); + }; + } + + function makeBinary(fn) { + return function(a, b) { + return fn.call(BigInteger(a), BigInteger(b)); + }; + } + + function makeTrinary(fn) { + return function(a, b, c) { + return fn.call(BigInteger(a), BigInteger(b), BigInteger(c)); + }; + } + + (function() { + var i, fn; + var unary = "toJSValue,isEven,isOdd,sign,isZero,isNegative,abs,isUnit,square,negate,isPositive,toString,next,prev,log".split(","); + var binary = "compare,remainder,divRem,subtract,add,quotient,divide,multiply,pow,compareAbs".split(","); + var trinary = ["modPow"]; + + for (i = 0; i < unary.length; i++) { + fn = unary[i]; + BigInteger[fn] = makeUnary(BigInteger.prototype[fn]); + } + + for (i = 0; i < binary.length; i++) { + fn = binary[i]; + BigInteger[fn] = makeBinary(BigInteger.prototype[fn]); + } + + for (i = 0; i < trinary.length; i++) { + fn = trinary[i]; + BigInteger[fn] = makeTrinary(BigInteger.prototype[fn]); + } + + BigInteger.exp10 = function(x, n) { + return BigInteger(x).exp10(n); + }; + })(); + })(); + + exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt + })(typeof exports !== 'undefined' ? exports : this); +},{}],12:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2784,7 +4276,234 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":3}],12:[function(require,module,exports){ +},{"buffer":3}],13:[function(require,module,exports){ +var JSBigInt = require('./biginteger')['JSBigInt']; + +/** +Copyright (c) 2017, moneroexamples + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Parts of the project are originally copyright (c) 2014-2017, MyMonero.com +*/ + +var cnBase58 = (function () { + var b58 = {}; + + var alphabet_str = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + var alphabet = []; + for (var i = 0; i < alphabet_str.length; i++) { + alphabet.push(alphabet_str.charCodeAt(i)); + } + var encoded_block_sizes = [0, 2, 3, 5, 6, 7, 9, 10, 11]; + + var alphabet_size = alphabet.length; + var full_block_size = 8; + var full_encoded_block_size = 11; + + var UINT64_MAX = new JSBigInt(2).pow(64); + + function hextobin(hex) { + if (hex.length % 2 !== 0) throw "Hex string has invalid length!"; + var res = new Uint8Array(hex.length / 2); + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); + } + return res; + } + + function bintohex(bin) { + var out = []; + for (var i = 0; i < bin.length; ++i) { + out.push(("0" + bin[i].toString(16)).slice(-2)); + } + return out.join(""); + } + + function strtobin(str) { + var res = new Uint8Array(str.length); + for (var i = 0; i < str.length; i++) { + res[i] = str.charCodeAt(i); + } + return res; + } + + function bintostr(bin) { + var out = []; + for (var i = 0; i < bin.length; i++) { + out.push(String.fromCharCode(bin[i])); + } + return out.join(""); + } + + function uint8_be_to_64(data) { + if (data.length < 1 || data.length > 8) { + throw "Invalid input length"; + } + var res = JSBigInt.ZERO; + var twopow8 = new JSBigInt(2).pow(8); + var i = 0; + switch (9 - data.length) { + case 1: + res = res.add(data[i++]); + case 2: + res = res.multiply(twopow8).add(data[i++]); + case 3: + res = res.multiply(twopow8).add(data[i++]); + case 4: + res = res.multiply(twopow8).add(data[i++]); + case 5: + res = res.multiply(twopow8).add(data[i++]); + case 6: + res = res.multiply(twopow8).add(data[i++]); + case 7: + res = res.multiply(twopow8).add(data[i++]); + case 8: + res = res.multiply(twopow8).add(data[i++]); + break; + default: + throw "Impossible condition"; + } + return res; + } + + function uint64_to_8be(num, size) { + var res = new Uint8Array(size); + if (size < 1 || size > 8) { + throw "Invalid input length"; + } + var twopow8 = new JSBigInt(2).pow(8); + for (var i = size - 1; i >= 0; i--) { + res[i] = num.remainder(twopow8).toJSValue(); + num = num.divide(twopow8); + } + return res; + } + + b58.encode_block = function (data, buf, index) { + if (data.length < 1 || data.length > full_encoded_block_size) { + throw "Invalid block length: " + data.length; + } + var num = uint8_be_to_64(data); + var i = encoded_block_sizes[data.length] - 1; + // while num > 0 + while (num.compare(0) === 1) { + var div = num.divRem(alphabet_size); + // remainder = num % alphabet_size + var remainder = div[1]; + // num = num / alphabet_size + num = div[0]; + buf[index + i] = alphabet[remainder.toJSValue()]; + i--; + } + return buf; + }; + + b58.encode = function (hex) { + var data = hextobin(hex); + if (data.length === 0) { + return ""; + } + var full_block_count = Math.floor(data.length / full_block_size); + var last_block_size = data.length % full_block_size; + var res_size = full_block_count * full_encoded_block_size + encoded_block_sizes[last_block_size]; + + var res = new Uint8Array(res_size); + var i; + for (i = 0; i < res_size; ++i) { + res[i] = alphabet[0]; + } + for (i = 0; i < full_block_count; i++) { + res = b58.encode_block(data.subarray(i * full_block_size, i * full_block_size + full_block_size), res, i * full_encoded_block_size); + } + if (last_block_size > 0) { + res = b58.encode_block(data.subarray(full_block_count * full_block_size, full_block_count * full_block_size + last_block_size), res, full_block_count * full_encoded_block_size) + } + return bintostr(res); + }; + + b58.decode_block = function (data, buf, index) { + if (data.length < 1 || data.length > full_encoded_block_size) { + throw "Invalid block length: " + data.length; + } + + var res_size = encoded_block_sizes.indexOf(data.length); + if (res_size <= 0) { + throw "Invalid block size"; + } + var res_num = new JSBigInt(0); + var order = new JSBigInt(1); + for (var i = data.length - 1; i >= 0; i--) { + var digit = alphabet.indexOf(data[i]); + if (digit < 0) { + throw "Invalid symbol"; + } + var product = order.multiply(digit).add(res_num); + // if product > UINT64_MAX + if (product.compare(UINT64_MAX) === 1) { + throw "Overflow"; + } + res_num = product; + order = order.multiply(alphabet_size); + } + if (res_size < full_block_size && (new JSBigInt(2).pow(8 * res_size).compare(res_num) <= 0)) { + throw "Overflow 2"; + } + buf.set(uint64_to_8be(res_num, res_size), index); + return buf; + }; + + b58.decode = function (enc) { + enc = strtobin(enc); + if (enc.length === 0) { + return ""; + } + var full_block_count = Math.floor(enc.length / full_encoded_block_size); + var last_block_size = enc.length % full_encoded_block_size; + var last_block_decoded_size = encoded_block_sizes.indexOf(last_block_size); + if (last_block_decoded_size < 0) { + throw "Invalid encoded length"; + } + var data_size = full_block_count * full_block_size + last_block_decoded_size; + var data = new Uint8Array(data_size); + for (var i = 0; i < full_block_count; i++) { + data = b58.decode_block(enc.subarray(i * full_encoded_block_size, i * full_encoded_block_size + full_encoded_block_size), data, i * full_block_size); + } + if (last_block_size > 0) { + data = b58.decode_block(enc.subarray(full_block_count * full_encoded_block_size, full_block_count * full_encoded_block_size + last_block_size), data, full_block_count * full_block_size); + } + return bintohex(data); + }; + + return b58; +})(); +module.exports = cnBase58; +},{"./biginteger":11}],14:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -2880,7 +4599,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":10}],13:[function(require,module,exports){ +},{"./bech32":10}],15:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -3524,7 +5243,7 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":6}],14:[function(require,module,exports){ +},{"_process":6}],16:[function(require,module,exports){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; @@ -3561,13 +5280,17 @@ module.exports = { }, keccak256: function (hexString) { return keccak256(hexString); + }, + keccak256Checksum: function (payload) { + return keccak256(payload).toString().substr(0, 8); } }; -},{"./blake256":11,"./sha3":13,"jssha/src/sha256":5}],15:[function(require,module,exports){ +},{"./blake256":12,"./sha3":15,"jssha/src/sha256":5}],17:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); +var XMRValidator = require('./monero_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -3759,6 +5482,12 @@ var CURRENCIES = [{ name: 'bankex', symbol: 'bkx', validator: ETHValidator +},{ + name: 'monero', + symbol: 'xmr', + addressTypes: {prod: ['18'], testnet: ['53']}, + iAddressTypes: {prod: ['19'], testnet: ['54']}, + validator: XMRValidator }]; @@ -3775,7 +5504,7 @@ module.exports = { } }; -},{"./bitcoin_validator":8,"./ethereum_validator":16,"./ripple_validator":17}],16:[function(require,module,exports){ +},{"./bitcoin_validator":8,"./ethereum_validator":18,"./monero_validator":19,"./ripple_validator":20}],18:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -3811,7 +5540,69 @@ module.exports = { } }; -},{"./crypto/utils":14}],17:[function(require,module,exports){ +},{"./crypto/utils":16}],19:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var cnBase58 = require('./crypto/cnBase58'); + +var DEFAULT_NETWORK_TYPE = 'prod'; +var addressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$'); +var integratedAddressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$'); + +function validateNetwork(decoded, currency, networkType, addressType){ + var network = currency.addressTypes; + if(addressType == 'integrated'){ + network = currency.iAddressTypes; + } + + switch(networkType){ + case 'prod': + return parseInt(decoded.substr(0,2), 16) == network.prod[0]; + case 'testnet': + return parseInt(decoded.substr(0,2), 16) == network.testnet[0]; + case 'both': + return parseInt(decoded.substr(0,2), 16) == network.prod[0] || parseInt(decoded.substr(0,2), 16) == network.testnet[0]; + default: + return false; + } +} + +function hextobin(hex) { + if (hex.length % 2 !== 0) return null; + var res = new Uint8Array(hex.length / 2); + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); + } + return res; +} + +module.exports = { + isValidAddress: function (address, currency, networkType) { + networkType = networkType || DEFAULT_NETWORK_TYPE; + var addressType = 'standard'; + if(!addressRegTest.test(address)){ + if(integratedAddressRegTest.test(address)){ + addressType = 'integrated'; + } + else{ + return false; + } + } + + var decodedAddrStr = cnBase58.decode(address); + if(!decodedAddrStr) + return false; + + if(!validateNetwork(decodedAddrStr, currency, networkType, addressType)) + return false; + + var addrChecksum = decodedAddrStr.slice(-8); + var hashChecksum = cryptoUtils.keccak256Checksum(hextobin(decodedAddrStr.slice(0, -8))); + + return addrChecksum === hashChecksum; + } +}; + +},{"./crypto/cnBase58":13,"./crypto/utils":16}],20:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -3841,7 +5632,7 @@ module.exports = { } }; -},{"./crypto/utils":14,"base-x":1}],18:[function(require,module,exports){ +},{"./crypto/utils":16,"base-x":1}],21:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -3858,5 +5649,5 @@ module.exports = { }, }; -},{"./currencies":15}]},{},[18])(18) +},{"./currencies":17}]},{},[21])(21) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index ec0dbbbc..e4c416f5 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,a,u){function f(r,t){if(!a[r]){if(!s[r]){var e="function"==typeof require&&require;if(!t&&e)return e(r,!0);if(h)return h(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[r]={exports:{}};s[r][0].call(o.exports,function(t){return f(s[r][1][t]||t)},o,o.exports,i,s,a,u)}return a[r].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[s++]=r>>8&255,i[s++]=255&r;var f,h;2===o&&(r=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,i[s++]=255&r);1===o&&(r=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,i[s++]=r>>8&255,i[s++]=255&r);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o=[],i=0,s=e-n;i>2]+a[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],o.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"="));return o.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return w(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,O(R(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return u=this,f=r,h=e,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,O(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function U(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function S(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=0,s=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,o),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,g,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,f,o)};break;case"B64":e=function(t){return E(t,f,o)};break;case"BYTES":e=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",a=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,o[s++]=r>>8&255,o[s++]=255&r;var f,h;2===i&&(r=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,o[s++]=255&r);1===i&&(r=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,o[s++]=r>>8&255,o[s++]=255&r);return o},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,i=[],o=0,s=e-n;o>2]+a[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],i.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"="));return i.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+a[i>>12&63]+a[i>>6&63]+a[63&i]);return o.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),o=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var i=2147483647;function s(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:L(t).length;r=(""+r).toLowerCase(),i=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function g(t,r,e,n,i){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:y(t,r,e,n,i);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):y(t,[r],e,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,r,e,n,i){var o,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(i){var h=-1;for(o=e;o>>10&1023|55296),h=56320|1023&h),n.push(h),i+=c}return function(t){var r=t.length;if(r<=_)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return A(this,r,e);case"latin1":case"binary":return E(this,r,e);case"base64":return b(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),""},c.prototype.compare=function(t,r,e,n,i){if(H(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&e<=r)return 0;if(i<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,M(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return u=this,f=r,h=e,M(O(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,M(function(t,r){for(var e,n,i,o=[],s=0;s>8,i=e%256,o.push(i),o.push(n);return o}(t,(o=this).length-s),o,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,r,e){var n="";e=Math.min(t.length,e);for(var i=r;it.length)throw new RangeError("Index out of range")}function U(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function S(t,r,e,n,i){return r=+r,e>>>=0,i||U(t,0,e,4),o.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,i){return r=+r,e>>>=0,i||U(t,0,e,8),o.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t],i=1,o=0;++o>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t+--r],i=1;0>>=0,r||x(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||x(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||x(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t],i=1,o=0;++o>>=0,r>>>=0,e||x(t,r,this.length);for(var n=r,i=1,o=this[t+--n];0>>=0,r||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||x(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||x(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||x(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||x(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||x(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||x(t,8,this.length),o.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||T(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o>>=0,e>>>=0,n)||T(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;0<=--i&&(o*=256);)this[r+i]=t/o&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var i=Math.pow(2,8*e-1);T(this,t,r,e,i-1,-i)}var o=0,s=1,a=0;for(this[r]=255&t;++o>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var i=Math.pow(2,8*e-1);T(this,t,r,e,i-1,-i)}var o=e-1,s=1,a=0;for(this[r+o]=255&t;0<=--o&&(s*=256);)t<0&&0===a&&0!==this[r+o+1]&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(o=r;o>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function M(t,r,e,n){for(var i=0;i=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function H(t,r){return t instanceof r||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===r.name}function F(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,c=e?i-1:0,l=e?-1:1,p=t[r+c];for(c+=l,o=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,i),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,i),s=0));8<=i;t[e+p]=255&a,p+=d,a/=256,i-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return F(t,r,s)},l=function(t,r,e,n){var i,o;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[i]=4294967295&r,t[i-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,y,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,i,o;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(i=k(r),t){case"HEX":e=function(t){return _(t,f,i)};break;case"B64":e=function(t){return A(t,f,i)};break;case"BYTES":e=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(y.slice(),v,g,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return e.outputUpper?o.toUpperCase():o}function A(t,r,e){var n,i,o,s="",a=r/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)s+=8*n+6*i<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):e.b64Pad;return s}function E(t,r){var e,n,i="",o=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,r){var e,n,i=r/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),e=0;e>>2]>>>8*(3+e%4*-1)&255;return o}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function x(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,i,o,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=o;)r.push(0);r[o]|=i<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,i,o,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=i[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,i,o,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i + object. + As an example, these calls are equivalent. + > BigInteger(4).multiply(5); // returns BigInteger(20); + > BigInteger.multiply(4, 5); // returns BigInteger(20); + > var a = 42; + > var a = BigInteger.toJSValue("0b101010"); // Not completely useless... + */ + + var CONSTRUCT = {}; // Unique token to call "private" version of constructor + + /* + Constructor: BigInteger() + Convert a value to a . + Although is the constructor for objects, it is + best not to call it as a constructor. If *n* is a object, it is + simply returned as-is. Otherwise, is equivalent to + without a radix argument. + > var n0 = BigInteger(); // Same as + > var n1 = BigInteger("123"); // Create a new with value 123 + > var n2 = BigInteger(123); // Create a new with value 123 + > var n3 = BigInteger(n2); // Return n2, unchanged + The constructor form only takes an array and a sign. *n* must be an + array of numbers in little-endian order, where each digit is between 0 + and BigInteger.base. The second parameter sets the sign: -1 for + negative, +1 for positive, or 0 for zero. The array is *not copied and + may be modified*. If the array contains only zeros, the sign parameter + is ignored and is forced to zero. + > new BigInteger([5], -1): create a new BigInteger with value -5 + Parameters: + n - Value to convert to a . + Returns: + A value. + See Also: + , + */ + function BigInteger(n, s, token) { + + if (token !== CONSTRUCT) { + if (n instanceof BigInteger) { + return n; + } + else if (typeof n === "undefined") { + return ZERO; + } + return BigInteger.parse(n); + } + + n = n || []; // Provide the nullary constructor for subclasses. + while (n.length && !n[n.length - 1]) { + --n.length; + } + this._d = n; + this._s = n.length ? (s || 1) : 0; + } + + BigInteger._construct = function(n, s) { + return new BigInteger(n, s, CONSTRUCT); + }; + + // Base-10 speedup hacks in parse, toString, exp10 and log functions + // require base to be a power of 10. 10^7 is the largest such power + // that won't cause a precision loss when digits are multiplied. + var BigInteger_base = 10000000; + var BigInteger_base_log10 = 7; + + BigInteger.base = BigInteger_base; + BigInteger.base_log10 = BigInteger_base_log10; + + var ZERO = new BigInteger([], 0, CONSTRUCT); + // Constant: ZERO + // 0. + BigInteger.ZERO = ZERO; + + var ONE = new BigInteger([1], 1, CONSTRUCT); + // Constant: ONE + // 1. + BigInteger.ONE = ONE; + + var M_ONE = new BigInteger(ONE._d, -1, CONSTRUCT); + // Constant: M_ONE + // -1. + BigInteger.M_ONE = M_ONE; + + // Constant: _0 + // Shortcut for . + BigInteger._0 = ZERO; + + // Constant: _1 + // Shortcut for . + BigInteger._1 = ONE; + + /* + Constant: small + Array of from 0 to 36. + These are used internally for parsing, but useful when you need a "small" + . + See Also: + , , <_0>, <_1> + */ + BigInteger.small = [ + ZERO, + ONE, + /* Assuming BigInteger_base > 36 */ + new BigInteger( [2], 1, CONSTRUCT), + new BigInteger( [3], 1, CONSTRUCT), + new BigInteger( [4], 1, CONSTRUCT), + new BigInteger( [5], 1, CONSTRUCT), + new BigInteger( [6], 1, CONSTRUCT), + new BigInteger( [7], 1, CONSTRUCT), + new BigInteger( [8], 1, CONSTRUCT), + new BigInteger( [9], 1, CONSTRUCT), + new BigInteger([10], 1, CONSTRUCT), + new BigInteger([11], 1, CONSTRUCT), + new BigInteger([12], 1, CONSTRUCT), + new BigInteger([13], 1, CONSTRUCT), + new BigInteger([14], 1, CONSTRUCT), + new BigInteger([15], 1, CONSTRUCT), + new BigInteger([16], 1, CONSTRUCT), + new BigInteger([17], 1, CONSTRUCT), + new BigInteger([18], 1, CONSTRUCT), + new BigInteger([19], 1, CONSTRUCT), + new BigInteger([20], 1, CONSTRUCT), + new BigInteger([21], 1, CONSTRUCT), + new BigInteger([22], 1, CONSTRUCT), + new BigInteger([23], 1, CONSTRUCT), + new BigInteger([24], 1, CONSTRUCT), + new BigInteger([25], 1, CONSTRUCT), + new BigInteger([26], 1, CONSTRUCT), + new BigInteger([27], 1, CONSTRUCT), + new BigInteger([28], 1, CONSTRUCT), + new BigInteger([29], 1, CONSTRUCT), + new BigInteger([30], 1, CONSTRUCT), + new BigInteger([31], 1, CONSTRUCT), + new BigInteger([32], 1, CONSTRUCT), + new BigInteger([33], 1, CONSTRUCT), + new BigInteger([34], 1, CONSTRUCT), + new BigInteger([35], 1, CONSTRUCT), + new BigInteger([36], 1, CONSTRUCT) + ]; + + // Used for parsing/radix conversion + BigInteger.digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""); + + /* + Method: toString + Convert a to a string. + When *base* is greater than 10, letters are upper case. + Parameters: + base - Optional base to represent the number in (default is base 10). + Must be between 2 and 36 inclusive, or an Error will be thrown. + Returns: + The string representation of the . + */ + BigInteger.prototype.toString = function(base) { + base = +base || 10; + if (base < 2 || base > 36) { + throw new Error("illegal radix " + base + "."); + } + if (this._s === 0) { + return "0"; + } + if (base === 10) { + var str = this._s < 0 ? "-" : ""; + str += this._d[this._d.length - 1].toString(); + for (var i = this._d.length - 2; i >= 0; i--) { + var group = this._d[i].toString(); + while (group.length < BigInteger_base_log10) group = '0' + group; + str += group; + } + return str; + } + else { + var numerals = BigInteger.digits; + base = BigInteger.small[base]; + var sign = this._s; + + var n = this.abs(); + var digits = []; + var digit; + + while (n._s !== 0) { + var divmod = n.divRem(base); + n = divmod[0]; + digit = divmod[1]; + // TODO: This could be changed to unshift instead of reversing at the end. + // Benchmark both to compare speeds. + digits.push(numerals[digit.valueOf()]); + } + return (sign < 0 ? "-" : "") + digits.reverse().join(""); + } + }; + + // Verify strings for parsing + BigInteger.radixRegex = [ + /^$/, + /^$/, + /^[01]*$/, + /^[012]*$/, + /^[0-3]*$/, + /^[0-4]*$/, + /^[0-5]*$/, + /^[0-6]*$/, + /^[0-7]*$/, + /^[0-8]*$/, + /^[0-9]*$/, + /^[0-9aA]*$/, + /^[0-9abAB]*$/, + /^[0-9abcABC]*$/, + /^[0-9a-dA-D]*$/, + /^[0-9a-eA-E]*$/, + /^[0-9a-fA-F]*$/, + /^[0-9a-gA-G]*$/, + /^[0-9a-hA-H]*$/, + /^[0-9a-iA-I]*$/, + /^[0-9a-jA-J]*$/, + /^[0-9a-kA-K]*$/, + /^[0-9a-lA-L]*$/, + /^[0-9a-mA-M]*$/, + /^[0-9a-nA-N]*$/, + /^[0-9a-oA-O]*$/, + /^[0-9a-pA-P]*$/, + /^[0-9a-qA-Q]*$/, + /^[0-9a-rA-R]*$/, + /^[0-9a-sA-S]*$/, + /^[0-9a-tA-T]*$/, + /^[0-9a-uA-U]*$/, + /^[0-9a-vA-V]*$/, + /^[0-9a-wA-W]*$/, + /^[0-9a-xA-X]*$/, + /^[0-9a-yA-Y]*$/, + /^[0-9a-zA-Z]*$/ + ]; + + /* + Function: parse + Parse a string into a . + *base* is optional but, if provided, must be from 2 to 36 inclusive. If + *base* is not provided, it will be guessed based on the leading characters + of *s* as follows: + - "0x" or "0X": *base* = 16 + - "0c" or "0C": *base* = 8 + - "0b" or "0B": *base* = 2 + - else: *base* = 10 + If no base is provided, or *base* is 10, the number can be in exponential + form. For example, these are all valid: + > BigInteger.parse("1e9"); // Same as "1000000000" + > BigInteger.parse("1.234*10^3"); // Same as 1234 + > BigInteger.parse("56789 * 10 ** -2"); // Same as 567 + If any characters fall outside the range defined by the radix, an exception + will be thrown. + Parameters: + s - The string to parse. + base - Optional radix (default is to guess based on *s*). + Returns: + a instance. + */ + BigInteger.parse = function(s, base) { + // Expands a number in exponential form to decimal form. + // expandExponential("-13.441*10^5") === "1344100"; + // expandExponential("1.12300e-1") === "0.112300"; + // expandExponential(1000000000000000000000000000000) === "1000000000000000000000000000000"; + function expandExponential(str) { + str = str.replace(/\s*[*xX]\s*10\s*(\^|\*\*)\s*/, "e"); + + return str.replace(/^([+\-])?(\d+)\.?(\d*)[eE]([+\-]?\d+)$/, function(x, s, n, f, c) { + c = +c; + var l = c < 0; + var i = n.length + c; + x = (l ? n : f).length; + c = ((c = Math.abs(c)) >= x ? c - x + l : 0); + var z = (new Array(c + 1)).join("0"); + var r = n + f; + return (s || "") + (l ? r = z + r : r += z).substr(0, i += l ? z.length : 0) + (i < r.length ? "." + r.substr(i) : ""); + }); + } + + s = s.toString(); + if (typeof base === "undefined" || +base === 10) { + s = expandExponential(s); + } + + var prefixRE; + if (typeof base === "undefined") { + prefixRE = '0[xcb]'; + } + else if (base == 16) { + prefixRE = '0x'; + } + else if (base == 8) { + prefixRE = '0c'; + } + else if (base == 2) { + prefixRE = '0b'; + } + else { + prefixRE = ''; + } + var parts = new RegExp('^([+\\-]?)(' + prefixRE + ')?([0-9a-z]*)(?:\\.\\d*)?$', 'i').exec(s); + if (parts) { + var sign = parts[1] || "+"; + var baseSection = parts[2] || ""; + var digits = parts[3] || ""; + + if (typeof base === "undefined") { + // Guess base + if (baseSection === "0x" || baseSection === "0X") { // Hex + base = 16; + } + else if (baseSection === "0c" || baseSection === "0C") { // Octal + base = 8; + } + else if (baseSection === "0b" || baseSection === "0B") { // Binary + base = 2; + } + else { + base = 10; + } + } + else if (base < 2 || base > 36) { + throw new Error("Illegal radix " + base + "."); + } + + base = +base; + + // Check for digits outside the range + if (!(BigInteger.radixRegex[base].test(digits))) { + throw new Error("Bad digit for radix " + base); + } + + // Strip leading zeros, and convert to array + digits = digits.replace(/^0+/, "").split(""); + if (digits.length === 0) { + return ZERO; + } + + // Get the sign (we know it's not zero) + sign = (sign === "-") ? -1 : 1; + + // Optimize 10 + if (base == 10) { + var d = []; + while (digits.length >= BigInteger_base_log10) { + d.push(parseInt(digits.splice(digits.length-BigInteger.base_log10, BigInteger.base_log10).join(''), 10)); + } + d.push(parseInt(digits.join(''), 10)); + return new BigInteger(d, sign, CONSTRUCT); + } + + // Do the conversion + var d = ZERO; + base = BigInteger.small[base]; + var small = BigInteger.small; + for (var i = 0; i < digits.length; i++) { + d = d.multiply(base).add(small[parseInt(digits[i], 36)]); + } + return new BigInteger(d._d, sign, CONSTRUCT); + } + else { + throw new Error("Invalid BigInteger format: " + s); + } + }; + + /* + Function: add + Add two . + Parameters: + n - The number to add to *this*. Will be converted to a . + Returns: + The numbers added together. + See Also: + , , , + */ + BigInteger.prototype.add = function(n) { + if (this._s === 0) { + return BigInteger(n); + } + + n = BigInteger(n); + if (n._s === 0) { + return this; + } + if (this._s !== n._s) { + n = n.negate(); + return this.subtract(n); + } + + var a = this._d; + var b = n._d; + var al = a.length; + var bl = b.length; + var sum = new Array(Math.max(al, bl) + 1); + var size = Math.min(al, bl); + var carry = 0; + var digit; + + for (var i = 0; i < size; i++) { + digit = a[i] + b[i] + carry; + sum[i] = digit % BigInteger_base; + carry = (digit / BigInteger_base) | 0; + } + if (bl > al) { + a = b; + al = bl; + } + for (i = size; carry && i < al; i++) { + digit = a[i] + carry; + sum[i] = digit % BigInteger_base; + carry = (digit / BigInteger_base) | 0; + } + if (carry) { + sum[i] = carry; + } + + for ( ; i < al; i++) { + sum[i] = a[i]; + } + + return new BigInteger(sum, this._s, CONSTRUCT); + }; + + /* + Function: negate + Get the additive inverse of a . + Returns: + A with the same magnatude, but with the opposite sign. + See Also: + + */ + BigInteger.prototype.negate = function() { + return new BigInteger(this._d, (-this._s) | 0, CONSTRUCT); + }; + + /* + Function: abs + Get the absolute value of a . + Returns: + A with the same magnatude, but always positive (or zero). + See Also: + + */ + BigInteger.prototype.abs = function() { + return (this._s < 0) ? this.negate() : this; + }; + + /* + Function: subtract + Subtract two . + Parameters: + n - The number to subtract from *this*. Will be converted to a . + Returns: + The *n* subtracted from *this*. + See Also: + , , , + */ + BigInteger.prototype.subtract = function(n) { + if (this._s === 0) { + return BigInteger(n).negate(); + } + + n = BigInteger(n); + if (n._s === 0) { + return this; + } + if (this._s !== n._s) { + n = n.negate(); + return this.add(n); + } + + var m = this; + // negative - negative => -|a| - -|b| => -|a| + |b| => |b| - |a| + if (this._s < 0) { + m = new BigInteger(n._d, 1, CONSTRUCT); + n = new BigInteger(this._d, 1, CONSTRUCT); + } + + // Both are positive => a - b + var sign = m.compareAbs(n); + if (sign === 0) { + return ZERO; + } + else if (sign < 0) { + // swap m and n + var t = n; + n = m; + m = t; + } + + // a > b + var a = m._d; + var b = n._d; + var al = a.length; + var bl = b.length; + var diff = new Array(al); // al >= bl since a > b + var borrow = 0; + var i; + var digit; + + for (i = 0; i < bl; i++) { + digit = a[i] - borrow - b[i]; + if (digit < 0) { + digit += BigInteger_base; + borrow = 1; + } + else { + borrow = 0; + } + diff[i] = digit; + } + for (i = bl; i < al; i++) { + digit = a[i] - borrow; + if (digit < 0) { + digit += BigInteger_base; + } + else { + diff[i++] = digit; + break; + } + diff[i] = digit; + } + for ( ; i < al; i++) { + diff[i] = a[i]; + } + + return new BigInteger(diff, sign, CONSTRUCT); + }; + + (function() { + function addOne(n, sign) { + var a = n._d; + var sum = a.slice(); + var carry = true; + var i = 0; + + while (true) { + var digit = (a[i] || 0) + 1; + sum[i] = digit % BigInteger_base; + if (digit <= BigInteger_base - 1) { + break; + } + ++i; + } + + return new BigInteger(sum, sign, CONSTRUCT); + } + + function subtractOne(n, sign) { + var a = n._d; + var sum = a.slice(); + var borrow = true; + var i = 0; + + while (true) { + var digit = (a[i] || 0) - 1; + if (digit < 0) { + sum[i] = digit + BigInteger_base; + } + else { + sum[i] = digit; + break; + } + ++i; + } + + return new BigInteger(sum, sign, CONSTRUCT); + } + + /* + Function: next + Get the next (add one). + Returns: + *this* + 1. + See Also: + , + */ + BigInteger.prototype.next = function() { + switch (this._s) { + case 0: + return ONE; + case -1: + return subtractOne(this, -1); + // case 1: + default: + return addOne(this, 1); + } + }; + + /* + Function: prev + Get the previous (subtract one). + Returns: + *this* - 1. + See Also: + , + */ + BigInteger.prototype.prev = function() { + switch (this._s) { + case 0: + return M_ONE; + case -1: + return addOne(this, -1); + // case 1: + default: + return subtractOne(this, 1); + } + }; + })(); + + /* + Function: compareAbs + Compare the absolute value of two . + Calling is faster than calling twice, then . + Parameters: + n - The number to compare to *this*. Will be converted to a . + Returns: + -1, 0, or +1 if *|this|* is less than, equal to, or greater than *|n|*. + See Also: + , + */ + BigInteger.prototype.compareAbs = function(n) { + if (this === n) { + return 0; + } + + if (!(n instanceof BigInteger)) { + if (!isFinite(n)) { + return(isNaN(n) ? n : -1); + } + n = BigInteger(n); + } + + if (this._s === 0) { + return (n._s !== 0) ? -1 : 0; + } + if (n._s === 0) { + return 1; + } + + var l = this._d.length; + var nl = n._d.length; + if (l < nl) { + return -1; + } + else if (l > nl) { + return 1; + } + + var a = this._d; + var b = n._d; + for (var i = l-1; i >= 0; i--) { + if (a[i] !== b[i]) { + return a[i] < b[i] ? -1 : 1; + } + } + + return 0; + }; + + /* + Function: compare + Compare two . + Parameters: + n - The number to compare to *this*. Will be converted to a . + Returns: + -1, 0, or +1 if *this* is less than, equal to, or greater than *n*. + See Also: + , , , + */ + BigInteger.prototype.compare = function(n) { + if (this === n) { + return 0; + } + + n = BigInteger(n); + + if (this._s === 0) { + return -n._s; + } + + if (this._s === n._s) { // both positive or both negative + var cmp = this.compareAbs(n); + return cmp * this._s; + } + else { + return this._s; + } + }; + + /* + Function: isUnit + Return true iff *this* is either 1 or -1. + Returns: + true if *this* compares equal to or . + See Also: + , , , , , + , + */ + BigInteger.prototype.isUnit = function() { + return this === ONE || + this === M_ONE || + (this._d.length === 1 && this._d[0] === 1); + }; + + /* + Function: multiply + Multiply two . + Parameters: + n - The number to multiply *this* by. Will be converted to a + . + Returns: + The numbers multiplied together. + See Also: + , , , + */ + BigInteger.prototype.multiply = function(n) { + // TODO: Consider adding Karatsuba multiplication for large numbers + if (this._s === 0) { + return ZERO; + } + + n = BigInteger(n); + if (n._s === 0) { + return ZERO; + } + if (this.isUnit()) { + if (this._s < 0) { + return n.negate(); + } + return n; + } + if (n.isUnit()) { + if (n._s < 0) { + return this.negate(); + } + return this; + } + if (this === n) { + return this.square(); + } + + var r = (this._d.length >= n._d.length); + var a = (r ? this : n)._d; // a will be longer than b + var b = (r ? n : this)._d; + var al = a.length; + var bl = b.length; + + var pl = al + bl; + var partial = new Array(pl); + var i; + for (i = 0; i < pl; i++) { + partial[i] = 0; + } + + for (i = 0; i < bl; i++) { + var carry = 0; + var bi = b[i]; + var jlimit = al + i; + var digit; + for (var j = i; j < jlimit; j++) { + digit = partial[j] + bi * a[j - i] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = (digit % BigInteger_base) | 0; + } + if (carry) { + digit = partial[j] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = digit % BigInteger_base; + } + } + return new BigInteger(partial, this._s * n._s, CONSTRUCT); + }; + + // Multiply a BigInteger by a single-digit native number + // Assumes that this and n are >= 0 + // This is not really intended to be used outside the library itself + BigInteger.prototype.multiplySingleDigit = function(n) { + if (n === 0 || this._s === 0) { + return ZERO; + } + if (n === 1) { + return this; + } + + var digit; + if (this._d.length === 1) { + digit = this._d[0] * n; + if (digit >= BigInteger_base) { + return new BigInteger([(digit % BigInteger_base)|0, + (digit / BigInteger_base)|0], 1, CONSTRUCT); + } + return new BigInteger([digit], 1, CONSTRUCT); + } + + if (n === 2) { + return this.add(this); + } + if (this.isUnit()) { + return new BigInteger([n], 1, CONSTRUCT); + } + + var a = this._d; + var al = a.length; + + var pl = al + 1; + var partial = new Array(pl); + for (var i = 0; i < pl; i++) { + partial[i] = 0; + } + + var carry = 0; + for (var j = 0; j < al; j++) { + digit = n * a[j] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = (digit % BigInteger_base) | 0; + } + if (carry) { + partial[j] = carry; + } + + return new BigInteger(partial, 1, CONSTRUCT); + }; + + /* + Function: square + Multiply a by itself. + This is slightly faster than regular multiplication, since it removes the + duplicated multiplcations. + Returns: + > this.multiply(this) + See Also: + + */ + BigInteger.prototype.square = function() { + // Normally, squaring a 10-digit number would take 100 multiplications. + // Of these 10 are unique diagonals, of the remaining 90 (100-10), 45 are repeated. + // This procedure saves (N*(N-1))/2 multiplications, (e.g., 45 of 100 multiplies). + // Based on code by Gary Darby, Intellitech Systems Inc., www.DelphiForFun.org + + if (this._s === 0) { + return ZERO; + } + if (this.isUnit()) { + return ONE; + } + + var digits = this._d; + var length = digits.length; + var imult1 = new Array(length + length + 1); + var product, carry, k; + var i; + + // Calculate diagonal + for (i = 0; i < length; i++) { + k = i * 2; + product = digits[i] * digits[i]; + carry = (product / BigInteger_base) | 0; + imult1[k] = product % BigInteger_base; + imult1[k + 1] = carry; + } + + // Calculate repeating part + for (i = 0; i < length; i++) { + carry = 0; + k = i * 2 + 1; + for (var j = i + 1; j < length; j++, k++) { + product = digits[j] * digits[i] * 2 + imult1[k] + carry; + carry = (product / BigInteger_base) | 0; + imult1[k] = product % BigInteger_base; + } + k = length + i; + var digit = carry + imult1[k]; + carry = (digit / BigInteger_base) | 0; + imult1[k] = digit % BigInteger_base; + imult1[k + 1] += carry; + } + + return new BigInteger(imult1, 1, CONSTRUCT); + }; + + /* + Function: quotient + Divide two and truncate towards zero. + throws an exception if *n* is zero. + Parameters: + n - The number to divide *this* by. Will be converted to a . + Returns: + The *this* / *n*, truncated to an integer. + See Also: + , , , , + */ + BigInteger.prototype.quotient = function(n) { + return this.divRem(n)[0]; + }; + + /* + Function: divide + Deprecated synonym for . + */ + BigInteger.prototype.divide = BigInteger.prototype.quotient; + + /* + Function: remainder + Calculate the remainder of two . + throws an exception if *n* is zero. + Parameters: + n - The remainder after *this* is divided *this* by *n*. Will be + converted to a . + Returns: + *this* % *n*. + See Also: + , + */ + BigInteger.prototype.remainder = function(n) { + return this.divRem(n)[1]; + }; + + /* + Function: divRem + Calculate the integer quotient and remainder of two . + throws an exception if *n* is zero. + Parameters: + n - The number to divide *this* by. Will be converted to a . + Returns: + A two-element array containing the quotient and the remainder. + > a.divRem(b) + is exactly equivalent to + > [a.quotient(b), a.remainder(b)] + except it is faster, because they are calculated at the same time. + See Also: + , + */ + BigInteger.prototype.divRem = function(n) { + n = BigInteger(n); + if (n._s === 0) { + throw new Error("Divide by zero"); + } + if (this._s === 0) { + return [ZERO, ZERO]; + } + if (n._d.length === 1) { + return this.divRemSmall(n._s * n._d[0]); + } + + // Test for easy cases -- |n1| <= |n2| + switch (this.compareAbs(n)) { + case 0: // n1 == n2 + return [this._s === n._s ? ONE : M_ONE, ZERO]; + case -1: // |n1| < |n2| + return [ZERO, this]; + } + + var sign = this._s * n._s; + var a = n.abs(); + var b_digits = this._d; + var b_index = b_digits.length; + var digits = n._d.length; + var quot = []; + var guess; + + var part = new BigInteger([], 0, CONSTRUCT); + + while (b_index) { + part._d.unshift(b_digits[--b_index]); + part = new BigInteger(part._d, 1, CONSTRUCT); + + if (part.compareAbs(n) < 0) { + quot.push(0); + continue; + } + if (part._s === 0) { + guess = 0; + } + else { + var xlen = part._d.length, ylen = a._d.length; + var highx = part._d[xlen-1]*BigInteger_base + part._d[xlen-2]; + var highy = a._d[ylen-1]*BigInteger_base + a._d[ylen-2]; + if (part._d.length > a._d.length) { + // The length of part._d can either match a._d length, + // or exceed it by one. + highx = (highx+1)*BigInteger_base; + } + guess = Math.ceil(highx/highy); + } + do { + var check = a.multiplySingleDigit(guess); + if (check.compareAbs(part) <= 0) { + break; + } + guess--; + } while (guess); + + quot.push(guess); + if (!guess) { + continue; + } + var diff = part.subtract(check); + part._d = diff._d.slice(); + } + + return [new BigInteger(quot.reverse(), sign, CONSTRUCT), + new BigInteger(part._d, this._s, CONSTRUCT)]; + }; + + // Throws an exception if n is outside of (-BigInteger.base, -1] or + // [1, BigInteger.base). It's not necessary to call this, since the + // other division functions will call it if they are able to. + BigInteger.prototype.divRemSmall = function(n) { + var r; + n = +n; + if (n === 0) { + throw new Error("Divide by zero"); + } + + var n_s = n < 0 ? -1 : 1; + var sign = this._s * n_s; + n = Math.abs(n); + + if (n < 1 || n >= BigInteger_base) { + throw new Error("Argument out of range"); + } + + if (this._s === 0) { + return [ZERO, ZERO]; + } + + if (n === 1 || n === -1) { + return [(sign === 1) ? this.abs() : new BigInteger(this._d, sign, CONSTRUCT), ZERO]; + } + + // 2 <= n < BigInteger_base + + // divide a single digit by a single digit + if (this._d.length === 1) { + var q = new BigInteger([(this._d[0] / n) | 0], 1, CONSTRUCT); + r = new BigInteger([(this._d[0] % n) | 0], 1, CONSTRUCT); + if (sign < 0) { + q = q.negate(); + } + if (this._s < 0) { + r = r.negate(); + } + return [q, r]; + } + + var digits = this._d.slice(); + var quot = new Array(digits.length); + var part = 0; + var diff = 0; + var i = 0; + var guess; + + while (digits.length) { + part = part * BigInteger_base + digits[digits.length - 1]; + if (part < n) { + quot[i++] = 0; + digits.pop(); + diff = BigInteger_base * diff + part; + continue; + } + if (part === 0) { + guess = 0; + } + else { + guess = (part / n) | 0; + } + + var check = n * guess; + diff = part - check; + quot[i++] = guess; + if (!guess) { + digits.pop(); + continue; + } + + digits.pop(); + part = diff; + } + + r = new BigInteger([diff], 1, CONSTRUCT); + if (this._s < 0) { + r = r.negate(); + } + return [new BigInteger(quot.reverse(), sign, CONSTRUCT), r]; + }; + + /* + Function: isEven + Return true iff *this* is divisible by two. + Note that is even. + Returns: + true if *this* is even, false otherwise. + See Also: + + */ + BigInteger.prototype.isEven = function() { + var digits = this._d; + return this._s === 0 || digits.length === 0 || (digits[0] % 2) === 0; + }; + + /* + Function: isOdd + Return true iff *this* is not divisible by two. + Returns: + true if *this* is odd, false otherwise. + See Also: + + */ + BigInteger.prototype.isOdd = function() { + return !this.isEven(); + }; + + /* + Function: sign + Get the sign of a . + Returns: + * -1 if *this* < 0 + * 0 if *this* == 0 + * +1 if *this* > 0 + See Also: + , , , , + */ + BigInteger.prototype.sign = function() { + return this._s; + }; + + /* + Function: isPositive + Return true iff *this* > 0. + Returns: + true if *this*.compare() == 1. + See Also: + , , , , , + */ + BigInteger.prototype.isPositive = function() { + return this._s > 0; + }; + + /* + Function: isNegative + Return true iff *this* < 0. + Returns: + true if *this*.compare() == -1. + See Also: + , , , , , + */ + BigInteger.prototype.isNegative = function() { + return this._s < 0; + }; + + /* + Function: isZero + Return true iff *this* == 0. + Returns: + true if *this*.compare() == 0. + See Also: + , , , , + */ + BigInteger.prototype.isZero = function() { + return this._s === 0; + }; + + /* + Function: exp10 + Multiply a by a power of 10. + This is equivalent to, but faster than + > if (n >= 0) { + > return this.multiply(BigInteger("1e" + n)); + > } + > else { // n <= 0 + > return this.quotient(BigInteger("1e" + -n)); + > } + Parameters: + n - The power of 10 to multiply *this* by. *n* is converted to a + javascipt number and must be no greater than + (0x7FFFFFFF), or an exception will be thrown. + Returns: + *this* * (10 ** *n*), truncated to an integer if necessary. + See Also: + , + */ + BigInteger.prototype.exp10 = function(n) { + n = +n; + if (n === 0) { + return this; + } + if (Math.abs(n) > Number(MAX_EXP)) { + throw new Error("exponent too large in BigInteger.exp10"); + } + // Optimization for this == 0. This also keeps us from having to trim zeros in the positive n case + if (this._s === 0) { + return ZERO; + } + if (n > 0) { + var k = new BigInteger(this._d.slice(), this._s, CONSTRUCT); + + for (; n >= BigInteger_base_log10; n -= BigInteger_base_log10) { + k._d.unshift(0); + } + if (n == 0) + return k; + k._s = 1; + k = k.multiplySingleDigit(Math.pow(10, n)); + return (this._s < 0 ? k.negate() : k); + } else if (-n >= this._d.length*BigInteger_base_log10) { + return ZERO; + } else { + var k = new BigInteger(this._d.slice(), this._s, CONSTRUCT); + + for (n = -n; n >= BigInteger_base_log10; n -= BigInteger_base_log10) { + k._d.shift(); + } + return (n == 0) ? k : k.divRemSmall(Math.pow(10, n))[0]; + } + }; + + /* + Function: pow + Raise a to a power. + In this implementation, 0**0 is 1. + Parameters: + n - The exponent to raise *this* by. *n* must be no greater than + (0x7FFFFFFF), or an exception will be thrown. + Returns: + *this* raised to the *nth* power. + See Also: + + */ + BigInteger.prototype.pow = function(n) { + if (this.isUnit()) { + if (this._s > 0) { + return this; + } + else { + return BigInteger(n).isOdd() ? this : this.negate(); + } + } + + n = BigInteger(n); + if (n._s === 0) { + return ONE; + } + else if (n._s < 0) { + if (this._s === 0) { + throw new Error("Divide by zero"); + } + else { + return ZERO; + } + } + if (this._s === 0) { + return ZERO; + } + if (n.isUnit()) { + return this; + } + + if (n.compareAbs(MAX_EXP) > 0) { + throw new Error("exponent too large in BigInteger.pow"); + } + var x = this; + var aux = ONE; + var two = BigInteger.small[2]; + + while (n.isPositive()) { + if (n.isOdd()) { + aux = aux.multiply(x); + if (n.isUnit()) { + return aux; + } + } + x = x.square(); + n = n.quotient(two); + } + + return aux; + }; + + /* + Function: modPow + Raise a to a power (mod m). + Because it is reduced by a modulus, is not limited by + like . + Parameters: + exponent - The exponent to raise *this* by. Must be positive. + modulus - The modulus. + Returns: + *this* ^ *exponent* (mod *modulus*). + See Also: + , + */ + BigInteger.prototype.modPow = function(exponent, modulus) { + var result = ONE; + var base = this; + + while (exponent.isPositive()) { + if (exponent.isOdd()) { + result = result.multiply(base).remainder(modulus); + } + + exponent = exponent.quotient(BigInteger.small[2]); + if (exponent.isPositive()) { + base = base.square().remainder(modulus); + } + } + + return result; + }; + + /* + Function: log + Get the natural logarithm of a as a native JavaScript number. + This is equivalent to + > Math.log(this.toJSValue()) + but handles values outside of the native number range. + Returns: + log( *this* ) + See Also: + + */ + BigInteger.prototype.log = function() { + switch (this._s) { + case 0: return -Infinity; + case -1: return NaN; + default: // Fall through. + } + + var l = this._d.length; + + if (l*BigInteger_base_log10 < 30) { + return Math.log(this.valueOf()); + } + + var N = Math.ceil(30/BigInteger_base_log10); + var firstNdigits = this._d.slice(l - N); + return Math.log((new BigInteger(firstNdigits, 1, CONSTRUCT)).valueOf()) + (l - N) * Math.log(BigInteger_base); + }; + + /* + Function: valueOf + Convert a to a native JavaScript integer. + This is called automatically by JavaScipt to convert a to a + native value. + Returns: + > parseInt(this.toString(), 10) + See Also: + , + */ + BigInteger.prototype.valueOf = function() { + return parseInt(this.toString(), 10); + }; + + /* + Function: toJSValue + Convert a to a native JavaScript integer. + This is the same as valueOf, but more explicitly named. + Returns: + > parseInt(this.toString(), 10) + See Also: + , + */ + BigInteger.prototype.toJSValue = function() { + return parseInt(this.toString(), 10); + }; + + + /* + Function: lowVal + Author: Lucas Jones + */ + BigInteger.prototype.lowVal = function () { + return this._d[0] || 0; + }; + + var MAX_EXP = BigInteger(0x7FFFFFFF); + // Constant: MAX_EXP + // The largest exponent allowed in and (0x7FFFFFFF or 2147483647). + BigInteger.MAX_EXP = MAX_EXP; + + (function() { + function makeUnary(fn) { + return function(a) { + return fn.call(BigInteger(a)); + }; + } + + function makeBinary(fn) { + return function(a, b) { + return fn.call(BigInteger(a), BigInteger(b)); + }; + } + + function makeTrinary(fn) { + return function(a, b, c) { + return fn.call(BigInteger(a), BigInteger(b), BigInteger(c)); + }; + } + + (function() { + var i, fn; + var unary = "toJSValue,isEven,isOdd,sign,isZero,isNegative,abs,isUnit,square,negate,isPositive,toString,next,prev,log".split(","); + var binary = "compare,remainder,divRem,subtract,add,quotient,divide,multiply,pow,compareAbs".split(","); + var trinary = ["modPow"]; + + for (i = 0; i < unary.length; i++) { + fn = unary[i]; + BigInteger[fn] = makeUnary(BigInteger.prototype[fn]); + } + + for (i = 0; i < binary.length; i++) { + fn = binary[i]; + BigInteger[fn] = makeBinary(BigInteger.prototype[fn]); + } + + for (i = 0; i < trinary.length; i++) { + fn = trinary[i]; + BigInteger[fn] = makeTrinary(BigInteger.prototype[fn]); + } + + BigInteger.exp10 = function(x, n) { + return BigInteger(x).exp10(n); + }; + })(); + })(); + + exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt + })(typeof exports !== 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/crypto/cnBase58.js b/src/crypto/cnBase58.js new file mode 100644 index 00000000..5c3b59d4 --- /dev/null +++ b/src/crypto/cnBase58.js @@ -0,0 +1,226 @@ +var JSBigInt = require('./biginteger')['JSBigInt']; + +/** +Copyright (c) 2017, moneroexamples + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Parts of the project are originally copyright (c) 2014-2017, MyMonero.com +*/ + +var cnBase58 = (function () { + var b58 = {}; + + var alphabet_str = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + var alphabet = []; + for (var i = 0; i < alphabet_str.length; i++) { + alphabet.push(alphabet_str.charCodeAt(i)); + } + var encoded_block_sizes = [0, 2, 3, 5, 6, 7, 9, 10, 11]; + + var alphabet_size = alphabet.length; + var full_block_size = 8; + var full_encoded_block_size = 11; + + var UINT64_MAX = new JSBigInt(2).pow(64); + + function hextobin(hex) { + if (hex.length % 2 !== 0) throw "Hex string has invalid length!"; + var res = new Uint8Array(hex.length / 2); + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); + } + return res; + } + + function bintohex(bin) { + var out = []; + for (var i = 0; i < bin.length; ++i) { + out.push(("0" + bin[i].toString(16)).slice(-2)); + } + return out.join(""); + } + + function strtobin(str) { + var res = new Uint8Array(str.length); + for (var i = 0; i < str.length; i++) { + res[i] = str.charCodeAt(i); + } + return res; + } + + function bintostr(bin) { + var out = []; + for (var i = 0; i < bin.length; i++) { + out.push(String.fromCharCode(bin[i])); + } + return out.join(""); + } + + function uint8_be_to_64(data) { + if (data.length < 1 || data.length > 8) { + throw "Invalid input length"; + } + var res = JSBigInt.ZERO; + var twopow8 = new JSBigInt(2).pow(8); + var i = 0; + switch (9 - data.length) { + case 1: + res = res.add(data[i++]); + case 2: + res = res.multiply(twopow8).add(data[i++]); + case 3: + res = res.multiply(twopow8).add(data[i++]); + case 4: + res = res.multiply(twopow8).add(data[i++]); + case 5: + res = res.multiply(twopow8).add(data[i++]); + case 6: + res = res.multiply(twopow8).add(data[i++]); + case 7: + res = res.multiply(twopow8).add(data[i++]); + case 8: + res = res.multiply(twopow8).add(data[i++]); + break; + default: + throw "Impossible condition"; + } + return res; + } + + function uint64_to_8be(num, size) { + var res = new Uint8Array(size); + if (size < 1 || size > 8) { + throw "Invalid input length"; + } + var twopow8 = new JSBigInt(2).pow(8); + for (var i = size - 1; i >= 0; i--) { + res[i] = num.remainder(twopow8).toJSValue(); + num = num.divide(twopow8); + } + return res; + } + + b58.encode_block = function (data, buf, index) { + if (data.length < 1 || data.length > full_encoded_block_size) { + throw "Invalid block length: " + data.length; + } + var num = uint8_be_to_64(data); + var i = encoded_block_sizes[data.length] - 1; + // while num > 0 + while (num.compare(0) === 1) { + var div = num.divRem(alphabet_size); + // remainder = num % alphabet_size + var remainder = div[1]; + // num = num / alphabet_size + num = div[0]; + buf[index + i] = alphabet[remainder.toJSValue()]; + i--; + } + return buf; + }; + + b58.encode = function (hex) { + var data = hextobin(hex); + if (data.length === 0) { + return ""; + } + var full_block_count = Math.floor(data.length / full_block_size); + var last_block_size = data.length % full_block_size; + var res_size = full_block_count * full_encoded_block_size + encoded_block_sizes[last_block_size]; + + var res = new Uint8Array(res_size); + var i; + for (i = 0; i < res_size; ++i) { + res[i] = alphabet[0]; + } + for (i = 0; i < full_block_count; i++) { + res = b58.encode_block(data.subarray(i * full_block_size, i * full_block_size + full_block_size), res, i * full_encoded_block_size); + } + if (last_block_size > 0) { + res = b58.encode_block(data.subarray(full_block_count * full_block_size, full_block_count * full_block_size + last_block_size), res, full_block_count * full_encoded_block_size) + } + return bintostr(res); + }; + + b58.decode_block = function (data, buf, index) { + if (data.length < 1 || data.length > full_encoded_block_size) { + throw "Invalid block length: " + data.length; + } + + var res_size = encoded_block_sizes.indexOf(data.length); + if (res_size <= 0) { + throw "Invalid block size"; + } + var res_num = new JSBigInt(0); + var order = new JSBigInt(1); + for (var i = data.length - 1; i >= 0; i--) { + var digit = alphabet.indexOf(data[i]); + if (digit < 0) { + throw "Invalid symbol"; + } + var product = order.multiply(digit).add(res_num); + // if product > UINT64_MAX + if (product.compare(UINT64_MAX) === 1) { + throw "Overflow"; + } + res_num = product; + order = order.multiply(alphabet_size); + } + if (res_size < full_block_size && (new JSBigInt(2).pow(8 * res_size).compare(res_num) <= 0)) { + throw "Overflow 2"; + } + buf.set(uint64_to_8be(res_num, res_size), index); + return buf; + }; + + b58.decode = function (enc) { + enc = strtobin(enc); + if (enc.length === 0) { + return ""; + } + var full_block_count = Math.floor(enc.length / full_encoded_block_size); + var last_block_size = enc.length % full_encoded_block_size; + var last_block_decoded_size = encoded_block_sizes.indexOf(last_block_size); + if (last_block_decoded_size < 0) { + throw "Invalid encoded length"; + } + var data_size = full_block_count * full_block_size + last_block_decoded_size; + var data = new Uint8Array(data_size); + for (var i = 0; i < full_block_count; i++) { + data = b58.decode_block(enc.subarray(i * full_encoded_block_size, i * full_encoded_block_size + full_encoded_block_size), data, i * full_block_size); + } + if (last_block_size > 0) { + data = b58.decode_block(enc.subarray(full_block_count * full_encoded_block_size, full_block_count * full_encoded_block_size + last_block_size), data, full_block_count * full_block_size); + } + return bintohex(data); + }; + + return b58; +})(); +module.exports = cnBase58; \ No newline at end of file diff --git a/src/crypto/utils.js b/src/crypto/utils.js index 0d824c99..3cc39bdf 100644 --- a/src/crypto/utils.js +++ b/src/crypto/utils.js @@ -34,5 +34,8 @@ module.exports = { }, keccak256: function (hexString) { return keccak256(hexString); + }, + keccak256Checksum: function (payload) { + return keccak256(payload).toString().substr(0, 8); } }; diff --git a/src/currencies.js b/src/currencies.js index c8483af1..780b503b 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -1,6 +1,7 @@ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); +var XMRValidator = require('./monero_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -192,6 +193,12 @@ var CURRENCIES = [{ name: 'bankex', symbol: 'bkx', validator: ETHValidator +},{ + name: 'monero', + symbol: 'xmr', + addressTypes: {prod: ['18'], testnet: ['53']}, + iAddressTypes: {prod: ['19'], testnet: ['54']}, + validator: XMRValidator }]; diff --git a/src/monero_validator.js b/src/monero_validator.js new file mode 100644 index 00000000..3b7473a0 --- /dev/null +++ b/src/monero_validator.js @@ -0,0 +1,60 @@ +var cryptoUtils = require('./crypto/utils'); +var cnBase58 = require('./crypto/cnBase58'); + +var DEFAULT_NETWORK_TYPE = 'prod'; +var addressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$'); +var integratedAddressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$'); + +function validateNetwork(decoded, currency, networkType, addressType){ + var network = currency.addressTypes; + if(addressType == 'integrated'){ + network = currency.iAddressTypes; + } + + switch(networkType){ + case 'prod': + return parseInt(decoded.substr(0,2), 16) == network.prod[0]; + case 'testnet': + return parseInt(decoded.substr(0,2), 16) == network.testnet[0]; + case 'both': + return parseInt(decoded.substr(0,2), 16) == network.prod[0] || parseInt(decoded.substr(0,2), 16) == network.testnet[0]; + default: + return false; + } +} + +function hextobin(hex) { + if (hex.length % 2 !== 0) return null; + var res = new Uint8Array(hex.length / 2); + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); + } + return res; +} + +module.exports = { + isValidAddress: function (address, currency, networkType) { + networkType = networkType || DEFAULT_NETWORK_TYPE; + var addressType = 'standard'; + if(!addressRegTest.test(address)){ + if(integratedAddressRegTest.test(address)){ + addressType = 'integrated'; + } + else{ + return false; + } + } + + var decodedAddrStr = cnBase58.decode(address); + if(!decodedAddrStr) + return false; + + if(!validateNetwork(decodedAddrStr, currency, networkType, addressType)) + return false; + + var addrChecksum = decodedAddrStr.slice(-8); + var hashChecksum = cryptoUtils.keccak256Checksum(hextobin(decodedAddrStr.slice(0, -8))); + + return addrChecksum === hashChecksum; + } +}; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 27eefa65..1a727bf8 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -354,6 +354,16 @@ describe('WAValidator.validate()', function () { valid('0xf40d80FCfa5cdEa0bB1E570c2D52132ac9bC6aEC', 'bankex', 'testnet'); valid('0x8A7395f281EeCf2B471B689E87Cf4C7fa8bb957d', 'BKX', 'testnet'); }); + + it('should return true for correct monero addresses', function () { + valid('47zQ5LAivg6hNCgijXSEFVLX7mke1bgM6YGLFaANDoJbgXDymcAAZvvMNt2PmMpqEe5qRy2zyfMYXdwpmdyitiFh84xnPG2', 'monero'); + valid('48bWuoDG75CXMDHbmPEvUF2hm1vLDic7ZJ7hqRkL65QR9p13AQAX4eEACXNk4YP115Q4KRVZnAvmMBHrcGfv9FvKPZnH6vH', 'XMR'); + valid('A2be3UvzMtkJtxRYgcCbQt2y7Rp2eLVGqNTWfZeankrWimSMM4y7uMP6B9oAZaHsXTj8KFSerkSkkVRuEuEca9QM8VhxCNU', 'monero', 'testnet'); + + //integrated addresses + valid('4Gd4DLiXzBmbVX2FZZ3Cvu6fUaWACup1qDowprUCje1kSP4FmbftiJMSfV8kWZXNqmVwj4m52xqtgFNUudVmsmGkGvkLcCibWfVUfUFVB7', 'monero'); + valid('4J5sF94AzXgFgx8LuWc9dcWkJkGkD3cL3L2AuhX6QA9jFvSxxj6QhHqHXqM2b2Go7G8RyDzEbHxYd9G26XUUbuJChipEyBz9fENMU2Ua9b', 'XMR'); + }); }); describe('invalid results', function () { @@ -545,5 +555,15 @@ describe('WAValidator.validate()', function () { //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); }); + it('should return false for incorrect monero addresses', function () { + commonTests('monero'); + invalid('4AWygwA3hHNE4e4Yr9PtRWJiorXTjZkCi57g4ExYzfXDFFQ8DRFEFyui1dLqVknpqQjGUBdTMbgaFAZaDbrVHdk3GAKBZ3E', 'monero'); + invalid('44643dtxcxjgMWEQLo6mh1c4d9Zxx9GbgK9hEj9iGSiFEryCkbwHyJ3JqxZJRqeC3Hb7ZBLKq5NkaJwR1x95EYnR1bTgN6d', 'xmr'); + invalid('A17N9ztrxjQD3v3JJtHGvHVnq6BAbujDNEuensB6PFwBYFpkjAicih8hDtX76HBuEag5NeaCuMZmRMe6eE5NMRGxFTQn8nJ', 'monero', 'testnet'); + + //integrated + invalid('4LNSCKNSTPNbJYkyAEgL966eHJHLDHiq1PpwKoiFBybcSqNGYfLBJApC62uQEeGAFxfYEd29uXBBrJFo7DhKqFVNi3GhmN79EtD5dgycYz', 'monero'); + invalid('4JpzTwf3i1GeCV76beVr19179oa8j1L8xNSC1bXMtAxxdf4aTTLqubL8EvXfQmUGKt9MMigFtKy91VtoTTSfg1LU7LocPruT6KcGC9RKJV', 'xmr'); + }); }); }); From 74694d0c1c8b004b5000ca7184e737207b0e10dd Mon Sep 17 00:00:00 2001 From: Erhard Dinhobl Date: Tue, 17 Jul 2018 12:18:03 +0200 Subject: [PATCH 050/108] regex ripple improved --- src/ripple_validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ripple_validator.js b/src/ripple_validator.js index a3679fcf..e60bbbff 100644 --- a/src/ripple_validator.js +++ b/src/ripple_validator.js @@ -1,7 +1,7 @@ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); -var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; +var ALLOWED_CHARS = '[1-9A-HJ-NP-Za-km-z]'; var codec = baseX(ALLOWED_CHARS); var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); From e3eefbbe97eac2e603e3e4b6fdb248dc513713b6 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 25 Oct 2018 22:49:53 +0200 Subject: [PATCH 051/108] added support for cardano --- .vscode/launch.json | 23 + dist/wallet-address-validator.js | 15109 ++++++++++++++++++++++--- dist/wallet-address-validator.min.js | 1 - package.json | 4 + src/ada_validator.js | 45 + src/currencies.js | 5 + test/wallet_address_validator.js | 16 + yarn.lock | 3567 ++++++ 8 files changed, 17104 insertions(+), 1666 deletions(-) create mode 100644 .vscode/launch.json delete mode 100644 dist/wallet-address-validator.min.js create mode 100644 src/ada_validator.js create mode 100644 yarn.lock diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..22494998 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Mocha Tests", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "args": [ + "-u", + "tdd", + "--timeout", + "999999", + "--colors", + "${workspaceFolder}/test" + ], + "internalConsoleOptions": "openOnSessionStart" + } + ] +} \ No newline at end of file diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 9eba6b47..9178575b 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -92,7 +92,7 @@ module.exports = function base (ALPHABET) { } } -},{"safe-buffer":7}],2:[function(require,module,exports){ +},{"safe-buffer":71}],2:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -246,2111 +246,13885 @@ function fromByteArray (uint8) { } },{}],3:[function(require,module,exports){ -/*! - * The buffer module from node.js, for the browser. +;(function (globalObject) { + 'use strict'; + +/* + * bignumber.js v7.2.1 + * A JavaScript library for arbitrary-precision arithmetic. + * https://github.com/MikeMcl/bignumber.js + * Copyright (c) 2018 Michael Mclaughlin + * MIT Licensed. + * + * BigNumber.prototype methods | BigNumber methods + * | + * absoluteValue abs | clone + * comparedTo | config set + * decimalPlaces dp | DECIMAL_PLACES + * dividedBy div | ROUNDING_MODE + * dividedToIntegerBy idiv | EXPONENTIAL_AT + * exponentiatedBy pow | RANGE + * integerValue | CRYPTO + * isEqualTo eq | MODULO_MODE + * isFinite | POW_PRECISION + * isGreaterThan gt | FORMAT + * isGreaterThanOrEqualTo gte | ALPHABET + * isInteger | isBigNumber + * isLessThan lt | maximum max + * isLessThanOrEqualTo lte | minimum min + * isNaN | random + * isNegative | + * isPositive | + * isZero | + * minus | + * modulo mod | + * multipliedBy times | + * negated | + * plus | + * precision sd | + * shiftedBy | + * squareRoot sqrt | + * toExponential | + * toFixed | + * toFormat | + * toFraction | + * toJSON | + * toNumber | + * toPrecision | + * toString | + * valueOf | * - * @author Feross Aboukhadijeh - * @license MIT */ -/* eslint-disable no-proto */ -'use strict' -var base64 = require('base64-js') -var ieee754 = require('ieee754') + var BigNumber, + isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, + + mathceil = Math.ceil, + mathfloor = Math.floor, + + bignumberError = '[BigNumber Error] ', + tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ', + + BASE = 1e14, + LOG_BASE = 14, + MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1 + // MAX_INT32 = 0x7fffffff, // 2^31 - 1 + POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], + SQRT_BASE = 1e7, + + // EDITABLE + // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and + // the arguments to toExponential, toFixed, toFormat, and toPrecision. + MAX = 1E9; // 0 to MAX_INT32 -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 -var K_MAX_LENGTH = 0x7fffffff -exports.kMaxLength = K_MAX_LENGTH + /* + * Create and return a BigNumber constructor. + */ + function clone(configObject) { + var div, convertBase, parseNumeric, + P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null }, + ONE = new BigNumber(1), + + + //----------------------------- EDITABLE CONFIG DEFAULTS ------------------------------- + + + // The default values below must be integers within the inclusive ranges stated. + // The values can also be changed at run-time using BigNumber.set. + + // The maximum number of decimal places for operations involving division. + DECIMAL_PLACES = 20, // 0 to MAX + + // The rounding mode used when rounding to the above decimal places, and when using + // toExponential, toFixed, toFormat and toPrecision, and round (default value). + // UP 0 Away from zero. + // DOWN 1 Towards zero. + // CEIL 2 Towards +Infinity. + // FLOOR 3 Towards -Infinity. + // HALF_UP 4 Towards nearest neighbour. If equidistant, up. + // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. + // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. + // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. + // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. + ROUNDING_MODE = 4, // 0 to 8 + + // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS] + + // The exponent value at and beneath which toString returns exponential notation. + // Number type: -7 + TO_EXP_NEG = -7, // 0 to -MAX + + // The exponent value at and above which toString returns exponential notation. + // Number type: 21 + TO_EXP_POS = 21, // 0 to MAX + + // RANGE : [MIN_EXP, MAX_EXP] + + // The minimum exponent value, beneath which underflow to zero occurs. + // Number type: -324 (5e-324) + MIN_EXP = -1e7, // -1 to -MAX + + // The maximum exponent value, above which overflow to Infinity occurs. + // Number type: 308 (1.7976931348623157e+308) + // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow. + MAX_EXP = 1e7, // 1 to MAX + + // Whether to use cryptographically-secure random number generation, if available. + CRYPTO = false, // true or false + + // The modulo mode used when calculating the modulus: a mod n. + // The quotient (q = a / n) is calculated according to the corresponding rounding mode. + // The remainder (r) is calculated as: r = a - n * q. + // + // UP 0 The remainder is positive if the dividend is negative, else is negative. + // DOWN 1 The remainder has the same sign as the dividend. + // This modulo mode is commonly known as 'truncated division' and is + // equivalent to (a % n) in JavaScript. + // FLOOR 3 The remainder has the same sign as the divisor (Python %). + // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function. + // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). + // The remainder is always positive. + // + // The truncated division, floored division, Euclidian division and IEEE 754 remainder + // modes are commonly used for the modulus operation. + // Although the other rounding modes can also be used, they may not give useful results. + MODULO_MODE = 1, // 0 to 9 + + // 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 + + // The format specification used by the BigNumber.prototype.toFormat method. + FORMAT = { + decimalSeparator: '.', + groupSeparator: ',', + groupSize: 3, + secondaryGroupSize: 0, + fractionGroupSeparator: '\xA0', // non-breaking space + fractionGroupSize: 0 + }, + + // The alphabet used for base conversion. + // It must be at least 2 characters long, with no '.' or repeated character. + // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' + ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'; + + + //------------------------------------------------------------------------------------------ + + + // CONSTRUCTOR + + + /* + * The BigNumber constructor and exported function. + * Create and return a new instance of a BigNumber object. + * + * n {number|string|BigNumber} A numeric value. + * [b] {number} The base of n. Integer, 2 to ALPHABET.length inclusive. + */ + function BigNumber(n, b) { + var alphabet, c, caseChanged, e, i, isNum, len, str, + x = this; -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ -Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + // Enable constructor usage without new. + if (!(x instanceof BigNumber)) { -if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) -} + // Don't throw on constructor call without new (#81). + // '[BigNumber Error] Constructor call without new: {n}' + //throw Error(bignumberError + ' Constructor call without new: ' + n); + return new BigNumber(n, b); + } -function typedArraySupport () { - // Can typed array instances can be augmented? - try { - var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} - return arr.foo() === 42 - } catch (e) { - return false - } -} + if (b == null) { -Object.defineProperty(Buffer.prototype, 'parent', { - get: function () { - if (!(this instanceof Buffer)) { - return undefined - } - return this.buffer - } -}) + // Duplicate. + if (n instanceof BigNumber) { + x.s = n.s; + x.e = n.e; + x.c = (n = n.c) ? n.slice() : n; + return; + } -Object.defineProperty(Buffer.prototype, 'offset', { - get: function () { - if (!(this instanceof Buffer)) { - return undefined - } - return this.byteOffset - } -}) + isNum = typeof n == 'number'; -function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('Invalid typed array length') - } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype - return buf -} + if (isNum && n * 0 == 0) { -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ + // Use `1 / n` to handle minus zero also. + x.s = 1 / n < 0 ? (n = -n, -1) : 1; -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' - ) - } - return allocUnsafe(arg) - } - return from(arg, encodingOrOffset, length) -} + // Faster path for integers. + if (n === ~~n) { + for (e = 0, i = n; i >= 10; i /= 10, e++); + x.e = e; + x.c = [n]; + return; + } -// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) -} + str = n + ''; + } else { + if (!isNumeric.test(str = n + '')) return parseNumeric(x, str, isNum); + x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1; + } -Buffer.poolSize = 8192 // not used by this implementation + // Decimal point? + if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); -function from (value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') - } + // Exponential form? + if ((i = str.search(/e/i)) > 0) { - if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } + // Determine exponent. + if (e < 0) e = i; + e += +str.slice(i + 1); + str = str.substring(0, i); + } else if (e < 0) { - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } + // Integer. + e = str.length; + } - return fromObject(value) -} + } else { -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) -} + // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' + intCheck(b, 2, ALPHABET.length, 'Base'); + str = n + ''; -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array + // Allow exponential notation to be used with base 10 argument, while + // also rounding to DECIMAL_PLACES as with other bases. + if (b == 10) { + x = new BigNumber(n instanceof BigNumber ? n : str); + return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE); + } -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') - } -} + isNum = typeof n == 'number'; -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) -} + if (isNum) { -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) -} + // Avoid potential interpretation of Infinity and NaN as base 44+ values. + if (n * 0 != 0) return parseNumeric(x, str, isNum, b); -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) -} + x.s = 1 / n < 0 ? (str = str.slice(1), -1) : 1; -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) -} + // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' + if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) { + throw Error + (tooManyDigits + n); + } -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } + // Prevent later check for length on converted number. + isNum = false; + } else { + x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1; + } - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } + alphabet = ALPHABET.slice(0, b); + e = i = 0; + + // Check that str is a valid base b number. + // Don't use RegExp so alphabet can contain special characters. + for (len = str.length; i < len; i++) { + if (alphabet.indexOf(c = str.charAt(i)) < 0) { + if (c == '.') { + + // If '.' is not the first character and it has not be found before. + if (i > e) { + e = len; + continue; + } + } else if (!caseChanged) { + + // Allow e.g. hexadecimal 'FF' as well as 'ff'. + if (str == str.toUpperCase() && (str = str.toLowerCase()) || + str == str.toLowerCase() && (str = str.toUpperCase())) { + caseChanged = true; + i = -1; + e = 0; + continue; + } + } - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) + return parseNumeric(x, n + '', isNum, b); + } + } - var actual = buf.write(string, encoding) + str = convertBase(str, b, 10, x.s); - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } + // Decimal point? + if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); + else e = str.length; + } - return buf -} + // Determine leading zeros. + for (i = 0; str.charCodeAt(i) === 48; i++); -function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf -} + // Determine trailing zeros. + for (len = str.length; str.charCodeAt(--len) === 48;); -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } + str = str.slice(i, ++len); - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } + if (str) { + len -= i; - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } + // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' + if (isNum && BigNumber.DEBUG && + len > 15 && (n > MAX_SAFE_INTEGER || n !== mathfloor(n))) { + throw Error + (tooManyDigits + (x.s * n)); + } - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf -} + e = e - i - 1; -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) + // Overflow? + if (e > MAX_EXP) { - if (buf.length === 0) { - return buf - } + // Infinity. + x.c = x.e = null; - obj.copy(buf, 0, 0, len) - return buf - } + // Underflow? + } else if (e < MIN_EXP) { + + // Zero. + x.c = [x.e = 0]; + } else { + x.e = e; + x.c = []; - if (obj) { - if (ArrayBuffer.isView(obj) || 'length' in obj) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) + // Transform base + + // e is the base 10 exponent. + // i is where to slice str to get the first element of the coefficient array. + i = (e + 1) % LOG_BASE; + if (e < 0) i += LOG_BASE; + + if (i < len) { + if (i) x.c.push(+str.slice(0, i)); + + for (len -= LOG_BASE; i < len;) { + x.c.push(+str.slice(i, i += LOG_BASE)); + } + + str = str.slice(i); + i = LOG_BASE - str.length; + } else { + i -= len; + } + + for (; i--; str += '0'); + x.c.push(+str); + } + } else { + + // Zero. + x.c = [x.e = 0]; } - return fromArrayLike(obj) } - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } - } - throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') -} + // CONSTRUCTOR PROPERTIES + + + BigNumber.clone = clone; + + BigNumber.ROUND_UP = 0; + BigNumber.ROUND_DOWN = 1; + BigNumber.ROUND_CEIL = 2; + BigNumber.ROUND_FLOOR = 3; + BigNumber.ROUND_HALF_UP = 4; + BigNumber.ROUND_HALF_DOWN = 5; + BigNumber.ROUND_HALF_EVEN = 6; + BigNumber.ROUND_HALF_CEIL = 7; + BigNumber.ROUND_HALF_FLOOR = 8; + BigNumber.EUCLID = 9; + + + /* + * Configure infrequently-changing library-wide settings. + * + * Accept an object with the following optional properties (if the value of a property is + * a number, it must be an integer within the inclusive range stated): + * + * DECIMAL_PLACES {number} 0 to MAX + * ROUNDING_MODE {number} 0 to 8 + * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX] + * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX] + * CRYPTO {boolean} true or false + * 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 '.'. + * FORMAT {object} An object with some of the following properties: + * decimalSeparator {string} + * groupSeparator {string} + * groupSize {number} + * secondaryGroupSize {number} + * fractionGroupSeparator {string} + * fractionGroupSize {number} + * + * (The values assigned to the above FORMAT object properties are not checked for validity.) + * + * E.g. + * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 }) + * + * Ignore properties/parameters set to null or undefined, except for ALPHABET. + * + * Return an object with the properties current values. + */ + BigNumber.config = BigNumber.set = function (obj) { + var p, v; -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + if (obj != null) { + + if (typeof obj == 'object') { + + // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive. + // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) { + v = obj[p]; + intCheck(v, 0, MAX, p); + DECIMAL_PLACES = v; + } + + // ROUNDING_MODE {number} Integer, 0 to 8 inclusive. + // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) { + v = obj[p]; + intCheck(v, 0, 8, p); + ROUNDING_MODE = v; + } + + // EXPONENTIAL_AT {number|number[]} + // Integer, -MAX to MAX inclusive or + // [integer -MAX to 0 inclusive, 0 to MAX inclusive]. + // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) { + v = obj[p]; + if (isArray(v)) { + intCheck(v[0], -MAX, 0, p); + intCheck(v[1], 0, MAX, p); + TO_EXP_NEG = v[0]; + TO_EXP_POS = v[1]; + } else { + intCheck(v, -MAX, MAX, p); + TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v); + } + } + + // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or + // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive]. + // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}' + if (obj.hasOwnProperty(p = 'RANGE')) { + v = obj[p]; + if (isArray(v)) { + intCheck(v[0], -MAX, -1, p); + intCheck(v[1], 1, MAX, p); + MIN_EXP = v[0]; + MAX_EXP = v[1]; + } else { + intCheck(v, -MAX, MAX, p); + if (v) { + MIN_EXP = -(MAX_EXP = v < 0 ? -v : v); + } else { + throw Error + (bignumberError + p + ' cannot be zero: ' + v); + } + } + } + + // CRYPTO {boolean} true or false. + // '[BigNumber Error] CRYPTO not true or false: {v}' + // '[BigNumber Error] crypto unavailable' + if (obj.hasOwnProperty(p = 'CRYPTO')) { + v = obj[p]; + if (v === !!v) { + if (v) { + if (typeof crypto != 'undefined' && crypto && + (crypto.getRandomValues || crypto.randomBytes)) { + CRYPTO = v; + } else { + CRYPTO = !v; + throw Error + (bignumberError + 'crypto unavailable'); + } + } else { + CRYPTO = v; + } + } else { + throw Error + (bignumberError + p + ' not true or false: ' + v); + } + } + + // MODULO_MODE {number} Integer, 0 to 9 inclusive. + // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'MODULO_MODE')) { + v = obj[p]; + intCheck(v, 0, 9, p); + MODULO_MODE = v; + } + + // POW_PRECISION {number} Integer, 0 to MAX inclusive. + // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'POW_PRECISION')) { + v = obj[p]; + intCheck(v, 0, MAX, p); + POW_PRECISION = v; + } + + // FORMAT {object} + // '[BigNumber Error] FORMAT not an object: {v}' + if (obj.hasOwnProperty(p = 'FORMAT')) { + v = obj[p]; + if (typeof v == 'object') FORMAT = v; + else throw Error + (bignumberError + p + ' not an object: ' + v); + } + + // ALPHABET {string} + // '[BigNumber Error] ALPHABET invalid: {v}' + if (obj.hasOwnProperty(p = 'ALPHABET')) { + v = obj[p]; + + // Disallow if only one character, or contains '.' or a repeated character. + if (typeof v == 'string' && !/^.$|\.|(.).*\1/.test(v)) { + ALPHABET = v; + } else { + throw Error + (bignumberError + p + ' invalid: ' + v); + } + } + + } else { + + // '[BigNumber Error] Object expected: {v}' + throw Error + (bignumberError + 'Object expected: ' + obj); + } + } + + return { + DECIMAL_PLACES: DECIMAL_PLACES, + ROUNDING_MODE: ROUNDING_MODE, + EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS], + RANGE: [MIN_EXP, MAX_EXP], + CRYPTO: CRYPTO, + MODULO_MODE: MODULO_MODE, + POW_PRECISION: POW_PRECISION, + FORMAT: FORMAT, + ALPHABET: ALPHABET + }; + }; + + + /* + * Return true if v is a BigNumber instance, otherwise return false. + * + * v {any} + */ + BigNumber.isBigNumber = function (v) { + return v instanceof BigNumber || v && v._isBigNumber === true || false; + }; + + + /* + * Return a new BigNumber whose value is the maximum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.maximum = BigNumber.max = function () { + return maxOrMin(arguments, P.lt); + }; + + + /* + * Return a new BigNumber whose value is the minimum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.minimum = BigNumber.min = function () { + return maxOrMin(arguments, P.gt); + }; + + + /* + * Return a new BigNumber with a random value equal to or greater than 0 and less than 1, + * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing + * zeros are produced). + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}' + * '[BigNumber Error] crypto unavailable' + */ + BigNumber.random = (function () { + var pow2_53 = 0x20000000000000; + + // Return a 53 bit integer n, where 0 <= n < 9007199254740992. + // Check if Math.random() produces more than 32 bits of randomness. + // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits. + // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1. + var random53bitInt = (Math.random() * pow2_53) & 0x1fffff + ? function () { return mathfloor(Math.random() * pow2_53); } + : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) + + (Math.random() * 0x800000 | 0); }; + + return function (dp) { + var a, b, e, k, v, + i = 0, + c = [], + rand = new BigNumber(ONE); + + if (dp == null) dp = DECIMAL_PLACES; + else intCheck(dp, 0, MAX); + + k = mathceil(dp / LOG_BASE); + + if (CRYPTO) { + + // Browsers supporting crypto.getRandomValues. + if (crypto.getRandomValues) { + + a = crypto.getRandomValues(new Uint32Array(k *= 2)); + + for (; i < k;) { + + // 53 bits: + // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2) + // 11111 11111111 11111111 11111111 11100000 00000000 00000000 + // ((Math.pow(2, 32) - 1) >>> 11).toString(2) + // 11111 11111111 11111111 + // 0x20000 is 2^21. + v = a[i] * 0x20000 + (a[i + 1] >>> 11); + + // Rejection sampling: + // 0 <= v < 9007199254740992 + // Probability that v >= 9e15, is + // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251 + if (v >= 9e15) { + b = crypto.getRandomValues(new Uint32Array(2)); + a[i] = b[0]; + a[i + 1] = b[1]; + } else { + + // 0 <= v <= 8999999999999999 + // 0 <= (v % 1e14) <= 99999999999999 + c.push(v % 1e14); + i += 2; + } + } + i = k / 2; + + // Node.js supporting crypto.randomBytes. + } else if (crypto.randomBytes) { + + // buffer + a = crypto.randomBytes(k *= 7); + + for (; i < k;) { + + // 0x1000000000000 is 2^48, 0x10000000000 is 2^40 + // 0x100000000 is 2^32, 0x1000000 is 2^24 + // 11111 11111111 11111111 11111111 11111111 11111111 11111111 + // 0 <= v < 9007199254740992 + v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) + + (a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) + + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6]; + + if (v >= 9e15) { + crypto.randomBytes(7).copy(a, i); + } else { + + // 0 <= (v % 1e14) <= 99999999999999 + c.push(v % 1e14); + i += 7; + } + } + i = k / 7; + } else { + CRYPTO = false; + throw Error + (bignumberError + 'crypto unavailable'); + } + } + + // Use Math.random. + if (!CRYPTO) { + + for (; i < k;) { + v = random53bitInt(); + if (v < 9e15) c[i++] = v % 1e14; + } + } + + k = c[--i]; + dp %= LOG_BASE; + + // Convert trailing digits to zeros according to dp. + if (k && dp) { + v = POWS_TEN[LOG_BASE - dp]; + c[i] = mathfloor(k / v) * v; + } + + // Remove trailing elements which are zero. + for (; c[i] === 0; c.pop(), i--); + + // Zero? + if (i < 0) { + c = [e = 0]; + } else { + + // Remove leading elements which are zero and adjust exponent accordingly. + for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE); + + // Count the digits of the first element of c to determine leading zeros, and... + for (i = 1, v = c[0]; v >= 10; v /= 10, i++); + + // adjust the exponent accordingly. + if (i < LOG_BASE) e -= LOG_BASE - i; + } + + rand.e = e; + rand.c = c; + return rand; + }; + })(); + + + // PRIVATE FUNCTIONS + + + // Called by BigNumber and BigNumber.prototype.toString. + convertBase = (function () { + var decimal = '0123456789'; + + /* + * Convert string of baseIn to an array of numbers of baseOut. + * Eg. toBaseOut('255', 10, 16) returns [15, 15]. + * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5]. + */ + function toBaseOut(str, baseIn, baseOut, alphabet) { + var j, + arr = [0], + arrL, + i = 0, + len = str.length; + + for (; i < len;) { + for (arrL = arr.length; arrL--; arr[arrL] *= baseIn); + + arr[0] += alphabet.indexOf(str.charAt(i++)); + + for (j = 0; j < arr.length; j++) { + + if (arr[j] > baseOut - 1) { + if (arr[j + 1] == null) arr[j + 1] = 0; + arr[j + 1] += arr[j] / baseOut | 0; + arr[j] %= baseOut; + } + } + } + + return arr.reverse(); + } + + // Convert a numeric string of baseIn to a numeric string of baseOut. + // If the caller is toString, we are converting from base 10 to baseOut. + // If the caller is BigNumber, we are converting from baseIn to base 10. + return function (str, baseIn, baseOut, sign, callerIsToString) { + var alphabet, d, e, k, r, x, xc, y, + i = str.indexOf('.'), + dp = DECIMAL_PLACES, + rm = ROUNDING_MODE; + + // Non-integer. + if (i >= 0) { + k = POW_PRECISION; + + // Unlimited precision. + POW_PRECISION = 0; + str = str.replace('.', ''); + y = new BigNumber(baseIn); + x = y.pow(str.length - i); + POW_PRECISION = k; + + // Convert str as if an integer, then restore the fraction part by dividing the + // result by its base raised to a power. + + y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'), + 10, baseOut, decimal); + y.e = y.c.length; + } + + // Convert the number as integer. + + xc = toBaseOut(str, baseIn, baseOut, callerIsToString + ? (alphabet = ALPHABET, decimal) + : (alphabet = decimal, ALPHABET)); + + // xc now represents str as an integer and converted to baseOut. e is the exponent. + e = k = xc.length; + + // Remove trailing zeros. + for (; xc[--k] == 0; xc.pop()); + + // Zero? + if (!xc[0]) return alphabet.charAt(0); + + // Does str represent an integer? If so, no need for the division. + if (i < 0) { + --e; + } else { + x.c = xc; + x.e = e; + + // The sign is needed for correct rounding. + x.s = sign; + x = div(x, y, dp, rm, baseOut); + xc = x.c; + r = x.r; + e = x.e; + } + + // xc now represents str converted to baseOut. + + // THe index of the rounding digit. + d = e + dp + 1; + + // The rounding digit: the digit to the right of the digit that may be rounded up. + i = xc[d]; + + // Look at the rounding digits and mode to determine whether to round up. + + k = baseOut / 2; + r = r || d < 0 || xc[d + 1] != null; + + r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) + : i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 || + rm == (x.s < 0 ? 8 : 7)); + + // If the index of the rounding digit is not greater than zero, or xc represents + // zero, then the result of the base conversion is zero or, if rounding up, a value + // such as 0.00001. + if (d < 1 || !xc[0]) { + + // 1^-dp or 0 + str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) + : alphabet.charAt(0); + } else { + + // Truncate xc to the required number of decimal places. + xc.length = d; + + // Round up? + if (r) { + + // Rounding up may mean the previous digit has to be rounded up and so on. + for (--baseOut; ++xc[--d] > baseOut;) { + xc[d] = 0; + + if (!d) { + ++e; + xc = [1].concat(xc); + } + } + } + + // Determine trailing zeros. + for (k = xc.length; !xc[--k];); + + // E.g. [4, 11, 15] becomes 4bf. + for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++])); + + // Add leading zeros, decimal point and trailing zeros as required. + str = toFixedPoint(str, e, alphabet.charAt(0)); + } + + // The caller will add the sign. + return str; + }; + })(); + + + // Perform division in the specified base. Called by div and convertBase. + div = (function () { + + // Assume non-zero x and k. + function multiply(x, k, base) { + var m, temp, xlo, xhi, + carry = 0, + i = x.length, + klo = k % SQRT_BASE, + khi = k / SQRT_BASE | 0; + + for (x = x.slice(); i--;) { + xlo = x[i] % SQRT_BASE; + xhi = x[i] / SQRT_BASE | 0; + m = khi * xlo + xhi * klo; + temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry; + carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi; + x[i] = temp % base; + } + + if (carry) x = [carry].concat(x); + + return x; + } + + function compare(a, b, aL, bL) { + var i, cmp; + + if (aL != bL) { + cmp = aL > bL ? 1 : -1; + } else { + + for (i = cmp = 0; i < aL; i++) { + + if (a[i] != b[i]) { + cmp = a[i] > b[i] ? 1 : -1; + break; + } + } + } + + return cmp; + } + + function subtract(a, b, aL, base) { + var i = 0; + + // Subtract b from a. + for (; aL--;) { + a[aL] -= i; + i = a[aL] < b[aL] ? 1 : 0; + a[aL] = i * base + a[aL] - b[aL]; + } + + // Remove leading zeros. + for (; !a[0] && a.length > 1; a.splice(0, 1)); + } + + // x: dividend, y: divisor. + return function (x, y, dp, rm, base) { + var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, + yL, yz, + s = x.s == y.s ? 1 : -1, + xc = x.c, + yc = y.c; + + // Either NaN, Infinity or 0? + if (!xc || !xc[0] || !yc || !yc[0]) { + + return new BigNumber( + + // Return NaN if either NaN, or both Infinity or 0. + !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : + + // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0. + xc && xc[0] == 0 || !yc ? s * 0 : s / 0 + ); + } + + q = new BigNumber(s); + qc = q.c = []; + e = x.e - y.e; + s = dp + e + 1; + + if (!base) { + base = BASE; + e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE); + s = s / LOG_BASE | 0; + } + + // Result exponent may be one less then the current value of e. + // The coefficients of the BigNumbers from convertBase may have trailing zeros. + for (i = 0; yc[i] == (xc[i] || 0); i++); + + if (yc[i] > (xc[i] || 0)) e--; + + if (s < 0) { + qc.push(1); + more = true; + } else { + xL = xc.length; + yL = yc.length; + i = 0; + s += 2; + + // Normalise xc and yc so highest order digit of yc is >= base / 2. + + n = mathfloor(base / (yc[0] + 1)); + + // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1. + // if (n > 1 || n++ == 1 && yc[0] < base / 2) { + if (n > 1) { + yc = multiply(yc, n, base); + xc = multiply(xc, n, base); + yL = yc.length; + xL = xc.length; + } + + xi = yL; + rem = xc.slice(0, yL); + remL = rem.length; + + // Add zeros to make remainder as long as divisor. + for (; remL < yL; rem[remL++] = 0); + yz = yc.slice(); + yz = [0].concat(yz); + yc0 = yc[0]; + if (yc[1] >= base / 2) yc0++; + // Not necessary, but to prevent trial digit n > base, when using base 3. + // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15; + + do { + n = 0; + + // Compare divisor and remainder. + cmp = compare(yc, rem, yL, remL); + + // If divisor < remainder. + if (cmp < 0) { + + // Calculate trial digit, n. + + rem0 = rem[0]; + if (yL != remL) rem0 = rem0 * base + (rem[1] || 0); + + // n is how many times the divisor goes into the current remainder. + n = mathfloor(rem0 / yc0); + + // Algorithm: + // product = divisor multiplied by trial digit (n). + // Compare product and remainder. + // If product is greater than remainder: + // Subtract divisor from product, decrement trial digit. + // Subtract product from remainder. + // If product was less than remainder at the last compare: + // Compare new remainder and divisor. + // If remainder is greater than divisor: + // Subtract divisor from remainder, increment trial digit. + + if (n > 1) { + + // n may be > base only when base is 3. + if (n >= base) n = base - 1; + + // product = divisor * trial digit. + prod = multiply(yc, n, base); + prodL = prod.length; + remL = rem.length; + + // Compare product and remainder. + // If product > remainder then trial digit n too high. + // n is 1 too high about 5% of the time, and is not known to have + // ever been more than 1 too high. + while (compare(prod, rem, prodL, remL) == 1) { + n--; + + // Subtract divisor from product. + subtract(prod, yL < prodL ? yz : yc, prodL, base); + prodL = prod.length; + cmp = 1; + } + } else { + + // n is 0 or 1, cmp is -1. + // If n is 0, there is no need to compare yc and rem again below, + // so change cmp to 1 to avoid it. + // If n is 1, leave cmp as -1, so yc and rem are compared again. + if (n == 0) { + + // divisor < remainder, so n must be at least 1. + cmp = n = 1; + } + + // product = divisor + prod = yc.slice(); + prodL = prod.length; + } + + if (prodL < remL) prod = [0].concat(prod); + + // Subtract product from remainder. + subtract(rem, prod, remL, base); + remL = rem.length; + + // If product was < remainder. + if (cmp == -1) { + + // Compare divisor and new remainder. + // If divisor < new remainder, subtract divisor from remainder. + // Trial digit n too low. + // n is 1 too low about 5% of the time, and very rarely 2 too low. + while (compare(yc, rem, yL, remL) < 1) { + n++; + + // Subtract divisor from remainder. + subtract(rem, yL < remL ? yz : yc, remL, base); + remL = rem.length; + } + } + } else if (cmp === 0) { + n++; + rem = [0]; + } // else cmp === 1 and n will be 0 + + // Add the next digit, n, to the result array. + qc[i++] = n; + + // Update the remainder. + if (rem[0]) { + rem[remL++] = xc[xi] || 0; + } else { + rem = [xc[xi]]; + remL = 1; + } + } while ((xi++ < xL || rem[0] != null) && s--); + + more = rem[0] != null; + + // Leading zero? + if (!qc[0]) qc.splice(0, 1); + } + + if (base == BASE) { + + // To calculate q.e, first get the number of digits of qc[0]. + for (i = 1, s = qc[0]; s >= 10; s /= 10, i++); + + round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more); + + // Caller is convertBase. + } else { + q.e = e; + q.r = +more; + } + + return q; + }; + })(); + + + /* + * Return a string representing the value of BigNumber n in fixed-point or exponential + * notation rounded to the specified decimal places or significant digits. + * + * n: a BigNumber. + * i: the index of the last digit required (i.e. the digit that may be rounded up). + * rm: the rounding mode. + * id: 1 (toExponential) or 2 (toPrecision). + */ + function format(n, i, rm, id) { + var c0, e, ne, len, str; + + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + + if (!n.c) return n.toString(); + + c0 = n.c[0]; + ne = n.e; + + if (i == null) { + str = coeffToString(n.c); + str = id == 1 || id == 2 && ne <= TO_EXP_NEG + ? toExponential(str, ne) + : toFixedPoint(str, ne, '0'); + } else { + n = round(new BigNumber(n), i, rm); + + // n.e may have changed if the value was rounded up. + e = n.e; + + str = coeffToString(n.c); + len = str.length; + + // toPrecision returns exponential notation if the number of significant digits + // specified is less than the number of digits necessary to represent the integer + // part of the value in fixed-point notation. + + // Exponential notation. + if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) { + + // Append zeros? + for (; len < i; str += '0', len++); + str = toExponential(str, e); + + // Fixed-point notation. + } else { + i -= ne; + str = toFixedPoint(str, e, '0'); + + // Append zeros? + if (e + 1 > len) { + if (--i > 0) for (str += '.'; i--; str += '0'); + } else { + i += e - len; + if (i > 0) { + if (e + 1 == len) str += '.'; + for (; i--; str += '0'); + } + } + } + } + + return n.s < 0 && c0 ? '-' + str : str; + } + + + // Handle BigNumber.max and BigNumber.min. + function maxOrMin(args, method) { + var m, n, + i = 0; + + if (isArray(args[0])) args = args[0]; + m = new BigNumber(args[0]); + + for (; ++i < args.length;) { + n = new BigNumber(args[i]); + + // If any number is NaN, return NaN. + if (!n.s) { + m = n; + break; + } else if (method.call(m, n)) { + m = n; + } + } + + return m; + } + + + /* + * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP. + * Called by minus, plus and times. + */ + function normalise(n, c, e) { + var i = 1, + j = c.length; + + // Remove trailing zeros. + for (; !c[--j]; c.pop()); + + // Calculate the base 10 exponent. First get the number of digits of c[0]. + for (j = c[0]; j >= 10; j /= 10, i++); + + // Overflow? + if ((e = i + e * LOG_BASE - 1) > MAX_EXP) { + + // Infinity. + n.c = n.e = null; + + // Underflow? + } else if (e < MIN_EXP) { + + // Zero. + n.c = [n.e = 0]; + } else { + n.e = e; + n.c = c; + } + + return n; + } + + + // Handle values that fail the validity test in BigNumber. + parseNumeric = (function () { + var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, + dotAfter = /^([^.]+)\.$/, + dotBefore = /^\.([^.]+)$/, + isInfinityOrNaN = /^-?(Infinity|NaN)$/, + whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g; + + return function (x, str, isNum, b) { + var base, + s = isNum ? str : str.replace(whitespaceOrPlus, ''); + + // No exception on ±Infinity or NaN. + if (isInfinityOrNaN.test(s)) { + x.s = isNaN(s) ? null : s < 0 ? -1 : 1; + x.c = x.e = null; + } else { + if (!isNum) { + + // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i + s = s.replace(basePrefix, function (m, p1, p2) { + base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8; + return !b || b == base ? p1 : m; + }); + + if (b) { + base = b; + + // E.g. '1.' to '1', '.1' to '0.1' + s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1'); + } + + if (str != s) return new BigNumber(s, base); + } + + // '[BigNumber Error] Not a number: {n}' + // '[BigNumber Error] Not a base {b} number: {n}' + if (BigNumber.DEBUG) { + throw Error + (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str); + } + + // NaN + x.c = x.e = x.s = null; + } + } + })(); + + + /* + * Round x to sd significant digits using rounding mode rm. Check for over/under-flow. + * If r is truthy, it is known that there are more digits after the rounding digit. + */ + function round(x, sd, rm, r) { + var d, i, j, k, n, ni, rd, + xc = x.c, + pows10 = POWS_TEN; + + // if x is not Infinity or NaN... + if (xc) { + + // rd is the rounding digit, i.e. the digit after the digit that may be rounded up. + // n is a base 1e14 number, the value of the element of array x.c containing rd. + // ni is the index of n within x.c. + // d is the number of digits of n. + // i is the index of rd within n including leading zeros. + // j is the actual index of rd within n (if < 0, rd is a leading zero). + out: { + + // Get the number of digits of the first element of xc. + for (d = 1, k = xc[0]; k >= 10; k /= 10, d++); + i = sd - d; + + // If the rounding digit is in the first element of xc... + if (i < 0) { + i += LOG_BASE; + j = sd; + n = xc[ni = 0]; + + // Get the rounding digit at index j of n. + rd = n / pows10[d - j - 1] % 10 | 0; + } else { + ni = mathceil((i + 1) / LOG_BASE); + + if (ni >= xc.length) { + + if (r) { + + // Needed by sqrt. + for (; xc.length <= ni; xc.push(0)); + n = rd = 0; + d = 1; + i %= LOG_BASE; + j = i - LOG_BASE + 1; + } else { + break out; + } + } else { + n = k = xc[ni]; + + // Get the number of digits of n. + for (d = 1; k >= 10; k /= 10, d++); + + // Get the index of rd within n. + i %= LOG_BASE; + + // Get the index of rd within n, adjusted for leading zeros. + // The number of leading zeros of n is given by LOG_BASE - d. + j = i - LOG_BASE + d; + + // Get the rounding digit at index j of n. + rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0; + } + } + + r = r || sd < 0 || + + // Are there any non-zero digits after the rounding digit? + // The expression n % pows10[d - j - 1] returns all digits of n to the right + // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714. + xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]); + + r = rm < 4 + ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) + : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && + + // Check whether the digit to the left of the rounding digit is odd. + ((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 || + rm == (x.s < 0 ? 8 : 7)); + + if (sd < 1 || !xc[0]) { + xc.length = 0; + + if (r) { + + // Convert sd to decimal places. + sd -= x.e + 1; + + // 1, 0.1, 0.01, 0.001, 0.0001 etc. + xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE]; + x.e = -sd || 0; + } else { + + // Zero. + xc[0] = x.e = 0; + } + + return x; + } + + // Remove excess digits. + if (i == 0) { + xc.length = ni; + k = 1; + ni--; + } else { + xc.length = ni + 1; + k = pows10[LOG_BASE - i]; + + // E.g. 56700 becomes 56000 if 7 is the rounding digit. + // j > 0 means i > number of leading zeros of n. + xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0; + } + + // Round up? + if (r) { + + for (; ;) { + + // If the digit to be rounded up is in the first element of xc... + if (ni == 0) { + + // i will be the length of xc[0] before k is added. + for (i = 1, j = xc[0]; j >= 10; j /= 10, i++); + j = xc[0] += k; + for (k = 1; j >= 10; j /= 10, k++); + + // if i != k the length has increased. + if (i != k) { + x.e++; + if (xc[0] == BASE) xc[0] = 1; + } + + break; + } else { + xc[ni] += k; + if (xc[ni] != BASE) break; + xc[ni--] = 0; + k = 1; + } + } + } + + // Remove trailing zeros. + for (i = xc.length; xc[--i] === 0; xc.pop()); + } + + // Overflow? Infinity. + if (x.e > MAX_EXP) { + x.c = x.e = null; + + // Underflow? Zero. + } else if (x.e < MIN_EXP) { + x.c = [x.e = 0]; + } + } + + return x; + } + + + // PROTOTYPE/INSTANCE METHODS + + + /* + * Return a new BigNumber whose value is the absolute value of this BigNumber. + */ + P.absoluteValue = P.abs = function () { + var x = new BigNumber(this); + if (x.s < 0) x.s = 1; + return x; + }; + + + /* + * Return + * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b), + * -1 if the value of this BigNumber is less than the value of BigNumber(y, b), + * 0 if they have the same value, + * or null if the value of either is NaN. + */ + P.comparedTo = function (y, b) { + return compare(this, new BigNumber(y, b)); + }; + + + /* + * If dp is undefined or null or true or false, return the number of decimal places of the + * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. + * + * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this + * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or + * ROUNDING_MODE if rm is omitted. + * + * [dp] {number} Decimal places: integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.decimalPlaces = P.dp = function (dp, rm) { + var c, n, v, + x = this; + + if (dp != null) { + intCheck(dp, 0, MAX); + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + + return round(new BigNumber(x), dp + x.e + 1, rm); + } + + if (!(c = x.c)) return null; + n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE; + + // Subtract the number of trailing zeros of the last number. + if (v = c[v]) for (; v % 10 == 0; v /= 10, n--); + if (n < 0) n = 0; + + return n; + }; + + + /* + * n / 0 = I + * n / N = N + * n / I = 0 + * 0 / n = 0 + * 0 / 0 = N + * 0 / N = N + * 0 / I = 0 + * N / n = N + * N / 0 = N + * N / N = N + * N / I = N + * I / n = I + * I / 0 = I + * I / N = N + * I / I = N + * + * Return a new BigNumber whose value is the value of this BigNumber divided by the value of + * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE. + */ + P.dividedBy = P.div = function (y, b) { + return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE); + }; + + + /* + * Return a new BigNumber whose value is the integer part of dividing the value of this + * BigNumber by the value of BigNumber(y, b). + */ + P.dividedToIntegerBy = P.idiv = function (y, b) { + return div(this, new BigNumber(y, b), 0, 1); + }; + + + /* + * Return a BigNumber whose value is the value of this BigNumber exponentiated by n. + * + * If m is present, return the result modulo m. + * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE. + * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE. + * + * The modular power operation works efficiently when x, n, and m are integers, otherwise it + * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0. + * + * n {number|string|BigNumber} The exponent. An integer. + * [m] {number|string|BigNumber} The modulus. + * + * '[BigNumber Error] Exponent not an integer: {n}' + */ + P.exponentiatedBy = P.pow = function (n, m) { + var half, isModExp, k, more, nIsBig, nIsNeg, nIsOdd, y, + x = this; + + n = new BigNumber(n); + + // Allow NaN and ±Infinity, but not other non-integers. + if (n.c && !n.isInteger()) { + throw Error + (bignumberError + 'Exponent not an integer: ' + n); + } + + if (m != null) m = new BigNumber(m); + + // Exponent of MAX_SAFE_INTEGER is 15. + nIsBig = n.e > 14; + + // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0. + if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) { + + // The sign of the result of pow when x is negative depends on the evenness of n. + // If +n overflows to ±Infinity, the evenness of n would be not be known. + y = new BigNumber(Math.pow(+x.valueOf(), nIsBig ? 2 - isOdd(n) : +n)); + return m ? y.mod(m) : y; + } + + nIsNeg = n.s < 0; + + if (m) { + + // x % m returns NaN if abs(m) is zero, or m is NaN. + if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN); + + isModExp = !nIsNeg && x.isInteger() && m.isInteger(); + + if (isModExp) x = x.mod(m); + + // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15. + // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15. + } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 + // [1, 240000000] + ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 + // [80000000000000] [99999750000000] + : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) { + + // If x is negative and n is odd, k = -0, else k = 0. + k = x.s < 0 && isOdd(n) ? -0 : 0; + + // If x >= 1, k = ±Infinity. + if (x.e > -1) k = 1 / k; + + // If n is negative return ±0, else return ±Infinity. + return new BigNumber(nIsNeg ? 1 / k : k); + + } else if (POW_PRECISION) { + + // Truncating each coefficient array to a length of k after each multiplication + // equates to truncating significant digits to POW_PRECISION + [28, 41], + // i.e. there will be a minimum of 28 guard digits retained. + k = mathceil(POW_PRECISION / LOG_BASE + 2); + } + + if (nIsBig) { + half = new BigNumber(0.5); + nIsOdd = isOdd(n); + } else { + nIsOdd = n % 2; + } + + if (nIsNeg) n.s = 1; + + y = new BigNumber(ONE); + + // Performs 54 loop iterations for n of 9007199254740991. + for (; ;) { + + if (nIsOdd) { + y = y.times(x); + if (!y.c) break; + + if (k) { + if (y.c.length > k) y.c.length = k; + } else if (isModExp) { + y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m)); + } + } + + if (nIsBig) { + n = n.times(half); + round(n, n.e + 1, 1); + if (!n.c[0]) break; + nIsBig = n.e > 14; + nIsOdd = isOdd(n); + } else { + n = mathfloor(n / 2); + if (!n) break; + nIsOdd = n % 2; + } + + x = x.times(x); + + if (k) { + if (x.c && x.c.length > k) x.c.length = k; + } else if (isModExp) { + x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m)); + } + } + + if (isModExp) return y; + if (nIsNeg) y = ONE.div(y); + + return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y; + }; + + + /* + * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer + * using rounding mode rm, or ROUNDING_MODE if rm is omitted. + * + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}' + */ + P.integerValue = function (rm) { + var n = new BigNumber(this); + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + return round(n, n.e + 1, rm); + }; + + + /* + * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b), + * otherwise return false. + */ + P.isEqualTo = P.eq = function (y, b) { + return compare(this, new BigNumber(y, b)) === 0; + }; + + + /* + * Return true if the value of this BigNumber is a finite number, otherwise return false. + */ + P.isFinite = function () { + return !!this.c; + }; + + + /* + * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b), + * otherwise return false. + */ + P.isGreaterThan = P.gt = function (y, b) { + return compare(this, new BigNumber(y, b)) > 0; + }; + + + /* + * Return true if the value of this BigNumber is greater than or equal to the value of + * BigNumber(y, b), otherwise return false. + */ + P.isGreaterThanOrEqualTo = P.gte = function (y, b) { + return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0; + + }; + + + /* + * Return true if the value of this BigNumber is an integer, otherwise return false. + */ + P.isInteger = function () { + return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2; + }; + + + /* + * Return true if the value of this BigNumber is less than the value of BigNumber(y, b), + * otherwise return false. + */ + P.isLessThan = P.lt = function (y, b) { + return compare(this, new BigNumber(y, b)) < 0; + }; + + + /* + * Return true if the value of this BigNumber is less than or equal to the value of + * BigNumber(y, b), otherwise return false. + */ + P.isLessThanOrEqualTo = P.lte = function (y, b) { + return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0; + }; + + + /* + * Return true if the value of this BigNumber is NaN, otherwise return false. + */ + P.isNaN = function () { + return !this.s; + }; + + + /* + * Return true if the value of this BigNumber is negative, otherwise return false. + */ + P.isNegative = function () { + return this.s < 0; + }; + + + /* + * Return true if the value of this BigNumber is positive, otherwise return false. + */ + P.isPositive = function () { + return this.s > 0; + }; + + + /* + * Return true if the value of this BigNumber is 0 or -0, otherwise return false. + */ + P.isZero = function () { + return !!this.c && this.c[0] == 0; + }; + + + /* + * n - 0 = n + * n - N = N + * n - I = -I + * 0 - n = -n + * 0 - 0 = 0 + * 0 - N = N + * 0 - I = -I + * N - n = N + * N - 0 = N + * N - N = N + * N - I = N + * I - n = I + * I - 0 = I + * I - N = N + * I - I = N + * + * Return a new BigNumber whose value is the value of this BigNumber minus the value of + * BigNumber(y, b). + */ + P.minus = function (y, b) { + var i, j, t, xLTy, + x = this, + a = x.s; + + y = new BigNumber(y, b); + b = y.s; + + // Either NaN? + if (!a || !b) return new BigNumber(NaN); + + // Signs differ? + if (a != b) { + y.s = -b; + return x.plus(y); + } + + var xe = x.e / LOG_BASE, + ye = y.e / LOG_BASE, + xc = x.c, + yc = y.c; + + if (!xe || !ye) { + + // Either Infinity? + if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN); + + // Either zero? + if (!xc[0] || !yc[0]) { + + // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. + return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x : + + // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity + ROUNDING_MODE == 3 ? -0 : 0); + } + } + + xe = bitFloor(xe); + ye = bitFloor(ye); + xc = xc.slice(); + + // Determine which is the bigger number. + if (a = xe - ye) { + + if (xLTy = a < 0) { + a = -a; + t = xc; + } else { + ye = xe; + t = yc; + } + + t.reverse(); + + // Prepend zeros to equalise exponents. + for (b = a; b--; t.push(0)); + t.reverse(); + } else { + + // Exponents equal. Check digit by digit. + j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b; + + for (a = b = 0; b < j; b++) { + + if (xc[b] != yc[b]) { + xLTy = xc[b] < yc[b]; + break; + } + } + } + + // x < y? Point xc to the array of the bigger number. + if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s; + + b = (j = yc.length) - (i = xc.length); + + // Append zeros to xc if shorter. + // No need to add zeros to yc if shorter as subtract only needs to start at yc.length. + if (b > 0) for (; b--; xc[i++] = 0); + b = BASE - 1; + + // Subtract yc from xc. + for (; j > a;) { + + if (xc[--j] < yc[j]) { + for (i = j; i && !xc[--i]; xc[i] = b); + --xc[i]; + xc[j] += BASE; + } + + xc[j] -= yc[j]; + } + + // Remove leading zeros and adjust exponent accordingly. + for (; xc[0] == 0; xc.splice(0, 1), --ye); + + // Zero? + if (!xc[0]) { + + // Following IEEE 754 (2008) 6.3, + // n - n = +0 but n - n = -0 when rounding towards -Infinity. + y.s = ROUNDING_MODE == 3 ? -1 : 1; + y.c = [y.e = 0]; + return y; + } + + // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity + // for finite x and y. + return normalise(y, xc, ye); + }; + + + /* + * n % 0 = N + * n % N = N + * n % I = n + * 0 % n = 0 + * -0 % n = -0 + * 0 % 0 = N + * 0 % N = N + * 0 % I = 0 + * N % n = N + * N % 0 = N + * N % N = N + * N % I = N + * I % n = N + * I % 0 = N + * I % N = N + * I % I = N + * + * Return a new BigNumber whose value is the value of this BigNumber modulo the value of + * BigNumber(y, b). The result depends on the value of MODULO_MODE. + */ + P.modulo = P.mod = function (y, b) { + var q, s, + x = this; + + y = new BigNumber(y, b); + + // Return NaN if x is Infinity or NaN, or y is NaN or zero. + if (!x.c || !y.s || y.c && !y.c[0]) { + return new BigNumber(NaN); + + // Return x if y is Infinity or x is zero. + } else if (!y.c || x.c && !x.c[0]) { + return new BigNumber(x); + } + + if (MODULO_MODE == 9) { + + // Euclidian division: q = sign(y) * floor(x / abs(y)) + // r = x - qy where 0 <= r < abs(y) + s = y.s; + y.s = 1; + q = div(x, y, 0, 3); + y.s = s; + q.s *= s; + } else { + q = div(x, y, 0, MODULO_MODE); + } + + y = x.minus(q.times(y)); + + // To match JavaScript %, ensure sign of zero is sign of dividend. + if (!y.c[0] && MODULO_MODE == 1) y.s = x.s; + + return y; + }; + + + /* + * n * 0 = 0 + * n * N = N + * n * I = I + * 0 * n = 0 + * 0 * 0 = 0 + * 0 * N = N + * 0 * I = N + * N * n = N + * N * 0 = N + * N * N = N + * N * I = N + * I * n = I + * I * 0 = N + * I * N = N + * I * I = I + * + * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value + * of BigNumber(y, b). + */ + P.multipliedBy = P.times = function (y, b) { + var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, + base, sqrtBase, + x = this, + xc = x.c, + yc = (y = new BigNumber(y, b)).c; + + // Either NaN, ±Infinity or ±0? + if (!xc || !yc || !xc[0] || !yc[0]) { + + // Return NaN if either is NaN, or one is 0 and the other is Infinity. + if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) { + y.c = y.e = y.s = null; + } else { + y.s *= x.s; + + // Return ±Infinity if either is ±Infinity. + if (!xc || !yc) { + y.c = y.e = null; + + // Return ±0 if either is ±0. + } else { + y.c = [0]; + y.e = 0; + } + } + + return y; + } + + e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE); + y.s *= x.s; + xcL = xc.length; + ycL = yc.length; + + // Ensure xc points to longer array and xcL to its length. + if (xcL < ycL) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i; + + // Initialise the result array with zeros. + for (i = xcL + ycL, zc = []; i--; zc.push(0)); + + base = BASE; + sqrtBase = SQRT_BASE; + + for (i = ycL; --i >= 0;) { + c = 0; + ylo = yc[i] % sqrtBase; + yhi = yc[i] / sqrtBase | 0; + + for (k = xcL, j = i + k; j > i;) { + xlo = xc[--k] % sqrtBase; + xhi = xc[k] / sqrtBase | 0; + m = yhi * xlo + xhi * ylo; + xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c; + c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi; + zc[j--] = xlo % base; + } + + zc[j] = c; + } + + if (c) { + ++e; + } else { + zc.splice(0, 1); + } + + return normalise(y, zc, e); + }; + + + /* + * Return a new BigNumber whose value is the value of this BigNumber negated, + * i.e. multiplied by -1. + */ + P.negated = function () { + var x = new BigNumber(this); + x.s = -x.s || null; + return x; + }; + + + /* + * n + 0 = n + * n + N = N + * n + I = I + * 0 + n = n + * 0 + 0 = 0 + * 0 + N = N + * 0 + I = I + * N + n = N + * N + 0 = N + * N + N = N + * N + I = N + * I + n = I + * I + 0 = I + * I + N = N + * I + I = I + * + * Return a new BigNumber whose value is the value of this BigNumber plus the value of + * BigNumber(y, b). + */ + P.plus = function (y, b) { + var t, + x = this, + a = x.s; + + y = new BigNumber(y, b); + b = y.s; + + // Either NaN? + if (!a || !b) return new BigNumber(NaN); + + // Signs differ? + if (a != b) { + y.s = -b; + return x.minus(y); + } + + var xe = x.e / LOG_BASE, + ye = y.e / LOG_BASE, + xc = x.c, + yc = y.c; + + if (!xe || !ye) { + + // Return ±Infinity if either ±Infinity. + if (!xc || !yc) return new BigNumber(a / 0); + + // Either zero? + // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. + if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0); + } + + xe = bitFloor(xe); + ye = bitFloor(ye); + xc = xc.slice(); + + // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts. + if (a = xe - ye) { + if (a > 0) { + ye = xe; + t = yc; + } else { + a = -a; + t = xc; + } + + t.reverse(); + for (; a--; t.push(0)); + t.reverse(); + } + + a = xc.length; + b = yc.length; + + // Point xc to the longer array, and b to the shorter length. + if (a - b < 0) t = yc, yc = xc, xc = t, b = a; + + // Only start adding at yc.length - 1 as the further digits of xc can be ignored. + for (a = 0; b;) { + a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0; + xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE; + } + + if (a) { + xc = [a].concat(xc); + ++ye; + } + + // No need to check for zero, as +x + +y != 0 && -x + -y != 0 + // ye = MAX_EXP + 1 possible + return normalise(y, xc, ye); + }; + + + /* + * If sd is undefined or null or true or false, return the number of significant digits of + * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. + * If sd is true include integer-part trailing zeros in the count. + * + * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this + * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or + * ROUNDING_MODE if rm is omitted. + * + * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive. + * boolean: whether to count integer-part trailing zeros: true or false. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' + */ + P.precision = P.sd = function (sd, rm) { + var c, n, v, + x = this; + + if (sd != null && sd !== !!sd) { + intCheck(sd, 1, MAX); + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + + return round(new BigNumber(x), sd, rm); + } + + if (!(c = x.c)) return null; + v = c.length - 1; + n = v * LOG_BASE + 1; + + if (v = c[v]) { + + // Subtract the number of trailing zeros of the last element. + for (; v % 10 == 0; v /= 10, n--); + + // Add the number of digits of the first element. + for (v = c[0]; v >= 10; v /= 10, n++); + } + + if (sd && x.e + 1 > n) n = x.e + 1; + + return n; + }; + + + /* + * Return a new BigNumber whose value is the value of this BigNumber shifted by k places + * (powers of 10). Shift to the right if n > 0, and to the left if n < 0. + * + * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}' + */ + P.shiftedBy = function (k) { + intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER); + return this.times('1e' + k); + }; + + + /* + * sqrt(-n) = N + * sqrt(N) = N + * sqrt(-I) = N + * sqrt(I) = I + * sqrt(0) = 0 + * sqrt(-0) = -0 + * + * Return a new BigNumber whose value is the square root of the value of this BigNumber, + * rounded according to DECIMAL_PLACES and ROUNDING_MODE. + */ + P.squareRoot = P.sqrt = function () { + var m, n, r, rep, t, + x = this, + c = x.c, + s = x.s, + e = x.e, + dp = DECIMAL_PLACES + 4, + half = new BigNumber('0.5'); + + // Negative/NaN/Infinity/zero? + if (s !== 1 || !c || !c[0]) { + return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0); + } + + // Initial estimate. + s = Math.sqrt(+x); + + // Math.sqrt underflow/overflow? + // Pass x to Math.sqrt as integer, then adjust the exponent of the result. + if (s == 0 || s == 1 / 0) { + n = coeffToString(c); + if ((n.length + e) % 2 == 0) n += '0'; + s = Math.sqrt(n); + e = bitFloor((e + 1) / 2) - (e < 0 || e % 2); + + if (s == 1 / 0) { + n = '1e' + e; + } else { + n = s.toExponential(); + n = n.slice(0, n.indexOf('e') + 1) + e; + } + + r = new BigNumber(n); + } else { + r = new BigNumber(s + ''); + } + + // Check for zero. + // r could be zero if MIN_EXP is changed after the this value was created. + // This would cause a division by zero (x/t) and hence Infinity below, which would cause + // coeffToString to throw. + if (r.c[0]) { + e = r.e; + s = e + dp; + if (s < 3) s = 0; + + // Newton-Raphson iteration. + for (; ;) { + t = r; + r = half.times(t.plus(div(x, t, dp, 1))); + + if (coeffToString(t.c ).slice(0, s) === (n = + coeffToString(r.c)).slice(0, s)) { + + // The exponent of r may here be one less than the final result exponent, + // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits + // are indexed correctly. + if (r.e < e) --s; + n = n.slice(s - 3, s + 1); + + // The 4th rounding digit may be in error by -1 so if the 4 rounding digits + // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the + // iteration. + if (n == '9999' || !rep && n == '4999') { + + // On the first iteration only, check to see if rounding up gives the + // exact result as the nines may infinitely repeat. + if (!rep) { + round(t, t.e + DECIMAL_PLACES + 2, 0); + + if (t.times(t).eq(x)) { + r = t; + break; + } + } + + dp += 4; + s += 4; + rep = 1; + } else { + + // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact + // result. If not, then there are further digits and m will be truthy. + if (!+n || !+n.slice(1) && n.charAt(0) == '5') { + + // Truncate to the first rounding digit. + round(r, r.e + DECIMAL_PLACES + 2, 1); + m = !r.times(r).eq(x); + } + + break; + } + } + } + } + + return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m); + }; + + + /* + * Return a string representing the value of this BigNumber in exponential notation and + * rounded using ROUNDING_MODE to dp fixed decimal places. + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toExponential = function (dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX); + dp++; + } + return format(this, dp, rm, 1); + }; + + + /* + * Return a string representing the value of this BigNumber in fixed-point notation rounding + * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted. + * + * Note: as with JavaScript's number type, (-0).toFixed(0) is '0', + * but e.g. (-0.00001).toFixed(0) is '-0'. + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toFixed = function (dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX); + dp = dp + this.e + 1; + } + return format(this, dp, rm); + }; + + + /* + * Return a string representing the value of this BigNumber in fixed-point notation rounded + * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties + * of the FORMAT object (see BigNumber.set). + * + * FORMAT = { + * decimalSeparator : '.', + * groupSeparator : ',', + * groupSize : 3, + * secondaryGroupSize : 0, + * fractionGroupSeparator : '\xA0', // non-breaking space + * fractionGroupSize : 0 + * }; + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toFormat = function (dp, rm) { + var str = this.toFixed(dp, rm); + + if (this.c) { + var i, + arr = str.split('.'), + g1 = +FORMAT.groupSize, + g2 = +FORMAT.secondaryGroupSize, + groupSeparator = FORMAT.groupSeparator, + intPart = arr[0], + fractionPart = arr[1], + isNeg = this.s < 0, + intDigits = isNeg ? intPart.slice(1) : intPart, + len = intDigits.length; + + if (g2) i = g1, g1 = g2, g2 = i, len -= i; + + if (g1 > 0 && len > 0) { + i = len % g1 || g1; + intPart = intDigits.substr(0, i); + + for (; i < len; i += g1) { + intPart += groupSeparator + intDigits.substr(i, g1); + } + + if (g2 > 0) intPart += groupSeparator + intDigits.slice(i); + if (isNeg) intPart = '-' + intPart; + } + + str = fractionPart + ? intPart + FORMAT.decimalSeparator + ((g2 = +FORMAT.fractionGroupSize) + ? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'), + '$&' + FORMAT.fractionGroupSeparator) + : fractionPart) + : intPart; + } + + return str; + }; + + + /* + * Return a string array representing the value of this BigNumber as a simple fraction with + * an integer numerator and an integer denominator. The denominator will be a positive + * non-zero value less than or equal to the specified maximum denominator. If a maximum + * denominator is not specified, the denominator will be the lowest value necessary to + * represent the number exactly. + * + * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator. + * + * '[BigNumber Error] Argument {not an integer|out of range} : {md}' + */ + P.toFraction = function (md) { + var arr, d, d0, d1, d2, e, exp, n, n0, n1, q, s, + x = this, + xc = x.c; + + if (md != null) { + n = new BigNumber(md); + + // Throw if md is less than one or is not an integer, unless it is Infinity. + if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) { + throw Error + (bignumberError + 'Argument ' + + (n.isInteger() ? 'out of range: ' : 'not an integer: ') + md); + } + } + + if (!xc) return x.toString(); + + d = new BigNumber(ONE); + n1 = d0 = new BigNumber(ONE); + d1 = n0 = new BigNumber(ONE); + s = coeffToString(xc); + + // Determine initial denominator. + // d is a power of 10 and the minimum max denominator that specifies the value exactly. + e = d.e = s.length - x.e - 1; + d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp]; + md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n; + + exp = MAX_EXP; + MAX_EXP = 1 / 0; + n = new BigNumber(s); + + // n0 = d1 = 0 + n0.c[0] = 0; + + for (; ;) { + q = div(n, d, 0, 1); + d2 = d0.plus(q.times(d1)); + if (d2.comparedTo(md) == 1) break; + d0 = d1; + d1 = d2; + n1 = n0.plus(q.times(d2 = n1)); + n0 = d2; + d = n.minus(q.times(d2 = d)); + n = d2; + } + + d2 = div(md.minus(d0), d1, 0, 1); + n0 = n0.plus(d2.times(n1)); + d0 = d0.plus(d2.times(d1)); + n0.s = n1.s = x.s; + e *= 2; + + // Determine which fraction is closer to x, n0/d0 or n1/d1 + arr = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo( + div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 + ? [n1.toString(), d1.toString()] + : [n0.toString(), d0.toString()]; + + MAX_EXP = exp; + return arr; + }; + + + /* + * Return the value of this BigNumber converted to a number primitive. + */ + P.toNumber = function () { + return +this; + }; + + + /* + * Return a string representing the value of this BigNumber rounded to sd significant digits + * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits + * necessary to represent the integer part of the value in fixed-point notation, then use + * exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' + */ + P.toPrecision = function (sd, rm) { + if (sd != null) intCheck(sd, 1, MAX); + return format(this, sd, rm, 2); + }; + + + /* + * Return a string representing the value of this BigNumber in base b, or base 10 if b is + * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and + * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent + * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than + * TO_EXP_NEG, return exponential notation. + * + * [b] {number} Integer, 2 to ALPHABET.length inclusive. + * + * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' + */ + P.toString = function (b) { + var str, + n = this, + s = n.s, + e = n.e; + + // Infinity or NaN? + if (e === null) { + + if (s) { + str = 'Infinity'; + if (s < 0) str = '-' + str; + } else { + str = 'NaN'; + } + } else { + str = coeffToString(n.c); + + if (b == null) { + str = e <= TO_EXP_NEG || e >= TO_EXP_POS + ? toExponential(str, e) + : toFixedPoint(str, e, '0'); + } else { + intCheck(b, 2, ALPHABET.length, 'Base'); + str = convertBase(toFixedPoint(str, e, '0'), 10, b, s, true); + } + + if (s < 0 && n.c[0]) str = '-' + str; + } + + return str; + }; + + + /* + * Return as toString, but do not accept a base argument, and include the minus sign for + * negative zero. + */ + P.valueOf = P.toJSON = function () { + var str, + n = this, + e = n.e; + + if (e === null) return n.toString(); + + str = coeffToString(n.c); + + str = e <= TO_EXP_NEG || e >= TO_EXP_POS + ? toExponential(str, e) + : toFixedPoint(str, e, '0'); + + return n.s < 0 ? '-' + str : str; + }; + + + P._isBigNumber = true; + + if (configObject != null) BigNumber.set(configObject); + + return BigNumber; + } + + + // PRIVATE HELPER FUNCTIONS + + + function bitFloor(n) { + var i = n | 0; + return n > 0 || n === i ? i : i - 1; + } + + + // Return a coefficient array as a string of base 10 digits. + function coeffToString(a) { + var s, z, + i = 1, + j = a.length, + r = a[0] + ''; + + for (; i < j;) { + s = a[i++] + ''; + z = LOG_BASE - s.length; + for (; z--; s = '0' + s); + r += s; + } + + // Determine trailing zeros. + for (j = r.length; r.charCodeAt(--j) === 48;); + return r.slice(0, j + 1 || 1); + } + + + // Compare the value of BigNumbers x and y. + function compare(x, y) { + var a, b, + xc = x.c, + yc = y.c, + i = x.s, + j = y.s, + k = x.e, + l = y.e; + + // Either NaN? + if (!i || !j) return null; + + a = xc && !xc[0]; + b = yc && !yc[0]; + + // Either zero? + if (a || b) return a ? b ? 0 : -j : i; + + // Signs differ? + if (i != j) return i; + + a = i < 0; + b = k == l; + + // Either Infinity? + if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1; + + // Compare exponents. + if (!b) return k > l ^ a ? 1 : -1; + + j = (k = xc.length) < (l = yc.length) ? k : l; + + // Compare digit by digit. + for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1; + + // Compare lengths. + return k == l ? 0 : k > l ^ a ? 1 : -1; + } + + + /* + * Check that n is a primitive number, an integer, and in range, otherwise throw. + */ + function intCheck(n, min, max, name) { + if (n < min || n > max || n !== (n < 0 ? mathceil(n) : mathfloor(n))) { + throw Error + (bignumberError + (name || 'Argument') + (typeof n == 'number' + ? n < min || n > max ? ' out of range: ' : ' not an integer: ' + : ' not a primitive number: ') + n); + } + } + + + function isArray(obj) { + return Object.prototype.toString.call(obj) == '[object Array]'; + } + + + // Assumes finite n. + function isOdd(n) { + var k = n.c.length - 1; + return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0; + } + + + function toExponential(str, e) { + return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) + + (e < 0 ? 'e' : 'e+') + e; + } + + + function toFixedPoint(str, e, z) { + var len, zs; + + // Negative exponent? + if (e < 0) { + + // Prepend zeros. + for (zs = z + '.'; ++e; zs += z); + str = zs + str; + + // Positive exponent + } else { + len = str.length; + + // Append zeros. + if (++e > len) { + for (zs = z, e -= len; --e; zs += z); + str += zs; + } else if (e < len) { + str = str.slice(0, e) + '.' + str.slice(e); + } + } + + return str; + } + + + // EXPORT + + + BigNumber = clone(); + BigNumber['default'] = BigNumber.BigNumber = BigNumber; + + // AMD. + if (typeof define == 'function' && define.amd) { + define(function () { return BigNumber; }); + + // Node.js and other environments that support module.exports. + } else if (typeof module != 'undefined' && module.exports) { + module.exports = BigNumber; + + // Browser. + } else { + if (!globalObject) { + globalObject = typeof self != 'undefined' && self ? self : window; + } + + globalObject.BigNumber = BigNumber; + } +})(this); + +},{}],4:[function(require,module,exports){ + +},{}],5:[function(require,module,exports){ +var basex = require('base-x') +var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' + +module.exports = basex(ALPHABET) + +},{"base-x":1}],6:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + +'use strict' + +var base64 = require('base64-js') +var ieee754 = require('ieee754') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} + +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } + return arr.foo() === 42 + } catch (e) { + return false + } +} + +Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.buffer + } +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.byteOffset + } +}) + +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError( + 'The "string" argument must be of type string. Received type number' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} + +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species != null && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) +} + +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + if (ArrayBuffer.isView(value)) { + return fromArrayLike(value) + } + + if (value == null) { + throw TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) + } + + if (isInstance(value, ArrayBuffer) || + (value && isInstance(value.buffer, ArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'number') { + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) + } + + var valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) + } + + var b = fromObject(value) + if (b) return b + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && + typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from( + value[Symbol.toPrimitive]('string'), encodingOrOffset, length + ) + } + + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } +} + +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf +} + +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} + +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf +} + +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } +} + +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when // length is NaN (which is otherwise coerced to zero.) if (length >= K_MAX_LENGTH) { throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') } - return length | 0 -} + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true && + b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false +} + +Buffer.compare = function compare (a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (isInstance(buf, Uint8Array)) { + buf = Buffer.from(buf) + } + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) + } + + var len = string.length + var mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.toLocaleString = Buffer.prototype.toString + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength) + } + if (!Buffer.isBuffer(target)) { + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : Buffer.from(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass +// the `instanceof` check but they should be treated as of that type. +// See: https://github.com/feross/buffer/issues/166 +function isInstance (obj, type) { + return obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && + obj.constructor.name === type.name) +} +function numberIsNaN (obj) { + // For IE11 support + return obj !== obj // eslint-disable-line no-self-compare +} + +},{"base64-js":2,"ieee754":45}],7:[function(require,module,exports){ +'use strict' + +exports.Commented = require('./commented') +exports.Diagnose = require('./diagnose') +exports.Decoder = require('./decoder') +exports.Encoder = require('./encoder') +exports.Simple = require('./simple') +exports.Tagged = require('./tagged') +exports.Map = require('./map') + +exports.comment = exports.Commented.comment +exports.decodeAll = exports.Decoder.decodeAll +exports.decodeFirst = exports.Decoder.decodeFirst +exports.decodeAllSync = exports.Decoder.decodeAllSync +exports.decodeFirstSync = exports.Decoder.decodeFirstSync +exports.diagnose = exports.Diagnose.diagnose +exports.encode = exports.Encoder.encode +exports.encodeCanonical = exports.Encoder.encodeCanonical +exports.encodeOne = exports.Encoder.encodeOne +exports.decode = exports.Decoder.decodeFirstSync + +exports.leveldb = { + decode: exports.Decoder.decodeAllSync, + encode: exports.Encoder.encode, + buffer: true, + name: 'cbor' +} + +},{"./commented":8,"./decoder":10,"./diagnose":11,"./encoder":12,"./map":13,"./simple":14,"./tagged":15}],8:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const stream = require('stream') +const util = require('util') +const utils = require('./utils') +const Simple = require('./simple') +const Decoder = require('./decoder') +const constants = require('./constants') +const bignumber = require('bignumber.js') +const NoFilter = require('nofilter') + +const MT = constants.MT +const NUMBYTES = constants.NUMBYTES +const SYMS = constants.SYMS + +function plural(c) { + if (c > 1) { + return 's' + } else { + return '' + } +} + +/** + * Generate the expanded format of RFC 7049, section 2.2.1 + * + * @extends {stream.Transform} + */ +class Commented extends stream.Transform { + /** + * Create a CBOR commenter. + * + * @param {any} [options={}] - Stream options + * @param {bool} [options.max_depth=10] - how many times to indent the dashes + */ + constructor(options) { + options = options || {} + options.readableObjectMode = false + options.writableObjectMode = false + const max_depth = (options.max_depth != null) ? options.max_depth : 10 + delete options.max_depth + super(options) + + this.depth = 1 + this.max_depth = max_depth + this.all = new NoFilter + this.parser = new Decoder(options) + this.parser.on('value', this._on_value.bind(this)) + this.parser.on('start', this._on_start.bind(this)) + this.parser.on('start-string', this._on_start_string.bind(this)) + this.parser.on('stop', this._on_stop.bind(this)) + this.parser.on('more-bytes', this._on_more.bind(this)) + this.parser.on('error', this._on_error.bind(this)) + this.parser.on('data', this._on_data.bind(this)) + this.parser.bs.on('read', this._on_read.bind(this)) + } + + /** + * @private + */ + _transform(fresh, encoding, cb) { + this.parser.write(fresh, encoding, cb) + } + + /** + * @private + */ + _flush(cb) { + // TODO: find the test that covers this, and look at the return value + return this.parser._flush(cb) + } + + /** + * @callback commentCallback + * @param {Error} error - if one was generated + * @param {string} commented - the comment string + */ + + /** + * Comment on an input Buffer or string, creating a string passed to the + * callback. If callback not specified, a promise is returned. + * + * @static + * @param {(string|Buffer|NoFilter)} input + * @param {(string|Object|function)} options + * @param {number} [options.max_depth=10] how many times to indent the dashes + * @param {commentCallback=} cb + * @returns {Promise} if cb not specified + */ + static comment(input, options, cb) { + if (input == null) { + throw new Error('input required') + } + let encoding = (typeof input === 'string') ? 'hex' : void 0 + let max_depth = 10 + switch (typeof options) { + case 'function': + cb = options + break + case 'string': + encoding = options + break + case 'number': + max_depth = options + break + case 'object': + const ref1 = options.encoding + const ref2 = options.max_depth + encoding = (ref1 != null) ? ref1 : encoding + max_depth = (ref2 != null) ? ref2 : max_depth + break + case 'undefined': + break + default: + throw new Error('Unknown option type') + } + const bs = new NoFilter + const d = new Commented({ + max_depth: max_depth + }) + let p = null + if (typeof cb === 'function') { + d.on('end', () => { + cb(null, bs.toString('utf8')) + }) + d.on('error', cb) + } else { + p = new Promise((resolve, reject) => { + d.on('end', () => { + resolve(bs.toString('utf8')) + }) + return d.on('error', reject) + }) + } + d.pipe(bs) + d.end(input, encoding) + return p + } + + /** + * @private + */ + _on_error(er) { + return this.push('ERROR: ') && + this.push(er.toString()) && + this.push('\n') + } + + /** + * @private + */ + _on_read(buf) { + this.all.write(buf) + const hex = buf.toString('hex') + this.push(new Array(this.depth + 1).join(' ')) + this.push(hex) + let ind = (this.max_depth - this.depth) * 2 + ind -= hex.length + if (ind < 1) { + ind = 1 + } + this.push(new Array(ind + 1).join(' ')) + return this.push('-- ') + } + + /** + * @private + */ + _on_more(mt, len, parent_mt, pos) { + this.depth++ + let desc = '' + switch (mt) { + case MT.POS_INT: + desc = 'Positive number,' + break + case MT.NEG_INT: + desc = 'Negative number,' + break + case MT.ARRAY: + desc = 'Array, length' + break + case MT.MAP: + desc = 'Map, count' + break + case MT.BYTE_STRING: + desc = 'Bytes, length' + break + case MT.UTF8_STRING: + desc = 'String, length' + break + case MT.SIMPLE_FLOAT: + if (len === 1) { + desc = 'Simple value,' + } else { + desc = 'Float,' + } + break + } + return this.push(desc + ' next ' + len + ' byte' + (plural(len)) + '\n') + } + + /** + * @private + */ + _on_start_string(mt, tag, parent_mt, pos) { + this.depth++ + let desc = '' + switch (mt) { + case MT.BYTE_STRING: + desc = 'Bytes, length: ' + tag + break + case MT.UTF8_STRING: + desc = 'String, length: ' + (tag.toString()) + break + } + return this.push(desc + '\n') + } + + /** + * @private + */ + _on_start(mt, tag, parent_mt, pos) { + this.depth++ + if (tag !== SYMS.BREAK) { + this.push((() => { + switch (parent_mt) { + case MT.ARRAY: + return '[' + pos + '], ' + case MT.MAP: + if (pos % 2) { + return '{Val:' + (Math.floor(pos / 2)) + '}, ' + } else { + return '{Key:' + (Math.floor(pos / 2)) + '}, ' + } + } + })()) + } + this.push((() => { + switch (mt) { + case MT.TAG: + return 'Tag #' + tag + case MT.ARRAY: + if (tag === SYMS.STREAM) { + return 'Array (streaming)' + } else { + return 'Array, ' + tag + ' item' + (plural(tag)) + } + case MT.MAP: + if (tag === SYMS.STREAM) { + return 'Map (streaming)' + } else { + return 'Map, ' + tag + ' pair' + (plural(tag)) + } + case MT.BYTE_STRING: + return 'Bytes (streaming)' + case MT.UTF8_STRING: + return 'String (streaming)' + } + })()) + return this.push('\n') + } + + /** + * @private + */ + _on_stop(mt) { + return this.depth-- + } + + /** + * @private + */ + _on_value(val, parent_mt, pos, ai) { + if (val !== SYMS.BREAK) { + this.push((() => { + switch (parent_mt) { + case MT.ARRAY: + return '[' + pos + '], ' + case MT.MAP: + if (pos % 2) { + return '{Val:' + (Math.floor(pos / 2)) + '}, ' + } else { + return '{Key:' + (Math.floor(pos / 2)) + '}, ' + } + } + })()) + } + + if (val === SYMS.BREAK) { + this.push('BREAK\n') + } else if (val === SYMS.NULL) { + this.push('null\n') + } else if (val === SYMS.UNDEFINED) { + this.push('undefined\n') + } else if (typeof val === 'string') { + this.depth-- + if (val.length > 0 ) { + this.push(JSON.stringify(val)) + this.push('\n') + } + } else if (Buffer.isBuffer(val)) { + this.depth-- + if (val.length > 0) { + this.push(val.toString('hex')) + this.push('\n') + } + } else if (val instanceof bignumber) { + this.push(val.toString()) + this.push('\n') + } else { + this.push(util.inspect(val)) + this.push('\n') + } + + switch (ai) { + case NUMBYTES.ONE: + case NUMBYTES.TWO: + case NUMBYTES.FOUR: + case NUMBYTES.EIGHT: + this.depth-- + } + } + + /** + * @private + */ + _on_data() { + this.push('0x') + this.push(this.all.read().toString('hex')) + return this.push('\n') + } +} + +module.exports = Commented + +}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":47,"./constants":9,"./decoder":10,"./simple":14,"./utils":16,"bignumber.js":3,"nofilter":50,"stream":72,"util":78}],9:[function(require,module,exports){ +'use strict' + +exports.MT = { + POS_INT: 0, + NEG_INT: 1, + BYTE_STRING: 2, + UTF8_STRING: 3, + ARRAY: 4, + MAP: 5, + TAG: 6, + SIMPLE_FLOAT: 7 +} + +exports.TAG = { + DATE_STRING: 0, + DATE_EPOCH: 1, + POS_BIGINT: 2, + NEG_BIGINT: 3, + DECIMAL_FRAC: 4, + BIGFLOAT: 5, + BASE64URL_EXPECTED: 21, + BASE64_EXPECTED: 22, + BASE16_EXPECTED: 23, + CBOR: 24, + URI: 32, + BASE64URL: 33, + BASE64: 34, + REGEXP: 35, + MIME: 36 +} + +exports.NUMBYTES = { + ZERO: 0, + ONE: 24, + TWO: 25, + FOUR: 26, + EIGHT: 27, + INDEFINITE: 31 +} + +exports.SIMPLE = { + FALSE: 20, + TRUE: 21, + NULL: 22, + UNDEFINED: 23 +} + +exports.SYMS = { + NULL: Symbol('null'), + UNDEFINED: Symbol('undef'), + PARENT: Symbol('parent'), + BREAK: Symbol('break'), + STREAM: Symbol('stream') +} + +exports.SHIFT32 = Math.pow(2, 32) + +},{}],10:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const BinaryParseStream = require('../vendor/binary-parse-stream') +const Tagged = require('./tagged') +const Simple = require('./simple') +const utils = require('./utils') +const bignumber = require('bignumber.js') +const NoFilter = require('nofilter') +const constants = require('./constants') +// Do not fix this if you want to support node v4 +const MT = constants.MT +const NUMBYTES = constants.NUMBYTES +const SIMPLE = constants.SIMPLE +const SYMS = constants.SYMS + +const NEG_ONE = new bignumber(-1) +const NEG_MAX = NEG_ONE.minus( + new bignumber(Number.MAX_SAFE_INTEGER.toString(16), 16)) +const COUNT = Symbol('count') +const PENDING_KEY = Symbol('pending_key') +const MAJOR = Symbol('major type') +const ERROR = Symbol('error') +const NOT_FOUND = Symbol('not found') + +function parentArray(parent, typ, count) { + const a = [] + a[COUNT] = count + a[SYMS.PARENT] = parent + a[MAJOR] = typ + return a +} + +function parentBufferStream(parent, typ) { + const b = new NoFilter + b[SYMS.PARENT] = parent + b[MAJOR] = typ + return b +} + +/** + * Decode a stream of CBOR bytes by transforming them into equivalent + * JavaScript data. Because of the limitations of Node object streams, + * special symbols are emitted instead of NULL or UNDEFINED. Fix those + * up by calling {@link Decoder.nullcheck}. + * + * @extends {BinaryParseStream} + */ +class Decoder extends BinaryParseStream { + + /** + * Create a parsing stream. + * + * @param {object} [options={}] + * @param {number} [options.max_depth=-1] - the maximum depth to parse. + * Use -1 for "until you run out of memory". Set this to a finite + * positive number for un-trusted inputs. Most standard inputs won't nest + * more than 100 or so levels; I've tested into the millions before + * running out of memory. + * @param {object=} options.tags - mapping from tag number to function(v), + * where v is the decoded value that comes after the tag, and where the + * function returns the correctly-created value for that tag. + */ + constructor(options) { + options = options || {} + const tags = options.tags + delete options.tags + const max_depth = (options.max_depth != null) ? options.max_depth : -1 + delete options.max_depth + super(options) + + this.running = true + this.max_depth = max_depth + this.tags = tags + } + + /** + * Check the given value for a symbol encoding a NULL or UNDEFINED value in + * the CBOR stream. + * + * @static + * @param {any} val - the value to check + * @returns {any} the corrected value + * + * @example + * myDecoder.on('data', function(val) { + * val = Decoder.nullcheck(val); + * ... + * }); + */ + static nullcheck(val) { + switch (val) { + case SYMS.NULL: + return null + case SYMS.UNDEFINED: + return undefined + case NOT_FOUND: + throw new Error('Value not found') + default: + return val + } + } + + /** + * Decode the first CBOR item in the input, synchronously. This will throw an + * exception if the input is not valid CBOR. + * + * @static + * @param {(string|Buffer)} input + * @param {object} [options={encoding: 'hex'}] + * @param {string} [options.encoding: 'hex'] - The encoding of the input. + * Ignored if input is a Buffer. + * @returns {any} - the decoded value + */ + static decodeFirstSync(input, options) { + options = options || { encoding: 'hex' } + let opts = {} + let encod + switch (typeof options) { + case 'string': + encod = options + break + case 'object': + opts = utils.extend({}, options) + encod = opts.encoding + delete opts.encoding + break + } + const c = new Decoder(opts) + const s = new NoFilter( + input, + encod != null ? encod : utils.guessEncoding(input)) + const parser = c._parse() + let state = parser.next() + while (!state.done) { + const b = s.read(state.value) + if ((b == null) || (b.length !== state.value)) { + throw new Error('Insufficient data') + } + state = parser.next(b) + } + return Decoder.nullcheck(state.value) + } + + /** + * Decode all of the CBOR items in the input into an array. This will throw + * an exception if the input is not valid CBOR; a zero-length input will + * return an empty array. + * + * @static + * @param {(string|Buffer)} input + * @param {(string|Object)} [options={encoding: 'hex'}] + * @param {string} [options.encoding: 'hex'] - The encoding of the input. + * Ignored if input is a Buffer. + * @returns {Array} - Array of all found items + */ + static decodeAllSync(input, options) { + options = options || { encoding: 'hex' } + let opts = {} + let encod + switch (typeof options) { + case 'string': + encod = options + break + case 'object': + opts = utils.extend({}, options) + encod = opts.encoding + delete opts.encoding + } + const c = new Decoder(opts) + const s = new NoFilter( + input, + encod != null ? encod : utils.guessEncoding(input)) + const res = [] + while (s.length > 0) { + const parser = c._parse() + let state = parser.next() + while (!state.done) { + const b = s.read(state.value) + if ((b == null) || (b.length !== state.value)) { + throw new Error('Insufficient data') + } + state = parser.next(b) + } + res.push(Decoder.nullcheck(state.value)) + } + return res + } + + /** + * @callback decodeCallback + * @param {Error} error - if one was generated + * @param {any} value - the decoded value + */ + + /** + * Decode the first CBOR item in the input. This will error if there are more + * bytes left over at the end, and optionally if there were no valid CBOR + * bytes in the input. Emits the {Decoder.NOT_FOUND} Symbol in the callback + * if no data was found and the `required` option is false. + * + * @static + * @param {(string|Buffer)} input - the input to parse + * @param {(function|string|Object)} options + * @param {string} [options.encoding: 'hex'] - The encoding of the input. + * Ignored if input is a Buffer. + * @param {decodeCallback} cb + * @returns {Promise} if no cb specified + */ + static decodeFirst(input, options, cb) { + let opts = {} + let required = false + let encod = 'hex' + switch (typeof options) { + case 'function': + cb = options + encod = utils.guessEncoding(input) + break + case 'string': + encod = options + break + case 'object': + opts = utils.extend({}, options) + encod = (opts.encoding != null) ? + opts.encoding : utils.guessEncoding(input) + delete opts.encoding + required = (opts.required != null) ? opts.required : false + delete opts.required + } + const c = new Decoder(opts) + let p + let v = NOT_FOUND + c.on('data', (val) => { + v = Decoder.nullcheck(val) + c.close() + }) + if (typeof cb === 'function') { + c.once('error', (er) => { + const u = v + v = ERROR + c.close() + return cb(er, u) + }) + c.once('end', () => { + switch (v) { + case NOT_FOUND: + if (required) { + return cb(new Error('No CBOR found')) + } else { + return cb(null, v) + } + case ERROR: + return void 0 + default: + return cb(null, v) + } + }) + } else { + p = new Promise((resolve, reject) => { + c.once('error', (er) => { + v = ERROR + c.close() + return reject(er) + }) + return c.once('end', () => { + switch (v) { + case NOT_FOUND: + if (required) { + return reject(new Error('No CBOR found')) + } else { + return resolve(v) + } + case ERROR: + return void 0 + default: + return resolve(v) + } + }) + }) + } + c.end(input, encod) + return p + } + + /** + * @callback decodeAllCallback + * @param {Error} error - if one was generated + * @param {Array} value - all of the decoded values, wrapped in an Array + */ + + /** + * Decode all of the CBOR items in the input. This will error if there are + * more bytes left over at the end. + * + * @static + * @param {(string|Buffer)} input - the input to parse + * @param {(string|Object)} options - Decoding options. + * If string, the input encoding. + * @param {decodeAllCallback} cb + * @returns {Promise} if no callback + */ + static decodeAll(input, options, cb) { + let opts = {} + let encod = 'hex' + switch (typeof options) { + case 'function': + cb = options + encod = utils.guessEncoding(input) + break + case 'string': + encod = options + break + case 'object': + opts = utils.extend({}, options) + encod = (opts.encoding != null) ? + opts.encoding : utils.guessEncoding(input) + delete opts.encoding + } + const c = new Decoder(opts) + let p + const vals = [] + c.on('data', (val) => { + return vals.push(Decoder.nullcheck(val)) + }) + if (typeof cb === 'function') { + c.on('error', cb) + c.on('end', () => cb(null, vals)) + } else { + p = new Promise((resolve, reject) => { + c.on('error', reject) + c.on('end', () => resolve(vals)) + }) + } + c.end(input, encod) + return p + } + + /** + * Stop processing + */ + close() { + this.running = false + this.__fresh = true + } + + *_parse() { + let parent = null + let depth = 0 + let val = null + while (true) { + if ((this.max_depth >= 0) && (depth > this.max_depth)) { + throw new Error('Maximum depth ' + this.max_depth + ' exceeded') + } + const octet = (yield 1)[0] + if (!this.running) { + throw new Error('Unexpected data: 0x' + (octet.toString(16))) + } + const mt = octet >> 5 + const ai = octet & 0x1f + const parent_major = (parent != null) ? parent[MAJOR] : undefined + const parent_length = (parent != null) ? parent.length : undefined + switch (ai) { + case NUMBYTES.ONE: + this.emit('more-bytes', mt, 1, parent_major, parent_length) + val = (yield 1)[0] + break + case NUMBYTES.TWO: + case NUMBYTES.FOUR: + case NUMBYTES.EIGHT: + const numbytes = 1 << (ai - 24) + this.emit('more-bytes', mt, numbytes, parent_major, parent_length) + const buf = yield numbytes + val = (mt === MT.SIMPLE_FLOAT) ? buf : utils.parseCBORint(ai, buf) + break + case 28: + case 29: + case 30: + this.running = false + throw new Error('Additional info not implemented: ' + ai) + case NUMBYTES.INDEFINITE: + val = -1 + break + default: + val = ai + } + switch (mt) { + case MT.POS_INT: + // val already decoded + break + case MT.NEG_INT: + if (val === Number.MAX_SAFE_INTEGER) { + val = NEG_MAX + } else if (val instanceof bignumber) { + val = NEG_ONE.minus(val) + } else { + val = -1 - val + } + break + case MT.BYTE_STRING: + case MT.UTF8_STRING: + switch (val) { + case 0: + this.emit('start-string', mt, val, parent_major, parent_length) + val = (mt === MT.BYTE_STRING) ? Buffer.allocUnsafe(0) : '' + break + case -1: + this.emit('start', mt, SYMS.STREAM, parent_major, parent_length) + parent = parentBufferStream(parent, mt) + depth++ + continue + default: + this.emit('start-string', mt, val, parent_major, parent_length) + val = yield val + if (mt === MT.UTF8_STRING) { + val = val.toString('utf-8') + } + } + break + case MT.ARRAY: + case MT.MAP: + switch (val) { + case 0: + val = (mt === MT.MAP) ? {} : [] + break + case -1: + this.emit('start', mt, SYMS.STREAM, parent_major, parent_length) + parent = parentArray(parent, mt, -1) + depth++ + continue + default: + this.emit('start', mt, val, parent_major, parent_length) + parent = parentArray(parent, mt, val * (mt - 3)) + depth++ + continue + } + break + case MT.TAG: + this.emit('start', mt, val, parent_major, parent_length) + parent = parentArray(parent, mt, 1) + parent.push(val) + depth++ + continue + case MT.SIMPLE_FLOAT: + if (typeof val === 'number') { + val = Simple.decode(val, parent != null) + } else { + val = utils.parseCBORfloat(val) + } + } + this.emit('value', val, parent_major, parent_length, ai) + let again = false + while (parent != null) { + switch (false) { + case val !== SYMS.BREAK: + parent[COUNT] = 1 + break + case !Array.isArray(parent): + parent.push(val) + break + case !(parent instanceof NoFilter): + const pm = parent[MAJOR] + if ((pm != null) && (pm !== mt)) { + this.running = false + throw new Error('Invalid major type in indefinite encoding') + } + parent.write(val) + } + if ((--parent[COUNT]) !== 0) { + again = true + break + } + --depth + delete parent[COUNT] + this.emit('stop', parent[MAJOR]) + + if (Array.isArray(parent)) { + switch (parent[MAJOR]) { + case MT.ARRAY: + val = parent + break + case MT.MAP: + let allstrings = true + if ((parent.length % 2) !== 0) { + throw new Error('Invalid map length: ' + parent.length) + } + for (let i = 0, len = parent.length; i < len; i += 2) { + if (typeof parent[i] !== 'string') { + allstrings = false + break + } + } + if (allstrings) { + val = {} + for (let i = 0, len = parent.length; i < len; i += 2) { + val[parent[i]] = parent[i + 1] + } + } else { + val = new Map + for (let i = 0, len = parent.length; i < len; i += 2) { + val.set(parent[i], parent[i + 1]) + } + } + break + case MT.TAG: + const t = new Tagged(parent[0], parent[1]) + val = t.convert(this.tags) + break + } + } else if (parent instanceof NoFilter) { + switch (parent[MAJOR]) { + case MT.BYTE_STRING: + val = parent.slice() + break + case MT.UTF8_STRING: + val = parent.toString('utf-8') + break + } + } + + const old = parent + parent = parent[SYMS.PARENT] + delete old[SYMS.PARENT] + delete old[MAJOR] + } + if (!again) { + return val + } + } + } +} + +Decoder.NOT_FOUND = NOT_FOUND +module.exports = Decoder + +}).call(this,require("buffer").Buffer) +},{"../vendor/binary-parse-stream":17,"./constants":9,"./simple":14,"./tagged":15,"./utils":16,"bignumber.js":3,"buffer":6,"nofilter":50}],11:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const stream = require('stream') +const util = require('util') +const Decoder = require('./decoder') +const Simple = require('./simple') +const utils = require('./utils') +const constants = require('./constants') +const bignumber = require('bignumber.js') +const NoFilter = require('nofilter') + +const MT = constants.MT +const SYMS = constants.SYMS + +/** + * Output the diagnostic format from a stream of CBOR bytes. + * + * @extends {stream.Transform} + */ +class Diagnose extends stream.Transform { + + /** + * Creates an instance of Diagnose. + * + * @param {Object} [options={}] - options for creation + * @param {string} [options.separator='\n'] - output between detected objects + * @param {bool} [options.stream_errors=false] - put error info into the + * output stream + * @param {number} [options.max_depth=-1] - -1 for "until you run out of + * memory". Set this to a finite positive number for un-trusted inputs. + * Most standard inputs won't nest more than 100 or so levels; I've tested + * into the millions before running out of memory. + */ + constructor(options) { + options = options || {} + const separator = (options.separator != null) ? options.separator : '\n' + delete options.separator + const stream_errors = (options.stream_errors != null) ? + options.stream_errors : false + delete options.stream_errors + options.readableObjectMode = false + options.writableObjectMode = false + super(options) + + this.float_bytes = -1 + this.separator = separator + this.stream_errors = stream_errors + this.parser = new Decoder(options) + this.parser.on('more-bytes', this._on_more.bind(this)) + this.parser.on('value', this._on_value.bind(this)) + this.parser.on('start', this._on_start.bind(this)) + this.parser.on('stop', this._on_stop.bind(this)) + this.parser.on('data', this._on_data.bind(this)) + this.parser.on('error', this._on_error.bind(this)) + } + + _transform(fresh, encoding, cb) { + return this.parser.write(fresh, encoding, cb) + } + + _flush(cb) { + return this.parser._flush((er) => { + if (this.stream_errors) { + this._on_error(er) + return cb() + } else { + return cb(er) + } + }) + } + + /** + * Convenience function to return a string in diagnostic format. + * + * @param {(Buffer|string)} input - the CBOR bytes to format + * @param {string} [encoding='hex'] - the encoding of input, ignored if + * input is Buffer + * @param {commentCallback} cb - callback + * @returns {Promise} if callback not specified + */ + static diagnose(input, encoding, cb) { + if (input == null) { + throw new Error('input required') + } + let opts = {} + let encod = 'hex' + switch (typeof encoding) { + case 'function': + cb = encoding + encod = utils.guessEncoding(input) + break + case 'object': + opts = utils.extend({}, encoding) + encod = (opts.encoding != null) ? + opts.encoding : utils.guessEncoding(input) + delete opts.encoding + break + default: + encod = (encoding != null) ? encoding : 'hex' + } + const bs = new NoFilter + const d = new Diagnose(opts) + let p = null + if (typeof cb === 'function') { + d.on('end', () => cb(null, bs.toString('utf8'))) + d.on('error', cb) + } else { + p = new Promise((resolve, reject) => { + d.on('end', () => resolve(bs.toString('utf8'))) + return d.on('error', reject) + }) + } + d.pipe(bs) + d.end(input, encod) + return p + } + + _on_error(er) { + if (this.stream_errors) { + return this.push(er.toString()) + } else { + return this.emit('error', er) + } + } + + _on_more(mt, len, parent_mt, pos) { + if (mt === MT.SIMPLE_FLOAT) { + return this.float_bytes = (function() { + switch (len) { + case 2: + return 1 + case 4: + return 2 + case 8: + return 3 + } + })() + } + } + + _fore(parent_mt, pos) { + switch (parent_mt) { + case MT.BYTE_STRING: + case MT.UTF8_STRING: + case MT.ARRAY: + if (pos > 0) { + return this.push(', ') + } + break + case MT.MAP: + if (pos > 0) { + if (pos % 2) { + return this.push(': ') + } else { + return this.push(', ') + } + } + } + } + + _on_value(val, parent_mt, pos) { + if (val === SYMS.BREAK) { + return + } + this._fore(parent_mt, pos) + return this.push((function() { + switch (false) { + case val !== SYMS.NULL: + return 'null' + case val !== SYMS.UNDEFINED: + return 'undefined' + case typeof val !== 'string': + return JSON.stringify(val) + case !(this.float_bytes > 0): + const fb = this.float_bytes + this.float_bytes = -1 + return (util.inspect(val)) + '_' + fb + case !Buffer.isBuffer(val): + return 'h\'' + (val.toString('hex')) + '\'' + case !(val instanceof bignumber): + return val.toString() + default: + return util.inspect(val) + } + }).call(this)) + } + + _on_start(mt, tag, parent_mt, pos) { + this._fore(parent_mt, pos) + this.push((function() { + switch (mt) { + case MT.TAG: + return tag + '(' + case MT.ARRAY: + return '[' + case MT.MAP: + return '{' + case MT.BYTE_STRING: + case MT.UTF8_STRING: + return '(' + default: + // istanbul ignore next + throw new Error('Unknown diagnostic type: ' + mt) + } + })()) + if (tag === SYMS.STREAM) { + return this.push('_ ') + } + } + + _on_stop(mt) { + return this.push((function() { + switch (mt) { + case MT.TAG: + return ')' + case MT.ARRAY: + return ']' + case MT.MAP: + return '}' + case MT.BYTE_STRING: + case MT.UTF8_STRING: + return ')' + default: + // istanbul ignore next + throw new Error('Unknown diagnostic type: ' + mt) + } + })()) + } + + _on_data() { + return this.push(this.separator) + } +} + +module.exports = Diagnose + +}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":47,"./constants":9,"./decoder":10,"./simple":14,"./utils":16,"bignumber.js":3,"nofilter":50,"stream":72,"util":78}],12:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const stream = require('stream') +const url = require('url') +const bignumber = require('bignumber.js') +const NoFilter = require('nofilter') +const Tagged = require('./tagged') +const Simple = require('./simple') +const utils = require('./utils') + +const constants = require('./constants') +const MT = constants.MT +const NUMBYTES = constants.NUMBYTES +const SHIFT32 = constants.SHIFT32 +const SYMS = constants.SYMS +const TAG = constants.TAG +const HALF = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.TWO +const FLOAT = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.FOUR +const DOUBLE = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.EIGHT +const TRUE = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.TRUE +const FALSE = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.FALSE +const UNDEFINED = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.UNDEFINED +const NULL = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.NULL + +const MAXINT_BN = new bignumber('0x20000000000000') +const BUF_NAN = Buffer.from('f97e00', 'hex') +const BUF_INF_NEG = Buffer.from('f9fc00', 'hex') +const BUF_INF_POS = Buffer.from('f97c00', 'hex') +const BUF_NEG_ZERO = Buffer.from('f98000', 'hex') +const LOOP_DETECT = Symbol('CBOR_LOOP_DETECT') + +/** + * Transform JavaScript values into CBOR bytes. The `Writable` side of + * the stream is in object mode. + * + * @extends {stream.Transform} + */ +class Encoder extends stream.Transform { + + /** + * Creates an instance of Encoder. + * + * @param {Object} [options={}] - options for the encoder + * @param {any[]} [options.genTypes=[]] - array of pairs of `type`, + * `function(Encoder)` for semantic types to be encoded. Not needed + * for Array, Date, Buffer, Map, RegExp, Set, Url, or bignumber. + * @param {boolean} [options.canonical=false] - should the output be + * canonicalized + * @param {boolean|Symbol} [options.detectLoops=false] - should object loops + * be detected? This will currently modify the encoded object graph + * by adding a Symbol property to each object. If this bothers you, + * call `removeLoopDetectors` on the encoded object when done. Do not + * encode the same object twice on the same encoder, without calling + * `removeLoopDetectors` in between. + * @param {("number"|"float"|"int"|"string")} [options.dateType="number"] - + * how should dates be encoded? "number" means float or int, if no + * fractional seconds. + */ + constructor(options) { + options = options || {} + options.readableObjectMode = false + options.writableObjectMode = true + super(options) + + this.canonical = options.canonical + this.dateType = (options.dateType != null) ? + options.dateType.toLowerCase() : 'number' + + // new Symbol for each instance. Note: means we can't re-use the same + // encoder and encoded object + if (typeof(options.detectLoops) === 'symbol') { + this.detectLoops = options.detectLoops + } else { + this.detectLoops = !!options.detectLoops ? Symbol('CBOR_DETECT') : null + } + + this.semanticTypes = [ + Array, this._pushArray, + Date, this._pushDate, + Buffer, this._pushBuffer, + Map, this._pushMap, + NoFilter, this._pushNoFilter, + RegExp, this._pushRegexp, + Set, this._pushSet, + url.Url, this._pushUrl, + bignumber, this._pushBigNumber + ] + + const addTypes = options.genTypes || [] + for (let i = 0, len = addTypes.length; i < len; i += 2) { + this.addSemanticType(addTypes[i], addTypes[i + 1]) + } + } + + _transform(fresh, encoding, cb) { + const ret = this.pushAny(fresh) + // Old transformers might not return bool. undefined !== false + return cb((ret === false) ? new Error('Push Error') : undefined) + } + + _flush(cb) { + return cb() + } + + /** + * @callback encodeFunction + * @param {Encoder} encoder - the encoder to serialize into. Call "write" + * on the encoder as needed. + * @return {bool} - true on success, else false + */ + + /** + * Add an encoding function to the list of supported semantic types. This is + * useful for objects for which you can't add an encodeCBOR method + * + * @param {any} type + * @param {any} fun + * @returns {encodeFunction} + */ + addSemanticType(type, fun) { + for (let i = 0, len = this.semanticTypes.length; i < len; i += 2) { + const typ = this.semanticTypes[i] + if (typ === type) { + const old = this.semanticTypes[i + 1] + this.semanticTypes[i + 1] = fun + return old + } + } + this.semanticTypes.push(type, fun) + return null + } + + _pushUInt8(val) { + const b = Buffer.allocUnsafe(1) + b.writeUInt8(val) + return this.push(b) + } + + _pushUInt16BE(val) { + const b = Buffer.allocUnsafe(2) + b.writeUInt16BE(val) + return this.push(b) + } + + _pushUInt32BE(val) { + const b = Buffer.allocUnsafe(4) + b.writeUInt32BE(val) + return this.push(b) + } + + _pushDoubleBE(val) { + const b = Buffer.allocUnsafe(8) + b.writeDoubleBE(val) + return this.push(b) + } + + _pushNaN() { + return this.push(BUF_NAN) + } + + _pushInfinity(obj) { + const half = (obj < 0) ? BUF_INF_NEG : BUF_INF_POS + return this.push(half) + } + + _pushFloat(obj) { + if (this.canonical) { + // TODO: is this enough slower to hide behind canonical? + // It's certainly enough of a hack (see utils.parseHalf) + + // From section 3.9: + // If a protocol allows for IEEE floats, then additional canonicalization + // rules might need to be added. One example rule might be to have all + // floats start as a 64-bit float, then do a test conversion to a 32-bit + // float; if the result is the same numeric value, use the shorter value + // and repeat the process with a test conversion to a 16-bit float. (This + // rule selects 16-bit float for positive and negative Infinity as well.) + + // which seems pretty much backwards to me. + const b2 = Buffer.allocUnsafe(2) + if (utils.writeHalf(b2, obj)) { + if (utils.parseHalf(b2) === obj) { + return this._pushUInt8(HALF) && this.push(b2) + } + } + const b4 = Buffer.allocUnsafe(4) + b4.writeFloatBE(obj) + if (b4.readFloatBE(0) === obj) { + return this._pushUInt8(FLOAT) && this.push(b4) + } + } + + return this._pushUInt8(DOUBLE) && this._pushDoubleBE(obj) + } + + _pushInt(obj, mt, orig) { + const m = mt << 5 + switch (false) { + case !(obj < 24): + return this._pushUInt8(m | obj) + case !(obj <= 0xff): + return this._pushUInt8(m | NUMBYTES.ONE) && this._pushUInt8(obj) + case !(obj <= 0xffff): + return this._pushUInt8(m | NUMBYTES.TWO) && this._pushUInt16BE(obj) + case !(obj <= 0xffffffff): + return this._pushUInt8(m | NUMBYTES.FOUR) && this._pushUInt32BE(obj) + case !(obj <= Number.MAX_SAFE_INTEGER): + return this._pushUInt8(m | NUMBYTES.EIGHT) && + this._pushUInt32BE(Math.floor(obj / SHIFT32)) && + this._pushUInt32BE(obj % SHIFT32) + default: + if (mt === MT.NEG_INT) { + return this._pushFloat(orig) + } else { + return this._pushFloat(obj) + } + } + } + + _pushIntNum(obj) { + if (Object.is(obj, -0)) { + return this.push(BUF_NEG_ZERO) + } + + if (obj < 0) { + return this._pushInt(-obj - 1, MT.NEG_INT, obj) + } else { + return this._pushInt(obj, MT.POS_INT) + } + } + + _pushNumber(obj) { + switch (false) { + case !isNaN(obj): + return this._pushNaN(obj) + case isFinite(obj): + return this._pushInfinity(obj) + case Math.round(obj) !== obj: + return this._pushIntNum(obj) + default: + return this._pushFloat(obj) + } + } + + _pushString(obj) { + const len = Buffer.byteLength(obj, 'utf8') + return this._pushInt(len, MT.UTF8_STRING) && this.push(obj, 'utf8') + } + + _pushBoolean(obj) { + return this._pushUInt8(obj ? TRUE : FALSE) + } + + _pushUndefined(obj) { + return this._pushUInt8(UNDEFINED) + } + + _pushNull(obj) { + return this._pushUInt8(NULL) + } + + _pushArray(gen, obj) { + const len = obj.length + if (!gen._pushInt(len, MT.ARRAY)) { + return false + } + for (let j = 0; j < len; j++) { + if (!gen.pushAny(obj[j])) { + return false + } + } + return true + } + + _pushTag(tag) { + return this._pushInt(tag, MT.TAG) + } + + _pushDate(gen, obj) { + switch (gen.dateType) { + case 'string': + return gen._pushTag(TAG.DATE_STRING) && + gen._pushString(obj.toISOString()) + case 'int': + case 'integer': + return gen._pushTag(TAG.DATE_EPOCH) && + gen._pushIntNum(Math.round(obj / 1000)) + case 'float': + // force float + return gen._pushTag(TAG.DATE_EPOCH) && + gen._pushFloat(obj / 1000) + case 'number': + default: + // if we happen to have an integral number of seconds, + // use integer. Otherwise, use float. + return gen._pushTag(TAG.DATE_EPOCH) && + gen.pushAny(obj / 1000) + } + } + + _pushBuffer(gen, obj) { + return gen._pushInt(obj.length, MT.BYTE_STRING) && gen.push(obj) + } + + _pushNoFilter(gen, obj) { + return gen._pushBuffer(gen, obj.slice()) + } + + _pushRegexp(gen, obj) { + return gen._pushTag(TAG.REGEXP) && gen.pushAny(obj.source) + } + + _pushSet(gen, obj) { + if (!gen._pushInt(obj.size, MT.ARRAY)) { + return false + } + for (const x of obj) { + if (!gen.pushAny(x)) { + return false + } + } + return true + } + + _pushUrl(gen, obj) { + return gen._pushTag(TAG.URI) && gen.pushAny(obj.format()) + } + + _pushBigint(obj) { + let tag = TAG.POS_BIGINT + if (obj.isNegative()) { + obj = obj.negated().minus(1) + tag = TAG.NEG_BIGINT + } + let str = obj.toString(16) + if (str.length % 2) { + str = '0' + str + } + const buf = Buffer.from(str, 'hex') + return this._pushTag(tag) && this._pushBuffer(this, buf) + } + + _pushBigNumber(gen, obj) { + if (obj.isNaN()) { + return gen._pushNaN() + } + if (!obj.isFinite()) { + return gen._pushInfinity(obj.isNegative() ? -Infinity : Infinity) + } + if (obj.isInteger()) { + return gen._pushBigint(obj) + } + if (!(gen._pushTag(TAG.DECIMAL_FRAC) && + gen._pushInt(2, MT.ARRAY))) { + return false + } + + const dec = obj.decimalPlaces() + const slide = obj.times(new bignumber(10).pow(dec)) + if (!gen._pushIntNum(-dec)) { + return false + } + if (slide.abs().isLessThan(MAXINT_BN)) { + return gen._pushIntNum(slide.toNumber()) + } else { + return gen._pushBigint(slide) + } + } + + _pushMap(gen, obj) { + if (!gen._pushInt(obj.size, MT.MAP)) { + return false + } + // memoizing the cbor only helps in certain cases, and hurts in most + // others. Just avoid it. + if (gen.canonical) { + // keep the key/value pairs together, so we don't have to do odd + // gets with object keys later + const entries = [] + // iterator. If we drop support for node4, use ... + for (const e of obj.entries()) { + entries.push(e) + } + entries.sort((a, b) => { + // a, b are both entries of [key, value] + const a_cbor = Encoder.encode(a[0]) + const b_cbor = Encoder.encode(b[0]) + return a_cbor.compare(b_cbor) + }) + for (const kv of entries) { + if (!(gen.pushAny(kv[0]) && gen.pushAny(kv[1]))) { + return false + } + } + } else { + for (const kv of obj) { + if (!(gen.pushAny(kv[0]) && gen.pushAny(kv[1]))) { + return false + } + } + } + return true + } + + removeLoopDetectors(obj) { + if (!this.detectLoops || (typeof(obj) !== 'object') || !obj) { + return false + } + const dl = obj[LOOP_DETECT] + if (!dl || (dl !== this.detectLoops)) { + // ironically, use loop marking to detect loops on removal as well + return false + } + delete obj[LOOP_DETECT] + if (Array.isArray(obj)) { + for (const i of obj) { + this.removeLoopDetectors(i) + } + } else { + for (const k in obj) { + this.removeLoopDetectors(obj[k]) + } + } + return true + } + + _pushObject(obj) { + if (!obj) { + return this._pushNull(obj) + } + if (this.detectLoops) { + if (obj[LOOP_DETECT] === this.detectLoops) { + throw new Error('Loop detected while CBOR encoding') + } else { + obj[LOOP_DETECT] = this.detectLoops + } + } + const f = obj.encodeCBOR + if (typeof f === 'function') { + return f.call(obj, this) + } + for (let i = 0, len1 = this.semanticTypes.length; i < len1; i += 2) { + const typ = this.semanticTypes[i] + if (obj instanceof typ) { + return this.semanticTypes[i + 1].call(obj, this, obj) + } + } + const keys = Object.keys(obj) + const cbor_keys = {} + if (this.canonical) { + // note: this can't be a normal sort, because 'b' needs to sort before + // 'aa' + keys.sort((a, b) => { + // Always strings, so don't bother to pass options. + // hold on to the cbor versions, since there's no need + // to encode more than once + const a_cbor = cbor_keys[a] || (cbor_keys[a] = Encoder.encode(a)) + const b_cbor = cbor_keys[b] || (cbor_keys[b] = Encoder.encode(b)) + + return a_cbor.compare(b_cbor) + }) + } + if (!this._pushInt(keys.length, MT.MAP)) { + return false + } + let ck + for (let j = 0, len2 = keys.length; j < len2; j++) { + const k = keys[j] + if (this.canonical && ((ck = cbor_keys[k]))) { + if (!this.push(ck)) { // already a Buffer + return false + } + } else { + if (!this._pushString(k)) { + return false + } + } + if (!this.pushAny(obj[k])) { + return false + } + } + + return true + } + + /** + * Push any supported type onto the encoded stream + * + * @param {any} obj + * @returns {boolean} true on success + */ + pushAny(obj) { + switch (typeof obj) { + case 'number': + return this._pushNumber(obj) + case 'string': + return this._pushString(obj) + case 'boolean': + return this._pushBoolean(obj) + case 'undefined': + return this._pushUndefined(obj) + case 'object': + return this._pushObject(obj) + case 'symbol': + switch (obj) { + case SYMS.NULL: + return this._pushNull(null) + case SYMS.UNDEFINED: + return this._pushUndefined(void 0) + // TODO: Add pluggable support for other symbols + default: + throw new Error('Unknown symbol: ' + obj.toString()) + } + default: + throw new Error( + 'Unknown type: ' + typeof obj + ', ' + + (!!obj ? obj.toString() : '')) + } + } + + /* backwards-compat wrapper */ + _pushAny(obj) { + // TODO: write deprecation warning + return this.pushAny(obj) + } + + _encodeAll(objs) { + const bs = new NoFilter() + this.pipe(bs) + for (const o of objs) { + if (typeof o === 'undefined') { + this._pushUndefined() + } else if (o === null) { + this._pushNull(null) + } else { + this.write(o) + } + } + this.end() + return bs.read() + } + + /** + * Encode one or more JavaScript objects, and return a Buffer containing the + * CBOR bytes. + * + * @param {...any} objs - the objects to encode + * @returns {Buffer} - the encoded objects + */ + static encode() { + const objs = Array.prototype.slice.apply(arguments) + return new Encoder()._encodeAll(objs) + } + + /** + * Encode one or more JavaScript objects canonically (slower!), and return + * a Buffer containing the CBOR bytes. + * + * @param {...any} objs - the objects to encode + * @returns {Buffer} - the encoded objects + */ + static encodeCanonical() { + const objs = Array.prototype.slice.apply(arguments) + return new Encoder({canonical: true})._encodeAll(objs) + } + + /** + * Encode one JavaScript object using the given options. + * + * @static + * @param {any} obj - the object to encode + * @param {Object?} options - passed to the Encoder constructor + * @returns {Buffer} - the encoded objects + */ + static encodeOne(obj, options) { + return new Encoder(options)._encodeAll([obj]) + } +} + +module.exports = Encoder + +}).call(this,require("buffer").Buffer) +},{"./constants":9,"./simple":14,"./tagged":15,"./utils":16,"bignumber.js":3,"buffer":6,"nofilter":50,"stream":72,"url":74}],13:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const encoder = require('./encoder') +const decoder = require('./decoder') +const constants = require('./constants') +const MT = constants.MT + +/** + * Wrapper around a JavaScript Map object that allows the keys to be + * any complex type. The base Map object allows this, but will only + * compare the keys by identity, not by value. CborMap translates keys + * to CBOR first (and base64's them to ensure by-value comparison). + * + * This is not a subclass of Object, because it would be tough to get + * the semantics to be an exact match. + * + * @class CborMap + * @extends {Map} + */ +class CborMap extends Map { + /** + * Creates an instance of CborMap. + * @param {Iterable>} args An Array or other iterable object + * whose elements are key-value pairs (arrays with two elements, e.g. + * [[ 1, 'one' ],[ 2, 'two' ]]). Each key-value pair is added + * to the new CborMap; null values are treated as undefined. + */ + constructor(iterable) { + super(iterable) + } + + /** + * @private + */ + static _encode(key) { + return encoder.encodeCanonical(key).toString('base64') + } + + /** + * @private + */ + static _decode(key) { + return decoder.decodeFirstSync(key, 'base64') + } + + /** + * Retrieve a specified element. + * + * @param {any} key The key identifying the element to retrieve. + * Can be any type, which will be serialized into CBOR and compared by + * value. + * @returns {any} The element if it exists, or undefined. + */ + get(key) { + return super.get(CborMap._encode(key)) + } + + /** + * Adds or updates an element with a specified key and value. + * + * @param {any} key The key identifying the element to store. + * Can be any type, which will be serialized into CBOR and compared by + * value. + * @param {any} val The element to store + */ + set(key, val) { + return super.set(CborMap._encode(key), val) + } + + /** + * Removes the specified element. + * + * @param {any} key The key identifying the element to delete. + * Can be any type, which will be serialized into CBOR and compared by + * value. + * @returns {boolean} + */ + delete(key) { + return super.delete(CborMap._encode(key)) + } + + /** + * Does an element with the specified key exist? + * + * @param {any} key The key identifying the element to check. + * Can be any type, which will be serialized into CBOR and compared by + * value. + * @returns {boolean} + */ + has(key) { + return super.has(CborMap._encode(key)) + } + + /** + * Returns a new Iterator object that contains the keys for each element + * in the Map object in insertion order. The keys are decoded into their + * original format. + * + * @returns {Iterator} + */ + *keys() { + for (const k of super.keys()) { + yield CborMap._decode(k) + } + } + + /** + * Returns a new Iterator object that contains the [key, value] pairs for + * each element in the Map object in insertion order. + * + * @returns {Iterator.>} + */ + *entries() { + for (const kv of super.entries()) { + yield [CborMap._decode(kv[0]), kv[1]] + } + } + + /** + * Returns a new Iterator object that contains the [key, value] pairs for + * each element in the Map object in insertion order. + * + * @returns {Iterator.>} + */ + [Symbol.iterator]() { + return this.entries() + } + + /** + * Executes a provided function once per each key/value pair in the Map + * object, in insertion order. + * + * @param {function(any, any, CborMap)} fun Function to execute for each + * element, which takes a value, a key, and the Map being traversed. + * @param {any} thisArg Value to use as this when executing callback + */ + forEach(fun, thisArg) { + if (typeof(fun) !== 'function') { + throw new TypeError('Must be function') + } + for (const kv of super.entries()) { + fun.call(this, kv[1], CborMap._decode(kv[0]), this) + } + } + + /** + * Push the simple value onto the CBOR stream + * + * @param {cbor.Encoder} gen The generator to push onto + * @returns {boolean} true on success + */ + encodeCBOR(gen) { + if (!gen._pushInt(this.size, MT.MAP)) { + return false + } + if (gen.canonical) { + const entries = Array.from(super.entries()) + .map((kv) => [Buffer.from(kv[0], 'base64'), kv[1]]) + entries.sort((a, b) => a[0].compare(b[0])) + for (const kv of entries) { + if (!(gen.push(kv[0]) && gen.pushAny(kv[1]))) { + return false + } + } + } else { + for (const kv of super.entries()) { + if (!(gen.push(Buffer.from(kv[0], 'base64')) && gen.pushAny(kv[1]))) { + return false + } + } + } + return true + } +} + +module.exports = CborMap +}).call(this,require("buffer").Buffer) +},{"./constants":9,"./decoder":10,"./encoder":12,"buffer":6}],14:[function(require,module,exports){ +'use strict' + +const util = require('util') +const constants = require('./constants') +const MT = constants.MT +const SIMPLE = constants.SIMPLE +const SYMS = constants.SYMS + +/** + * A CBOR Simple Value that does not map onto a known constant. + */ +class Simple { + /** + * Creates an instance of Simple. + * + * @param {integer} value - the simple value's integer value + */ + constructor(value) { + if (typeof value !== 'number') { + throw new Error('Invalid Simple type: ' + (typeof value)) + } + if ((value < 0) || (value > 255) || ((value|0) !== value)) { + throw new Error('value must be a small positive integer: ' + value) + } + this.value = value + } + + /** + * Debug string for simple value + * + * @returns {string} simple(value) + */ + toString() { + return 'simple(' + this.value + ')' + } + + /** + * Debug string for simple value + * + * @returns {string} simple(value) + */ + [util.inspect.custom](depth, opts) { + return 'simple(' + this.value + ')' + } + + /** + * Debug string for simple value (backward-compatibility version) + * + * @returns {string} simple(value) + */ + inspect(depth, opts) { + return 'simple(' + this.value + ')' + } + + /** + * Push the simple value onto the CBOR stream + * + * @param {cbor.Encoder} gen The generator to push onto + */ + encodeCBOR(gen) { + return gen._pushInt(this.value, MT.SIMPLE_FLOAT) + } + + /** + * Is the given object a Simple? + * + * @param {any} obj - object to test + * @returns {bool} - is it Simple? + */ + static isSimple(obj) { + return obj instanceof Simple + } + + /** + * Decode from the CBOR additional information into a JavaScript value. + * If the CBOR item has no parent, return a "safe" symbol instead of + * `null` or `undefined`, so that the value can be passed through a + * stream in object mode. + * + * @param {number} val - the CBOR additional info to convert + * @param {bool} has_parent - Does the CBOR item have a parent? + * @returns {(null|undefined|bool|Symbol)} - the decoded value + */ + static decode(val, has_parent) { + if (has_parent == null) { + has_parent = true + } + switch (val) { + case SIMPLE.FALSE: + return false + case SIMPLE.TRUE: + return true + case SIMPLE.NULL: + if (has_parent) { + return null + } else { + return SYMS.NULL + } + case SIMPLE.UNDEFINED: + if (has_parent) { + return void 0 + } else { + return SYMS.UNDEFINED + } + case -1: + if (!has_parent) { + throw new Error('Invalid BREAK') + } + return SYMS.BREAK + default: + return new Simple(val) + } + } +} + +module.exports = Simple + +},{"./constants":9,"util":78}],15:[function(require,module,exports){ +'use strict' + +const bignumber = require('bignumber.js') +const utils = require('./utils') +const url = require('url') + +const MINUS_ONE = new bignumber(-1) +const TEN = new bignumber(10) +const TWO = new bignumber(2) + +/** + * A CBOR tagged item, where the tag does not have semantics specified at the + * moment, or those semantics threw an error during parsing. Typically this will + * be an extension point you're not yet expecting. + */ +class Tagged { + + /** + * Creates an instance of Tagged. + * + * @param {number} tag - the number of the tag + * @param {any} value - the value inside the tag + * @param {Error} err - the error that was thrown parsing the tag, or null + */ + constructor(tag, value, err) { + this.tag = tag + this.value = value + this.err = err + if (typeof this.tag !== 'number') { + throw new Error('Invalid tag type (' + (typeof this.tag) + ')') + } + if ((this.tag < 0) || ((this.tag | 0) !== this.tag)) { + throw new Error('Tag must be a positive integer: ' + this.tag) + } + } + + /** + * Convert to a String + * + * @returns {string} string of the form '1(2)' + */ + toString() { + return `${this.tag}(${JSON.stringify(this.value)})` + } + + /** + * Push the simple value onto the CBOR stream + * + * @param {cbor.Encoder} gen The generator to push onto + */ + encodeCBOR(gen) { + gen._pushTag(this.tag) + return gen.pushAny(this.value) + } + + /** + * If we have a converter for this type, do the conversion. Some converters + * are built-in. Additional ones can be passed in. If you want to remove + * a built-in converter, pass a converter in whose value is 'null' instead + * of a function. + * + * @param {Object} converters - keys in the object are a tag number, the value + * is a function that takes the decoded CBOR and returns a JavaScript value + * of the appropriate type. Throw an exception in the function on errors. + * @returns {any} - the converted item + */ + convert(converters) { + let f = converters != null ? converters[this.tag] : void 0 + if (typeof f !== 'function') { + f = Tagged['_tag_' + this.tag] + if (typeof f !== 'function') { + return this + } + } + try { + return f.call(Tagged, this.value) + } catch (error) { + this.err = error + return this + } + } + + static _tag_0(v) { + return new Date(v) + } + + static _tag_1(v) { + return new Date(v * 1000) + } + + static _tag_2(v) { + return utils.bufferToBignumber(v) + } + + static _tag_3(v) { + return MINUS_ONE.minus(utils.bufferToBignumber(v)) + } + + static _tag_4(v) { + return TEN.pow(v[0]).times(v[1]) + } + + static _tag_5(v) { + return TWO.pow(v[0]).times(v[1]) + } + + static _tag_32(v) { + return url.parse(v) + } + + static _tag_35(v) { + return new RegExp(v) + } +} + +module.exports = Tagged + +},{"./utils":16,"bignumber.js":3,"url":74}],16:[function(require,module,exports){ +(function (process,Buffer){ +'use strict' + +const fs = require('fs') +const stream = require('stream') +const bignumber = require('bignumber.js') + +const constants = require('./constants') +const NUMBYTES = constants.NUMBYTES +const SHIFT32 = constants.SHIFT32 +const MAX_SAFE_HIGH = 0x1fffff + +exports.parseCBORint = function(ai, buf) { + switch (ai) { + case NUMBYTES.ONE: + return buf.readUInt8(0) + case NUMBYTES.TWO: + return buf.readUInt16BE(0) + case NUMBYTES.FOUR: + return buf.readUInt32BE(0) + case NUMBYTES.EIGHT: + const f = buf.readUInt32BE(0) + const g = buf.readUInt32BE(4) + if (f > MAX_SAFE_HIGH) { + return new bignumber(f).times(SHIFT32).plus(g) + } else { + return (f * SHIFT32) + g + } + default: + throw new Error('Invalid additional info for int: ' + ai) + } +} + +exports.writeHalf = function writeHalf(buf, half) { + // assume 0, -0, NaN, Infinity, and -Infinity have already been caught + + // HACK: everyone settle in. This isn't going to be pretty. + // Translate cn-cbor's C code (from Carsten Borman): + + // uint32_t be32; + // uint16_t be16, u16; + // union { + // float f; + // uint32_t u; + // } u32; + // u32.f = float_val; + + const u32 = Buffer.allocUnsafe(4) + u32.writeFloatBE(half) + const u = u32.readUInt32BE(0) + + // if ((u32.u & 0x1FFF) == 0) { /* worth trying half */ + + // hildjj: If the lower 13 bits are 0, + // we won't lose anything in the conversion + if ((u & 0x1FFF) !== 0) { + return false + } + + // int s16 = (u32.u >> 16) & 0x8000; + // int exp = (u32.u >> 23) & 0xff; + // int mant = u32.u & 0x7fffff; + + let s16 = (u >> 16) & 0x8000 // top bit is sign + const exp = (u >> 23) & 0xff // then 5 bits of exponent + const mant = u & 0x7fffff + + // if (exp == 0 && mant == 0) + // ; /* 0.0, -0.0 */ + + // hildjj: zeros already handled. Assert if you don't believe me. + + // else if (exp >= 113 && exp <= 142) /* normalized */ + // s16 += ((exp - 112) << 10) + (mant >> 13); + + if ((exp >= 113) && (exp <= 142)) { + s16 += ((exp - 112) << 10) + (mant >> 13) + } else if ((exp >= 103) && (exp < 113)) { + // else if (exp >= 103 && exp < 113) { /* denorm, exp16 = 0 */ + // if (mant & ((1 << (126 - exp)) - 1)) + // goto float32; /* loss of precision */ + // s16 += ((mant + 0x800000) >> (126 - exp)); + + if (mant & ((1 << (126 - exp)) - 1)) { + return false + } + s16 += ((mant + 0x800000) >> (126 - exp)) + } else { + // } else if (exp == 255 && mant == 0) { /* Inf */ + // s16 += 0x7c00; + + // hildjj: Infinity already handled + + // } else + // goto float32; /* loss of range */ + + return false + } + + // ensure_writable(3); + // u16 = s16; + // be16 = hton16p((const uint8_t*)&u16); + buf.writeUInt16BE(s16) + return true +} + +exports.parseHalf = function parseHalf(buf) { + const sign = buf[0] & 0x80 ? -1 : 1 + const exp = (buf[0] & 0x7C) >> 2 + const mant = ((buf[0] & 0x03) << 8) | buf[1] + if (!exp) { + return sign * 5.9604644775390625e-8 * mant + } else if (exp === 0x1f) { + return sign * (mant ? 0 / 0 : 2e308) + } else { + return sign * Math.pow(2, exp - 25) * (1024 + mant) + } +} + +exports.parseCBORfloat = function parseCBORfloat(buf) { + switch (buf.length) { + case 2: + return exports.parseHalf(buf) + case 4: + return buf.readFloatBE(0) + case 8: + return buf.readDoubleBE(0) + default: + throw new Error('Invalid float size: ' + buf.length) + } +} + +exports.hex = function hex(s) { + return Buffer.from(s.replace(/^0x/, ''), 'hex') +} + +exports.bin = function bin(s) { + s = s.replace(/\s/g, '') + let start = 0 + let end = (s.length % 8) || 8 + const chunks = [] + while (end <= s.length) { + chunks.push(parseInt(s.slice(start, end), 2)) + start = end + end += 8 + } + return Buffer.from(chunks) +} + +exports.extend = function extend() { + let old = arguments[0] + const adds = (2 <= arguments.length) ? + Array.prototype.slice.call(arguments, 1) : [] + const len = adds.length + if (old == null) { + old = {} + } + for (let j = 0; j < len; j++) { + const a = adds[j] + for (const k in a) { + const v = a[k] + old[k] = v + } + } + return old +} + +exports.arrayEqual = function arrayEqual(a, b) { + if ((a == null) && (b == null)) { + return true + } + if ((a == null) || (b == null)) { + return false + } + return (a.length === b.length) && a.every((elem, i) => elem === b[i]) +} + +exports.bufferEqual = function bufferEqual(a, b) { + if ((a == null) && (b == null)) { + return true + } + if ((a == null) || (b == null)) { + return false + } + if (!(Buffer.isBuffer(a) && Buffer.isBuffer(b) && (a.length === b.length))) { + return false + } + const len = a.length + let ret = true + let i + let j + for (i = j = 0; j < len; i = ++j) { + const byte = a[i] + ret &= b[i] === byte + } + return !!ret +} + +exports.bufferToBignumber = function bufferToBignumber(buf) { + return new bignumber(buf.toString('hex'), 16) +} + +exports.DeHexStream = class DeHexStream extends stream.Readable { + constructor(hex) { + super() + hex = hex.replace(/^0x/, '') + if (hex) { + this.push(Buffer.from(hex, 'hex')) + } + this.push(null) + } +} + +exports.HexStream = class HexStream extends stream.Transform { + constructor(options) { + super(options) + } + + _transform(fresh, encoding, cb) { + this.push(fresh.toString('hex')) + return cb() + } +} + +function printError(er) { + if (er != null) { + return console.log(er) + } +} + +exports.streamFiles = function streamFiles(files, streamFunc, cb) { + if (cb == null) { + cb = printError + } + const f = files.shift() + if (!f) { + return cb() + } + const sf = streamFunc() + sf.on('end', () => exports.streamFiles(files, streamFunc, cb)) + sf.on('error', cb) + const s = (f === '-') ? + process.stdin : (f instanceof stream.Stream) ? f : fs.createReadStream(f) + s.on('error', cb) + return s.pipe(sf) +} + +exports.guessEncoding = function guessEncoding(input) { + switch (false) { + case typeof input !== 'string': + return 'hex' + case !Buffer.isBuffer(input): + return undefined + default: + throw new Error('Unknown input type') + } +} + +}).call(this,require('_process'),require("buffer").Buffer) +},{"./constants":9,"_process":52,"bignumber.js":3,"buffer":6,"fs":4,"stream":72}],17:[function(require,module,exports){ +// Tweaked version of nathan7's binary-parse-stream +// (see https://github.com/nathan7/binary-parse-stream) +// Uses NoFilter instead of the readable in the original. Removes +// the ability to read -1, which was odd and un-needed. +// License for binary-parse-stream: MIT + +'use strict'; +exports = module.exports = BinaryParseStream +var Stream = require('stream') + , TransformStream = Stream.Transform + , inherits = require('util').inherits + , NoFilter = require('nofilter') + +exports.One = -1 + +inherits(BinaryParseStream, TransformStream) +function BinaryParseStream(options) { + TransformStream.call(this, options) + this._writableState.objectMode = false + this._readableState.objectMode = true + + this.bs = new NoFilter() + this.__restart() +} + +BinaryParseStream.prototype._transform = function(fresh, encoding, cb) { var self = this + this.bs.write(fresh) + + while (this.bs.length >= this.__needed) { + var ret + , chunk = this.__needed === null + ? undefined + : this.bs.read(this.__needed) + + try { ret = this.__parser.next(chunk) } + catch (e) { + return cb(e) } + + if (this.__needed) + this.__fresh = false + + if (!ret.done) + this.__needed = ret.value | 0 + else { + this.push(ret.value) + this.__restart() + } + } + + return cb() +} + +BinaryParseStream.prototype.__restart = function() { + this.__needed = null + this.__parser = this._parse() + this.__fresh = true +} + +BinaryParseStream.prototype._flush = function(cb) { + cb(this.__fresh + ? null + : new Error('unexpected end of input')) +} + +},{"nofilter":50,"stream":72,"util":78}],18:[function(require,module,exports){ +(function (Buffer){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":47}],19:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc1').default; + +},{"./es6/crc1":30}],20:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16').default; + +},{"./es6/crc16":31}],21:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16ccitt').default; + +},{"./es6/crc16ccitt":32}],22:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16kermit').default; + +},{"./es6/crc16kermit":33}],23:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16modbus').default; + +},{"./es6/crc16modbus":34}],24:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16xmodem').default; + +},{"./es6/crc16xmodem":35}],25:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc24').default; + +},{"./es6/crc24":36}],26:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc32').default; + +},{"./es6/crc32":37}],27:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc8').default; + +},{"./es6/crc8":38}],28:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc81wire').default; + +},{"./es6/crc81wire":39}],29:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crcjam').default; + +},{"./es6/crcjam":40}],30:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var crc1 = (0, _define_crc2.default)('crc1', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = ~~previous; + var accum = 0; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + accum += byte; + } + + crc += accum % 256; + return crc % 256; +}); + +exports.default = crc1; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],31:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc16 = (0, _define_crc2.default)('crc-16', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = ~~previous; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; + } + + return crc; +}); + +exports.default = crc16; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],32:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=ccitt --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc16ccitt = (0, _define_crc2.default)('ccitt', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc >> 8 ^ byte) & 0xff] ^ crc << 8) & 0xffff; + } + + return crc; +}); + +exports.default = crc16ccitt; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],33:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc16kermit = (0, _define_crc2.default)('kermit', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0x0000; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; + } + + return crc; +}); + +exports.default = crc16kermit; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],34:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16-modbus --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc16modbus = (0, _define_crc2.default)('crc-16-modbus', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; + } + + return crc; +}); + +exports.default = crc16modbus; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],35:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var crc16xmodem = (0, _define_crc2.default)('xmodem', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0x0; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + var code = crc >>> 8 & 0xff; + + code ^= byte & 0xff; + code ^= code >>> 4; + crc = crc << 8 & 0xffff; + crc ^= code; + code = code << 5 & 0xffff; + crc ^= code; + code = code << 7 & 0xffff; + crc ^= code; + } + + return crc; +}); + +exports.default = crc16xmodem; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],36:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-drive --model=crc-24 --generate=c` +// prettier-ignore +var TABLE = [0x000000, 0x864cfb, 0x8ad50d, 0x0c99f6, 0x93e6e1, 0x15aa1a, 0x1933ec, 0x9f7f17, 0xa18139, 0x27cdc2, 0x2b5434, 0xad18cf, 0x3267d8, 0xb42b23, 0xb8b2d5, 0x3efe2e, 0xc54e89, 0x430272, 0x4f9b84, 0xc9d77f, 0x56a868, 0xd0e493, 0xdc7d65, 0x5a319e, 0x64cfb0, 0xe2834b, 0xee1abd, 0x685646, 0xf72951, 0x7165aa, 0x7dfc5c, 0xfbb0a7, 0x0cd1e9, 0x8a9d12, 0x8604e4, 0x00481f, 0x9f3708, 0x197bf3, 0x15e205, 0x93aefe, 0xad50d0, 0x2b1c2b, 0x2785dd, 0xa1c926, 0x3eb631, 0xb8faca, 0xb4633c, 0x322fc7, 0xc99f60, 0x4fd39b, 0x434a6d, 0xc50696, 0x5a7981, 0xdc357a, 0xd0ac8c, 0x56e077, 0x681e59, 0xee52a2, 0xe2cb54, 0x6487af, 0xfbf8b8, 0x7db443, 0x712db5, 0xf7614e, 0x19a3d2, 0x9fef29, 0x9376df, 0x153a24, 0x8a4533, 0x0c09c8, 0x00903e, 0x86dcc5, 0xb822eb, 0x3e6e10, 0x32f7e6, 0xb4bb1d, 0x2bc40a, 0xad88f1, 0xa11107, 0x275dfc, 0xdced5b, 0x5aa1a0, 0x563856, 0xd074ad, 0x4f0bba, 0xc94741, 0xc5deb7, 0x43924c, 0x7d6c62, 0xfb2099, 0xf7b96f, 0x71f594, 0xee8a83, 0x68c678, 0x645f8e, 0xe21375, 0x15723b, 0x933ec0, 0x9fa736, 0x19ebcd, 0x8694da, 0x00d821, 0x0c41d7, 0x8a0d2c, 0xb4f302, 0x32bff9, 0x3e260f, 0xb86af4, 0x2715e3, 0xa15918, 0xadc0ee, 0x2b8c15, 0xd03cb2, 0x567049, 0x5ae9bf, 0xdca544, 0x43da53, 0xc596a8, 0xc90f5e, 0x4f43a5, 0x71bd8b, 0xf7f170, 0xfb6886, 0x7d247d, 0xe25b6a, 0x641791, 0x688e67, 0xeec29c, 0x3347a4, 0xb50b5f, 0xb992a9, 0x3fde52, 0xa0a145, 0x26edbe, 0x2a7448, 0xac38b3, 0x92c69d, 0x148a66, 0x181390, 0x9e5f6b, 0x01207c, 0x876c87, 0x8bf571, 0x0db98a, 0xf6092d, 0x7045d6, 0x7cdc20, 0xfa90db, 0x65efcc, 0xe3a337, 0xef3ac1, 0x69763a, 0x578814, 0xd1c4ef, 0xdd5d19, 0x5b11e2, 0xc46ef5, 0x42220e, 0x4ebbf8, 0xc8f703, 0x3f964d, 0xb9dab6, 0xb54340, 0x330fbb, 0xac70ac, 0x2a3c57, 0x26a5a1, 0xa0e95a, 0x9e1774, 0x185b8f, 0x14c279, 0x928e82, 0x0df195, 0x8bbd6e, 0x872498, 0x016863, 0xfad8c4, 0x7c943f, 0x700dc9, 0xf64132, 0x693e25, 0xef72de, 0xe3eb28, 0x65a7d3, 0x5b59fd, 0xdd1506, 0xd18cf0, 0x57c00b, 0xc8bf1c, 0x4ef3e7, 0x426a11, 0xc426ea, 0x2ae476, 0xaca88d, 0xa0317b, 0x267d80, 0xb90297, 0x3f4e6c, 0x33d79a, 0xb59b61, 0x8b654f, 0x0d29b4, 0x01b042, 0x87fcb9, 0x1883ae, 0x9ecf55, 0x9256a3, 0x141a58, 0xefaaff, 0x69e604, 0x657ff2, 0xe33309, 0x7c4c1e, 0xfa00e5, 0xf69913, 0x70d5e8, 0x4e2bc6, 0xc8673d, 0xc4fecb, 0x42b230, 0xddcd27, 0x5b81dc, 0x57182a, 0xd154d1, 0x26359f, 0xa07964, 0xace092, 0x2aac69, 0xb5d37e, 0x339f85, 0x3f0673, 0xb94a88, 0x87b4a6, 0x01f85d, 0x0d61ab, 0x8b2d50, 0x145247, 0x921ebc, 0x9e874a, 0x18cbb1, 0xe37b16, 0x6537ed, 0x69ae1b, 0xefe2e0, 0x709df7, 0xf6d10c, 0xfa48fa, 0x7c0401, 0x42fa2f, 0xc4b6d4, 0xc82f22, 0x4e63d9, 0xd11cce, 0x575035, 0x5bc9c3, 0xdd8538]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc24 = (0, _define_crc2.default)('crc-24', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0xb704ce; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc >> 16 ^ byte) & 0xff] ^ crc << 8) & 0xffffff; + } + + return crc; +}); + +exports.default = crc24; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],37:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c` +// prettier-ignore +var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc32 = (0, _define_crc2.default)('crc-32', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = previous === 0 ? 0 : ~~previous ^ -1; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; + } + + return crc ^ -1; +}); + +exports.default = crc32; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],38:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-8 --generate=c` +// prettier-ignore +var TABLE = [0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc8 = (0, _define_crc2.default)('crc-8', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = ~~previous; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] & 0xff; + } + + return crc; +}); + +exports.default = crc8; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],39:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c` +// prettier-ignore +var TABLE = [0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62, 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff, 0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07, 0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a, 0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24, 0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9, 0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd, 0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50, 0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee, 0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73, 0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5, 0x8b, 0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16, 0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8, 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc81wire = (0, _define_crc2.default)('dallas-1-wire', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = ~~previous; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] & 0xff; + } + + return crc; +}); + +exports.default = crc81wire; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],40:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=jam --generate=c` +// prettier-ignore +var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crcjam = (0, _define_crc2.default)('jam', function (buf) { + var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; + + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = previous === 0 ? 0 : ~~previous; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; + } + + return crc; +}); + +exports.default = crcjam; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],41:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var createBuffer = _buffer.Buffer.from && _buffer.Buffer.alloc && _buffer.Buffer.allocUnsafe && _buffer.Buffer.allocUnsafeSlow ? _buffer.Buffer.from : // support for Node < 5.10 +function (val) { + return new _buffer.Buffer(val); +}; + +exports.default = createBuffer; + +},{"buffer":6}],42:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function (model, calc) { + var fn = function fn(buf, previous) { + return calc(buf, previous) >>> 0; + }; + fn.signed = calc; + fn.unsigned = fn; + fn.model = model; + + return fn; +}; + +},{}],43:[function(require,module,exports){ +'use strict'; + +module.exports = { + crc1: require('./crc1'), + crc8: require('./crc8'), + crc81wire: require('./crc8_1wire'), + crc16: require('./crc16'), + crc16ccitt: require('./crc16_ccitt'), + crc16modbus: require('./crc16_modbus'), + crc16xmodem: require('./crc16_xmodem'), + crc16kermit: require('./crc16_kermit'), + crc24: require('./crc24'), + crc32: require('./crc32'), + crcjam: require('./crcjam') +}; + +},{"./crc1":19,"./crc16":20,"./crc16_ccitt":21,"./crc16_kermit":22,"./crc16_modbus":23,"./crc16_xmodem":24,"./crc24":25,"./crc32":26,"./crc8":27,"./crc8_1wire":28,"./crcjam":29}],44:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + +},{}],45:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + +},{}],46:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + +},{}],47:[function(require,module,exports){ +/*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh + * @license MIT + */ + +// The _isBuffer check is for Safari 5-7 support, because it's missing +// Object.prototype.constructor. Remove this eventually +module.exports = function (obj) { + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) +} + +function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +} + +// For Node v0.10 support. Remove this eventually. +function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) +} + +},{}],48:[function(require,module,exports){ +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + +},{}],49:[function(require,module,exports){ +/* + A JavaScript implementation of the SHA family of hashes, as + defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding + HMAC implementation as defined in FIPS PUB 198a + + Copyright Brian Turek 2008-2017 + Distributed under the BSD License + See http://caligatio.github.com/jsSHA/ for more information + + Several functions taken from Paul Johnston +*/ +'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; +b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> +5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); +}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> +6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==k&&k 0) && (om !== _this._readableState.objectMode)) { + throw new Error('Do not switch objectMode in the middle of the stream'); + } + _this._readableState.objectMode = om; + return _this._writableState.objectMode = om; + }; + })(this)); + } + if (inp != null) { + this.end(inp, inpE); + } + } + + NoFilter.isNoFilter = function(obj) { + return obj instanceof this; + }; + + NoFilter.compare = function(nf1, nf2) { + if (!(nf1 instanceof this)) { + throw new TypeError('Arguments must be NoFilters'); + } + if (nf1 === nf2) { + return 0; + } else { + return nf1.compare(nf2); + } + }; + + NoFilter.concat = function(list, length) { + var bufs; + if (!Array.isArray(list)) { + throw new TypeError('list argument must be an Array of NoFilters'); + } + if ((list.length === 0) || (length === 0)) { + return new Buffer(0); + } + if (length == null) { + length = list.reduce(function(tot, nf) { + if (!(nf instanceof NoFilter)) { + throw new TypeError('list argument must be an Array of NoFilters'); + } + return tot + nf.length; + }, 0); + } + bufs = list.map(function(nf) { + if (!(nf instanceof NoFilter)) { + throw new TypeError('list argument must be an Array of NoFilters'); + } + if (nf._readableState.objectMode) { + throw new Error('NoFilter may not be in object mode for concat'); + } + return nf.slice(); + }); + return Buffer.concat(bufs, length); + }; + + NoFilter.prototype._transform = function(chunk, encoding, callback) { + if (!this._readableState.objectMode && !Buffer.isBuffer(chunk)) { + chunk = new Buffer(chunk, encoding); + } + this.push(chunk); + return callback(); + }; + + NoFilter.prototype._bufArray = function() { + var b, bufs; + bufs = this._readableState.buffer; + if (!Array.isArray(bufs)) { + b = bufs.head; + bufs = []; + while (b != null) { + bufs.push(b.data); + b = b.next; + } + } + return bufs; + }; + + NoFilter.prototype.read = function(size) { + var buf; + buf = NoFilter.__super__.read.call(this, size); + if (buf != null) { + this.emit('read', buf); + } + return buf; + }; + + NoFilter.prototype.promise = function(cb) { + var done; + done = false; + return new Promise((function(_this) { + return function(resolve, reject) { + _this.on('finish', function() { + var data; + data = _this.read(); + if ((cb != null) && !done) { + done = true; + cb(null, data); + } + return resolve(data); + }); + return _this.on('error', function(er) { + if ((cb != null) && !done) { + done = true; + cb(er); + } + return reject(er); + }); + }; + })(this)); + }; + + NoFilter.prototype.compare = function(other) { + if (!(other instanceof NoFilter)) { + throw new TypeError('Arguments must be NoFilters'); + } + if (this._readableState.objectMode || other._readableState.objectMode) { + throw new Error('Must not be in object mode to compare'); + } + if (this === other) { + return 0; + } else { + return this.slice().compare(other.slice()); + } + }; + + NoFilter.prototype.equals = function(other) { + return this.compare(other) === 0; + }; + + NoFilter.prototype.slice = function(start, end) { + var b, bufs; + if (this._readableState.objectMode) { + return this._bufArray().slice(start, end); + } else { + bufs = this._bufArray(); + switch (bufs.length) { + case 0: + return new Buffer(0); + case 1: + return bufs[0].slice(start, end); + default: + b = Buffer.concat(bufs); + return b.slice(start, end); + } + } + }; + + NoFilter.prototype.get = function(index) { + return this.slice()[index]; + }; + + NoFilter.prototype.toJSON = function() { + var b; + b = this.slice(); + if (Buffer.isBuffer(b)) { + return b.toJSON(); + } else { + return b; + } + }; + + NoFilter.prototype.toString = function(encoding, start, end) { + return this.slice().toString(encoding, start, end); + }; + + NoFilter.prototype.inspect = function(depth, options) { + var bufs, hex; + bufs = this._bufArray(); + hex = bufs.map(function(b) { + if (Buffer.isBuffer(b)) { + if (options != null ? options.stylize : void 0) { + return options.stylize(b.toString('hex'), 'string'); + } else { + return b.toString('hex'); + } + } else { + return util.inspect(b, options); + } + }).join(', '); + return this.constructor.name + " [" + hex + "]"; + }; + + _read_gen = function(meth, len) { + return function(val) { + var b; + b = this.read(len); + if (!Buffer.isBuffer(b)) { + return null; + } + return b[meth].call(b, 0, true); + }; + }; + + _write_gen = function(meth, len) { + return function(val) { + var b; + b = new Buffer(len); + b[meth].call(b, val, 0, true); + return this.push(b); + }; + }; + + NoFilter.prototype.writeUInt8 = _write_gen('writeUInt8', 1); + + NoFilter.prototype.writeUInt16LE = _write_gen('writeUInt16LE', 2); + + NoFilter.prototype.writeUInt16BE = _write_gen('writeUInt16BE', 2); + + NoFilter.prototype.writeUInt32LE = _write_gen('writeUInt32LE', 4); + + NoFilter.prototype.writeUInt32BE = _write_gen('writeUInt32BE', 4); + + NoFilter.prototype.writeInt8 = _write_gen('writeInt8', 1); + + NoFilter.prototype.writeInt16LE = _write_gen('writeInt16LE', 2); + + NoFilter.prototype.writeInt16BE = _write_gen('writeInt16BE', 2); + + NoFilter.prototype.writeInt32LE = _write_gen('writeInt32LE', 4); + + NoFilter.prototype.writeInt32BE = _write_gen('writeInt32BE', 4); + + NoFilter.prototype.writeFloatLE = _write_gen('writeFloatLE', 4); + + NoFilter.prototype.writeFloatBE = _write_gen('writeFloatBE', 4); + + NoFilter.prototype.writeDoubleLE = _write_gen('writeDoubleLE', 8); + + NoFilter.prototype.writeDoubleBE = _write_gen('writeDoubleBE', 8); + + NoFilter.prototype.readUInt8 = _read_gen('readUInt8', 1); + + NoFilter.prototype.readUInt16LE = _read_gen('readUInt16LE', 2); + + NoFilter.prototype.readUInt16BE = _read_gen('readUInt16BE', 2); + + NoFilter.prototype.readUInt32LE = _read_gen('readUInt32LE', 4); + + NoFilter.prototype.readUInt32BE = _read_gen('readUInt32BE', 4); + + NoFilter.prototype.readInt8 = _read_gen('readInt8', 1); + + NoFilter.prototype.readInt16LE = _read_gen('readInt16LE', 2); + + NoFilter.prototype.readInt16BE = _read_gen('readInt16BE', 2); + + NoFilter.prototype.readInt32LE = _read_gen('readInt32LE', 4); + + NoFilter.prototype.readInt32BE = _read_gen('readInt32BE', 4); + + NoFilter.prototype.readFloatLE = _read_gen('readFloatLE', 4); + + NoFilter.prototype.readFloatBE = _read_gen('readFloatBE', 4); + + NoFilter.prototype.readDoubleLE = _read_gen('readDoubleLE', 8); + + NoFilter.prototype.readDoubleBE = _read_gen('readDoubleBE', 8); + + get = function(props) { + var getter, name, results; + results = []; + for (name in props) { + getter = props[name]; + results.push(NoFilter.prototype.__defineGetter__(name, getter)); + } + return results; + }; + + get({ + length: function() { + return this._readableState.length; + } + }); + + return NoFilter; + + })(stream.Transform); + +}).call(this); + + + +}).call(this,require("buffer").Buffer) +},{"buffer":6,"stream":72,"util":78}],51:[function(require,module,exports){ +(function (process){ +'use strict'; + +if (!process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = { nextTick: nextTick }; +} else { + module.exports = process +} + +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } +} + + +}).call(this,require('_process')) +},{"_process":52}],52:[function(require,module,exports){ +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],53:[function(require,module,exports){ +(function (global){ +/*! https://mths.be/punycode v1.4.1 by @mathias */ +;(function(root) { + + /** Detect free variables */ + var freeExports = typeof exports == 'object' && exports && + !exports.nodeType && exports; + var freeModule = typeof module == 'object' && module && + !module.nodeType && module; + var freeGlobal = typeof global == 'object' && global; + if ( + freeGlobal.global === freeGlobal || + freeGlobal.window === freeGlobal || + freeGlobal.self === freeGlobal + ) { + root = freeGlobal; + } + + /** + * The `punycode` object. + * @name punycode + * @type Object + */ + var punycode, + + /** Highest positive signed 32-bit float value */ + maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 + + /** Bootstring parameters */ + base = 36, + tMin = 1, + tMax = 26, + skew = 38, + damp = 700, + initialBias = 72, + initialN = 128, // 0x80 + delimiter = '-', // '\x2D' + + /** Regular expressions */ + regexPunycode = /^xn--/, + regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars + regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators + + /** Error messages */ + errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }, + + /** Convenience shortcuts */ + baseMinusTMin = base - tMin, + floor = Math.floor, + stringFromCharCode = String.fromCharCode, + + /** Temporary variable */ + key; + + /*--------------------------------------------------------------------------*/ + + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error(type) { + throw new RangeError(errors[type]); + } + + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var length = array.length; + var result = []; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } + + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } + + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = [], + counter = 0, + length = string.length, + value, + extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } + + /** + * Creates a string based on an array of numeric code points. + * @see `punycode.ucs2.decode` + * @memberOf punycode.ucs2 + * @name encode + * @param {Array} codePoints The array of numeric code points. + * @returns {String} The new Unicode string (UCS-2). + */ + function ucs2encode(array) { + return map(array, function(value) { + var output = ''; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; + } + output += stringFromCharCode(value); + return output; + }).join(''); + } + + /** + * Converts a basic code point into a digit/integer. + * @see `digitToBasic()` + * @private + * @param {Number} codePoint The basic numeric code point value. + * @returns {Number} The numeric value of a basic code point (for use in + * representing integers) in the range `0` to `base - 1`, or `base` if + * the code point does not represent a value. + */ + function basicToDigit(codePoint) { + if (codePoint - 48 < 10) { + return codePoint - 22; + } + if (codePoint - 65 < 26) { + return codePoint - 65; + } + if (codePoint - 97 < 26) { + return codePoint - 97; + } + return base; + } + + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + } + + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + } + + /** + * Converts a Punycode string of ASCII-only symbols to a string of Unicode + * symbols. + * @memberOf punycode + * @param {String} input The Punycode string of ASCII-only symbols. + * @returns {String} The resulting string of Unicode symbols. + */ + function decode(input) { + // Don't use UCS-2 + var output = [], + inputLength = input.length, + out, + i = 0, + n = initialN, + bias = initialBias, + basic, + j, + index, + oldi, + w, + k, + digit, + t, + /** Cached calculation results */ + baseMinusT; + + // Handle the basic code points: let `basic` be the number of input code + // points before the last delimiter, or `0` if there is none, then copy + // the first basic code points to the output. + + basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } + + for (j = 0; j < basic; ++j) { + // if it's not a basic code point + if (input.charCodeAt(j) >= 0x80) { + error('not-basic'); + } + output.push(input.charCodeAt(j)); + } + + // Main decoding loop: start just after the last delimiter if any basic code + // points were copied; start at the beginning otherwise. + + for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { + + // `index` is the index of the next character to be consumed. + // Decode a generalized variable-length integer into `delta`, + // which gets added to `i`. The overflow checking is easier + // if we increase `i` as we go, then subtract off its starting + // value at the end to obtain `delta`. + for (oldi = i, w = 1, k = base; /* no condition */; k += base) { + + if (index >= inputLength) { + error('invalid-input'); + } + + digit = basicToDigit(input.charCodeAt(index++)); + + if (digit >= base || digit > floor((maxInt - i) / w)) { + error('overflow'); + } + + i += digit * w; + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + + if (digit < t) { + break; + } + + baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error('overflow'); + } + + w *= baseMinusT; + + } + + out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); + + // `i` was supposed to wrap around from `out` to `0`, + // incrementing `n` each time, so we'll fix that now: + if (floor(i / out) > maxInt - n) { + error('overflow'); + } + + n += floor(i / out); + i %= out; + + // Insert `n` at position `i` of the output + output.splice(i++, 0, n); + + } + + return ucs2encode(output); + } + + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + function encode(input) { + var n, + delta, + handledCPCount, + basicLength, + bias, + j, + m, + q, + k, + t, + currentValue, + output = [], + /** `inputLength` will hold the number of code points in `input`. */ + inputLength, + /** Cached calculation results */ + handledCPCountPlusOne, + baseMinusT, + qMinusT; + + // Convert the input in UCS-2 to Unicode + input = ucs2decode(input); + + // Cache the length + inputLength = input.length; + + // Initialize the state + n = initialN; + delta = 0; + bias = initialBias; + + // Handle the basic code points + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue < 0x80) { + output.push(stringFromCharCode(currentValue)); + } + } + + handledCPCount = basicLength = output.length; + + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. + + // Finish the basic string - if it is not empty - with a delimiter + if (basicLength) { + output.push(delimiter); + } + + // Main encoding loop: + while (handledCPCount < inputLength) { + + // All non-basic code points < n have been handled already. Find the next + // larger one: + for (m = maxInt, j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } + + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow + handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error('overflow'); + } + + delta += (m - n) * handledCPCountPlusOne; + n = m; + + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + + if (currentValue < n && ++delta > maxInt) { + error('overflow'); + } + + if (currentValue == n) { + // Represent delta as a generalized variable-length integer + for (q = delta, k = base; /* no condition */; k += base) { + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + if (q < t) { + break; + } + qMinusT = q - t; + baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor(qMinusT / baseMinusT); + } + + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } + + ++delta; + ++n; + + } + return output.join(''); + } + + /** + * Converts a Punycode string representing a domain name or an email address + * to Unicode. Only the Punycoded parts of the input will be converted, i.e. + * it doesn't matter if you call it on a string that has already been + * converted to Unicode. + * @memberOf punycode + * @param {String} input The Punycoded domain name or email address to + * convert to Unicode. + * @returns {String} The Unicode representation of the given Punycode + * string. + */ + function toUnicode(input) { + return mapDomain(input, function(string) { + return regexPunycode.test(string) + ? decode(string.slice(4).toLowerCase()) + : string; + }); + } + + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + function toASCII(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) + ? 'xn--' + encode(string) + : string; + }); + } + + /*--------------------------------------------------------------------------*/ + + /** Define the public API */ + punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + 'version': '1.4.1', + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + 'ucs2': { + 'decode': ucs2decode, + 'encode': ucs2encode + }, + 'decode': decode, + 'encode': encode, + 'toASCII': toASCII, + 'toUnicode': toUnicode + }; + + /** Expose `punycode` */ + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + typeof define == 'function' && + typeof define.amd == 'object' && + define.amd + ) { + define('punycode', function() { + return punycode; + }); + } else if (freeExports && freeModule) { + if (module.exports == freeExports) { + // in Node.js, io.js, or RingoJS v0.8.0+ + freeModule.exports = punycode; + } else { + // in Narwhal or RingoJS v0.7.0- + for (key in punycode) { + punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); + } + } + } else { + // in Rhino or a web browser + root.punycode = punycode; + } + +}(this)); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],54:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +'use strict'; + +// If obj.hasOwnProperty has been overridden, then calling +// obj.hasOwnProperty(prop) will break. +// See: https://github.com/joyent/node/issues/1707 +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +module.exports = function(qs, sep, eq, options) { + sep = sep || '&'; + eq = eq || '='; + var obj = {}; + + if (typeof qs !== 'string' || qs.length === 0) { + return obj; + } + + var regexp = /\+/g; + qs = qs.split(sep); + + var maxKeys = 1000; + if (options && typeof options.maxKeys === 'number') { + maxKeys = options.maxKeys; + } + + var len = qs.length; + // maxKeys <= 0 means that we should not limit keys count + if (maxKeys > 0 && len > maxKeys) { + len = maxKeys; + } + + for (var i = 0; i < len; ++i) { + var x = qs[i].replace(regexp, '%20'), + idx = x.indexOf(eq), + kstr, vstr, k, v; + + if (idx >= 0) { + kstr = x.substr(0, idx); + vstr = x.substr(idx + 1); + } else { + kstr = x; + vstr = ''; + } + + k = decodeURIComponent(kstr); + v = decodeURIComponent(vstr); + + if (!hasOwnProperty(obj, k)) { + obj[k] = v; + } else if (isArray(obj[k])) { + obj[k].push(v); + } else { + obj[k] = [obj[k], v]; + } + } + + return obj; +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + +},{}],55:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +'use strict'; + +var stringifyPrimitive = function(v) { + switch (typeof v) { + case 'string': + return v; + + case 'boolean': + return v ? 'true' : 'false'; + + case 'number': + return isFinite(v) ? v : ''; + + default: + return ''; + } +}; + +module.exports = function(obj, sep, eq, name) { + sep = sep || '&'; + eq = eq || '='; + if (obj === null) { + obj = undefined; + } + + if (typeof obj === 'object') { + return map(objectKeys(obj), function(k) { + var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; + if (isArray(obj[k])) { + return map(obj[k], function(v) { + return ks + encodeURIComponent(stringifyPrimitive(v)); + }).join(sep); + } else { + return ks + encodeURIComponent(stringifyPrimitive(obj[k])); + } + }).join(sep); + + } + + if (!name) return ''; + return encodeURIComponent(stringifyPrimitive(name)) + eq + + encodeURIComponent(stringifyPrimitive(obj)); +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + +function map (xs, f) { + if (xs.map) return xs.map(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + res.push(f(xs[i], i)); + } + return res; +} + +var objectKeys = Object.keys || function (obj) { + var res = []; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); + } + return res; +}; + +},{}],56:[function(require,module,exports){ +'use strict'; + +exports.decode = exports.parse = require('./decode'); +exports.encode = exports.stringify = require('./encode'); + +},{"./decode":54,"./encode":55}],57:[function(require,module,exports){ +module.exports = require('./lib/_stream_duplex.js'); + +},{"./lib/_stream_duplex.js":58}],58:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/**/ + +module.exports = Duplex; + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +{ + // avoid scope creep, the keys array can then be collected + var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + pna.nextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +Object.defineProperty(Duplex.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + pna.nextTick(cb, err); +}; +},{"./_stream_readable":60,"./_stream_writable":62,"core-util-is":18,"inherits":46,"process-nextick-args":51}],59:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +'use strict'; + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":61,"core-util-is":18,"inherits":46}],60:[function(require,module,exports){ +(function (process,global){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Readable; + +/**/ +var isArray = require('isarray'); +/**/ + +/**/ +var Duplex; +/**/ + +Readable.ReadableState = ReadableState; + +/**/ +var EE = require('events').EventEmitter; + +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream = require('./internal/streams/stream'); +/**/ + +/**/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +/**/ +var debugUtil = require('util'); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var BufferList = require('./internal/streams/BufferList'); +var destroyImpl = require('./internal/streams/destroy'); +var StringDecoder; + +util.inherits(Readable, Stream); + +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); + + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} + +function ReadableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // has it been destroyed + this.destroyed = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); +} + +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); + +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + } + } + + return needMoreData(state); +} + +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; } - return Buffer.alloc(+length) -} -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true -} + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; -Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); } - if (a === b) return 0 + if (ret !== null) this.emit('data', ret); - var x = a.length - var y = b.length + return ret; +}; - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; } } + state.ended = true; - if (x < y) return -1 - if (y < x) return 1 - return 0 + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); } -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); } } -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + pna.nextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; } + state.readingMore = false; +} - if (list.length === 0) { - return Buffer.alloc(0) +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('_read() is not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } } } - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (ArrayBuffer.isView(buf)) { - buf = Buffer.from(buf) + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); } - buf.copy(buffer, pos) - pos += buf.length + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; } - return buffer + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, unpipeInfo); + }return this; + } + + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this, unpipeInfo); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + pna.nextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); } -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); } - if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { - return string.byteLength + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + pna.nextTick(resume_, stream, state); } - if (typeof string !== 'string') { - string = '' + string +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); } - var len = string.length - if (len === 0) return 0 + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - case undefined: - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} } -Buffer.byteLength = byteLength -function slowToString (encoding, start, end) { - var loweredCase = false +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var _this = this; - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. + var state = this._readableState; + var paused = false; - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' + + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); } - if (end === undefined || end > this.length) { - end = this.length + // when we try to consume some more bytes, simply unpause the + // underlying stream. + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; +}; + +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._readableState.highWaterMark; } +}); - if (end <= 0) { - return '' +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); } - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 + return ret; +} - if (end <= start) { - return '' +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); } + return ret; +} - if (!encoding) encoding = 'utf8' +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) +function endReadable(stream) { + var state = stream._readableState; - case 'ascii': - return asciiSlice(this, start, end) + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) + if (!state.endEmitted) { + state.ended = true; + pna.nextTick(endReadableNT, state, stream); + } +} - case 'base64': - return base64Slice(this, start, end) +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./_stream_duplex":58,"./internal/streams/BufferList":63,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":52,"core-util-is":18,"events":44,"inherits":46,"isarray":48,"process-nextick-args":51,"safe-buffer":71,"string_decoder/":66,"util":4}],61:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } +'use strict'; + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); + } + + ts.writechunk = null; + ts.writecb = null; + + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + + cb(er); + + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); } } -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i -} + Duplex.call(this, options); -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; } - return this + + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); } -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); } - return this } -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; } - return this -} +}; -Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} +Transform.prototype._destroy = function (err, cb) { + var _this2 = this; -Buffer.prototype.toLocaleString = Buffer.prototype.toString + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this2.emit('close'); + }); +}; -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 +function done(stream, er, data) { + if (er) return stream.emit('error', er); + + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); + + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + + return stream.push(null); } +},{"./_stream_duplex":58,"core-util-is":18,"inherits":46}],62:[function(require,module,exports){ +(function (process,global,setImmediate){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; } -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (!Buffer.isBuffer(target)) { - throw new TypeError('Argument must be a Buffer') - } +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; +/**/ - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } +/**/ +var Duplex; +/**/ - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 +Writable.WritableState = WritableState; - if (this === target) return 0 +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) +/**/ +var internalUtil = { + deprecate: require('util-deprecate') +}; +/**/ - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) +/**/ +var Stream = require('./internal/streams/stream'); +/**/ - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } +/**/ - if (x < y) return -1 - if (y < x) return 1 - return 0 +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 +/**/ - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } +var destroyImpl = require('./internal/streams/destroy'); - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } +util.inherits(Writable, Stream); - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } +function nop() {} - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); - throw new TypeError('val must be string, number or Buffer') -} + options = options || {}; -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // has it been destroyed + this.destroyed = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; - return -1 -} + // a flag to see when we're in the middle of a write. + this.writing = false; -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} + // when true all writes will be buffered until .uncork() call + this.corked = 0; -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); } -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; } + return out; +}; - var strLen = string.length +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); + +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} - if (length > strLen / 2) { - length = strLen / 2 +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; } - return i -} -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) + Stream.call(this); } -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); +}; -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + pna.nextTick(cb, er); } -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + pna.nextTick(cb, er); + valid = false; + } + return valid; } -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); } - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } - if (!encoding) encoding = 'utf8' + return ret; +}; - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) +Writable.prototype.cork = function () { + var state = this._writableState; - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) + state.corked++; +}; - case 'ascii': - return asciiWrite(this, string, offset, length) +Writable.prototype.uncork = function () { + var state = this._writableState; - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) + if (state.corked) { + state.corked--; - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); } + return chunk; } -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); } + + return ret; } -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + pna.nextTick(cb, er); + // this can emit finish, and it will always happen + // after error + pna.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); } else { - return base64.fromByteArray(buf.slice(start, end)) + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); } } -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint + onwriteStateUpdate(state); - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); } - res.push(codePoint) - i += bytesPerSequence + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); + } } - - return decodeCodePointsArray(res) } -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); } - return res } -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; + + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) + if (entry === null) state.lastBufferedRequest = null; } - return ret + + state.bufferedRequest = entry; + state.bufferProcessing = false; } -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); +}; - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; } - return ret -} -function hexSlice (buf, start, end) { - var len = buf.length + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + pna.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } } - return out } -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + } } - return res + return need; } -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; } +} - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; } +}); - if (end < start) end = start +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); +}; +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) +},{"./_stream_duplex":58,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":52,"core-util-is":18,"inherits":46,"process-nextick-args":51,"safe-buffer":71,"timers":73,"util-deprecate":76}],63:[function(require,module,exports){ +'use strict'; - var newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf -} +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Buffer = require('safe-buffer').Buffer; +var util = require('util'); + +function copyBuffer(src, target, offset) { + src.copy(target, offset); +} + +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); + + this.head = null; + this.tail = null; + this.length = 0; + } + + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; + + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; + + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; + + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; + + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; + + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; + }; -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') + return BufferList; +}(); + +if (util && util.inspect && util.inspect.custom) { + module.exports.prototype[util.inspect.custom] = function () { + var obj = util.inspect({ length: this.length }); + return this.constructor.name + ' ' + obj; + }; } +},{"safe-buffer":71,"util":4}],64:[function(require,module,exports){ +'use strict'; -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) +/**/ - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul +var pna = require('process-nextick-args'); +/**/ + +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + pna.nextTick(emitErrorNT, this, err); + } + return this; } - return val -} + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) + if (this._readableState) { + this._readableState.destroyed = true; } - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; } - return val -} + this._destroy(err || null, function (err) { + if (!cb && err) { + pna.nextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); + } + }); -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] + return this; } -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } } -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] +function emitErrorNT(self, err) { + self.emit('error', err); } -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) +module.exports = { + destroy: destroy, + undestroy: undestroy +}; +},{"process-nextick-args":51}],65:[function(require,module,exports){ +module.exports = require('events').EventEmitter; - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} +},{"events":44}],66:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) +'use strict'; - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} +/**/ -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) +var Buffer = require('safe-buffer').Buffer; +/**/ - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; } - mul *= 0x80 +}; - if (val >= mul) val -= Math.pow(2, 8 * byteLength) +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } +}; - return val -} +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); +} + +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) +StringDecoder.prototype.end = utf8End; - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; + +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); } - mul *= 0x80 + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; - if (val >= mul) val -= Math.pow(2, 8 * byteLength) +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. If an invalid byte is detected, -2 is returned. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; +} + +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; +} + +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } +} - return val +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} + +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} + +// For UTF-8, a replacement character is added when ending on a partial +// character. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; +} + +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); } -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; } -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); } -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; } -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; } +},{"safe-buffer":71}],67:[function(require,module,exports){ +module.exports = require('./readable').PassThrough -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) +},{"./readable":68}],68:[function(require,module,exports){ +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} +},{"./lib/_stream_duplex.js":58,"./lib/_stream_passthrough.js":59,"./lib/_stream_readable.js":60,"./lib/_stream_transform.js":61,"./lib/_stream_writable.js":62}],69:[function(require,module,exports){ +module.exports = require('./readable').Transform -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) +},{"./readable":68}],70:[function(require,module,exports){ +module.exports = require('./lib/_stream_writable.js'); + +},{"./lib/_stream_writable.js":62}],71:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer } -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) } -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) } -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf } -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') } + return Buffer(size) +} - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') } - - return offset + byteLength + return buffer.SlowBuffer(size) } -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } +},{"buffer":6}],72:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } +module.exports = Stream; - return offset + byteLength -} +var EE = require('events').EventEmitter; +var inherits = require('inherits'); -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 -} +inherits(Stream, EE); +Stream.Readable = require('readable-stream/readable.js'); +Stream.Writable = require('readable-stream/writable.js'); +Stream.Duplex = require('readable-stream/duplex.js'); +Stream.Transform = require('readable-stream/transform.js'); +Stream.PassThrough = require('readable-stream/passthrough.js'); -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 -} -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. + +function Stream() { + EE.call(this); } -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) +Stream.prototype.pipe = function(dest, options) { + var source = this; - checkInt(this, value, offset, byteLength, limit - 1, -limit) + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } } - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } - return offset + byteLength -} + dest.on('drain', ondrain); -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } - checkInt(this, value, offset, byteLength, limit - 1, -limit) + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); } - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } - return offset + byteLength -} + source.on('error', onerror); + dest.on('error', onerror); -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} + source.removeListener('end', onend); + source.removeListener('close', onclose); -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} + source.removeListener('error', onerror); + dest.removeListener('error', onerror); -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 -} + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} + dest.removeListener('close', cleanup); + } -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} + source.on('end', cleanup); + source.on('close', cleanup); -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} + dest.on('close', cleanup); -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} + dest.emit('pipe', source); -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; + +},{"events":44,"inherits":46,"readable-stream/duplex.js":57,"readable-stream/passthrough.js":67,"readable-stream/readable.js":68,"readable-stream/transform.js":69,"readable-stream/writable.js":70}],73:[function(require,module,exports){ +(function (setImmediate,clearImmediate){ +var nextTick = require('process/browser.js').nextTick; +var apply = Function.prototype.apply; +var slice = Array.prototype.slice; +var immediateIds = {}; +var nextImmediateId = 0; + +// DOM APIs, for completeness + +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { timeout.close(); }; + +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; } +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; + +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; + +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} +}; -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} +// That's not how node.js implements it but the exposed api is the same. +exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { + var id = nextImmediateId++; + var args = arguments.length < 2 ? false : slice.call(arguments, 1); -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} + immediateIds[id] = true; -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start + nextTick(function onNextTick() { + if (immediateIds[id]) { + // fn.call() is faster so we optimize for the common use-case + // @see http://jsperf.com/call-apply-segu + if (args) { + fn.apply(null, args); + } else { + fn.call(null); + } + // Prevent ids from leaking + exports.clearImmediate(id); + } + }); - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 + return id; +}; - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') +exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { + delete immediateIds[id]; +}; +}).call(this,require("timers").setImmediate,require("timers").clearImmediate) +},{"process/browser.js":52,"timers":73}],74:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start +'use strict'; + +var punycode = require('punycode'); +var util = require('./util'); + +exports.parse = urlParse; +exports.resolve = urlResolve; +exports.resolveObject = urlResolveObject; +exports.format = urlFormat; + +exports.Url = Url; + +function Url() { + this.protocol = null; + this.slashes = null; + this.auth = null; + this.host = null; + this.port = null; + this.hostname = null; + this.hash = null; + this.search = null; + this.query = null; + this.pathname = null; + this.path = null; + this.href = null; +} + +// Reference: RFC 3986, RFC 1808, RFC 2396 + +// define these here so at least they only have to be +// compiled once on the first module load. +var protocolPattern = /^([a-z0-9.+-]+:)/i, + portPattern = /:[0-9]*$/, + + // Special case for a simple path URL + simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, + + // RFC 2396: characters reserved for delimiting URLs. + // We actually just auto-escape these. + delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], + + // RFC 2396: characters not allowed for various reasons. + unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), + + // Allowed by RFCs, but cause of XSS attacks. Always escape these. + autoEscape = ['\''].concat(unwise), + // Characters that are never ever allowed in a hostname. + // Note that any invalid chars are also handled, but these + // are the ones that are *expected* to be seen, so we fast-path + // them. + nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), + hostEndingChars = ['/', '?', '#'], + hostnameMaxLen = 255, + hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, + hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, + // protocols that can allow "unsafe" and "unwise" chars. + unsafeProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that never have a hostname. + hostlessProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that always contain a // bit. + slashedProtocol = { + 'http': true, + 'https': true, + 'ftp': true, + 'gopher': true, + 'file': true, + 'http:': true, + 'https:': true, + 'ftp:': true, + 'gopher:': true, + 'file:': true + }, + querystring = require('querystring'); + +function urlParse(url, parseQueryString, slashesDenoteHost) { + if (url && util.isObject(url) && url instanceof Url) return url; + + var u = new Url; + u.parse(url, parseQueryString, slashesDenoteHost); + return u; +} + +Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { + if (!util.isString(url)) { + throw new TypeError("Parameter 'url' must be a string, not " + typeof url); + } + + // Copy chrome, IE, opera backslash-handling behavior. + // Back slashes before the query string get converted to forward slashes + // See: https://code.google.com/p/chromium/issues/detail?id=25916 + var queryIndex = url.indexOf('?'), + splitter = + (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', + uSplit = url.split(splitter), + slashRegex = /\\/g; + uSplit[0] = uSplit[0].replace(slashRegex, '/'); + url = uSplit.join(splitter); + + var rest = url; + + // trim before proceeding. + // This is to support parse stuff like " http://foo.com \n" + rest = rest.trim(); + + if (!slashesDenoteHost && url.split('#').length === 1) { + // Try fast path regexp + var simplePath = simplePathPattern.exec(rest); + if (simplePath) { + this.path = rest; + this.href = rest; + this.pathname = simplePath[1]; + if (simplePath[2]) { + this.search = simplePath[2]; + if (parseQueryString) { + this.query = querystring.parse(this.search.substr(1)); + } else { + this.query = this.search.substr(1); + } + } else if (parseQueryString) { + this.search = ''; + this.query = {}; + } + return this; + } } - var len = end - start + var proto = protocolPattern.exec(rest); + if (proto) { + proto = proto[0]; + var lowerProto = proto.toLowerCase(); + this.protocol = lowerProto; + rest = rest.substr(proto.length); + } - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] + // figure out if it's got a host + // user@server is *always* interpreted as a hostname, and url + // resolution will treat //foo/bar as host=foo,path=bar because that's + // how the browser resolves relative URLs. + if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { + var slashes = rest.substr(0, 2) === '//'; + if (slashes && !(proto && hostlessProtocol[proto])) { + rest = rest.substr(2); + this.slashes = true; } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) } - return len -} + if (!hostlessProtocol[proto] && + (slashes || (proto && !slashedProtocol[proto]))) { + + // there's a hostname. + // the first instance of /, ?, ;, or # ends the host. + // + // If there is an @ in the hostname, then non-host chars *are* allowed + // to the left of the last @ sign, unless some host-ending character + // comes *before* the @-sign. + // URLs are obnoxious. + // + // ex: + // http://a@b@c/ => user:a@b host:c + // http://a@b?@c => user:a host:c path:/?@c + + // v0.12 TODO(isaacs): This is not quite how Chrome does things. + // Review our test case against browsers more comprehensively. + + // find the first instance of any hostEndingChars + var hostEnd = -1; + for (var i = 0; i < hostEndingChars.length; i++) { + var hec = rest.indexOf(hostEndingChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; + } -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length + // at this point, either we have an explicit point where the + // auth portion cannot go past, or the last @ char is the decider. + var auth, atSign; + if (hostEnd === -1) { + // atSign can be anywhere. + atSign = rest.lastIndexOf('@'); + } else { + // atSign must be in auth portion. + // http://a@b/c@d => host:b auth:a path:/c@d + atSign = rest.lastIndexOf('@', hostEnd); } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') + + // Now we have a portion which is definitely the auth. + // Pull that off. + if (atSign !== -1) { + auth = rest.slice(0, atSign); + rest = rest.slice(atSign + 1); + this.auth = decodeURIComponent(auth); } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) + + // the host is the remaining to the left of the first non-host char + hostEnd = -1; + for (var i = 0; i < nonHostChars.length; i++) { + var hec = rest.indexOf(nonHostChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code + // if we still have not hit it, then the entire thing is a host. + if (hostEnd === -1) + hostEnd = rest.length; + + this.host = rest.slice(0, hostEnd); + rest = rest.slice(hostEnd); + + // pull out port. + this.parseHost(); + + // we've indicated that there is a hostname, + // so even if it's empty, it has to be present. + this.hostname = this.hostname || ''; + + // if hostname begins with [ and ends with ] + // assume that it's an IPv6 address. + var ipv6Hostname = this.hostname[0] === '[' && + this.hostname[this.hostname.length - 1] === ']'; + + // validate a little. + if (!ipv6Hostname) { + var hostparts = this.hostname.split(/\./); + for (var i = 0, l = hostparts.length; i < l; i++) { + var part = hostparts[i]; + if (!part) continue; + if (!part.match(hostnamePartPattern)) { + var newpart = ''; + for (var j = 0, k = part.length; j < k; j++) { + if (part.charCodeAt(j) > 127) { + // we replace non-ASCII char with a temporary placeholder + // we need this to make sure size of hostname is not + // broken by replacing non-ASCII by nothing + newpart += 'x'; + } else { + newpart += part[j]; + } + } + // we test again with ASCII char only + if (!newpart.match(hostnamePartPattern)) { + var validParts = hostparts.slice(0, i); + var notHost = hostparts.slice(i + 1); + var bit = part.match(hostnamePartStart); + if (bit) { + validParts.push(bit[1]); + notHost.unshift(bit[2]); + } + if (notHost.length) { + rest = '/' + notHost.join('.') + rest; + } + this.hostname = validParts.join('.'); + break; + } + } + } + } + + if (this.hostname.length > hostnameMaxLen) { + this.hostname = ''; + } else { + // hostnames are always lower case. + this.hostname = this.hostname.toLowerCase(); + } + + if (!ipv6Hostname) { + // IDNA Support: Returns a punycoded representation of "domain". + // It only converts parts of the domain name that + // have non-ASCII characters, i.e. it doesn't matter if + // you call it with a domain that already is ASCII-only. + this.hostname = punycode.toASCII(this.hostname); + } + + var p = this.port ? ':' + this.port : ''; + var h = this.hostname || ''; + this.host = h + p; + this.href += this.host; + + // strip [ and ] from the hostname + // the host field still retains them, though + if (ipv6Hostname) { + this.hostname = this.hostname.substr(1, this.hostname.length - 2); + if (rest[0] !== '/') { + rest = '/' + rest; } } - } else if (typeof val === 'number') { - val = val & 255 } - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') + // now rest is set to the post-host stuff. + // chop off any delim chars. + if (!unsafeProtocol[lowerProto]) { + + // First, make 100% sure that any "autoEscape" chars get + // escaped, even if encodeURIComponent doesn't think they + // need to be. + for (var i = 0, l = autoEscape.length; i < l; i++) { + var ae = autoEscape[i]; + if (rest.indexOf(ae) === -1) + continue; + var esc = encodeURIComponent(ae); + if (esc === ae) { + esc = escape(ae); + } + rest = rest.split(ae).join(esc); + } } - if (end <= start) { - return this + + // chop off from the tail first. + var hash = rest.indexOf('#'); + if (hash !== -1) { + // got a fragment string. + this.hash = rest.substr(hash); + rest = rest.slice(0, hash); + } + var qm = rest.indexOf('?'); + if (qm !== -1) { + this.search = rest.substr(qm); + this.query = rest.substr(qm + 1); + if (parseQueryString) { + this.query = querystring.parse(this.query); + } + rest = rest.slice(0, qm); + } else if (parseQueryString) { + // no query string, but parseQueryString still requested + this.search = ''; + this.query = {}; + } + if (rest) this.pathname = rest; + if (slashedProtocol[lowerProto] && + this.hostname && !this.pathname) { + this.pathname = '/'; } - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 + //to support http.request + if (this.pathname || this.search) { + var p = this.pathname || ''; + var s = this.search || ''; + this.path = p + s; + } - if (!val) val = 0 + // finally, reconstruct the href based on what has been validated. + this.href = this.format(); + return this; +}; - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : new Buffer(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] +// format a parsed object into a url string +function urlFormat(obj) { + // ensure it's an object, and not a string url. + // If it's an obj, this is a no-op. + // this way, you can call url_format() on strings + // to clean up potentially wonky urls. + if (util.isString(obj)) obj = urlParse(obj); + if (!(obj instanceof Url)) return Url.prototype.format.call(obj); + return obj.format(); +} + +Url.prototype.format = function() { + var auth = this.auth || ''; + if (auth) { + auth = encodeURIComponent(auth); + auth = auth.replace(/%3A/i, ':'); + auth += '@'; + } + + var protocol = this.protocol || '', + pathname = this.pathname || '', + hash = this.hash || '', + host = false, + query = ''; + + if (this.host) { + host = auth + this.host; + } else if (this.hostname) { + host = auth + (this.hostname.indexOf(':') === -1 ? + this.hostname : + '[' + this.hostname + ']'); + if (this.port) { + host += ':' + this.port; } } - return this -} + if (this.query && + util.isObject(this.query) && + Object.keys(this.query).length) { + query = querystring.stringify(this.query); + } -// HELPER FUNCTIONS -// ================ + var search = this.search || (query && ('?' + query)) || ''; -var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + if (protocol && protocol.substr(-1) !== ':') protocol += ':'; -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' + // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. + // unless they had them to begin with. + if (this.slashes || + (!protocol || slashedProtocol[protocol]) && host !== false) { + host = '//' + (host || ''); + if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; + } else if (!host) { + host = ''; } - return str + + if (hash && hash.charAt(0) !== '#') hash = '#' + hash; + if (search && search.charAt(0) !== '?') search = '?' + search; + + pathname = pathname.replace(/[?#]/g, function(match) { + return encodeURIComponent(match); + }); + search = search.replace('#', '%23'); + + return protocol + host + pathname + search + hash; +}; + +function urlResolve(source, relative) { + return urlParse(source, false, true).resolve(relative); } -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) +Url.prototype.resolve = function(relative) { + return this.resolveObject(urlParse(relative, false, true)).format(); +}; + +function urlResolveObject(source, relative) { + if (!source) return relative; + return urlParse(source, false, true).resolveObject(relative); } -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] +Url.prototype.resolveObject = function(relative) { + if (util.isString(relative)) { + var rel = new Url(); + rel.parse(relative, false, true); + relative = rel; + } - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) + var result = new Url(); + var tkeys = Object.keys(this); + for (var tk = 0; tk < tkeys.length; tk++) { + var tkey = tkeys[tk]; + result[tkey] = this[tkey]; + } - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } + // hash is always overridden, no matter what. + // even href="" will remove it. + result.hash = relative.hash; - // valid lead - leadSurrogate = codePoint + // if the relative url is empty, then there's nothing left to do here. + if (relative.href === '') { + result.href = result.format(); + return result; + } - continue - } + // hrefs like //foo/bar always cut to the protocol. + if (relative.slashes && !relative.protocol) { + // take everything except the protocol from relative + var rkeys = Object.keys(relative); + for (var rk = 0; rk < rkeys.length; rk++) { + var rkey = rkeys[rk]; + if (rkey !== 'protocol') + result[rkey] = relative[rkey]; + } - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } + //urlParse appends trailing / to urls like http://www.example.com + if (slashedProtocol[result.protocol] && + result.hostname && !result.pathname) { + result.path = result.pathname = '/'; + } - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + result.href = result.format(); + return result; + } + + if (relative.protocol && relative.protocol !== result.protocol) { + // if it's a known url protocol, then changing + // the protocol does weird things + // first, if it's not file:, then we MUST have a host, + // and if there was a path + // to begin with, then we MUST have a path. + // if it is file:, then the host is dropped, + // because that's known to be hostless. + // anything else is assumed to be absolute. + if (!slashedProtocol[relative.protocol]) { + var keys = Object.keys(relative); + for (var v = 0; v < keys.length; v++) { + var k = keys[v]; + result[k] = relative[k]; + } + result.href = result.format(); + return result; } - leadSurrogate = null + result.protocol = relative.protocol; + if (!relative.host && !hostlessProtocol[relative.protocol]) { + var relPath = (relative.pathname || '').split('/'); + while (relPath.length && !(relative.host = relPath.shift())); + if (!relative.host) relative.host = ''; + if (!relative.hostname) relative.hostname = ''; + if (relPath[0] !== '') relPath.unshift(''); + if (relPath.length < 2) relPath.unshift(''); + result.pathname = relPath.join('/'); + } else { + result.pathname = relative.pathname; + } + result.search = relative.search; + result.query = relative.query; + result.host = relative.host || ''; + result.auth = relative.auth; + result.hostname = relative.hostname || relative.host; + result.port = relative.port; + // to support http.request + if (result.pathname || result.search) { + var p = result.pathname || ''; + var s = result.search || ''; + result.path = p + s; + } + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; + } + + var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), + isRelAbs = ( + relative.host || + relative.pathname && relative.pathname.charAt(0) === '/' + ), + mustEndAbs = (isRelAbs || isSourceAbs || + (result.host && relative.pathname)), + removeAllDots = mustEndAbs, + srcPath = result.pathname && result.pathname.split('/') || [], + relPath = relative.pathname && relative.pathname.split('/') || [], + psychotic = result.protocol && !slashedProtocol[result.protocol]; + + // if the url is a non-slashed url, then relative + // links like ../.. should be able + // to crawl up to the hostname, as well. This is strange. + // result.protocol has already been set by now. + // Later on, put the first path part into the host field. + if (psychotic) { + result.hostname = ''; + result.port = null; + if (result.host) { + if (srcPath[0] === '') srcPath[0] = result.host; + else srcPath.unshift(result.host); + } + result.host = ''; + if (relative.protocol) { + relative.hostname = null; + relative.port = null; + if (relative.host) { + if (relPath[0] === '') relPath[0] = relative.host; + else relPath.unshift(relative.host); + } + relative.host = null; + } + mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); + } + + if (isRelAbs) { + // it's absolute. + result.host = (relative.host || relative.host === '') ? + relative.host : result.host; + result.hostname = (relative.hostname || relative.hostname === '') ? + relative.hostname : result.hostname; + result.search = relative.search; + result.query = relative.query; + srcPath = relPath; + // fall through to the dot-handling below. + } else if (relPath.length) { + // it's relative + // throw away the existing file, and take the new path instead. + if (!srcPath) srcPath = []; + srcPath.pop(); + srcPath = srcPath.concat(relPath); + result.search = relative.search; + result.query = relative.query; + } else if (!util.isNullOrUndefined(relative.search)) { + // just pull out the search. + // like href='?foo'. + // Put this after the other two cases because it simplifies the booleans + if (psychotic) { + result.hostname = result.host = srcPath.shift(); + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + var authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } + } + result.search = relative.search; + result.query = relative.query; + //to support http.request + if (!util.isNull(result.pathname) || !util.isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.href = result.format(); + return result; + } - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) + if (!srcPath.length) { + // no path at all. easy. + // we've already handled the other stuff above. + result.pathname = null; + //to support http.request + if (result.search) { + result.path = '/' + result.search; } else { - throw new Error('Invalid code point') + result.path = null; + } + result.href = result.format(); + return result; + } + + // if a url ENDs in . or .., then it must get a trailing slash. + // however, if it ends in anything else non-slashy, + // then it must NOT get a trailing slash. + var last = srcPath.slice(-1)[0]; + var hasTrailingSlash = ( + (result.host || relative.host || srcPath.length > 1) && + (last === '.' || last === '..') || last === ''); + + // strip single dots, resolve double dots to parent dir + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = srcPath.length; i >= 0; i--) { + last = srcPath[i]; + if (last === '.') { + srcPath.splice(i, 1); + } else if (last === '..') { + srcPath.splice(i, 1); + up++; + } else if (up) { + srcPath.splice(i, 1); + up--; } } - return bytes -} + // if the path is allowed to go above the root, restore leading ..s + if (!mustEndAbs && !removeAllDots) { + for (; up--; up) { + srcPath.unshift('..'); + } + } -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) + if (mustEndAbs && srcPath[0] !== '' && + (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { + srcPath.unshift(''); + } + + if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { + srcPath.push(''); } - return byteArray -} -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break + var isAbsolute = srcPath[0] === '' || + (srcPath[0] && srcPath[0].charAt(0) === '/'); - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) + // put the host back + if (psychotic) { + result.hostname = result.host = isAbsolute ? '' : + srcPath.length ? srcPath.shift() : ''; + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + var authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } } - return byteArray -} + mustEndAbs = mustEndAbs || (result.host && srcPath.length); -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} + if (mustEndAbs && !isAbsolute) { + srcPath.unshift(''); + } -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] + if (!srcPath.length) { + result.pathname = null; + result.path = null; + } else { + result.pathname = srcPath.join('/'); } - return i -} -// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check -// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 -function isArrayBuffer (obj) { - return obj instanceof ArrayBuffer || - (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && - typeof obj.byteLength === 'number') -} + //to support request.http + if (!util.isNull(result.pathname) || !util.isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.auth = relative.auth || result.auth; + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; +}; -function numberIsNaN (obj) { - return obj !== obj // eslint-disable-line no-self-compare -} +Url.prototype.parseHost = function() { + var host = this.host; + var port = portPattern.exec(host); + if (port) { + port = port[0]; + if (port !== ':') { + this.port = port.substr(1); + } + host = host.substr(0, host.length - port.length); + } + if (host) this.hostname = host; +}; -},{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] +},{"./util":75,"punycode":53,"querystring":56}],75:[function(require,module,exports){ +'use strict'; - i += d +module.exports = { + isString: function(arg) { + return typeof(arg) === 'string'; + }, + isObject: function(arg) { + return typeof(arg) === 'object' && arg !== null; + }, + isNull: function(arg) { + return arg === null; + }, + isNullOrUndefined: function(arg) { + return arg == null; + } +}; - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} +},{}],76:[function(require,module,exports){ +(function (global){ - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} +/** + * Module exports. + */ - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias +module.exports = deprecate; + +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + +function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) + + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; } -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ - value = Math.abs(value) +function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; + } + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],77:[function(require,module,exports){ +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; +} +},{}],78:[function(require,module,exports){ +(function (process,global){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); } - if (e + eBias >= 1) { - value += rt / c + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; } else { - value += rt * Math.pow(2, 1 - eBias) + str += ' ' + inspect(x); } - if (value * c >= 2) { - e++ - c /= 2 + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + if (process.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; } + return fn.apply(this, arguments); + } - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) - e = e + eBias + return deprecated; +}; + + +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 + debugs[set] = function() {}; } } + return debugs[set]; +}; - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; - buffer[offset + i - d] |= s * 128 -} +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; -},{}],5:[function(require,module,exports){ -/* - A JavaScript implementation of the SHA family of hashes, as - defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding - HMAC implementation as defined in FIPS PUB 198a - Copyright Brian Turek 2008-2017 - Distributed under the BSD License - See http://caligatio.github.com/jsSHA/ for more information +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; - Several functions taken from Paul Johnston -*/ -'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; -b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> -5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); -}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> -6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); -if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, -"");if(-1!==k&&k= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + ctx.seen.pop(); + return reduceToSingleString(output, base, braces); } -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; } -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); } else { - queueIndex = -1; + output.push(''); } - if (queue.length) { - drainQueue(); + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); } + }); + return output; } -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); } + } + } else { + str = ctx.stylize('[Circular]', 'special'); } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; } -}; + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; + return name + ': ' + str; } -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; -function noop() {} -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); -process.listeners = function (name) { return [] } + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; -},{}],7:[function(require,module,exports){ -/* eslint-disable node/no-deprecated-api */ -var buffer = require('buffer') -var Buffer = buffer.Buffer +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; -// alternative to using Object.keys for old browsers -function copyProps (src, dst) { - for (var key in src) { - dst[key] = src[key] - } +function isBoolean(arg) { + return typeof arg === 'boolean'; } -if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer -} else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; } +exports.isNull = isNull; -function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) +function isNullOrUndefined(arg) { + return arg == null; } +exports.isNullOrUndefined = isNullOrUndefined; -// Copy static methods from Buffer -copyProps(Buffer, SafeBuffer) +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; -SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) +function isString(arg) { + return typeof arg === 'string'; } +exports.isString = isString; -SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) - } - return buf +function isSymbol(arg) { + return typeof arg === 'symbol'; } +exports.isSymbol = isSymbol; -SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) +function isUndefined(arg) { + return arg === void 0; } +exports.isUndefined = isUndefined; -SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = require('./support/isBuffer'); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = require('inherits'); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; } - return buffer.SlowBuffer(size) + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./support/isBuffer":77,"_process":52,"inherits":46}],79:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var base58 = require('./crypto/base58'); + +const bs58 = require('bs58'); +const CRC = require('crc'); +const cbor = require('cbor'); +const Tagged = cbor.Tagged; + +function getDecoded(address) { + try { + var decoded = bs58.decode(address); + return decoded = cbor.decode(decoded); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } } -},{"buffer":3}],8:[function(require,module,exports){ +module.exports = { + isValidAddress: function (address) { + var decoded = getDecoded(address); + + if (!decoded || (!Array.isArray(decoded) && decoded.length != 2)) { + return false; + } + + var [tagged, validCrc] = decoded; + if (!tagged instanceof Tagged) { + return false; + } + if (typeof (validCrc) != 'number') { + return false; + } + + // not sure what this is + if (tagged.tag != 24) { + return false; + } + + // get crc of the payload + let crc = CRC.crc32(tagged.value); + + return crc == validCrc; + } +}; + +},{"./crypto/base58":81,"./crypto/utils":86,"bs58":5,"cbor":7,"crc":43}],80:[function(require,module,exports){ var base58 = require('./crypto/base58'); var segwit = require('./crypto/segwit_addr'); var cryptoUtils = require('./crypto/utils'); @@ -2427,7 +14201,7 @@ module.exports = { } }; -},{"./crypto/base58":9,"./crypto/segwit_addr":12,"./crypto/utils":14}],9:[function(require,module,exports){ +},{"./crypto/base58":81,"./crypto/segwit_addr":84,"./crypto/utils":86}],81:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -2475,7 +14249,7 @@ module.exports = { } }; -},{}],10:[function(require,module,exports){ +},{}],82:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -2593,7 +14367,7 @@ function decode (bechString) { return {hrp: hrp, data: data.slice(0, data.length - 6)}; } -},{}],11:[function(require,module,exports){ +},{}],83:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2784,7 +14558,7 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":3}],12:[function(require,module,exports){ +},{"buffer":6}],84:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -2880,7 +14654,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":10}],13:[function(require,module,exports){ +},{"./bech32":82}],85:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -3524,7 +15298,7 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":6}],14:[function(require,module,exports){ +},{"_process":52}],86:[function(require,module,exports){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; @@ -3564,10 +15338,11 @@ module.exports = { } }; -},{"./blake256":11,"./sha3":13,"jssha/src/sha256":5}],15:[function(require,module,exports){ +},{"./blake256":83,"./sha3":85,"jssha/src/sha256":49}],87:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); +var ADAValidator = require('./ada_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -3759,6 +15534,10 @@ var CURRENCIES = [{ name: 'bankex', symbol: 'bkx', validator: ETHValidator +},{ + name: 'cardano', + symbol: 'ada', + validator: ADAValidator }]; @@ -3775,7 +15554,7 @@ module.exports = { } }; -},{"./bitcoin_validator":8,"./ethereum_validator":16,"./ripple_validator":17}],16:[function(require,module,exports){ +},{"./ada_validator":79,"./bitcoin_validator":80,"./ethereum_validator":88,"./ripple_validator":89}],88:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -3811,7 +15590,7 @@ module.exports = { } }; -},{"./crypto/utils":14}],17:[function(require,module,exports){ +},{"./crypto/utils":86}],89:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -3841,7 +15620,7 @@ module.exports = { } }; -},{"./crypto/utils":14,"base-x":1}],18:[function(require,module,exports){ +},{"./crypto/utils":86,"base-x":1}],90:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -3858,5 +15637,5 @@ module.exports = { }, }; -},{"./currencies":15}]},{},[18])(18) +},{"./currencies":87}]},{},[90])(90) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js deleted file mode 100644 index ec0dbbbc..00000000 --- a/dist/wallet-address-validator.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,a,u){function f(r,t){if(!a[r]){if(!s[r]){var e="function"==typeof require&&require;if(!t&&e)return e(r,!0);if(h)return h(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[r]={exports:{}};s[r][0].call(o.exports,function(t){return f(s[r][1][t]||t)},o,o.exports,i,s,a,u)}return a[r].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[s++]=r>>8&255,i[s++]=255&r;var f,h;2===o&&(r=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,i[s++]=255&r);1===o&&(r=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,i[s++]=r>>8&255,i[s++]=255&r);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o=[],i=0,s=e-n;i>2]+a[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],o.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"="));return o.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return w(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,O(R(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return u=this,f=r,h=e,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,O(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function U(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function S(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=0,s=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,o),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,g,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,f,o)};break;case"B64":e=function(t){return E(t,f,o)};break;case"BYTES":e=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",a=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o=2.2.7 <3" + +abbrev@1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" + +accepts@~1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.5.tgz#eb777df6011723a3b14e8a72c0805c8e86746bd2" + dependencies: + mime-types "~2.1.18" + negotiator "0.6.1" + +acorn-dynamic-import@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz#482210140582a36b83c3e342e1cfebcaa9240948" + +acorn-node@^1.2.0, acorn-node@^1.3.0, acorn-node@^1.5.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/acorn-node/-/acorn-node-1.6.2.tgz#b7d7ceca6f22e6417af933a62cad4de01048d5d2" + dependencies: + acorn "^6.0.2" + acorn-dynamic-import "^4.0.0" + acorn-walk "^6.1.0" + xtend "^4.0.1" + +acorn-walk@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.1.0.tgz#c957f4a1460da46af4a0388ce28b4c99355b0cbc" + +acorn@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.0.2.tgz#6a459041c320ab17592c6317abbfdf4bbaa98ca4" + +addressparser@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/addressparser/-/addressparser-1.0.1.tgz#47afbe1a2a9262191db6838e4fd1d39b40821746" + +after@0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" + +agent-base@4, agent-base@^4.1.0, agent-base@^4.2.0, agent-base@~4.2.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9" + dependencies: + es6-promisify "^5.0.0" + +ajv@^5.3.0: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + +amqplib@^0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/amqplib/-/amqplib-0.5.2.tgz#d2d7313c7ffaa4d10bcf1e6252de4591b6cc7b63" + dependencies: + bitsyntax "~0.0.4" + bluebird "^3.4.6" + buffer-more-ints "0.0.2" + readable-stream "1.x >=1.1.9" + safe-buffer "^5.0.1" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +anymatch@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" + dependencies: + micromatch "^3.1.4" + normalize-path "^2.1.1" + +aproba@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + +are-we-there-yet@~1.1.2: + version "1.1.5" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.6" + +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + +arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + +array-filter@~0.0.0: + version "0.0.1" + resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-0.0.1.tgz#7da8cf2e26628ed732803581fd21f67cacd2eeec" + +array-map@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/array-map/-/array-map-0.0.0.tgz#88a2bab73d1cf7bcd5c1b118a003f66f665fa662" + +array-reduce@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b" + +array-slice@^0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-0.2.3.tgz#dd3cfb80ed7973a75117cdac69b0b99ec86186f5" + +array-unique@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + +arraybuffer.slice@~0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675" + +asn1.js@^4.0.0: + version "4.10.1" + resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0" + dependencies: + bn.js "^4.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + +asn1@~0.2.3: + version "0.2.4" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" + dependencies: + safer-buffer "~2.1.0" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +assert@^1.4.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91" + dependencies: + util "0.10.3" + +assertion-error@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + +ast-types@0.x.x: + version "0.11.6" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.11.6.tgz#4e2266c2658829aef3b40cc33ad599c4e9eb89ef" + +async-each@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" + +async-limiter@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" + +async@~2.6.0: + version "2.6.1" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610" + dependencies: + lodash "^4.17.10" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +atob@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + +aws4@^1.2.1, aws4@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" + +axios@^0.15.3: + version "0.15.3" + resolved "http://registry.npmjs.org/axios/-/axios-0.15.3.tgz#2c9d638b2e191a08ea1d6cc988eadd6ba5bdc053" + dependencies: + follow-redirects "1.0.0" + +backo2@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +base-x@^3.0.2, base-x@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.4.tgz#94c1788736da065edb1d68808869e357c977fa77" + dependencies: + safe-buffer "^5.0.1" + +base64-arraybuffer@0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" + +base64-js@^1.0.2: + version "1.3.0" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" + +base64id@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6" + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + +bcrypt-pbkdf@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" + dependencies: + tweetnacl "^0.14.3" + +better-assert@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" + dependencies: + callsite "1.0.0" + +bignumber.js@^7.2.1: + version "7.2.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f" + +binary-extensions@^1.0.0: + version "1.12.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.12.0.tgz#c2d780f53d45bba8317a8902d4ceeaf3a6385b14" + +bitsyntax@~0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/bitsyntax/-/bitsyntax-0.0.4.tgz#eb10cc6f82b8c490e3e85698f07e83d46e0cba82" + dependencies: + buffer-more-ints "0.0.2" + +bl@~1.1.2: + version "1.1.2" + resolved "http://registry.npmjs.org/bl/-/bl-1.1.2.tgz#fdca871a99713aa00d19e3bbba41c44787a65398" + dependencies: + readable-stream "~2.0.5" + +blob@0.0.4: + version "0.0.4" + resolved "http://registry.npmjs.org/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" + +bluebird@^3.3.0, bluebird@^3.4.6: + version "3.5.2" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.2.tgz#1be0908e054a751754549c270489c1505d4ab15a" + +bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: + version "4.11.8" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" + +body-parser@^1.16.1: + version "1.18.3" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.3.tgz#5b292198ffdd553b3a0f20ded0592b956955c8b4" + dependencies: + bytes "3.0.0" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.2" + http-errors "~1.6.3" + iconv-lite "0.4.23" + on-finished "~2.3.0" + qs "6.5.2" + raw-body "2.3.3" + type-is "~1.6.16" + +boom@2.x.x: + version "2.10.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^0.1.2: + version "0.1.5" + resolved "https://registry.yarnpkg.com/braces/-/braces-0.1.5.tgz#c085711085291d8b75fdd74eab0f8597280711e6" + dependencies: + expand-range "^0.1.0" + +braces@^2.3.0, braces@^2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + +brorand@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" + +browser-pack@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/browser-pack/-/browser-pack-6.1.0.tgz#c34ba10d0b9ce162b5af227c7131c92c2ecd5774" + dependencies: + JSONStream "^1.0.3" + combine-source-map "~0.8.0" + defined "^1.0.0" + safe-buffer "^5.1.1" + through2 "^2.0.0" + umd "^3.0.0" + +browser-resolve@^1.11.0, browser-resolve@^1.7.0: + version "1.11.3" + resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.3.tgz#9b7cbb3d0f510e4cb86bdbd796124d28b5890af6" + dependencies: + resolve "1.1.7" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + +browserify-aes@^1.0.0, browserify-aes@^1.0.4: + version "1.2.0" + resolved "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" + dependencies: + buffer-xor "^1.0.3" + cipher-base "^1.0.0" + create-hash "^1.1.0" + evp_bytestokey "^1.0.3" + inherits "^2.0.1" + safe-buffer "^5.0.1" + +browserify-cipher@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" + dependencies: + browserify-aes "^1.0.4" + browserify-des "^1.0.0" + evp_bytestokey "^1.0.0" + +browserify-des@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.2.tgz#3af4f1f59839403572f1c66204375f7a7f703e9c" + dependencies: + cipher-base "^1.0.1" + des.js "^1.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +browserify-rsa@^4.0.0: + version "4.0.1" + resolved "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz#21e0abfaf6f2029cf2fafb133567a701d4135524" + dependencies: + bn.js "^4.1.0" + randombytes "^2.0.1" + +browserify-sign@^4.0.0: + version "4.0.4" + resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.0.4.tgz#aa4eb68e5d7b658baa6bf6a57e630cbd7a93d298" + dependencies: + bn.js "^4.1.1" + browserify-rsa "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.2" + elliptic "^6.0.0" + inherits "^2.0.1" + parse-asn1 "^5.0.0" + +browserify-zlib@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.2.0.tgz#2869459d9aa3be245fe8fe2ca1f46e2e7f54d73f" + dependencies: + pako "~1.0.5" + +browserify@^15.1.0: + version "15.2.0" + resolved "https://registry.yarnpkg.com/browserify/-/browserify-15.2.0.tgz#1e121ba1fa72cf9fd2d8df002f8674b68b45df89" + dependencies: + JSONStream "^1.0.3" + assert "^1.4.0" + browser-pack "^6.0.1" + browser-resolve "^1.11.0" + browserify-zlib "~0.2.0" + buffer "^5.0.2" + cached-path-relative "^1.0.0" + concat-stream "~1.5.1" + console-browserify "^1.1.0" + constants-browserify "~1.0.0" + crypto-browserify "^3.0.0" + defined "^1.0.0" + deps-sort "^2.0.0" + domain-browser "~1.1.0" + duplexer2 "~0.1.2" + events "~1.1.0" + glob "^7.1.0" + has "^1.0.0" + htmlescape "^1.1.0" + https-browserify "^1.0.0" + inherits "~2.0.1" + insert-module-globals "^7.0.0" + labeled-stream-splicer "^2.0.0" + mkdirp "^0.5.0" + module-deps "^5.0.1" + os-browserify "~0.3.0" + parents "^1.0.1" + path-browserify "~0.0.0" + process "~0.11.0" + punycode "^1.3.2" + querystring-es3 "~0.2.0" + read-only-stream "^2.0.0" + readable-stream "^2.0.2" + resolve "^1.1.4" + shasum "^1.0.0" + shell-quote "^1.6.1" + stream-browserify "^2.0.0" + stream-http "^2.0.0" + string_decoder "~1.0.0" + subarg "^1.0.0" + syntax-error "^1.1.1" + through2 "^2.0.0" + timers-browserify "^1.0.1" + tty-browserify "~0.0.0" + url "~0.11.0" + util "~0.10.1" + vm-browserify "~0.0.1" + xtend "^4.0.0" + +bs58@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" + dependencies: + base-x "^3.0.2" + +buffer-alloc-unsafe@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" + +buffer-alloc@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec" + dependencies: + buffer-alloc-unsafe "^1.1.0" + buffer-fill "^1.0.0" + +buffer-fill@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + +buffer-more-ints@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/buffer-more-ints/-/buffer-more-ints-0.0.2.tgz#26b3885d10fa13db7fc01aae3aab870199e0124c" + +buffer-xor@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" + +buffer@^5.0.2, buffer@^5.1.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.2.1.tgz#dd57fa0f109ac59c602479044dca7b8b3d0b71d6" + dependencies: + base64-js "^1.0.2" + ieee754 "^1.1.4" + +buildmail@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/buildmail/-/buildmail-4.0.1.tgz#877f7738b78729871c9a105e3b837d2be11a7a72" + dependencies: + addressparser "1.0.1" + libbase64 "0.1.0" + libmime "3.0.0" + libqp "1.1.0" + nodemailer-fetch "1.6.0" + nodemailer-shared "1.1.0" + punycode "1.4.1" + +builtin-status-codes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" + +bytes@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" + +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + +cached-path-relative@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cached-path-relative/-/cached-path-relative-1.0.1.tgz#d09c4b52800aa4c078e2dd81a869aac90d2e54e7" + +callsite@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" + +caseless@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + +cbor@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/cbor/-/cbor-4.1.1.tgz#a6bc17020b45685d315c6bbc971f3bb3c973fde9" + dependencies: + bignumber.js "^7.2.1" + commander "^2.16.0" + json-text-sequence "^0.1" + nofilter "^0.0.3" + +chai@^4.1.2: + version "4.2.0" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5" + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^3.0.1" + get-func-name "^2.0.0" + pathval "^1.1.0" + type-detect "^4.0.5" + +chalk@^1.1.1: + version "1.1.3" + resolved "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +check-error@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" + +chokidar@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.0.4.tgz#356ff4e2b0e8e43e322d18a372460bbcf3accd26" + dependencies: + anymatch "^2.0.0" + async-each "^1.0.0" + braces "^2.3.0" + glob-parent "^3.1.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^4.0.0" + lodash.debounce "^4.0.8" + normalize-path "^2.1.1" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + upath "^1.0.5" + optionalDependencies: + fsevents "^1.2.2" + +chownr@^1.0.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" + +cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + +circular-json@^0.5.4: + version "0.5.9" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.5.9.tgz#932763ae88f4f7dead7a0d09c8a51a4743a53b1d" + +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" + +colors@^1.1.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.2.tgz#2df8ff573dfbf255af562f8ce7181d6b971a359b" + +combine-lists@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/combine-lists/-/combine-lists-1.0.1.tgz#458c07e09e0d900fc28b70a3fec2dacd1d2cb7f6" + dependencies: + lodash "^4.5.0" + +combine-source-map@^0.8.0, combine-source-map@~0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.8.0.tgz#a58d0df042c186fcf822a8e8015f5450d2d79a8b" + dependencies: + convert-source-map "~1.1.0" + inline-source-map "~0.6.0" + lodash.memoize "~3.0.3" + source-map "~0.5.3" + +combined-stream@^1.0.5, combined-stream@^1.0.6, combined-stream@~1.0.5, combined-stream@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828" + dependencies: + delayed-stream "~1.0.0" + +commander@2.15.1: + version "2.15.1" + resolved "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" + +commander@^2.16.0, commander@^2.9.0: + version "2.19.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" + +commander@~2.17.1: + version "2.17.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" + +component-bind@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" + +component-emitter@1.2.1, component-emitter@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" + +component-inherit@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +concat-stream@^1.6.1, concat-stream@~1.6.0: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +concat-stream@~1.5.1: + version "1.5.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.2.tgz#708978624d856af41a5a741defdd261da752c266" + dependencies: + inherits "~2.0.1" + readable-stream "~2.0.0" + typedarray "~0.0.5" + +connect@^3.6.0: + version "3.6.6" + resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.6.tgz#09eff6c55af7236e137135a72574858b6786f524" + dependencies: + debug "2.6.9" + finalhandler "1.1.0" + parseurl "~1.3.2" + utils-merge "1.0.1" + +console-browserify@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" + dependencies: + date-now "^0.1.4" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +constants-browserify@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" + +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + +convert-source-map@~1.1.0: + version "1.1.3" + resolved "http://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860" + +cookie@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" + +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + +core-js@^2.2.0: + version "2.5.7" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" + +core-util-is@1.0.2, core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +crc@^3.8.0: + version "3.8.0" + resolved "https://registry.yarnpkg.com/crc/-/crc-3.8.0.tgz#ad60269c2c856f8c299e2c4cc0de4556914056c6" + dependencies: + buffer "^5.1.0" + +create-ecdh@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff" + dependencies: + bn.js "^4.1.0" + elliptic "^6.0.0" + +create-hash@^1.1.0, create-hash@^1.1.2: + version "1.2.0" + resolved "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" + dependencies: + cipher-base "^1.0.1" + inherits "^2.0.1" + md5.js "^1.3.4" + ripemd160 "^2.0.1" + sha.js "^2.4.0" + +create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: + version "1.1.7" + resolved "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" + dependencies: + cipher-base "^1.0.3" + create-hash "^1.1.0" + inherits "^2.0.1" + ripemd160 "^2.0.0" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +crypto-browserify@^3.0.0: + version "3.12.0" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" + dependencies: + browserify-cipher "^1.0.0" + browserify-sign "^4.0.0" + create-ecdh "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.0" + diffie-hellman "^5.0.0" + inherits "^2.0.1" + pbkdf2 "^3.0.3" + public-encrypt "^4.0.0" + randombytes "^2.0.0" + randomfill "^1.0.3" + +custom-event@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +data-uri-to-buffer@1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz#77163ea9c20d8641b4707e8f18abdf9a78f34835" + +date-format@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/date-format/-/date-format-1.2.0.tgz#615e828e233dd1ab9bb9ae0950e0ceccfa6ecad8" + +date-now@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" + +debug@2, debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@~2.6.4, debug@~2.6.6: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +debug@3.1.0, debug@=3.1.0, debug@~3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + +debug@^3.1.0: + version "3.2.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" + dependencies: + ms "^2.1.1" + +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + +deep-eql@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" + dependencies: + type-detect "^4.0.0" + +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + +defined@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" + +degenerator@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-1.0.4.tgz#fcf490a37ece266464d9cc431ab98c5819ced095" + dependencies: + ast-types "0.x.x" + escodegen "1.x.x" + esprima "3.x.x" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +delimit-stream@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/delimit-stream/-/delimit-stream-0.1.0.tgz#9b8319477c0e5f8aeb3ce357ae305fc25ea1cd2b" + +depd@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + +deps-sort@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/deps-sort/-/deps-sort-2.0.0.tgz#091724902e84658260eb910748cccd1af6e21fb5" + dependencies: + JSONStream "^1.0.3" + shasum "^1.0.0" + subarg "^1.0.0" + through2 "^2.0.0" + +des.js@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.0.tgz#c074d2e2aa6a8a9a07dbd61f9a15c2cd83ec8ecc" + dependencies: + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + +detect-libc@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + +detective@^5.0.2: + version "5.1.0" + resolved "https://registry.yarnpkg.com/detective/-/detective-5.1.0.tgz#7a20d89236d7b331ccea65832e7123b5551bb7cb" + dependencies: + acorn-node "^1.3.0" + defined "^1.0.0" + minimist "^1.1.1" + +di@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" + +diff@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + +diffie-hellman@^5.0.0: + version "5.0.3" + resolved "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" + dependencies: + bn.js "^4.1.0" + miller-rabin "^4.0.0" + randombytes "^2.0.0" + +dom-serialize@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" + dependencies: + custom-event "~1.0.0" + ent "~2.2.0" + extend "^3.0.0" + void-elements "^2.0.0" + +domain-browser@~1.1.0: + version "1.1.7" + resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" + +double-ended-queue@^2.1.0-0: + version "2.1.0-0" + resolved "https://registry.yarnpkg.com/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz#103d3527fd31528f40188130c841efdd78264e5c" + +duplexer2@^0.1.2, duplexer2@~0.1.0, duplexer2@~0.1.2: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" + dependencies: + readable-stream "^2.0.2" + +ecc-jsbn@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" + dependencies: + jsbn "~0.1.0" + safer-buffer "^2.1.0" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + +elliptic@^6.0.0: + version "6.4.1" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.1.tgz#c2d0b7776911b86722c632c3c06c60f2f819939a" + dependencies: + bn.js "^4.4.0" + brorand "^1.0.1" + hash.js "^1.0.0" + hmac-drbg "^1.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.0" + +encodeurl@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + +engine.io-client@~3.1.0: + version "3.1.6" + resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.1.6.tgz#5bdeb130f8b94a50ac5cbeb72583e7a4a063ddfd" + dependencies: + component-emitter "1.2.1" + component-inherit "0.0.3" + debug "~3.1.0" + engine.io-parser "~2.1.1" + has-cors "1.1.0" + indexof "0.0.1" + parseqs "0.0.5" + parseuri "0.0.5" + ws "~3.3.1" + xmlhttprequest-ssl "~1.5.4" + yeast "0.1.2" + +engine.io-parser@~2.1.0, engine.io-parser@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-2.1.2.tgz#4c0f4cff79aaeecbbdcfdea66a823c6085409196" + dependencies: + after "0.8.2" + arraybuffer.slice "~0.0.7" + base64-arraybuffer "0.1.5" + blob "0.0.4" + has-binary2 "~1.0.2" + +engine.io@~3.1.0: + version "3.1.5" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.1.5.tgz#0e7ef9d690eb0b35597f1d4ad02a26ca2dba3845" + dependencies: + accepts "~1.3.4" + base64id "1.0.0" + cookie "0.3.1" + debug "~3.1.0" + engine.io-parser "~2.1.0" + ws "~3.3.1" + optionalDependencies: + uws "~9.14.0" + +ent@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" + +es6-promise@^4.0.3: + version "4.2.5" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.5.tgz#da6d0d5692efb461e082c14817fe2427d8f5d054" + +es6-promisify@^5.0.0: + version "5.0.0" + resolved "http://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" + dependencies: + es6-promise "^4.0.3" + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +escodegen@1.x.x: + version "1.11.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.11.0.tgz#b27a9389481d5bfd5bec76f7bb1eb3f8f4556589" + dependencies: + esprima "^3.1.3" + estraverse "^4.2.0" + esutils "^2.0.2" + optionator "^0.8.1" + optionalDependencies: + source-map "~0.6.1" + +esprima@3.x.x, esprima@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" + +estraverse@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +eventemitter3@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.0.tgz#090b4d6cdbd645ed10bf750d4b5407942d7ba163" + +events@~1.1.0: + version "1.1.1" + resolved "http://registry.npmjs.org/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" + +evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" + dependencies: + md5.js "^1.3.4" + safe-buffer "^5.1.1" + +expand-braces@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/expand-braces/-/expand-braces-0.1.2.tgz#488b1d1d2451cb3d3a6b192cfc030f44c5855fea" + dependencies: + array-slice "^0.2.3" + array-unique "^0.2.1" + braces "^0.1.2" + +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +expand-range@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-0.1.1.tgz#4cb8eda0993ca56fa4f41fc42f3cbb4ccadff044" + dependencies: + is-number "^0.1.1" + repeat-string "^0.2.2" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + dependencies: + is-extendable "^0.1.0" + +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + +extend@3, extend@^3.0.0, extend@~3.0.0, extend@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + +fast-deep-equal@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614" + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + +file-uri-to-path@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + +finalhandler@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" + dependencies: + debug "2.6.9" + encodeurl "~1.0.1" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.2" + statuses "~1.3.1" + unpipe "~1.0.0" + +follow-redirects@1.0.0: + version "1.0.0" + resolved "http://registry.npmjs.org/follow-redirects/-/follow-redirects-1.0.0.tgz#8e34298cbd2e176f254effec75a1c78cc849fd37" + dependencies: + debug "^2.2.0" + +follow-redirects@^1.0.0: + version "1.5.9" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.9.tgz#c9ed9d748b814a39535716e531b9196a845d89c6" + dependencies: + debug "=3.1.0" + +for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~2.0.0: + version "2.0.0" + resolved "http://registry.npmjs.org/form-data/-/form-data-2.0.0.tgz#6f0aebadcc5da16c13e1ecc11137d85f9b883b25" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.11" + +form-data@~2.3.0, form-data@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" + +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + dependencies: + map-cache "^0.2.2" + +fs-access@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a" + dependencies: + null-check "^1.0.0" + +fs-minipass@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d" + dependencies: + minipass "^2.2.1" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +fsevents@^1.2.2: + version "1.2.4" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.4.tgz#f41dcb1af2582af3692da36fc55cbd8e1041c426" + dependencies: + nan "^2.9.2" + node-pre-gyp "^0.10.0" + +ftp@~0.3.10: + version "0.3.10" + resolved "https://registry.yarnpkg.com/ftp/-/ftp-0.3.10.tgz#9197d861ad8142f3e63d5a83bfe4c59f7330885d" + dependencies: + readable-stream "1.1.x" + xregexp "2.0.0" + +function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +generate-function@^2.0.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.3.1.tgz#f069617690c10c868e73b8465746764f97c3479f" + dependencies: + is-property "^1.0.2" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + +get-assigned-identifiers@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz#6dbf411de648cbaf8d9169ebb0d2d576191e2ff1" + +get-func-name@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" + +get-uri@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-2.0.2.tgz#5c795e71326f6ca1286f2fc82575cd2bab2af578" + dependencies: + data-uri-to-buffer "1" + debug "2" + extend "3" + file-uri-to-path "1" + ftp "~0.3.10" + readable-stream "2" + +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + dependencies: + assert-plus "^1.0.0" + +glob-parent@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" + dependencies: + is-glob "^3.1.0" + path-dirname "^1.0.0" + +glob@7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@^7.0.5, glob@^7.1.0, glob@^7.1.1: + version "7.1.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +graceful-fs@^4.1.11, graceful-fs@^4.1.2: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +growl@1.10.5: + version "1.10.5" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + +har-validator@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + dependencies: + chalk "^1.1.1" + commander "^2.9.0" + is-my-json-valid "^2.12.4" + pinkie-promise "^2.0.0" + +har-validator@~5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.0.tgz#44657f5688a22cfd4b72486e81b3a3fb11742c29" + dependencies: + ajv "^5.3.0" + har-schema "^2.0.0" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-binary2@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-binary2/-/has-binary2-1.0.3.tgz#7776ac627f3ea77250cfc332dab7ddf5e4f5d11d" + dependencies: + isarray "2.0.1" + +has-cors@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +has@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + dependencies: + function-bind "^1.1.1" + +hash-base@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.0.4.tgz#5fc8686847ecd73499403319a6b0a3f3f6ae4918" + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + +hash.js@^1.0.0, hash.js@^1.0.3: + version "1.1.5" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.5.tgz#e38ab4b85dfb1e0c40fe9265c0e9b54854c23812" + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.1" + +hawk@~3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +he@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" + +hipchat-notifier@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/hipchat-notifier/-/hipchat-notifier-1.1.0.tgz#b6d249755437c191082367799d3ba9a0f23b231e" + dependencies: + lodash "^4.0.0" + request "^2.0.0" + +hmac-drbg@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" + dependencies: + hash.js "^1.0.3" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.1" + +hoek@2.x.x: + version "2.16.3" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +htmlescape@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/htmlescape/-/htmlescape-1.1.1.tgz#3a03edc2214bca3b66424a3e7959349509cb0351" + +http-errors@1.6.3, http-errors@~1.6.3: + version "1.6.3" + resolved "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" + dependencies: + depd "~1.1.2" + inherits "2.0.3" + setprototypeof "1.1.0" + statuses ">= 1.4.0 < 2" + +http-proxy-agent@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405" + dependencies: + agent-base "4" + debug "3.1.0" + +http-proxy@^1.13.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.17.0.tgz#7ad38494658f84605e2f6db4436df410f4e5be9a" + dependencies: + eventemitter3 "^3.0.0" + follow-redirects "^1.0.0" + requires-port "^1.0.0" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +httpntlm@1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/httpntlm/-/httpntlm-1.6.1.tgz#ad01527143a2e8773cfae6a96f58656bb52a34b2" + dependencies: + httpreq ">=0.4.22" + underscore "~1.7.0" + +httpreq@>=0.4.22: + version "0.4.24" + resolved "https://registry.yarnpkg.com/httpreq/-/httpreq-0.4.24.tgz#4335ffd82cd969668a39465c929ac61d6393627f" + +https-browserify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" + +https-proxy-agent@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0" + dependencies: + agent-base "^4.1.0" + debug "^3.1.0" + +iconv-lite@0.4.15: + version "0.4.15" + resolved "http://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" + +iconv-lite@0.4.23: + version "0.4.23" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63" + dependencies: + safer-buffer ">= 2.1.2 < 3" + +iconv-lite@^0.4.4: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + dependencies: + safer-buffer ">= 2.1.2 < 3" + +ieee754@^1.1.4: + version "1.1.12" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.12.tgz#50bf24e5b9c8bb98af4964c941cdb0918da7b60b" + +ignore-walk@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8" + dependencies: + minimatch "^3.0.4" + +indexof@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" + +inflection@~1.12.0: + version "1.12.0" + resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.12.0.tgz#a200935656d6f5f6bc4dc7502e1aecb703228416" + +inflection@~1.3.0: + version "1.3.8" + resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.3.8.tgz#cbd160da9f75b14c3cc63578d4f396784bf3014e" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +inherits@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" + +ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + +inline-source-map@~0.6.0: + version "0.6.2" + resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.6.2.tgz#f9393471c18a79d1724f863fa38b586370ade2a5" + dependencies: + source-map "~0.5.3" + +insert-module-globals@^7.0.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/insert-module-globals/-/insert-module-globals-7.2.0.tgz#ec87e5b42728479e327bd5c5c71611ddfb4752ba" + dependencies: + JSONStream "^1.0.3" + acorn-node "^1.5.2" + combine-source-map "^0.8.0" + concat-stream "^1.6.1" + is-buffer "^1.1.0" + path-is-absolute "^1.0.1" + process "~0.11.0" + through2 "^2.0.0" + undeclared-identifiers "^1.1.2" + xtend "^4.0.0" + +ip@^1.1.2, ip@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" + +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + dependencies: + kind-of "^6.0.0" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.1.0, is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + dependencies: + kind-of "^3.0.2" + +is-data-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + dependencies: + kind-of "^6.0.0" + +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + dependencies: + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + dependencies: + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + dependencies: + is-plain-object "^2.0.4" + +is-extglob@^2.1.0, is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + +is-glob@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" + dependencies: + is-extglob "^2.1.0" + +is-glob@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0" + dependencies: + is-extglob "^2.1.1" + +is-my-ip-valid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz#7b351b8e8edd4d3995d4d066680e664d94696824" + +is-my-json-valid@^2.12.4: + version "2.19.0" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.19.0.tgz#8fd6e40363cd06b963fa877d444bfb5eddc62175" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + is-my-ip-valid "^1.0.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + +is-number@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-0.1.1.tgz#69a7af116963d47206ec9bd9b48a14216f1e3806" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + dependencies: + kind-of "^3.0.2" + +is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + dependencies: + isobject "^3.0.1" + +is-property@^1.0.0, is-property@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + +is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isarray@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e" + +isarray@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.4.tgz#38e7bcbb0f3ba1b7933c86ba1894ddfc3781bbb7" + +isbinaryfile@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-3.0.3.tgz#5d6def3edebf6e8ca8cae9c30183a804b5f8be80" + dependencies: + buffer-alloc "^1.2.0" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + dependencies: + isarray "1.0.0" + +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + +json-schema-traverse@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stable-stringify@~0.0.0: + version "0.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz#611c23e814db375527df851193db59dd2af27f45" + dependencies: + jsonify "~0.0.0" + +json-stringify-safe@5.0.x, json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json-text-sequence@^0.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/json-text-sequence/-/json-text-sequence-0.1.1.tgz#a72f217dc4afc4629fff5feb304dc1bd51a2f3d2" + dependencies: + delimit-stream "0.1.0" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsonparse@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" + +jsonpointer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" + +jsprim@^1.2.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.2.3" + verror "1.10.0" + +jssha@2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/jssha/-/jssha-2.3.1.tgz#147b2125369035ca4b2f7d210dc539f009b3de9a" + +karma-chai@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/karma-chai/-/karma-chai-0.1.0.tgz#bee5ad40400517811ae34bb945f762909108b79a" + +karma-chrome-launcher@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz#cf1b9d07136cc18fe239327d24654c3dbc368acf" + dependencies: + fs-access "^1.0.0" + which "^1.2.1" + +karma-mocha@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/karma-mocha/-/karma-mocha-1.3.0.tgz#eeaac7ffc0e201eb63c467440d2b69c7cf3778bf" + dependencies: + minimist "1.2.0" + +karma@^2.0.0: + version "2.0.5" + resolved "https://registry.yarnpkg.com/karma/-/karma-2.0.5.tgz#3710c7a2e71b1c439313f283846d88e04e4f918c" + dependencies: + bluebird "^3.3.0" + body-parser "^1.16.1" + chokidar "^2.0.3" + colors "^1.1.0" + combine-lists "^1.0.0" + connect "^3.6.0" + core-js "^2.2.0" + di "^0.0.1" + dom-serialize "^2.2.0" + expand-braces "^0.1.1" + glob "^7.1.1" + graceful-fs "^4.1.2" + http-proxy "^1.13.0" + isbinaryfile "^3.0.0" + lodash "^4.17.4" + log4js "^2.5.3" + mime "^1.3.4" + minimatch "^3.0.2" + optimist "^0.6.1" + qjobs "^1.1.4" + range-parser "^1.2.0" + rimraf "^2.6.0" + safe-buffer "^5.0.1" + socket.io "2.0.4" + source-map "^0.6.1" + tmp "0.0.33" + useragent "2.2.1" + +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + dependencies: + is-buffer "^1.1.5" + +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" + +labeled-stream-splicer@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz#9cffa32fd99e1612fd1d86a8db962416d5292926" + dependencies: + inherits "^2.0.1" + isarray "^2.0.4" + stream-splicer "^2.0.0" + +levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +libbase64@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/libbase64/-/libbase64-0.1.0.tgz#62351a839563ac5ff5bd26f12f60e9830bb751e6" + +libmime@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/libmime/-/libmime-3.0.0.tgz#51a1a9e7448ecbd32cda54421675bb21bc093da6" + dependencies: + iconv-lite "0.4.15" + libbase64 "0.1.0" + libqp "1.1.0" + +libqp@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/libqp/-/libqp-1.1.0.tgz#f5e6e06ad74b794fb5b5b66988bf728ef1dedbe8" + +lodash.debounce@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" + +lodash.memoize@~3.0.3: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" + +lodash@^4.0.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.5.0: + version "4.17.11" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" + +log4js@^2.5.3: + version "2.11.0" + resolved "https://registry.yarnpkg.com/log4js/-/log4js-2.11.0.tgz#bf3902eff65c6923d9ce9cfbd2db54160e34005a" + dependencies: + circular-json "^0.5.4" + date-format "^1.2.0" + debug "^3.1.0" + semver "^5.5.0" + streamroller "0.7.0" + optionalDependencies: + amqplib "^0.5.2" + axios "^0.15.3" + hipchat-notifier "^1.1.0" + loggly "^1.1.0" + mailgun-js "^0.18.0" + nodemailer "^2.5.0" + redis "^2.7.1" + slack-node "~0.2.0" + +loggly@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/loggly/-/loggly-1.1.1.tgz#0a0fc1d3fa3a5ec44fdc7b897beba2a4695cebee" + dependencies: + json-stringify-safe "5.0.x" + request "2.75.x" + timespan "2.3.x" + +lru-cache@2.2.x: + version "2.2.4" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d" + +lru-cache@^4.1.2: + version "4.1.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c" + dependencies: + pseudomap "^1.0.2" + yallist "^2.1.2" + +mailcomposer@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/mailcomposer/-/mailcomposer-4.0.1.tgz#0e1c44b2a07cf740ee17dc149ba009f19cadfeb4" + dependencies: + buildmail "4.0.1" + libmime "3.0.0" + +mailgun-js@^0.18.0: + version "0.18.1" + resolved "https://registry.yarnpkg.com/mailgun-js/-/mailgun-js-0.18.1.tgz#ee39aa18d7bb598a5ce9ede84afb681defc8a6b0" + dependencies: + async "~2.6.0" + debug "~3.1.0" + form-data "~2.3.0" + inflection "~1.12.0" + is-stream "^1.1.0" + path-proxy "~1.0.0" + promisify-call "^2.0.2" + proxy-agent "~3.0.0" + tsscmp "~1.0.0" + +map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + dependencies: + object-visit "^1.0.0" + +md5.js@^1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +media-typer@0.3.0: + version "0.3.0" + resolved "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + +micromatch@^3.1.10, micromatch@^3.1.4: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + +miller-rabin@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" + dependencies: + bn.js "^4.0.0" + brorand "^1.0.1" + +mime-db@~1.37.0: + version "1.37.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8" + +mime-types@^2.1.11, mime-types@^2.1.12, mime-types@~2.1.18, mime-types@~2.1.19, mime-types@~2.1.7: + version "2.1.21" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.21.tgz#28995aa1ecb770742fe6ae7e58f9181c744b3f96" + dependencies: + mime-db "~1.37.0" + +mime@^1.3.4: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + +minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + +minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" + +minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimist@0.0.8: + version "0.0.8" + resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0: + version "1.2.0" + resolved "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +minimist@~0.0.1: + version "0.0.10" + resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + +minipass@^2.2.1, minipass@^2.3.3: + version "2.3.5" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848" + dependencies: + safe-buffer "^5.1.2" + yallist "^3.0.0" + +minizlib@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.1.1.tgz#6734acc045a46e61d596a43bb9d9cd326e19cc42" + dependencies: + minipass "^2.2.1" + +mixin-deep@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + +mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1: + version "0.5.1" + resolved "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mocha@^5.0.2: + version "5.2.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6" + dependencies: + browser-stdout "1.3.1" + commander "2.15.1" + debug "3.1.0" + diff "3.5.0" + escape-string-regexp "1.0.5" + glob "7.1.2" + growl "1.10.5" + he "1.1.1" + minimatch "3.0.4" + mkdirp "0.5.1" + supports-color "5.4.0" + +module-deps@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-5.0.1.tgz#3bc47c14b0a6d925aff2ec4a177b456a96ae0396" + dependencies: + JSONStream "^1.0.3" + browser-resolve "^1.7.0" + cached-path-relative "^1.0.0" + concat-stream "~1.6.0" + defined "^1.0.0" + detective "^5.0.2" + duplexer2 "^0.1.2" + inherits "^2.0.1" + parents "^1.0.0" + readable-stream "^2.0.2" + resolve "^1.1.3" + stream-combiner2 "^1.1.1" + subarg "^1.0.0" + through2 "^2.0.0" + xtend "^4.0.0" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +ms@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + +nan@^2.9.2: + version "2.11.1" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766" + +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +needle@^2.2.1: + version "2.2.4" + resolved "https://registry.yarnpkg.com/needle/-/needle-2.2.4.tgz#51931bff82533b1928b7d1d69e01f1b00ffd2a4e" + dependencies: + debug "^2.1.2" + iconv-lite "^0.4.4" + sax "^1.2.4" + +negotiator@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" + +netmask@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35" + +node-pre-gyp@^0.10.0: + version "0.10.3" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc" + dependencies: + detect-libc "^1.0.2" + mkdirp "^0.5.1" + needle "^2.2.1" + nopt "^4.0.1" + npm-packlist "^1.1.6" + npmlog "^4.0.2" + rc "^1.2.7" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^4" + +node-uuid@~1.4.7: + version "1.4.8" + resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" + +nodemailer-direct-transport@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/nodemailer-direct-transport/-/nodemailer-direct-transport-3.3.2.tgz#e96fafb90358560947e569017d97e60738a50a86" + dependencies: + nodemailer-shared "1.1.0" + smtp-connection "2.12.0" + +nodemailer-fetch@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/nodemailer-fetch/-/nodemailer-fetch-1.6.0.tgz#79c4908a1c0f5f375b73fe888da9828f6dc963a4" + +nodemailer-shared@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/nodemailer-shared/-/nodemailer-shared-1.1.0.tgz#cf5994e2fd268d00f5cf0fa767a08169edb07ec0" + dependencies: + nodemailer-fetch "1.6.0" + +nodemailer-smtp-pool@2.8.2: + version "2.8.2" + resolved "https://registry.yarnpkg.com/nodemailer-smtp-pool/-/nodemailer-smtp-pool-2.8.2.tgz#2eb94d6cf85780b1b4725ce853b9cbd5e8da8c72" + dependencies: + nodemailer-shared "1.1.0" + nodemailer-wellknown "0.1.10" + smtp-connection "2.12.0" + +nodemailer-smtp-transport@2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/nodemailer-smtp-transport/-/nodemailer-smtp-transport-2.7.2.tgz#03d71c76314f14ac7dbc7bf033a6a6d16d67fb77" + dependencies: + nodemailer-shared "1.1.0" + nodemailer-wellknown "0.1.10" + smtp-connection "2.12.0" + +nodemailer-wellknown@0.1.10: + version "0.1.10" + resolved "https://registry.yarnpkg.com/nodemailer-wellknown/-/nodemailer-wellknown-0.1.10.tgz#586db8101db30cb4438eb546737a41aad0cf13d5" + +nodemailer@^2.5.0: + version "2.7.2" + resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-2.7.2.tgz#f242e649aeeae39b6c7ed740ef7b061c404d30f9" + dependencies: + libmime "3.0.0" + mailcomposer "4.0.1" + nodemailer-direct-transport "3.3.2" + nodemailer-shared "1.1.0" + nodemailer-smtp-pool "2.8.2" + nodemailer-smtp-transport "2.7.2" + socks "1.1.9" + +nofilter@^0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-0.0.3.tgz#241e342078177a8693a3043e83f37567e276410c" + +nopt@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" + dependencies: + abbrev "1" + osenv "^0.1.4" + +normalize-path@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + dependencies: + remove-trailing-separator "^1.0.1" + +npm-bundled@^1.0.1: + version "1.0.5" + resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.5.tgz#3c1732b7ba936b3a10325aef616467c0ccbcc979" + +npm-packlist@^1.1.6: + version "1.1.12" + resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.1.12.tgz#22bde2ebc12e72ca482abd67afc51eb49377243a" + dependencies: + ignore-walk "^3.0.1" + npm-bundled "^1.0.1" + +npmlog@^4.0.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + +null-check@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +oauth-sign@~0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + +object-assign@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +object-component@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" + +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + dependencies: + isobject "^3.0.0" + +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + dependencies: + isobject "^3.0.1" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + dependencies: + ee-first "1.1.1" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +optimist@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +optionator@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + +os-browserify@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-tmpdir@^1.0.0, os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +osenv@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +pac-proxy-agent@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-3.0.0.tgz#11d578b72a164ad74bf9d5bac9ff462a38282432" + dependencies: + agent-base "^4.2.0" + debug "^3.1.0" + get-uri "^2.0.0" + http-proxy-agent "^2.1.0" + https-proxy-agent "^2.2.1" + pac-resolver "^3.0.0" + raw-body "^2.2.0" + socks-proxy-agent "^4.0.1" + +pac-resolver@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-3.0.0.tgz#6aea30787db0a891704deb7800a722a7615a6f26" + dependencies: + co "^4.6.0" + degenerator "^1.0.4" + ip "^1.1.5" + netmask "^1.0.6" + thunkify "^2.1.2" + +pako@~1.0.5: + version "1.0.6" + resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258" + +parents@^1.0.0, parents@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parents/-/parents-1.0.1.tgz#fedd4d2bf193a77745fe71e371d73c3307d9c751" + dependencies: + path-platform "~0.11.15" + +parse-asn1@^5.0.0: + version "5.1.1" + resolved "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz#f6bf293818332bd0dab54efb16087724745e6ca8" + dependencies: + asn1.js "^4.0.0" + browserify-aes "^1.0.0" + create-hash "^1.1.0" + evp_bytestokey "^1.0.0" + pbkdf2 "^3.0.3" + +parseqs@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" + dependencies: + better-assert "~1.0.0" + +parseuri@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a" + dependencies: + better-assert "~1.0.0" + +parseurl@~1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" + +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + +path-browserify@~0.0.0: + version "0.0.1" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" + +path-dirname@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" + +path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-parse@^1.0.5: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + +path-platform@~0.11.15: + version "0.11.15" + resolved "https://registry.yarnpkg.com/path-platform/-/path-platform-0.11.15.tgz#e864217f74c36850f0852b78dc7bf7d4a5721bf2" + +path-proxy@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/path-proxy/-/path-proxy-1.0.0.tgz#18e8a36859fc9d2f1a53b48dee138543c020de5e" + dependencies: + inflection "~1.3.0" + +pathval@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" + +pbkdf2@^3.0.3: + version "3.0.17" + resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6" + dependencies: + create-hash "^1.1.2" + create-hmac "^1.1.4" + ripemd160 "^2.0.1" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + +process@~0.11.0: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + +promisify-call@^2.0.2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/promisify-call/-/promisify-call-2.0.4.tgz#d48c2d45652ccccd52801ddecbd533a6d4bd5fba" + dependencies: + with-callback "^1.0.2" + +proxy-agent@~3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-3.0.3.tgz#1c1a33db60ef5f2e9e35b876fd63c2bc681c611d" + dependencies: + agent-base "^4.2.0" + debug "^3.1.0" + http-proxy-agent "^2.1.0" + https-proxy-agent "^2.2.1" + lru-cache "^4.1.2" + pac-proxy-agent "^3.0.0" + proxy-from-env "^1.0.0" + socks-proxy-agent "^4.0.1" + +proxy-from-env@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" + +pseudomap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + +psl@^1.1.24: + version "1.1.29" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.29.tgz#60f580d360170bb722a797cc704411e6da850c67" + +public-encrypt@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" + dependencies: + bn.js "^4.1.0" + browserify-rsa "^4.0.0" + create-hash "^1.1.0" + parse-asn1 "^5.0.0" + randombytes "^2.0.1" + safe-buffer "^5.1.2" + +punycode@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + +punycode@1.4.1, punycode@^1.3.2, punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +qjobs@^1.1.4: + version "1.2.0" + resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" + +qs@6.5.2, qs@~6.5.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" + +qs@~6.2.0: + version "6.2.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.3.tgz#1cfcb25c10a9b2b483053ff39f5dfc9233908cfe" + +querystring-es3@~0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" + +querystring@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + +randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: + version "2.0.6" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.0.6.tgz#d302c522948588848a8d300c932b44c24231da80" + dependencies: + safe-buffer "^5.1.0" + +randomfill@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" + dependencies: + randombytes "^2.0.5" + safe-buffer "^5.1.0" + +range-parser@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + +raw-body@2.3.3, raw-body@^2.2.0: + version "2.3.3" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.3.tgz#1b324ece6b5706e153855bc1148c65bb7f6ea0c3" + dependencies: + bytes "3.0.0" + http-errors "1.6.3" + iconv-lite "0.4.23" + unpipe "1.0.0" + +rc@^1.2.7: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +read-only-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-only-stream/-/read-only-stream-2.0.0.tgz#2724fd6a8113d73764ac288d4386270c1dbf17f0" + dependencies: + readable-stream "^2.0.2" + +readable-stream@1.1.x, "readable-stream@1.x >=1.1.9": + version "1.1.14" + resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@2, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.6: + version "2.3.6" + resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +readable-stream@~2.0.0, readable-stream@~2.0.5: + version "2.0.6" + resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + +readdirp@^2.0.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525" + dependencies: + graceful-fs "^4.1.11" + micromatch "^3.1.10" + readable-stream "^2.0.2" + +redis-commands@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.4.0.tgz#52f9cf99153efcce56a8f86af986bd04e988602f" + +redis-parser@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/redis-parser/-/redis-parser-2.6.0.tgz#52ed09dacac108f1a631c07e9b69941e7a19504b" + +redis@^2.7.1: + version "2.8.0" + resolved "https://registry.yarnpkg.com/redis/-/redis-2.8.0.tgz#202288e3f58c49f6079d97af7a10e1303ae14b02" + dependencies: + double-ended-queue "^2.1.0-0" + redis-commands "^1.2.0" + redis-parser "^2.6.0" + +regex-not@^1.0.0, regex-not@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + +remove-trailing-separator@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" + +repeat-element@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" + +repeat-string@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-0.2.2.tgz#c7a8d3236068362059a7e4651fc6884e8b1fb4ae" + +repeat-string@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +request@2.75.x: + version "2.75.0" + resolved "http://registry.npmjs.org/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + bl "~1.1.2" + caseless "~0.11.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.0.0" + har-validator "~2.0.6" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + node-uuid "~1.4.7" + oauth-sign "~0.8.1" + qs "~6.2.0" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "~0.4.1" + +request@^2.0.0, request@^2.74.0: + version "2.88.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.0" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.4.3" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + +requestretry@^1.2.2: + version "1.13.0" + resolved "https://registry.yarnpkg.com/requestretry/-/requestretry-1.13.0.tgz#213ec1006eeb750e8b8ce54176283d15a8d55d94" + dependencies: + extend "^3.0.0" + lodash "^4.15.0" + request "^2.74.0" + when "^3.7.7" + +requires-port@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + +resolve@1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" + +resolve@^1.1.3, resolve@^1.1.4: + version "1.8.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" + dependencies: + path-parse "^1.0.5" + +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + +rimraf@^2.6.0, rimraf@^2.6.1: + version "2.6.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" + dependencies: + glob "^7.0.5" + +ripemd160@^2.0.0, ripemd160@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + dependencies: + ret "~0.1.10" + +"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + +sax@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" + +semver@^5.3.0, semver@^5.5.0: + version "5.6.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" + +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +set-value@^0.4.3: + version "0.4.3" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1" + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.1" + to-object-path "^0.3.0" + +set-value@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274" + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + +sha.js@^2.4.0, sha.js@^2.4.8, sha.js@~2.4.4: + version "2.4.11" + resolved "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + +shasum@^1.0.0: + version "1.0.2" + resolved "http://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz#e7012310d8f417f4deb5712150e5678b87ae565f" + dependencies: + json-stable-stringify "~0.0.0" + sha.js "~2.4.4" + +shell-quote@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767" + dependencies: + array-filter "~0.0.0" + array-map "~0.0.0" + array-reduce "~0.0.0" + jsonify "~0.0.0" + +signal-exit@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +simple-concat@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6" + +slack-node@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/slack-node/-/slack-node-0.2.0.tgz#de4b8dddaa8b793f61dbd2938104fdabf37dfa30" + dependencies: + requestretry "^1.2.2" + +smart-buffer@^1.0.4: + version "1.1.15" + resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-1.1.15.tgz#7f114b5b65fab3e2a35aa775bb12f0d1c649bf16" + +smart-buffer@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.0.1.tgz#07ea1ca8d4db24eb4cac86537d7d18995221ace3" + +smtp-connection@2.12.0: + version "2.12.0" + resolved "https://registry.yarnpkg.com/smtp-connection/-/smtp-connection-2.12.0.tgz#d76ef9127cb23c2259edb1e8349c2e8d5e2d74c1" + dependencies: + httpntlm "1.6.1" + nodemailer-shared "1.1.0" + +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + +sntp@1.x.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +socket.io-adapter@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz#2a805e8a14d6372124dd9159ad4502f8cb07f06b" + +socket.io-client@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.0.4.tgz#0918a552406dc5e540b380dcd97afc4a64332f8e" + dependencies: + backo2 "1.0.2" + base64-arraybuffer "0.1.5" + component-bind "1.0.0" + component-emitter "1.2.1" + debug "~2.6.4" + engine.io-client "~3.1.0" + has-cors "1.1.0" + indexof "0.0.1" + object-component "0.0.3" + parseqs "0.0.5" + parseuri "0.0.5" + socket.io-parser "~3.1.1" + to-array "0.1.4" + +socket.io-parser@~3.1.1: + version "3.1.3" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.1.3.tgz#ed2da5ee79f10955036e3da413bfd7f1e4d86c8e" + dependencies: + component-emitter "1.2.1" + debug "~3.1.0" + has-binary2 "~1.0.2" + isarray "2.0.1" + +socket.io@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.0.4.tgz#c1a4590ceff87ecf13c72652f046f716b29e6014" + dependencies: + debug "~2.6.6" + engine.io "~3.1.0" + socket.io-adapter "~1.1.0" + socket.io-client "2.0.4" + socket.io-parser "~3.1.1" + +socks-proxy-agent@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-4.0.1.tgz#5936bf8b707a993079c6f37db2091821bffa6473" + dependencies: + agent-base "~4.2.0" + socks "~2.2.0" + +socks@1.1.9: + version "1.1.9" + resolved "https://registry.yarnpkg.com/socks/-/socks-1.1.9.tgz#628d7e4d04912435445ac0b6e459376cb3e6d691" + dependencies: + ip "^1.1.2" + smart-buffer "^1.0.4" + +socks@~2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.2.1.tgz#68ad678b3642fbc5d99c64c165bc561eab0215f9" + dependencies: + ip "^1.1.5" + smart-buffer "^4.0.1" + +source-map-resolve@^0.5.0: + version "0.5.2" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259" + dependencies: + atob "^2.1.1" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + +source-map-url@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" + +source-map@^0.5.6, source-map@~0.5.3: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + +source-map@^0.6.1, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + dependencies: + extend-shallow "^3.0.0" + +sshpk@^1.7.0: + version "1.15.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.15.1.tgz#b79a089a732e346c6e0714830f36285cd38191a2" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + bcrypt-pbkdf "^1.0.0" + dashdash "^1.12.0" + ecc-jsbn "~0.1.1" + getpass "^0.1.1" + jsbn "~0.1.0" + safer-buffer "^2.0.2" + tweetnacl "~0.14.0" + +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + +"statuses@>= 1.4.0 < 2": + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + +statuses@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" + +stream-browserify@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.1.tgz#66266ee5f9bdb9940a4e4514cafb43bb71e5c9db" + dependencies: + inherits "~2.0.1" + readable-stream "^2.0.2" + +stream-combiner2@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/stream-combiner2/-/stream-combiner2-1.1.1.tgz#fb4d8a1420ea362764e21ad4780397bebcb41cbe" + dependencies: + duplexer2 "~0.1.0" + readable-stream "^2.0.2" + +stream-http@^2.0.0: + version "2.8.3" + resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.8.3.tgz#b2d242469288a5a27ec4fe8933acf623de6514fc" + dependencies: + builtin-status-codes "^3.0.0" + inherits "^2.0.1" + readable-stream "^2.3.6" + to-arraybuffer "^1.0.0" + xtend "^4.0.0" + +stream-splicer@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/stream-splicer/-/stream-splicer-2.0.0.tgz#1b63be438a133e4b671cc1935197600175910d83" + dependencies: + inherits "^2.0.1" + readable-stream "^2.0.2" + +streamroller@0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-0.7.0.tgz#a1d1b7cf83d39afb0d63049a5acbf93493bdf64b" + dependencies: + date-format "^1.2.0" + debug "^3.1.0" + mkdirp "^0.5.1" + readable-stream "^2.3.0" + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +"string-width@^1.0.2 || 2": + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +string_decoder@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" + dependencies: + safe-buffer "~5.1.0" + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + dependencies: + safe-buffer "~5.1.0" + +stringstream@~0.0.4: + version "0.0.6" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.6.tgz#7880225b0d4ad10e30927d167a1d6f2fd3b33a72" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + dependencies: + ansi-regex "^3.0.0" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +subarg@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/subarg/-/subarg-1.0.0.tgz#f62cf17581e996b48fc965699f54c06ae268b8d2" + dependencies: + minimist "^1.1.0" + +supports-color@5.4.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54" + dependencies: + has-flag "^3.0.0" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +syntax-error@^1.1.1: + version "1.4.0" + resolved "https://registry.yarnpkg.com/syntax-error/-/syntax-error-1.4.0.tgz#2d9d4ff5c064acb711594a3e3b95054ad51d907c" + dependencies: + acorn-node "^1.2.0" + +tar@^4: + version "4.4.6" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.6.tgz#63110f09c00b4e60ac8bcfe1bf3c8660235fbc9b" + dependencies: + chownr "^1.0.1" + fs-minipass "^1.2.5" + minipass "^2.3.3" + minizlib "^1.1.0" + mkdirp "^0.5.0" + safe-buffer "^5.1.2" + yallist "^3.0.2" + +through2@^2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" + dependencies: + readable-stream "^2.1.5" + xtend "~4.0.1" + +"through@>=2.2.7 <3": + version "2.3.8" + resolved "http://registry.npmjs.org/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + +thunkify@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/thunkify/-/thunkify-2.1.2.tgz#faa0e9d230c51acc95ca13a361ac05ca7e04553d" + +timers-browserify@^1.0.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-1.4.2.tgz#c9c58b575be8407375cb5e2462dacee74359f41d" + dependencies: + process "~0.11.0" + +timespan@2.3.x: + version "2.3.0" + resolved "https://registry.yarnpkg.com/timespan/-/timespan-2.3.0.tgz#4902ce040bd13d845c8f59b27e9d59bad6f39929" + +tmp@0.0.33, tmp@0.0.x: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + dependencies: + os-tmpdir "~1.0.2" + +to-array@0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" + +to-arraybuffer@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" + +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + dependencies: + kind-of "^3.0.2" + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + +tough-cookie@~2.3.0: + version "2.3.4" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655" + dependencies: + punycode "^1.4.1" + +tough-cookie@~2.4.3: + version "2.4.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" + dependencies: + psl "^1.1.24" + punycode "^1.4.1" + +tsscmp@~1.0.0: + version "1.0.6" + resolved "https://registry.yarnpkg.com/tsscmp/-/tsscmp-1.0.6.tgz#85b99583ac3589ec4bfef825b5000aa911d605eb" + +tty-browserify@~0.0.0: + version "0.0.1" + resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + +tunnel-agent@~0.4.1: + version "0.4.3" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + dependencies: + prelude-ls "~1.1.2" + +type-detect@^4.0.0, type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + +type-is@~1.6.16: + version "1.6.16" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" + dependencies: + media-typer "0.3.0" + mime-types "~2.1.18" + +typedarray@^0.0.6, typedarray@~0.0.5: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + +uglify-js@^3.3.13: + version "3.4.9" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3" + dependencies: + commander "~2.17.1" + source-map "~0.6.1" + +ultron@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" + +umd@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.3.tgz#aa9fe653c42b9097678489c01000acb69f0b26cf" + +undeclared-identifiers@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz#7d850a98887cff4bd0bf64999c014d08ed6d1acc" + dependencies: + acorn-node "^1.3.0" + get-assigned-identifiers "^1.2.0" + simple-concat "^1.0.0" + xtend "^4.0.1" + +underscore@~1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.7.0.tgz#6bbaf0877500d36be34ecaa584e0db9fef035209" + +union-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^0.4.3" + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +upath@^1.0.5: + version "1.1.0" + resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.0.tgz#35256597e46a581db4793d0ce47fa9aebfc9fabd" + +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + +url@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" + dependencies: + punycode "1.3.2" + querystring "0.2.0" + +use@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" + +useragent@2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.2.1.tgz#cf593ef4f2d175875e8bb658ea92e18a4fd06d8e" + dependencies: + lru-cache "2.2.x" + tmp "0.0.x" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +util@0.10.3: + version "0.10.3" + resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" + dependencies: + inherits "2.0.1" + +util@~0.10.1: + version "0.10.4" + resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901" + dependencies: + inherits "2.0.3" + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + +uuid@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + +uws@~9.14.0: + version "9.14.0" + resolved "https://registry.yarnpkg.com/uws/-/uws-9.14.0.tgz#fac8386befc33a7a3705cbd58dc47b430ca4dd95" + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +vm-browserify@~0.0.1: + version "0.0.4" + resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73" + dependencies: + indexof "0.0.1" + +void-elements@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" + +when@^3.7.7: + version "3.7.8" + resolved "https://registry.yarnpkg.com/when/-/when-3.7.8.tgz#c7130b6a7ea04693e842cdc9e7a1f2aa39a39f82" + +which@^1.2.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + dependencies: + isexe "^2.0.0" + +wide-align@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + dependencies: + string-width "^1.0.2 || 2" + +with-callback@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/with-callback/-/with-callback-1.0.2.tgz#a09629b9a920028d721404fb435bdcff5c91bc21" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +ws@~3.3.1: + version "3.3.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" + dependencies: + async-limiter "~1.0.0" + safe-buffer "~5.1.0" + ultron "~1.1.0" + +xmlhttprequest-ssl@~1.5.4: + version "1.5.5" + resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e" + +xregexp@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943" + +xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + +yallist@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + +yallist@^3.0.0, yallist@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" + +yeast@0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" From a117a2687ae2b24f81a8634951121adc22b1481f Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 25 Oct 2018 23:08:32 +0200 Subject: [PATCH 052/108] Revert "regex ripple improved" This reverts commit 4cc61759a96dce06ace1495d4ec464d95c104604. --- src/ripple_validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ripple_validator.js b/src/ripple_validator.js index e60bbbff..a3679fcf 100644 --- a/src/ripple_validator.js +++ b/src/ripple_validator.js @@ -1,7 +1,7 @@ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); -var ALLOWED_CHARS = '[1-9A-HJ-NP-Za-km-z]'; +var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; var codec = baseX(ALLOWED_CHARS); var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); From f11da7a7033fbf8f63f2bb534966aaff1ce99f8f Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 25 Oct 2018 23:31:46 +0200 Subject: [PATCH 053/108] added xmr from a fork --- README.md | 2 + dist/wallet-address-validator.js | 15641 ----------------------------- package.json | 1 + src/crypto/biginteger.js | 1450 +++ src/crypto/cnBase58.js | 226 + src/crypto/utils.js | 3 + src/currencies.js | 7 + src/monero_validator.js | 60 + test/wallet_address_validator.js | 20 + 9 files changed, 1769 insertions(+), 15641 deletions(-) create mode 100644 src/crypto/biginteger.js create mode 100644 src/crypto/cnBase58.js create mode 100644 src/monero_validator.js diff --git a/README.md b/README.md index ef22e425..77d8e619 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ npm install wallet-address-validator * Megacoin/MEC, `'megacoin'` or `'MEC'` +* Monero/XMR, `'monero'` or `'XMR'` + * Namecoin/NMC, `'namecoin'` or `'NMC'` * NEO/NEO, `'NEO'` or `'NEO'` * NeoGas/GAS, `'neogas'` or `'GAS'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 9178575b..e69de29b 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,15641 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0) { - digits.push(carry % BASE) - carry = (carry / BASE) | 0 - } - } - - var string = '' - - // deal with leading zeros - for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER - // convert digits to a string - for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] - - return string - } - - function decodeUnsafe (string) { - if (typeof string !== 'string') throw new TypeError('Expected String') - if (string.length === 0) return Buffer.allocUnsafe(0) - - var bytes = [0] - for (var i = 0; i < string.length; i++) { - var value = ALPHABET_MAP[string[i]] - if (value === undefined) return - - for (var j = 0, carry = value; j < bytes.length; ++j) { - carry += bytes[j] * BASE - bytes[j] = carry & 0xff - carry >>= 8 - } - - while (carry > 0) { - bytes.push(carry & 0xff) - carry >>= 8 - } - } - - // deal with leading zeros - for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { - bytes.push(0) - } - - return Buffer.from(bytes.reverse()) - } - - function decode (string) { - var buffer = decodeUnsafe(string) - if (buffer) return buffer - - throw new Error('Non-base' + BASE + ' character') - } - - return { - encode: encode, - decodeUnsafe: decodeUnsafe, - decode: decode - } -} - -},{"safe-buffer":71}],2:[function(require,module,exports){ -'use strict' - -exports.byteLength = byteLength -exports.toByteArray = toByteArray -exports.fromByteArray = fromByteArray - -var lookup = [] -var revLookup = [] -var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - -var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i -} - -// Support decoding URL-safe base64 strings, as Node.js does. -// See: https://en.wikipedia.org/wiki/Base64#URL_applications -revLookup['-'.charCodeAt(0)] = 62 -revLookup['_'.charCodeAt(0)] = 63 - -function getLens (b64) { - var len = b64.length - - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // Trim off extra bytes after placeholder bytes are found - // See: https://github.com/beatgammit/base64-js/issues/42 - var validLen = b64.indexOf('=') - if (validLen === -1) validLen = len - - var placeHoldersLen = validLen === len - ? 0 - : 4 - (validLen % 4) - - return [validLen, placeHoldersLen] -} - -// base64 is 4/3 + up to two characters of the original data -function byteLength (b64) { - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function _byteLength (b64, validLen, placeHoldersLen) { - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function toByteArray (b64) { - var tmp - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - - var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) - - var curByte = 0 - - // if there are placeholders, only get up to the last complete 4 chars - var len = placeHoldersLen > 0 - ? validLen - 4 - : validLen - - for (var i = 0; i < len; i += 4) { - tmp = - (revLookup[b64.charCodeAt(i)] << 18) | - (revLookup[b64.charCodeAt(i + 1)] << 12) | - (revLookup[b64.charCodeAt(i + 2)] << 6) | - revLookup[b64.charCodeAt(i + 3)] - arr[curByte++] = (tmp >> 16) & 0xFF - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 2) { - tmp = - (revLookup[b64.charCodeAt(i)] << 2) | - (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 1) { - tmp = - (revLookup[b64.charCodeAt(i)] << 10) | - (revLookup[b64.charCodeAt(i + 1)] << 4) | - (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + - lookup[num >> 12 & 0x3F] + - lookup[num >> 6 & 0x3F] + - lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = - ((uint8[i] << 16) & 0xFF0000) + - ((uint8[i + 1] << 8) & 0xFF00) + - (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk( - uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) - )) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - parts.push( - lookup[tmp >> 2] + - lookup[(tmp << 4) & 0x3F] + - '==' - ) - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + uint8[len - 1] - parts.push( - lookup[tmp >> 10] + - lookup[(tmp >> 4) & 0x3F] + - lookup[(tmp << 2) & 0x3F] + - '=' - ) - } - - return parts.join('') -} - -},{}],3:[function(require,module,exports){ -;(function (globalObject) { - 'use strict'; - -/* - * bignumber.js v7.2.1 - * A JavaScript library for arbitrary-precision arithmetic. - * https://github.com/MikeMcl/bignumber.js - * Copyright (c) 2018 Michael Mclaughlin - * MIT Licensed. - * - * BigNumber.prototype methods | BigNumber methods - * | - * absoluteValue abs | clone - * comparedTo | config set - * decimalPlaces dp | DECIMAL_PLACES - * dividedBy div | ROUNDING_MODE - * dividedToIntegerBy idiv | EXPONENTIAL_AT - * exponentiatedBy pow | RANGE - * integerValue | CRYPTO - * isEqualTo eq | MODULO_MODE - * isFinite | POW_PRECISION - * isGreaterThan gt | FORMAT - * isGreaterThanOrEqualTo gte | ALPHABET - * isInteger | isBigNumber - * isLessThan lt | maximum max - * isLessThanOrEqualTo lte | minimum min - * isNaN | random - * isNegative | - * isPositive | - * isZero | - * minus | - * modulo mod | - * multipliedBy times | - * negated | - * plus | - * precision sd | - * shiftedBy | - * squareRoot sqrt | - * toExponential | - * toFixed | - * toFormat | - * toFraction | - * toJSON | - * toNumber | - * toPrecision | - * toString | - * valueOf | - * - */ - - - var BigNumber, - isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, - - mathceil = Math.ceil, - mathfloor = Math.floor, - - bignumberError = '[BigNumber Error] ', - tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ', - - BASE = 1e14, - LOG_BASE = 14, - MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1 - // MAX_INT32 = 0x7fffffff, // 2^31 - 1 - POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], - SQRT_BASE = 1e7, - - // EDITABLE - // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and - // the arguments to toExponential, toFixed, toFormat, and toPrecision. - MAX = 1E9; // 0 to MAX_INT32 - - - /* - * Create and return a BigNumber constructor. - */ - function clone(configObject) { - var div, convertBase, parseNumeric, - P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null }, - ONE = new BigNumber(1), - - - //----------------------------- EDITABLE CONFIG DEFAULTS ------------------------------- - - - // The default values below must be integers within the inclusive ranges stated. - // The values can also be changed at run-time using BigNumber.set. - - // The maximum number of decimal places for operations involving division. - DECIMAL_PLACES = 20, // 0 to MAX - - // The rounding mode used when rounding to the above decimal places, and when using - // toExponential, toFixed, toFormat and toPrecision, and round (default value). - // UP 0 Away from zero. - // DOWN 1 Towards zero. - // CEIL 2 Towards +Infinity. - // FLOOR 3 Towards -Infinity. - // HALF_UP 4 Towards nearest neighbour. If equidistant, up. - // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. - // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. - // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. - // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. - ROUNDING_MODE = 4, // 0 to 8 - - // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS] - - // The exponent value at and beneath which toString returns exponential notation. - // Number type: -7 - TO_EXP_NEG = -7, // 0 to -MAX - - // The exponent value at and above which toString returns exponential notation. - // Number type: 21 - TO_EXP_POS = 21, // 0 to MAX - - // RANGE : [MIN_EXP, MAX_EXP] - - // The minimum exponent value, beneath which underflow to zero occurs. - // Number type: -324 (5e-324) - MIN_EXP = -1e7, // -1 to -MAX - - // The maximum exponent value, above which overflow to Infinity occurs. - // Number type: 308 (1.7976931348623157e+308) - // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow. - MAX_EXP = 1e7, // 1 to MAX - - // Whether to use cryptographically-secure random number generation, if available. - CRYPTO = false, // true or false - - // The modulo mode used when calculating the modulus: a mod n. - // The quotient (q = a / n) is calculated according to the corresponding rounding mode. - // The remainder (r) is calculated as: r = a - n * q. - // - // UP 0 The remainder is positive if the dividend is negative, else is negative. - // DOWN 1 The remainder has the same sign as the dividend. - // This modulo mode is commonly known as 'truncated division' and is - // equivalent to (a % n) in JavaScript. - // FLOOR 3 The remainder has the same sign as the divisor (Python %). - // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function. - // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). - // The remainder is always positive. - // - // The truncated division, floored division, Euclidian division and IEEE 754 remainder - // modes are commonly used for the modulus operation. - // Although the other rounding modes can also be used, they may not give useful results. - MODULO_MODE = 1, // 0 to 9 - - // 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 - - // The format specification used by the BigNumber.prototype.toFormat method. - FORMAT = { - decimalSeparator: '.', - groupSeparator: ',', - groupSize: 3, - secondaryGroupSize: 0, - fractionGroupSeparator: '\xA0', // non-breaking space - fractionGroupSize: 0 - }, - - // The alphabet used for base conversion. - // It must be at least 2 characters long, with no '.' or repeated character. - // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' - ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'; - - - //------------------------------------------------------------------------------------------ - - - // CONSTRUCTOR - - - /* - * The BigNumber constructor and exported function. - * Create and return a new instance of a BigNumber object. - * - * n {number|string|BigNumber} A numeric value. - * [b] {number} The base of n. Integer, 2 to ALPHABET.length inclusive. - */ - function BigNumber(n, b) { - var alphabet, c, caseChanged, e, i, isNum, len, str, - x = this; - - // Enable constructor usage without new. - if (!(x instanceof BigNumber)) { - - // Don't throw on constructor call without new (#81). - // '[BigNumber Error] Constructor call without new: {n}' - //throw Error(bignumberError + ' Constructor call without new: ' + n); - return new BigNumber(n, b); - } - - if (b == null) { - - // Duplicate. - if (n instanceof BigNumber) { - x.s = n.s; - x.e = n.e; - x.c = (n = n.c) ? n.slice() : n; - return; - } - - isNum = typeof n == 'number'; - - if (isNum && n * 0 == 0) { - - // Use `1 / n` to handle minus zero also. - x.s = 1 / n < 0 ? (n = -n, -1) : 1; - - // Faster path for integers. - if (n === ~~n) { - for (e = 0, i = n; i >= 10; i /= 10, e++); - x.e = e; - x.c = [n]; - return; - } - - str = n + ''; - } else { - if (!isNumeric.test(str = n + '')) return parseNumeric(x, str, isNum); - x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1; - } - - // Decimal point? - if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); - - // Exponential form? - if ((i = str.search(/e/i)) > 0) { - - // Determine exponent. - if (e < 0) e = i; - e += +str.slice(i + 1); - str = str.substring(0, i); - } else if (e < 0) { - - // Integer. - e = str.length; - } - - } else { - - // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' - intCheck(b, 2, ALPHABET.length, 'Base'); - str = n + ''; - - // Allow exponential notation to be used with base 10 argument, while - // also rounding to DECIMAL_PLACES as with other bases. - if (b == 10) { - x = new BigNumber(n instanceof BigNumber ? n : str); - return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE); - } - - isNum = typeof n == 'number'; - - if (isNum) { - - // Avoid potential interpretation of Infinity and NaN as base 44+ values. - if (n * 0 != 0) return parseNumeric(x, str, isNum, b); - - x.s = 1 / n < 0 ? (str = str.slice(1), -1) : 1; - - // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' - if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) { - throw Error - (tooManyDigits + n); - } - - // Prevent later check for length on converted number. - isNum = false; - } else { - x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1; - } - - alphabet = ALPHABET.slice(0, b); - e = i = 0; - - // Check that str is a valid base b number. - // Don't use RegExp so alphabet can contain special characters. - for (len = str.length; i < len; i++) { - if (alphabet.indexOf(c = str.charAt(i)) < 0) { - if (c == '.') { - - // If '.' is not the first character and it has not be found before. - if (i > e) { - e = len; - continue; - } - } else if (!caseChanged) { - - // Allow e.g. hexadecimal 'FF' as well as 'ff'. - if (str == str.toUpperCase() && (str = str.toLowerCase()) || - str == str.toLowerCase() && (str = str.toUpperCase())) { - caseChanged = true; - i = -1; - e = 0; - continue; - } - } - - return parseNumeric(x, n + '', isNum, b); - } - } - - str = convertBase(str, b, 10, x.s); - - // Decimal point? - if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); - else e = str.length; - } - - // Determine leading zeros. - for (i = 0; str.charCodeAt(i) === 48; i++); - - // Determine trailing zeros. - for (len = str.length; str.charCodeAt(--len) === 48;); - - str = str.slice(i, ++len); - - if (str) { - len -= i; - - // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' - if (isNum && BigNumber.DEBUG && - len > 15 && (n > MAX_SAFE_INTEGER || n !== mathfloor(n))) { - throw Error - (tooManyDigits + (x.s * n)); - } - - e = e - i - 1; - - // Overflow? - if (e > MAX_EXP) { - - // Infinity. - x.c = x.e = null; - - // Underflow? - } else if (e < MIN_EXP) { - - // Zero. - x.c = [x.e = 0]; - } else { - x.e = e; - x.c = []; - - // Transform base - - // e is the base 10 exponent. - // i is where to slice str to get the first element of the coefficient array. - i = (e + 1) % LOG_BASE; - if (e < 0) i += LOG_BASE; - - if (i < len) { - if (i) x.c.push(+str.slice(0, i)); - - for (len -= LOG_BASE; i < len;) { - x.c.push(+str.slice(i, i += LOG_BASE)); - } - - str = str.slice(i); - i = LOG_BASE - str.length; - } else { - i -= len; - } - - for (; i--; str += '0'); - x.c.push(+str); - } - } else { - - // Zero. - x.c = [x.e = 0]; - } - } - - - // CONSTRUCTOR PROPERTIES - - - BigNumber.clone = clone; - - BigNumber.ROUND_UP = 0; - BigNumber.ROUND_DOWN = 1; - BigNumber.ROUND_CEIL = 2; - BigNumber.ROUND_FLOOR = 3; - BigNumber.ROUND_HALF_UP = 4; - BigNumber.ROUND_HALF_DOWN = 5; - BigNumber.ROUND_HALF_EVEN = 6; - BigNumber.ROUND_HALF_CEIL = 7; - BigNumber.ROUND_HALF_FLOOR = 8; - BigNumber.EUCLID = 9; - - - /* - * Configure infrequently-changing library-wide settings. - * - * Accept an object with the following optional properties (if the value of a property is - * a number, it must be an integer within the inclusive range stated): - * - * DECIMAL_PLACES {number} 0 to MAX - * ROUNDING_MODE {number} 0 to 8 - * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX] - * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX] - * CRYPTO {boolean} true or false - * 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 '.'. - * FORMAT {object} An object with some of the following properties: - * decimalSeparator {string} - * groupSeparator {string} - * groupSize {number} - * secondaryGroupSize {number} - * fractionGroupSeparator {string} - * fractionGroupSize {number} - * - * (The values assigned to the above FORMAT object properties are not checked for validity.) - * - * E.g. - * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 }) - * - * Ignore properties/parameters set to null or undefined, except for ALPHABET. - * - * Return an object with the properties current values. - */ - BigNumber.config = BigNumber.set = function (obj) { - var p, v; - - if (obj != null) { - - if (typeof obj == 'object') { - - // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive. - // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) { - v = obj[p]; - intCheck(v, 0, MAX, p); - DECIMAL_PLACES = v; - } - - // ROUNDING_MODE {number} Integer, 0 to 8 inclusive. - // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) { - v = obj[p]; - intCheck(v, 0, 8, p); - ROUNDING_MODE = v; - } - - // EXPONENTIAL_AT {number|number[]} - // Integer, -MAX to MAX inclusive or - // [integer -MAX to 0 inclusive, 0 to MAX inclusive]. - // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) { - v = obj[p]; - if (isArray(v)) { - intCheck(v[0], -MAX, 0, p); - intCheck(v[1], 0, MAX, p); - TO_EXP_NEG = v[0]; - TO_EXP_POS = v[1]; - } else { - intCheck(v, -MAX, MAX, p); - TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v); - } - } - - // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or - // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive]. - // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}' - if (obj.hasOwnProperty(p = 'RANGE')) { - v = obj[p]; - if (isArray(v)) { - intCheck(v[0], -MAX, -1, p); - intCheck(v[1], 1, MAX, p); - MIN_EXP = v[0]; - MAX_EXP = v[1]; - } else { - intCheck(v, -MAX, MAX, p); - if (v) { - MIN_EXP = -(MAX_EXP = v < 0 ? -v : v); - } else { - throw Error - (bignumberError + p + ' cannot be zero: ' + v); - } - } - } - - // CRYPTO {boolean} true or false. - // '[BigNumber Error] CRYPTO not true or false: {v}' - // '[BigNumber Error] crypto unavailable' - if (obj.hasOwnProperty(p = 'CRYPTO')) { - v = obj[p]; - if (v === !!v) { - if (v) { - if (typeof crypto != 'undefined' && crypto && - (crypto.getRandomValues || crypto.randomBytes)) { - CRYPTO = v; - } else { - CRYPTO = !v; - throw Error - (bignumberError + 'crypto unavailable'); - } - } else { - CRYPTO = v; - } - } else { - throw Error - (bignumberError + p + ' not true or false: ' + v); - } - } - - // MODULO_MODE {number} Integer, 0 to 9 inclusive. - // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'MODULO_MODE')) { - v = obj[p]; - intCheck(v, 0, 9, p); - MODULO_MODE = v; - } - - // POW_PRECISION {number} Integer, 0 to MAX inclusive. - // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'POW_PRECISION')) { - v = obj[p]; - intCheck(v, 0, MAX, p); - POW_PRECISION = v; - } - - // FORMAT {object} - // '[BigNumber Error] FORMAT not an object: {v}' - if (obj.hasOwnProperty(p = 'FORMAT')) { - v = obj[p]; - if (typeof v == 'object') FORMAT = v; - else throw Error - (bignumberError + p + ' not an object: ' + v); - } - - // ALPHABET {string} - // '[BigNumber Error] ALPHABET invalid: {v}' - if (obj.hasOwnProperty(p = 'ALPHABET')) { - v = obj[p]; - - // Disallow if only one character, or contains '.' or a repeated character. - if (typeof v == 'string' && !/^.$|\.|(.).*\1/.test(v)) { - ALPHABET = v; - } else { - throw Error - (bignumberError + p + ' invalid: ' + v); - } - } - - } else { - - // '[BigNumber Error] Object expected: {v}' - throw Error - (bignumberError + 'Object expected: ' + obj); - } - } - - return { - DECIMAL_PLACES: DECIMAL_PLACES, - ROUNDING_MODE: ROUNDING_MODE, - EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS], - RANGE: [MIN_EXP, MAX_EXP], - CRYPTO: CRYPTO, - MODULO_MODE: MODULO_MODE, - POW_PRECISION: POW_PRECISION, - FORMAT: FORMAT, - ALPHABET: ALPHABET - }; - }; - - - /* - * Return true if v is a BigNumber instance, otherwise return false. - * - * v {any} - */ - BigNumber.isBigNumber = function (v) { - return v instanceof BigNumber || v && v._isBigNumber === true || false; - }; - - - /* - * Return a new BigNumber whose value is the maximum of the arguments. - * - * arguments {number|string|BigNumber} - */ - BigNumber.maximum = BigNumber.max = function () { - return maxOrMin(arguments, P.lt); - }; - - - /* - * Return a new BigNumber whose value is the minimum of the arguments. - * - * arguments {number|string|BigNumber} - */ - BigNumber.minimum = BigNumber.min = function () { - return maxOrMin(arguments, P.gt); - }; - - - /* - * Return a new BigNumber with a random value equal to or greater than 0 and less than 1, - * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing - * zeros are produced). - * - * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}' - * '[BigNumber Error] crypto unavailable' - */ - BigNumber.random = (function () { - var pow2_53 = 0x20000000000000; - - // Return a 53 bit integer n, where 0 <= n < 9007199254740992. - // Check if Math.random() produces more than 32 bits of randomness. - // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits. - // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1. - var random53bitInt = (Math.random() * pow2_53) & 0x1fffff - ? function () { return mathfloor(Math.random() * pow2_53); } - : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) + - (Math.random() * 0x800000 | 0); }; - - return function (dp) { - var a, b, e, k, v, - i = 0, - c = [], - rand = new BigNumber(ONE); - - if (dp == null) dp = DECIMAL_PLACES; - else intCheck(dp, 0, MAX); - - k = mathceil(dp / LOG_BASE); - - if (CRYPTO) { - - // Browsers supporting crypto.getRandomValues. - if (crypto.getRandomValues) { - - a = crypto.getRandomValues(new Uint32Array(k *= 2)); - - for (; i < k;) { - - // 53 bits: - // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2) - // 11111 11111111 11111111 11111111 11100000 00000000 00000000 - // ((Math.pow(2, 32) - 1) >>> 11).toString(2) - // 11111 11111111 11111111 - // 0x20000 is 2^21. - v = a[i] * 0x20000 + (a[i + 1] >>> 11); - - // Rejection sampling: - // 0 <= v < 9007199254740992 - // Probability that v >= 9e15, is - // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251 - if (v >= 9e15) { - b = crypto.getRandomValues(new Uint32Array(2)); - a[i] = b[0]; - a[i + 1] = b[1]; - } else { - - // 0 <= v <= 8999999999999999 - // 0 <= (v % 1e14) <= 99999999999999 - c.push(v % 1e14); - i += 2; - } - } - i = k / 2; - - // Node.js supporting crypto.randomBytes. - } else if (crypto.randomBytes) { - - // buffer - a = crypto.randomBytes(k *= 7); - - for (; i < k;) { - - // 0x1000000000000 is 2^48, 0x10000000000 is 2^40 - // 0x100000000 is 2^32, 0x1000000 is 2^24 - // 11111 11111111 11111111 11111111 11111111 11111111 11111111 - // 0 <= v < 9007199254740992 - v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) + - (a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) + - (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6]; - - if (v >= 9e15) { - crypto.randomBytes(7).copy(a, i); - } else { - - // 0 <= (v % 1e14) <= 99999999999999 - c.push(v % 1e14); - i += 7; - } - } - i = k / 7; - } else { - CRYPTO = false; - throw Error - (bignumberError + 'crypto unavailable'); - } - } - - // Use Math.random. - if (!CRYPTO) { - - for (; i < k;) { - v = random53bitInt(); - if (v < 9e15) c[i++] = v % 1e14; - } - } - - k = c[--i]; - dp %= LOG_BASE; - - // Convert trailing digits to zeros according to dp. - if (k && dp) { - v = POWS_TEN[LOG_BASE - dp]; - c[i] = mathfloor(k / v) * v; - } - - // Remove trailing elements which are zero. - for (; c[i] === 0; c.pop(), i--); - - // Zero? - if (i < 0) { - c = [e = 0]; - } else { - - // Remove leading elements which are zero and adjust exponent accordingly. - for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE); - - // Count the digits of the first element of c to determine leading zeros, and... - for (i = 1, v = c[0]; v >= 10; v /= 10, i++); - - // adjust the exponent accordingly. - if (i < LOG_BASE) e -= LOG_BASE - i; - } - - rand.e = e; - rand.c = c; - return rand; - }; - })(); - - - // PRIVATE FUNCTIONS - - - // Called by BigNumber and BigNumber.prototype.toString. - convertBase = (function () { - var decimal = '0123456789'; - - /* - * Convert string of baseIn to an array of numbers of baseOut. - * Eg. toBaseOut('255', 10, 16) returns [15, 15]. - * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5]. - */ - function toBaseOut(str, baseIn, baseOut, alphabet) { - var j, - arr = [0], - arrL, - i = 0, - len = str.length; - - for (; i < len;) { - for (arrL = arr.length; arrL--; arr[arrL] *= baseIn); - - arr[0] += alphabet.indexOf(str.charAt(i++)); - - for (j = 0; j < arr.length; j++) { - - if (arr[j] > baseOut - 1) { - if (arr[j + 1] == null) arr[j + 1] = 0; - arr[j + 1] += arr[j] / baseOut | 0; - arr[j] %= baseOut; - } - } - } - - return arr.reverse(); - } - - // Convert a numeric string of baseIn to a numeric string of baseOut. - // If the caller is toString, we are converting from base 10 to baseOut. - // If the caller is BigNumber, we are converting from baseIn to base 10. - return function (str, baseIn, baseOut, sign, callerIsToString) { - var alphabet, d, e, k, r, x, xc, y, - i = str.indexOf('.'), - dp = DECIMAL_PLACES, - rm = ROUNDING_MODE; - - // Non-integer. - if (i >= 0) { - k = POW_PRECISION; - - // Unlimited precision. - POW_PRECISION = 0; - str = str.replace('.', ''); - y = new BigNumber(baseIn); - x = y.pow(str.length - i); - POW_PRECISION = k; - - // Convert str as if an integer, then restore the fraction part by dividing the - // result by its base raised to a power. - - y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'), - 10, baseOut, decimal); - y.e = y.c.length; - } - - // Convert the number as integer. - - xc = toBaseOut(str, baseIn, baseOut, callerIsToString - ? (alphabet = ALPHABET, decimal) - : (alphabet = decimal, ALPHABET)); - - // xc now represents str as an integer and converted to baseOut. e is the exponent. - e = k = xc.length; - - // Remove trailing zeros. - for (; xc[--k] == 0; xc.pop()); - - // Zero? - if (!xc[0]) return alphabet.charAt(0); - - // Does str represent an integer? If so, no need for the division. - if (i < 0) { - --e; - } else { - x.c = xc; - x.e = e; - - // The sign is needed for correct rounding. - x.s = sign; - x = div(x, y, dp, rm, baseOut); - xc = x.c; - r = x.r; - e = x.e; - } - - // xc now represents str converted to baseOut. - - // THe index of the rounding digit. - d = e + dp + 1; - - // The rounding digit: the digit to the right of the digit that may be rounded up. - i = xc[d]; - - // Look at the rounding digits and mode to determine whether to round up. - - k = baseOut / 2; - r = r || d < 0 || xc[d + 1] != null; - - r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) - : i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 || - rm == (x.s < 0 ? 8 : 7)); - - // If the index of the rounding digit is not greater than zero, or xc represents - // zero, then the result of the base conversion is zero or, if rounding up, a value - // such as 0.00001. - if (d < 1 || !xc[0]) { - - // 1^-dp or 0 - str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) - : alphabet.charAt(0); - } else { - - // Truncate xc to the required number of decimal places. - xc.length = d; - - // Round up? - if (r) { - - // Rounding up may mean the previous digit has to be rounded up and so on. - for (--baseOut; ++xc[--d] > baseOut;) { - xc[d] = 0; - - if (!d) { - ++e; - xc = [1].concat(xc); - } - } - } - - // Determine trailing zeros. - for (k = xc.length; !xc[--k];); - - // E.g. [4, 11, 15] becomes 4bf. - for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++])); - - // Add leading zeros, decimal point and trailing zeros as required. - str = toFixedPoint(str, e, alphabet.charAt(0)); - } - - // The caller will add the sign. - return str; - }; - })(); - - - // Perform division in the specified base. Called by div and convertBase. - div = (function () { - - // Assume non-zero x and k. - function multiply(x, k, base) { - var m, temp, xlo, xhi, - carry = 0, - i = x.length, - klo = k % SQRT_BASE, - khi = k / SQRT_BASE | 0; - - for (x = x.slice(); i--;) { - xlo = x[i] % SQRT_BASE; - xhi = x[i] / SQRT_BASE | 0; - m = khi * xlo + xhi * klo; - temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry; - carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi; - x[i] = temp % base; - } - - if (carry) x = [carry].concat(x); - - return x; - } - - function compare(a, b, aL, bL) { - var i, cmp; - - if (aL != bL) { - cmp = aL > bL ? 1 : -1; - } else { - - for (i = cmp = 0; i < aL; i++) { - - if (a[i] != b[i]) { - cmp = a[i] > b[i] ? 1 : -1; - break; - } - } - } - - return cmp; - } - - function subtract(a, b, aL, base) { - var i = 0; - - // Subtract b from a. - for (; aL--;) { - a[aL] -= i; - i = a[aL] < b[aL] ? 1 : 0; - a[aL] = i * base + a[aL] - b[aL]; - } - - // Remove leading zeros. - for (; !a[0] && a.length > 1; a.splice(0, 1)); - } - - // x: dividend, y: divisor. - return function (x, y, dp, rm, base) { - var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, - yL, yz, - s = x.s == y.s ? 1 : -1, - xc = x.c, - yc = y.c; - - // Either NaN, Infinity or 0? - if (!xc || !xc[0] || !yc || !yc[0]) { - - return new BigNumber( - - // Return NaN if either NaN, or both Infinity or 0. - !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : - - // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0. - xc && xc[0] == 0 || !yc ? s * 0 : s / 0 - ); - } - - q = new BigNumber(s); - qc = q.c = []; - e = x.e - y.e; - s = dp + e + 1; - - if (!base) { - base = BASE; - e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE); - s = s / LOG_BASE | 0; - } - - // Result exponent may be one less then the current value of e. - // The coefficients of the BigNumbers from convertBase may have trailing zeros. - for (i = 0; yc[i] == (xc[i] || 0); i++); - - if (yc[i] > (xc[i] || 0)) e--; - - if (s < 0) { - qc.push(1); - more = true; - } else { - xL = xc.length; - yL = yc.length; - i = 0; - s += 2; - - // Normalise xc and yc so highest order digit of yc is >= base / 2. - - n = mathfloor(base / (yc[0] + 1)); - - // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1. - // if (n > 1 || n++ == 1 && yc[0] < base / 2) { - if (n > 1) { - yc = multiply(yc, n, base); - xc = multiply(xc, n, base); - yL = yc.length; - xL = xc.length; - } - - xi = yL; - rem = xc.slice(0, yL); - remL = rem.length; - - // Add zeros to make remainder as long as divisor. - for (; remL < yL; rem[remL++] = 0); - yz = yc.slice(); - yz = [0].concat(yz); - yc0 = yc[0]; - if (yc[1] >= base / 2) yc0++; - // Not necessary, but to prevent trial digit n > base, when using base 3. - // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15; - - do { - n = 0; - - // Compare divisor and remainder. - cmp = compare(yc, rem, yL, remL); - - // If divisor < remainder. - if (cmp < 0) { - - // Calculate trial digit, n. - - rem0 = rem[0]; - if (yL != remL) rem0 = rem0 * base + (rem[1] || 0); - - // n is how many times the divisor goes into the current remainder. - n = mathfloor(rem0 / yc0); - - // Algorithm: - // product = divisor multiplied by trial digit (n). - // Compare product and remainder. - // If product is greater than remainder: - // Subtract divisor from product, decrement trial digit. - // Subtract product from remainder. - // If product was less than remainder at the last compare: - // Compare new remainder and divisor. - // If remainder is greater than divisor: - // Subtract divisor from remainder, increment trial digit. - - if (n > 1) { - - // n may be > base only when base is 3. - if (n >= base) n = base - 1; - - // product = divisor * trial digit. - prod = multiply(yc, n, base); - prodL = prod.length; - remL = rem.length; - - // Compare product and remainder. - // If product > remainder then trial digit n too high. - // n is 1 too high about 5% of the time, and is not known to have - // ever been more than 1 too high. - while (compare(prod, rem, prodL, remL) == 1) { - n--; - - // Subtract divisor from product. - subtract(prod, yL < prodL ? yz : yc, prodL, base); - prodL = prod.length; - cmp = 1; - } - } else { - - // n is 0 or 1, cmp is -1. - // If n is 0, there is no need to compare yc and rem again below, - // so change cmp to 1 to avoid it. - // If n is 1, leave cmp as -1, so yc and rem are compared again. - if (n == 0) { - - // divisor < remainder, so n must be at least 1. - cmp = n = 1; - } - - // product = divisor - prod = yc.slice(); - prodL = prod.length; - } - - if (prodL < remL) prod = [0].concat(prod); - - // Subtract product from remainder. - subtract(rem, prod, remL, base); - remL = rem.length; - - // If product was < remainder. - if (cmp == -1) { - - // Compare divisor and new remainder. - // If divisor < new remainder, subtract divisor from remainder. - // Trial digit n too low. - // n is 1 too low about 5% of the time, and very rarely 2 too low. - while (compare(yc, rem, yL, remL) < 1) { - n++; - - // Subtract divisor from remainder. - subtract(rem, yL < remL ? yz : yc, remL, base); - remL = rem.length; - } - } - } else if (cmp === 0) { - n++; - rem = [0]; - } // else cmp === 1 and n will be 0 - - // Add the next digit, n, to the result array. - qc[i++] = n; - - // Update the remainder. - if (rem[0]) { - rem[remL++] = xc[xi] || 0; - } else { - rem = [xc[xi]]; - remL = 1; - } - } while ((xi++ < xL || rem[0] != null) && s--); - - more = rem[0] != null; - - // Leading zero? - if (!qc[0]) qc.splice(0, 1); - } - - if (base == BASE) { - - // To calculate q.e, first get the number of digits of qc[0]. - for (i = 1, s = qc[0]; s >= 10; s /= 10, i++); - - round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more); - - // Caller is convertBase. - } else { - q.e = e; - q.r = +more; - } - - return q; - }; - })(); - - - /* - * Return a string representing the value of BigNumber n in fixed-point or exponential - * notation rounded to the specified decimal places or significant digits. - * - * n: a BigNumber. - * i: the index of the last digit required (i.e. the digit that may be rounded up). - * rm: the rounding mode. - * id: 1 (toExponential) or 2 (toPrecision). - */ - function format(n, i, rm, id) { - var c0, e, ne, len, str; - - if (rm == null) rm = ROUNDING_MODE; - else intCheck(rm, 0, 8); - - if (!n.c) return n.toString(); - - c0 = n.c[0]; - ne = n.e; - - if (i == null) { - str = coeffToString(n.c); - str = id == 1 || id == 2 && ne <= TO_EXP_NEG - ? toExponential(str, ne) - : toFixedPoint(str, ne, '0'); - } else { - n = round(new BigNumber(n), i, rm); - - // n.e may have changed if the value was rounded up. - e = n.e; - - str = coeffToString(n.c); - len = str.length; - - // toPrecision returns exponential notation if the number of significant digits - // specified is less than the number of digits necessary to represent the integer - // part of the value in fixed-point notation. - - // Exponential notation. - if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) { - - // Append zeros? - for (; len < i; str += '0', len++); - str = toExponential(str, e); - - // Fixed-point notation. - } else { - i -= ne; - str = toFixedPoint(str, e, '0'); - - // Append zeros? - if (e + 1 > len) { - if (--i > 0) for (str += '.'; i--; str += '0'); - } else { - i += e - len; - if (i > 0) { - if (e + 1 == len) str += '.'; - for (; i--; str += '0'); - } - } - } - } - - return n.s < 0 && c0 ? '-' + str : str; - } - - - // Handle BigNumber.max and BigNumber.min. - function maxOrMin(args, method) { - var m, n, - i = 0; - - if (isArray(args[0])) args = args[0]; - m = new BigNumber(args[0]); - - for (; ++i < args.length;) { - n = new BigNumber(args[i]); - - // If any number is NaN, return NaN. - if (!n.s) { - m = n; - break; - } else if (method.call(m, n)) { - m = n; - } - } - - return m; - } - - - /* - * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP. - * Called by minus, plus and times. - */ - function normalise(n, c, e) { - var i = 1, - j = c.length; - - // Remove trailing zeros. - for (; !c[--j]; c.pop()); - - // Calculate the base 10 exponent. First get the number of digits of c[0]. - for (j = c[0]; j >= 10; j /= 10, i++); - - // Overflow? - if ((e = i + e * LOG_BASE - 1) > MAX_EXP) { - - // Infinity. - n.c = n.e = null; - - // Underflow? - } else if (e < MIN_EXP) { - - // Zero. - n.c = [n.e = 0]; - } else { - n.e = e; - n.c = c; - } - - return n; - } - - - // Handle values that fail the validity test in BigNumber. - parseNumeric = (function () { - var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, - dotAfter = /^([^.]+)\.$/, - dotBefore = /^\.([^.]+)$/, - isInfinityOrNaN = /^-?(Infinity|NaN)$/, - whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g; - - return function (x, str, isNum, b) { - var base, - s = isNum ? str : str.replace(whitespaceOrPlus, ''); - - // No exception on ±Infinity or NaN. - if (isInfinityOrNaN.test(s)) { - x.s = isNaN(s) ? null : s < 0 ? -1 : 1; - x.c = x.e = null; - } else { - if (!isNum) { - - // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i - s = s.replace(basePrefix, function (m, p1, p2) { - base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8; - return !b || b == base ? p1 : m; - }); - - if (b) { - base = b; - - // E.g. '1.' to '1', '.1' to '0.1' - s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1'); - } - - if (str != s) return new BigNumber(s, base); - } - - // '[BigNumber Error] Not a number: {n}' - // '[BigNumber Error] Not a base {b} number: {n}' - if (BigNumber.DEBUG) { - throw Error - (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str); - } - - // NaN - x.c = x.e = x.s = null; - } - } - })(); - - - /* - * Round x to sd significant digits using rounding mode rm. Check for over/under-flow. - * If r is truthy, it is known that there are more digits after the rounding digit. - */ - function round(x, sd, rm, r) { - var d, i, j, k, n, ni, rd, - xc = x.c, - pows10 = POWS_TEN; - - // if x is not Infinity or NaN... - if (xc) { - - // rd is the rounding digit, i.e. the digit after the digit that may be rounded up. - // n is a base 1e14 number, the value of the element of array x.c containing rd. - // ni is the index of n within x.c. - // d is the number of digits of n. - // i is the index of rd within n including leading zeros. - // j is the actual index of rd within n (if < 0, rd is a leading zero). - out: { - - // Get the number of digits of the first element of xc. - for (d = 1, k = xc[0]; k >= 10; k /= 10, d++); - i = sd - d; - - // If the rounding digit is in the first element of xc... - if (i < 0) { - i += LOG_BASE; - j = sd; - n = xc[ni = 0]; - - // Get the rounding digit at index j of n. - rd = n / pows10[d - j - 1] % 10 | 0; - } else { - ni = mathceil((i + 1) / LOG_BASE); - - if (ni >= xc.length) { - - if (r) { - - // Needed by sqrt. - for (; xc.length <= ni; xc.push(0)); - n = rd = 0; - d = 1; - i %= LOG_BASE; - j = i - LOG_BASE + 1; - } else { - break out; - } - } else { - n = k = xc[ni]; - - // Get the number of digits of n. - for (d = 1; k >= 10; k /= 10, d++); - - // Get the index of rd within n. - i %= LOG_BASE; - - // Get the index of rd within n, adjusted for leading zeros. - // The number of leading zeros of n is given by LOG_BASE - d. - j = i - LOG_BASE + d; - - // Get the rounding digit at index j of n. - rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0; - } - } - - r = r || sd < 0 || - - // Are there any non-zero digits after the rounding digit? - // The expression n % pows10[d - j - 1] returns all digits of n to the right - // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714. - xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]); - - r = rm < 4 - ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) - : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && - - // Check whether the digit to the left of the rounding digit is odd. - ((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 || - rm == (x.s < 0 ? 8 : 7)); - - if (sd < 1 || !xc[0]) { - xc.length = 0; - - if (r) { - - // Convert sd to decimal places. - sd -= x.e + 1; - - // 1, 0.1, 0.01, 0.001, 0.0001 etc. - xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE]; - x.e = -sd || 0; - } else { - - // Zero. - xc[0] = x.e = 0; - } - - return x; - } - - // Remove excess digits. - if (i == 0) { - xc.length = ni; - k = 1; - ni--; - } else { - xc.length = ni + 1; - k = pows10[LOG_BASE - i]; - - // E.g. 56700 becomes 56000 if 7 is the rounding digit. - // j > 0 means i > number of leading zeros of n. - xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0; - } - - // Round up? - if (r) { - - for (; ;) { - - // If the digit to be rounded up is in the first element of xc... - if (ni == 0) { - - // i will be the length of xc[0] before k is added. - for (i = 1, j = xc[0]; j >= 10; j /= 10, i++); - j = xc[0] += k; - for (k = 1; j >= 10; j /= 10, k++); - - // if i != k the length has increased. - if (i != k) { - x.e++; - if (xc[0] == BASE) xc[0] = 1; - } - - break; - } else { - xc[ni] += k; - if (xc[ni] != BASE) break; - xc[ni--] = 0; - k = 1; - } - } - } - - // Remove trailing zeros. - for (i = xc.length; xc[--i] === 0; xc.pop()); - } - - // Overflow? Infinity. - if (x.e > MAX_EXP) { - x.c = x.e = null; - - // Underflow? Zero. - } else if (x.e < MIN_EXP) { - x.c = [x.e = 0]; - } - } - - return x; - } - - - // PROTOTYPE/INSTANCE METHODS - - - /* - * Return a new BigNumber whose value is the absolute value of this BigNumber. - */ - P.absoluteValue = P.abs = function () { - var x = new BigNumber(this); - if (x.s < 0) x.s = 1; - return x; - }; - - - /* - * Return - * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b), - * -1 if the value of this BigNumber is less than the value of BigNumber(y, b), - * 0 if they have the same value, - * or null if the value of either is NaN. - */ - P.comparedTo = function (y, b) { - return compare(this, new BigNumber(y, b)); - }; - - - /* - * If dp is undefined or null or true or false, return the number of decimal places of the - * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. - * - * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this - * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or - * ROUNDING_MODE if rm is omitted. - * - * [dp] {number} Decimal places: integer, 0 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' - */ - P.decimalPlaces = P.dp = function (dp, rm) { - var c, n, v, - x = this; - - if (dp != null) { - intCheck(dp, 0, MAX); - if (rm == null) rm = ROUNDING_MODE; - else intCheck(rm, 0, 8); - - return round(new BigNumber(x), dp + x.e + 1, rm); - } - - if (!(c = x.c)) return null; - n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE; - - // Subtract the number of trailing zeros of the last number. - if (v = c[v]) for (; v % 10 == 0; v /= 10, n--); - if (n < 0) n = 0; - - return n; - }; - - - /* - * n / 0 = I - * n / N = N - * n / I = 0 - * 0 / n = 0 - * 0 / 0 = N - * 0 / N = N - * 0 / I = 0 - * N / n = N - * N / 0 = N - * N / N = N - * N / I = N - * I / n = I - * I / 0 = I - * I / N = N - * I / I = N - * - * Return a new BigNumber whose value is the value of this BigNumber divided by the value of - * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE. - */ - P.dividedBy = P.div = function (y, b) { - return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE); - }; - - - /* - * Return a new BigNumber whose value is the integer part of dividing the value of this - * BigNumber by the value of BigNumber(y, b). - */ - P.dividedToIntegerBy = P.idiv = function (y, b) { - return div(this, new BigNumber(y, b), 0, 1); - }; - - - /* - * Return a BigNumber whose value is the value of this BigNumber exponentiated by n. - * - * If m is present, return the result modulo m. - * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE. - * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE. - * - * The modular power operation works efficiently when x, n, and m are integers, otherwise it - * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0. - * - * n {number|string|BigNumber} The exponent. An integer. - * [m] {number|string|BigNumber} The modulus. - * - * '[BigNumber Error] Exponent not an integer: {n}' - */ - P.exponentiatedBy = P.pow = function (n, m) { - var half, isModExp, k, more, nIsBig, nIsNeg, nIsOdd, y, - x = this; - - n = new BigNumber(n); - - // Allow NaN and ±Infinity, but not other non-integers. - if (n.c && !n.isInteger()) { - throw Error - (bignumberError + 'Exponent not an integer: ' + n); - } - - if (m != null) m = new BigNumber(m); - - // Exponent of MAX_SAFE_INTEGER is 15. - nIsBig = n.e > 14; - - // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0. - if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) { - - // The sign of the result of pow when x is negative depends on the evenness of n. - // If +n overflows to ±Infinity, the evenness of n would be not be known. - y = new BigNumber(Math.pow(+x.valueOf(), nIsBig ? 2 - isOdd(n) : +n)); - return m ? y.mod(m) : y; - } - - nIsNeg = n.s < 0; - - if (m) { - - // x % m returns NaN if abs(m) is zero, or m is NaN. - if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN); - - isModExp = !nIsNeg && x.isInteger() && m.isInteger(); - - if (isModExp) x = x.mod(m); - - // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15. - // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15. - } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 - // [1, 240000000] - ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 - // [80000000000000] [99999750000000] - : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) { - - // If x is negative and n is odd, k = -0, else k = 0. - k = x.s < 0 && isOdd(n) ? -0 : 0; - - // If x >= 1, k = ±Infinity. - if (x.e > -1) k = 1 / k; - - // If n is negative return ±0, else return ±Infinity. - return new BigNumber(nIsNeg ? 1 / k : k); - - } else if (POW_PRECISION) { - - // Truncating each coefficient array to a length of k after each multiplication - // equates to truncating significant digits to POW_PRECISION + [28, 41], - // i.e. there will be a minimum of 28 guard digits retained. - k = mathceil(POW_PRECISION / LOG_BASE + 2); - } - - if (nIsBig) { - half = new BigNumber(0.5); - nIsOdd = isOdd(n); - } else { - nIsOdd = n % 2; - } - - if (nIsNeg) n.s = 1; - - y = new BigNumber(ONE); - - // Performs 54 loop iterations for n of 9007199254740991. - for (; ;) { - - if (nIsOdd) { - y = y.times(x); - if (!y.c) break; - - if (k) { - if (y.c.length > k) y.c.length = k; - } else if (isModExp) { - y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m)); - } - } - - if (nIsBig) { - n = n.times(half); - round(n, n.e + 1, 1); - if (!n.c[0]) break; - nIsBig = n.e > 14; - nIsOdd = isOdd(n); - } else { - n = mathfloor(n / 2); - if (!n) break; - nIsOdd = n % 2; - } - - x = x.times(x); - - if (k) { - if (x.c && x.c.length > k) x.c.length = k; - } else if (isModExp) { - x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m)); - } - } - - if (isModExp) return y; - if (nIsNeg) y = ONE.div(y); - - return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y; - }; - - - /* - * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer - * using rounding mode rm, or ROUNDING_MODE if rm is omitted. - * - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}' - */ - P.integerValue = function (rm) { - var n = new BigNumber(this); - if (rm == null) rm = ROUNDING_MODE; - else intCheck(rm, 0, 8); - return round(n, n.e + 1, rm); - }; - - - /* - * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b), - * otherwise return false. - */ - P.isEqualTo = P.eq = function (y, b) { - return compare(this, new BigNumber(y, b)) === 0; - }; - - - /* - * Return true if the value of this BigNumber is a finite number, otherwise return false. - */ - P.isFinite = function () { - return !!this.c; - }; - - - /* - * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b), - * otherwise return false. - */ - P.isGreaterThan = P.gt = function (y, b) { - return compare(this, new BigNumber(y, b)) > 0; - }; - - - /* - * Return true if the value of this BigNumber is greater than or equal to the value of - * BigNumber(y, b), otherwise return false. - */ - P.isGreaterThanOrEqualTo = P.gte = function (y, b) { - return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0; - - }; - - - /* - * Return true if the value of this BigNumber is an integer, otherwise return false. - */ - P.isInteger = function () { - return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2; - }; - - - /* - * Return true if the value of this BigNumber is less than the value of BigNumber(y, b), - * otherwise return false. - */ - P.isLessThan = P.lt = function (y, b) { - return compare(this, new BigNumber(y, b)) < 0; - }; - - - /* - * Return true if the value of this BigNumber is less than or equal to the value of - * BigNumber(y, b), otherwise return false. - */ - P.isLessThanOrEqualTo = P.lte = function (y, b) { - return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0; - }; - - - /* - * Return true if the value of this BigNumber is NaN, otherwise return false. - */ - P.isNaN = function () { - return !this.s; - }; - - - /* - * Return true if the value of this BigNumber is negative, otherwise return false. - */ - P.isNegative = function () { - return this.s < 0; - }; - - - /* - * Return true if the value of this BigNumber is positive, otherwise return false. - */ - P.isPositive = function () { - return this.s > 0; - }; - - - /* - * Return true if the value of this BigNumber is 0 or -0, otherwise return false. - */ - P.isZero = function () { - return !!this.c && this.c[0] == 0; - }; - - - /* - * n - 0 = n - * n - N = N - * n - I = -I - * 0 - n = -n - * 0 - 0 = 0 - * 0 - N = N - * 0 - I = -I - * N - n = N - * N - 0 = N - * N - N = N - * N - I = N - * I - n = I - * I - 0 = I - * I - N = N - * I - I = N - * - * Return a new BigNumber whose value is the value of this BigNumber minus the value of - * BigNumber(y, b). - */ - P.minus = function (y, b) { - var i, j, t, xLTy, - x = this, - a = x.s; - - y = new BigNumber(y, b); - b = y.s; - - // Either NaN? - if (!a || !b) return new BigNumber(NaN); - - // Signs differ? - if (a != b) { - y.s = -b; - return x.plus(y); - } - - var xe = x.e / LOG_BASE, - ye = y.e / LOG_BASE, - xc = x.c, - yc = y.c; - - if (!xe || !ye) { - - // Either Infinity? - if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN); - - // Either zero? - if (!xc[0] || !yc[0]) { - - // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. - return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x : - - // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity - ROUNDING_MODE == 3 ? -0 : 0); - } - } - - xe = bitFloor(xe); - ye = bitFloor(ye); - xc = xc.slice(); - - // Determine which is the bigger number. - if (a = xe - ye) { - - if (xLTy = a < 0) { - a = -a; - t = xc; - } else { - ye = xe; - t = yc; - } - - t.reverse(); - - // Prepend zeros to equalise exponents. - for (b = a; b--; t.push(0)); - t.reverse(); - } else { - - // Exponents equal. Check digit by digit. - j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b; - - for (a = b = 0; b < j; b++) { - - if (xc[b] != yc[b]) { - xLTy = xc[b] < yc[b]; - break; - } - } - } - - // x < y? Point xc to the array of the bigger number. - if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s; - - b = (j = yc.length) - (i = xc.length); - - // Append zeros to xc if shorter. - // No need to add zeros to yc if shorter as subtract only needs to start at yc.length. - if (b > 0) for (; b--; xc[i++] = 0); - b = BASE - 1; - - // Subtract yc from xc. - for (; j > a;) { - - if (xc[--j] < yc[j]) { - for (i = j; i && !xc[--i]; xc[i] = b); - --xc[i]; - xc[j] += BASE; - } - - xc[j] -= yc[j]; - } - - // Remove leading zeros and adjust exponent accordingly. - for (; xc[0] == 0; xc.splice(0, 1), --ye); - - // Zero? - if (!xc[0]) { - - // Following IEEE 754 (2008) 6.3, - // n - n = +0 but n - n = -0 when rounding towards -Infinity. - y.s = ROUNDING_MODE == 3 ? -1 : 1; - y.c = [y.e = 0]; - return y; - } - - // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity - // for finite x and y. - return normalise(y, xc, ye); - }; - - - /* - * n % 0 = N - * n % N = N - * n % I = n - * 0 % n = 0 - * -0 % n = -0 - * 0 % 0 = N - * 0 % N = N - * 0 % I = 0 - * N % n = N - * N % 0 = N - * N % N = N - * N % I = N - * I % n = N - * I % 0 = N - * I % N = N - * I % I = N - * - * Return a new BigNumber whose value is the value of this BigNumber modulo the value of - * BigNumber(y, b). The result depends on the value of MODULO_MODE. - */ - P.modulo = P.mod = function (y, b) { - var q, s, - x = this; - - y = new BigNumber(y, b); - - // Return NaN if x is Infinity or NaN, or y is NaN or zero. - if (!x.c || !y.s || y.c && !y.c[0]) { - return new BigNumber(NaN); - - // Return x if y is Infinity or x is zero. - } else if (!y.c || x.c && !x.c[0]) { - return new BigNumber(x); - } - - if (MODULO_MODE == 9) { - - // Euclidian division: q = sign(y) * floor(x / abs(y)) - // r = x - qy where 0 <= r < abs(y) - s = y.s; - y.s = 1; - q = div(x, y, 0, 3); - y.s = s; - q.s *= s; - } else { - q = div(x, y, 0, MODULO_MODE); - } - - y = x.minus(q.times(y)); - - // To match JavaScript %, ensure sign of zero is sign of dividend. - if (!y.c[0] && MODULO_MODE == 1) y.s = x.s; - - return y; - }; - - - /* - * n * 0 = 0 - * n * N = N - * n * I = I - * 0 * n = 0 - * 0 * 0 = 0 - * 0 * N = N - * 0 * I = N - * N * n = N - * N * 0 = N - * N * N = N - * N * I = N - * I * n = I - * I * 0 = N - * I * N = N - * I * I = I - * - * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value - * of BigNumber(y, b). - */ - P.multipliedBy = P.times = function (y, b) { - var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, - base, sqrtBase, - x = this, - xc = x.c, - yc = (y = new BigNumber(y, b)).c; - - // Either NaN, ±Infinity or ±0? - if (!xc || !yc || !xc[0] || !yc[0]) { - - // Return NaN if either is NaN, or one is 0 and the other is Infinity. - if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) { - y.c = y.e = y.s = null; - } else { - y.s *= x.s; - - // Return ±Infinity if either is ±Infinity. - if (!xc || !yc) { - y.c = y.e = null; - - // Return ±0 if either is ±0. - } else { - y.c = [0]; - y.e = 0; - } - } - - return y; - } - - e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE); - y.s *= x.s; - xcL = xc.length; - ycL = yc.length; - - // Ensure xc points to longer array and xcL to its length. - if (xcL < ycL) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i; - - // Initialise the result array with zeros. - for (i = xcL + ycL, zc = []; i--; zc.push(0)); - - base = BASE; - sqrtBase = SQRT_BASE; - - for (i = ycL; --i >= 0;) { - c = 0; - ylo = yc[i] % sqrtBase; - yhi = yc[i] / sqrtBase | 0; - - for (k = xcL, j = i + k; j > i;) { - xlo = xc[--k] % sqrtBase; - xhi = xc[k] / sqrtBase | 0; - m = yhi * xlo + xhi * ylo; - xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c; - c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi; - zc[j--] = xlo % base; - } - - zc[j] = c; - } - - if (c) { - ++e; - } else { - zc.splice(0, 1); - } - - return normalise(y, zc, e); - }; - - - /* - * Return a new BigNumber whose value is the value of this BigNumber negated, - * i.e. multiplied by -1. - */ - P.negated = function () { - var x = new BigNumber(this); - x.s = -x.s || null; - return x; - }; - - - /* - * n + 0 = n - * n + N = N - * n + I = I - * 0 + n = n - * 0 + 0 = 0 - * 0 + N = N - * 0 + I = I - * N + n = N - * N + 0 = N - * N + N = N - * N + I = N - * I + n = I - * I + 0 = I - * I + N = N - * I + I = I - * - * Return a new BigNumber whose value is the value of this BigNumber plus the value of - * BigNumber(y, b). - */ - P.plus = function (y, b) { - var t, - x = this, - a = x.s; - - y = new BigNumber(y, b); - b = y.s; - - // Either NaN? - if (!a || !b) return new BigNumber(NaN); - - // Signs differ? - if (a != b) { - y.s = -b; - return x.minus(y); - } - - var xe = x.e / LOG_BASE, - ye = y.e / LOG_BASE, - xc = x.c, - yc = y.c; - - if (!xe || !ye) { - - // Return ±Infinity if either ±Infinity. - if (!xc || !yc) return new BigNumber(a / 0); - - // Either zero? - // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. - if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0); - } - - xe = bitFloor(xe); - ye = bitFloor(ye); - xc = xc.slice(); - - // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts. - if (a = xe - ye) { - if (a > 0) { - ye = xe; - t = yc; - } else { - a = -a; - t = xc; - } - - t.reverse(); - for (; a--; t.push(0)); - t.reverse(); - } - - a = xc.length; - b = yc.length; - - // Point xc to the longer array, and b to the shorter length. - if (a - b < 0) t = yc, yc = xc, xc = t, b = a; - - // Only start adding at yc.length - 1 as the further digits of xc can be ignored. - for (a = 0; b;) { - a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0; - xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE; - } - - if (a) { - xc = [a].concat(xc); - ++ye; - } - - // No need to check for zero, as +x + +y != 0 && -x + -y != 0 - // ye = MAX_EXP + 1 possible - return normalise(y, xc, ye); - }; - - - /* - * If sd is undefined or null or true or false, return the number of significant digits of - * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. - * If sd is true include integer-part trailing zeros in the count. - * - * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this - * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or - * ROUNDING_MODE if rm is omitted. - * - * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive. - * boolean: whether to count integer-part trailing zeros: true or false. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' - */ - P.precision = P.sd = function (sd, rm) { - var c, n, v, - x = this; - - if (sd != null && sd !== !!sd) { - intCheck(sd, 1, MAX); - if (rm == null) rm = ROUNDING_MODE; - else intCheck(rm, 0, 8); - - return round(new BigNumber(x), sd, rm); - } - - if (!(c = x.c)) return null; - v = c.length - 1; - n = v * LOG_BASE + 1; - - if (v = c[v]) { - - // Subtract the number of trailing zeros of the last element. - for (; v % 10 == 0; v /= 10, n--); - - // Add the number of digits of the first element. - for (v = c[0]; v >= 10; v /= 10, n++); - } - - if (sd && x.e + 1 > n) n = x.e + 1; - - return n; - }; - - - /* - * Return a new BigNumber whose value is the value of this BigNumber shifted by k places - * (powers of 10). Shift to the right if n > 0, and to the left if n < 0. - * - * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}' - */ - P.shiftedBy = function (k) { - intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER); - return this.times('1e' + k); - }; - - - /* - * sqrt(-n) = N - * sqrt(N) = N - * sqrt(-I) = N - * sqrt(I) = I - * sqrt(0) = 0 - * sqrt(-0) = -0 - * - * Return a new BigNumber whose value is the square root of the value of this BigNumber, - * rounded according to DECIMAL_PLACES and ROUNDING_MODE. - */ - P.squareRoot = P.sqrt = function () { - var m, n, r, rep, t, - x = this, - c = x.c, - s = x.s, - e = x.e, - dp = DECIMAL_PLACES + 4, - half = new BigNumber('0.5'); - - // Negative/NaN/Infinity/zero? - if (s !== 1 || !c || !c[0]) { - return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0); - } - - // Initial estimate. - s = Math.sqrt(+x); - - // Math.sqrt underflow/overflow? - // Pass x to Math.sqrt as integer, then adjust the exponent of the result. - if (s == 0 || s == 1 / 0) { - n = coeffToString(c); - if ((n.length + e) % 2 == 0) n += '0'; - s = Math.sqrt(n); - e = bitFloor((e + 1) / 2) - (e < 0 || e % 2); - - if (s == 1 / 0) { - n = '1e' + e; - } else { - n = s.toExponential(); - n = n.slice(0, n.indexOf('e') + 1) + e; - } - - r = new BigNumber(n); - } else { - r = new BigNumber(s + ''); - } - - // Check for zero. - // r could be zero if MIN_EXP is changed after the this value was created. - // This would cause a division by zero (x/t) and hence Infinity below, which would cause - // coeffToString to throw. - if (r.c[0]) { - e = r.e; - s = e + dp; - if (s < 3) s = 0; - - // Newton-Raphson iteration. - for (; ;) { - t = r; - r = half.times(t.plus(div(x, t, dp, 1))); - - if (coeffToString(t.c ).slice(0, s) === (n = - coeffToString(r.c)).slice(0, s)) { - - // The exponent of r may here be one less than the final result exponent, - // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits - // are indexed correctly. - if (r.e < e) --s; - n = n.slice(s - 3, s + 1); - - // The 4th rounding digit may be in error by -1 so if the 4 rounding digits - // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the - // iteration. - if (n == '9999' || !rep && n == '4999') { - - // On the first iteration only, check to see if rounding up gives the - // exact result as the nines may infinitely repeat. - if (!rep) { - round(t, t.e + DECIMAL_PLACES + 2, 0); - - if (t.times(t).eq(x)) { - r = t; - break; - } - } - - dp += 4; - s += 4; - rep = 1; - } else { - - // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact - // result. If not, then there are further digits and m will be truthy. - if (!+n || !+n.slice(1) && n.charAt(0) == '5') { - - // Truncate to the first rounding digit. - round(r, r.e + DECIMAL_PLACES + 2, 1); - m = !r.times(r).eq(x); - } - - break; - } - } - } - } - - return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m); - }; - - - /* - * Return a string representing the value of this BigNumber in exponential notation and - * rounded using ROUNDING_MODE to dp fixed decimal places. - * - * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' - */ - P.toExponential = function (dp, rm) { - if (dp != null) { - intCheck(dp, 0, MAX); - dp++; - } - return format(this, dp, rm, 1); - }; - - - /* - * Return a string representing the value of this BigNumber in fixed-point notation rounding - * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted. - * - * Note: as with JavaScript's number type, (-0).toFixed(0) is '0', - * but e.g. (-0.00001).toFixed(0) is '-0'. - * - * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' - */ - P.toFixed = function (dp, rm) { - if (dp != null) { - intCheck(dp, 0, MAX); - dp = dp + this.e + 1; - } - return format(this, dp, rm); - }; - - - /* - * Return a string representing the value of this BigNumber in fixed-point notation rounded - * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties - * of the FORMAT object (see BigNumber.set). - * - * FORMAT = { - * decimalSeparator : '.', - * groupSeparator : ',', - * groupSize : 3, - * secondaryGroupSize : 0, - * fractionGroupSeparator : '\xA0', // non-breaking space - * fractionGroupSize : 0 - * }; - * - * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' - */ - P.toFormat = function (dp, rm) { - var str = this.toFixed(dp, rm); - - if (this.c) { - var i, - arr = str.split('.'), - g1 = +FORMAT.groupSize, - g2 = +FORMAT.secondaryGroupSize, - groupSeparator = FORMAT.groupSeparator, - intPart = arr[0], - fractionPart = arr[1], - isNeg = this.s < 0, - intDigits = isNeg ? intPart.slice(1) : intPart, - len = intDigits.length; - - if (g2) i = g1, g1 = g2, g2 = i, len -= i; - - if (g1 > 0 && len > 0) { - i = len % g1 || g1; - intPart = intDigits.substr(0, i); - - for (; i < len; i += g1) { - intPart += groupSeparator + intDigits.substr(i, g1); - } - - if (g2 > 0) intPart += groupSeparator + intDigits.slice(i); - if (isNeg) intPart = '-' + intPart; - } - - str = fractionPart - ? intPart + FORMAT.decimalSeparator + ((g2 = +FORMAT.fractionGroupSize) - ? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'), - '$&' + FORMAT.fractionGroupSeparator) - : fractionPart) - : intPart; - } - - return str; - }; - - - /* - * Return a string array representing the value of this BigNumber as a simple fraction with - * an integer numerator and an integer denominator. The denominator will be a positive - * non-zero value less than or equal to the specified maximum denominator. If a maximum - * denominator is not specified, the denominator will be the lowest value necessary to - * represent the number exactly. - * - * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator. - * - * '[BigNumber Error] Argument {not an integer|out of range} : {md}' - */ - P.toFraction = function (md) { - var arr, d, d0, d1, d2, e, exp, n, n0, n1, q, s, - x = this, - xc = x.c; - - if (md != null) { - n = new BigNumber(md); - - // Throw if md is less than one or is not an integer, unless it is Infinity. - if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) { - throw Error - (bignumberError + 'Argument ' + - (n.isInteger() ? 'out of range: ' : 'not an integer: ') + md); - } - } - - if (!xc) return x.toString(); - - d = new BigNumber(ONE); - n1 = d0 = new BigNumber(ONE); - d1 = n0 = new BigNumber(ONE); - s = coeffToString(xc); - - // Determine initial denominator. - // d is a power of 10 and the minimum max denominator that specifies the value exactly. - e = d.e = s.length - x.e - 1; - d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp]; - md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n; - - exp = MAX_EXP; - MAX_EXP = 1 / 0; - n = new BigNumber(s); - - // n0 = d1 = 0 - n0.c[0] = 0; - - for (; ;) { - q = div(n, d, 0, 1); - d2 = d0.plus(q.times(d1)); - if (d2.comparedTo(md) == 1) break; - d0 = d1; - d1 = d2; - n1 = n0.plus(q.times(d2 = n1)); - n0 = d2; - d = n.minus(q.times(d2 = d)); - n = d2; - } - - d2 = div(md.minus(d0), d1, 0, 1); - n0 = n0.plus(d2.times(n1)); - d0 = d0.plus(d2.times(d1)); - n0.s = n1.s = x.s; - e *= 2; - - // Determine which fraction is closer to x, n0/d0 or n1/d1 - arr = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo( - div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 - ? [n1.toString(), d1.toString()] - : [n0.toString(), d0.toString()]; - - MAX_EXP = exp; - return arr; - }; - - - /* - * Return the value of this BigNumber converted to a number primitive. - */ - P.toNumber = function () { - return +this; - }; - - - /* - * Return a string representing the value of this BigNumber rounded to sd significant digits - * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits - * necessary to represent the integer part of the value in fixed-point notation, then use - * exponential notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' - */ - P.toPrecision = function (sd, rm) { - if (sd != null) intCheck(sd, 1, MAX); - return format(this, sd, rm, 2); - }; - - - /* - * Return a string representing the value of this BigNumber in base b, or base 10 if b is - * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and - * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent - * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than - * TO_EXP_NEG, return exponential notation. - * - * [b] {number} Integer, 2 to ALPHABET.length inclusive. - * - * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' - */ - P.toString = function (b) { - var str, - n = this, - s = n.s, - e = n.e; - - // Infinity or NaN? - if (e === null) { - - if (s) { - str = 'Infinity'; - if (s < 0) str = '-' + str; - } else { - str = 'NaN'; - } - } else { - str = coeffToString(n.c); - - if (b == null) { - str = e <= TO_EXP_NEG || e >= TO_EXP_POS - ? toExponential(str, e) - : toFixedPoint(str, e, '0'); - } else { - intCheck(b, 2, ALPHABET.length, 'Base'); - str = convertBase(toFixedPoint(str, e, '0'), 10, b, s, true); - } - - if (s < 0 && n.c[0]) str = '-' + str; - } - - return str; - }; - - - /* - * Return as toString, but do not accept a base argument, and include the minus sign for - * negative zero. - */ - P.valueOf = P.toJSON = function () { - var str, - n = this, - e = n.e; - - if (e === null) return n.toString(); - - str = coeffToString(n.c); - - str = e <= TO_EXP_NEG || e >= TO_EXP_POS - ? toExponential(str, e) - : toFixedPoint(str, e, '0'); - - return n.s < 0 ? '-' + str : str; - }; - - - P._isBigNumber = true; - - if (configObject != null) BigNumber.set(configObject); - - return BigNumber; - } - - - // PRIVATE HELPER FUNCTIONS - - - function bitFloor(n) { - var i = n | 0; - return n > 0 || n === i ? i : i - 1; - } - - - // Return a coefficient array as a string of base 10 digits. - function coeffToString(a) { - var s, z, - i = 1, - j = a.length, - r = a[0] + ''; - - for (; i < j;) { - s = a[i++] + ''; - z = LOG_BASE - s.length; - for (; z--; s = '0' + s); - r += s; - } - - // Determine trailing zeros. - for (j = r.length; r.charCodeAt(--j) === 48;); - return r.slice(0, j + 1 || 1); - } - - - // Compare the value of BigNumbers x and y. - function compare(x, y) { - var a, b, - xc = x.c, - yc = y.c, - i = x.s, - j = y.s, - k = x.e, - l = y.e; - - // Either NaN? - if (!i || !j) return null; - - a = xc && !xc[0]; - b = yc && !yc[0]; - - // Either zero? - if (a || b) return a ? b ? 0 : -j : i; - - // Signs differ? - if (i != j) return i; - - a = i < 0; - b = k == l; - - // Either Infinity? - if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1; - - // Compare exponents. - if (!b) return k > l ^ a ? 1 : -1; - - j = (k = xc.length) < (l = yc.length) ? k : l; - - // Compare digit by digit. - for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1; - - // Compare lengths. - return k == l ? 0 : k > l ^ a ? 1 : -1; - } - - - /* - * Check that n is a primitive number, an integer, and in range, otherwise throw. - */ - function intCheck(n, min, max, name) { - if (n < min || n > max || n !== (n < 0 ? mathceil(n) : mathfloor(n))) { - throw Error - (bignumberError + (name || 'Argument') + (typeof n == 'number' - ? n < min || n > max ? ' out of range: ' : ' not an integer: ' - : ' not a primitive number: ') + n); - } - } - - - function isArray(obj) { - return Object.prototype.toString.call(obj) == '[object Array]'; - } - - - // Assumes finite n. - function isOdd(n) { - var k = n.c.length - 1; - return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0; - } - - - function toExponential(str, e) { - return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) + - (e < 0 ? 'e' : 'e+') + e; - } - - - function toFixedPoint(str, e, z) { - var len, zs; - - // Negative exponent? - if (e < 0) { - - // Prepend zeros. - for (zs = z + '.'; ++e; zs += z); - str = zs + str; - - // Positive exponent - } else { - len = str.length; - - // Append zeros. - if (++e > len) { - for (zs = z, e -= len; --e; zs += z); - str += zs; - } else if (e < len) { - str = str.slice(0, e) + '.' + str.slice(e); - } - } - - return str; - } - - - // EXPORT - - - BigNumber = clone(); - BigNumber['default'] = BigNumber.BigNumber = BigNumber; - - // AMD. - if (typeof define == 'function' && define.amd) { - define(function () { return BigNumber; }); - - // Node.js and other environments that support module.exports. - } else if (typeof module != 'undefined' && module.exports) { - module.exports = BigNumber; - - // Browser. - } else { - if (!globalObject) { - globalObject = typeof self != 'undefined' && self ? self : window; - } - - globalObject.BigNumber = BigNumber; - } -})(this); - -},{}],4:[function(require,module,exports){ - -},{}],5:[function(require,module,exports){ -var basex = require('base-x') -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' - -module.exports = basex(ALPHABET) - -},{"base-x":1}],6:[function(require,module,exports){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' - -var base64 = require('base64-js') -var ieee754 = require('ieee754') - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -var K_MAX_LENGTH = 0x7fffffff -exports.kMaxLength = K_MAX_LENGTH - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ -Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - -if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) -} - -function typedArraySupport () { - // Can typed array instances can be augmented? - try { - var arr = new Uint8Array(1) - arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } - return arr.foo() === 42 - } catch (e) { - return false - } -} - -Object.defineProperty(Buffer.prototype, 'parent', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.buffer - } -}) - -Object.defineProperty(Buffer.prototype, 'offset', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.byteOffset - } -}) - -function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('The value "' + length + '" is invalid for option "size"') - } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype - return buf -} - -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new TypeError( - 'The "string" argument must be of type string. Received type number' - ) - } - return allocUnsafe(arg) - } - return from(arg, encodingOrOffset, length) -} - -// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species != null && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) -} - -Buffer.poolSize = 8192 // not used by this implementation - -function from (value, encodingOrOffset, length) { - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } - - if (ArrayBuffer.isView(value)) { - return fromArrayLike(value) - } - - if (value == null) { - throw TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) - } - - if (isInstance(value, ArrayBuffer) || - (value && isInstance(value.buffer, ArrayBuffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - - if (typeof value === 'number') { - throw new TypeError( - 'The "value" argument must not be of type number. Received type number' - ) - } - - var valueOf = value.valueOf && value.valueOf() - if (valueOf != null && valueOf !== value) { - return Buffer.from(valueOf, encodingOrOffset, length) - } - - var b = fromObject(value) - if (b) return b - - if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && - typeof value[Symbol.toPrimitive] === 'function') { - return Buffer.from( - value[Symbol.toPrimitive]('string'), encodingOrOffset, length - ) - } - - throw new TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) -} - -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) -} - -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array - -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('The value "' + size + '" is invalid for option "size"') - } -} - -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) -} - -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) -} - -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) -} - -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) -} - -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) - - var actual = buf.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } - - return buf -} - -function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf -} - -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } - - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } - - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf -} - -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } - - obj.copy(buf, 0, 0, len) - return buf - } - - if (obj.length !== undefined) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } - - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } -} - -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} - -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true && - b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false -} - -Buffer.compare = function compare (a, b) { - if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) - if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError( - 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' - ) - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (isInstance(buf, Uint8Array)) { - buf = Buffer.from(buf) - } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer -} - -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { - return string.byteLength - } - if (typeof string !== 'string') { - throw new TypeError( - 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + - 'Received type ' + typeof string - ) - } - - var len = string.length - var mustMatch = (arguments.length > 2 && arguments[2] === true) - if (!mustMatch && len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) { - return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 - } - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true - -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i -} - -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} - -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} - -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.toLocaleString = Buffer.prototype.toString - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() - if (this.length > max) str += ' ... ' - return '' -} - -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (isInstance(target, Uint8Array)) { - target = Buffer.from(target, target.offset, target.byteLength) - } - if (!Buffer.isBuffer(target)) { - throw new TypeError( - 'The "target" argument must be one of type Buffer or Uint8Array. ' + - 'Received type ' + (typeof target) - ) - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 -} - -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} - -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - var strLen = string.length - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) - } - - return len -} - -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code - } - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : Buffer.from(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this -} - -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass -// the `instanceof` check but they should be treated as of that type. -// See: https://github.com/feross/buffer/issues/166 -function isInstance (obj, type) { - return obj instanceof type || - (obj != null && obj.constructor != null && obj.constructor.name != null && - obj.constructor.name === type.name) -} -function numberIsNaN (obj) { - // For IE11 support - return obj !== obj // eslint-disable-line no-self-compare -} - -},{"base64-js":2,"ieee754":45}],7:[function(require,module,exports){ -'use strict' - -exports.Commented = require('./commented') -exports.Diagnose = require('./diagnose') -exports.Decoder = require('./decoder') -exports.Encoder = require('./encoder') -exports.Simple = require('./simple') -exports.Tagged = require('./tagged') -exports.Map = require('./map') - -exports.comment = exports.Commented.comment -exports.decodeAll = exports.Decoder.decodeAll -exports.decodeFirst = exports.Decoder.decodeFirst -exports.decodeAllSync = exports.Decoder.decodeAllSync -exports.decodeFirstSync = exports.Decoder.decodeFirstSync -exports.diagnose = exports.Diagnose.diagnose -exports.encode = exports.Encoder.encode -exports.encodeCanonical = exports.Encoder.encodeCanonical -exports.encodeOne = exports.Encoder.encodeOne -exports.decode = exports.Decoder.decodeFirstSync - -exports.leveldb = { - decode: exports.Decoder.decodeAllSync, - encode: exports.Encoder.encode, - buffer: true, - name: 'cbor' -} - -},{"./commented":8,"./decoder":10,"./diagnose":11,"./encoder":12,"./map":13,"./simple":14,"./tagged":15}],8:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const stream = require('stream') -const util = require('util') -const utils = require('./utils') -const Simple = require('./simple') -const Decoder = require('./decoder') -const constants = require('./constants') -const bignumber = require('bignumber.js') -const NoFilter = require('nofilter') - -const MT = constants.MT -const NUMBYTES = constants.NUMBYTES -const SYMS = constants.SYMS - -function plural(c) { - if (c > 1) { - return 's' - } else { - return '' - } -} - -/** - * Generate the expanded format of RFC 7049, section 2.2.1 - * - * @extends {stream.Transform} - */ -class Commented extends stream.Transform { - /** - * Create a CBOR commenter. - * - * @param {any} [options={}] - Stream options - * @param {bool} [options.max_depth=10] - how many times to indent the dashes - */ - constructor(options) { - options = options || {} - options.readableObjectMode = false - options.writableObjectMode = false - const max_depth = (options.max_depth != null) ? options.max_depth : 10 - delete options.max_depth - super(options) - - this.depth = 1 - this.max_depth = max_depth - this.all = new NoFilter - this.parser = new Decoder(options) - this.parser.on('value', this._on_value.bind(this)) - this.parser.on('start', this._on_start.bind(this)) - this.parser.on('start-string', this._on_start_string.bind(this)) - this.parser.on('stop', this._on_stop.bind(this)) - this.parser.on('more-bytes', this._on_more.bind(this)) - this.parser.on('error', this._on_error.bind(this)) - this.parser.on('data', this._on_data.bind(this)) - this.parser.bs.on('read', this._on_read.bind(this)) - } - - /** - * @private - */ - _transform(fresh, encoding, cb) { - this.parser.write(fresh, encoding, cb) - } - - /** - * @private - */ - _flush(cb) { - // TODO: find the test that covers this, and look at the return value - return this.parser._flush(cb) - } - - /** - * @callback commentCallback - * @param {Error} error - if one was generated - * @param {string} commented - the comment string - */ - - /** - * Comment on an input Buffer or string, creating a string passed to the - * callback. If callback not specified, a promise is returned. - * - * @static - * @param {(string|Buffer|NoFilter)} input - * @param {(string|Object|function)} options - * @param {number} [options.max_depth=10] how many times to indent the dashes - * @param {commentCallback=} cb - * @returns {Promise} if cb not specified - */ - static comment(input, options, cb) { - if (input == null) { - throw new Error('input required') - } - let encoding = (typeof input === 'string') ? 'hex' : void 0 - let max_depth = 10 - switch (typeof options) { - case 'function': - cb = options - break - case 'string': - encoding = options - break - case 'number': - max_depth = options - break - case 'object': - const ref1 = options.encoding - const ref2 = options.max_depth - encoding = (ref1 != null) ? ref1 : encoding - max_depth = (ref2 != null) ? ref2 : max_depth - break - case 'undefined': - break - default: - throw new Error('Unknown option type') - } - const bs = new NoFilter - const d = new Commented({ - max_depth: max_depth - }) - let p = null - if (typeof cb === 'function') { - d.on('end', () => { - cb(null, bs.toString('utf8')) - }) - d.on('error', cb) - } else { - p = new Promise((resolve, reject) => { - d.on('end', () => { - resolve(bs.toString('utf8')) - }) - return d.on('error', reject) - }) - } - d.pipe(bs) - d.end(input, encoding) - return p - } - - /** - * @private - */ - _on_error(er) { - return this.push('ERROR: ') && - this.push(er.toString()) && - this.push('\n') - } - - /** - * @private - */ - _on_read(buf) { - this.all.write(buf) - const hex = buf.toString('hex') - this.push(new Array(this.depth + 1).join(' ')) - this.push(hex) - let ind = (this.max_depth - this.depth) * 2 - ind -= hex.length - if (ind < 1) { - ind = 1 - } - this.push(new Array(ind + 1).join(' ')) - return this.push('-- ') - } - - /** - * @private - */ - _on_more(mt, len, parent_mt, pos) { - this.depth++ - let desc = '' - switch (mt) { - case MT.POS_INT: - desc = 'Positive number,' - break - case MT.NEG_INT: - desc = 'Negative number,' - break - case MT.ARRAY: - desc = 'Array, length' - break - case MT.MAP: - desc = 'Map, count' - break - case MT.BYTE_STRING: - desc = 'Bytes, length' - break - case MT.UTF8_STRING: - desc = 'String, length' - break - case MT.SIMPLE_FLOAT: - if (len === 1) { - desc = 'Simple value,' - } else { - desc = 'Float,' - } - break - } - return this.push(desc + ' next ' + len + ' byte' + (plural(len)) + '\n') - } - - /** - * @private - */ - _on_start_string(mt, tag, parent_mt, pos) { - this.depth++ - let desc = '' - switch (mt) { - case MT.BYTE_STRING: - desc = 'Bytes, length: ' + tag - break - case MT.UTF8_STRING: - desc = 'String, length: ' + (tag.toString()) - break - } - return this.push(desc + '\n') - } - - /** - * @private - */ - _on_start(mt, tag, parent_mt, pos) { - this.depth++ - if (tag !== SYMS.BREAK) { - this.push((() => { - switch (parent_mt) { - case MT.ARRAY: - return '[' + pos + '], ' - case MT.MAP: - if (pos % 2) { - return '{Val:' + (Math.floor(pos / 2)) + '}, ' - } else { - return '{Key:' + (Math.floor(pos / 2)) + '}, ' - } - } - })()) - } - this.push((() => { - switch (mt) { - case MT.TAG: - return 'Tag #' + tag - case MT.ARRAY: - if (tag === SYMS.STREAM) { - return 'Array (streaming)' - } else { - return 'Array, ' + tag + ' item' + (plural(tag)) - } - case MT.MAP: - if (tag === SYMS.STREAM) { - return 'Map (streaming)' - } else { - return 'Map, ' + tag + ' pair' + (plural(tag)) - } - case MT.BYTE_STRING: - return 'Bytes (streaming)' - case MT.UTF8_STRING: - return 'String (streaming)' - } - })()) - return this.push('\n') - } - - /** - * @private - */ - _on_stop(mt) { - return this.depth-- - } - - /** - * @private - */ - _on_value(val, parent_mt, pos, ai) { - if (val !== SYMS.BREAK) { - this.push((() => { - switch (parent_mt) { - case MT.ARRAY: - return '[' + pos + '], ' - case MT.MAP: - if (pos % 2) { - return '{Val:' + (Math.floor(pos / 2)) + '}, ' - } else { - return '{Key:' + (Math.floor(pos / 2)) + '}, ' - } - } - })()) - } - - if (val === SYMS.BREAK) { - this.push('BREAK\n') - } else if (val === SYMS.NULL) { - this.push('null\n') - } else if (val === SYMS.UNDEFINED) { - this.push('undefined\n') - } else if (typeof val === 'string') { - this.depth-- - if (val.length > 0 ) { - this.push(JSON.stringify(val)) - this.push('\n') - } - } else if (Buffer.isBuffer(val)) { - this.depth-- - if (val.length > 0) { - this.push(val.toString('hex')) - this.push('\n') - } - } else if (val instanceof bignumber) { - this.push(val.toString()) - this.push('\n') - } else { - this.push(util.inspect(val)) - this.push('\n') - } - - switch (ai) { - case NUMBYTES.ONE: - case NUMBYTES.TWO: - case NUMBYTES.FOUR: - case NUMBYTES.EIGHT: - this.depth-- - } - } - - /** - * @private - */ - _on_data() { - this.push('0x') - this.push(this.all.read().toString('hex')) - return this.push('\n') - } -} - -module.exports = Commented - -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":47,"./constants":9,"./decoder":10,"./simple":14,"./utils":16,"bignumber.js":3,"nofilter":50,"stream":72,"util":78}],9:[function(require,module,exports){ -'use strict' - -exports.MT = { - POS_INT: 0, - NEG_INT: 1, - BYTE_STRING: 2, - UTF8_STRING: 3, - ARRAY: 4, - MAP: 5, - TAG: 6, - SIMPLE_FLOAT: 7 -} - -exports.TAG = { - DATE_STRING: 0, - DATE_EPOCH: 1, - POS_BIGINT: 2, - NEG_BIGINT: 3, - DECIMAL_FRAC: 4, - BIGFLOAT: 5, - BASE64URL_EXPECTED: 21, - BASE64_EXPECTED: 22, - BASE16_EXPECTED: 23, - CBOR: 24, - URI: 32, - BASE64URL: 33, - BASE64: 34, - REGEXP: 35, - MIME: 36 -} - -exports.NUMBYTES = { - ZERO: 0, - ONE: 24, - TWO: 25, - FOUR: 26, - EIGHT: 27, - INDEFINITE: 31 -} - -exports.SIMPLE = { - FALSE: 20, - TRUE: 21, - NULL: 22, - UNDEFINED: 23 -} - -exports.SYMS = { - NULL: Symbol('null'), - UNDEFINED: Symbol('undef'), - PARENT: Symbol('parent'), - BREAK: Symbol('break'), - STREAM: Symbol('stream') -} - -exports.SHIFT32 = Math.pow(2, 32) - -},{}],10:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const BinaryParseStream = require('../vendor/binary-parse-stream') -const Tagged = require('./tagged') -const Simple = require('./simple') -const utils = require('./utils') -const bignumber = require('bignumber.js') -const NoFilter = require('nofilter') -const constants = require('./constants') -// Do not fix this if you want to support node v4 -const MT = constants.MT -const NUMBYTES = constants.NUMBYTES -const SIMPLE = constants.SIMPLE -const SYMS = constants.SYMS - -const NEG_ONE = new bignumber(-1) -const NEG_MAX = NEG_ONE.minus( - new bignumber(Number.MAX_SAFE_INTEGER.toString(16), 16)) -const COUNT = Symbol('count') -const PENDING_KEY = Symbol('pending_key') -const MAJOR = Symbol('major type') -const ERROR = Symbol('error') -const NOT_FOUND = Symbol('not found') - -function parentArray(parent, typ, count) { - const a = [] - a[COUNT] = count - a[SYMS.PARENT] = parent - a[MAJOR] = typ - return a -} - -function parentBufferStream(parent, typ) { - const b = new NoFilter - b[SYMS.PARENT] = parent - b[MAJOR] = typ - return b -} - -/** - * Decode a stream of CBOR bytes by transforming them into equivalent - * JavaScript data. Because of the limitations of Node object streams, - * special symbols are emitted instead of NULL or UNDEFINED. Fix those - * up by calling {@link Decoder.nullcheck}. - * - * @extends {BinaryParseStream} - */ -class Decoder extends BinaryParseStream { - - /** - * Create a parsing stream. - * - * @param {object} [options={}] - * @param {number} [options.max_depth=-1] - the maximum depth to parse. - * Use -1 for "until you run out of memory". Set this to a finite - * positive number for un-trusted inputs. Most standard inputs won't nest - * more than 100 or so levels; I've tested into the millions before - * running out of memory. - * @param {object=} options.tags - mapping from tag number to function(v), - * where v is the decoded value that comes after the tag, and where the - * function returns the correctly-created value for that tag. - */ - constructor(options) { - options = options || {} - const tags = options.tags - delete options.tags - const max_depth = (options.max_depth != null) ? options.max_depth : -1 - delete options.max_depth - super(options) - - this.running = true - this.max_depth = max_depth - this.tags = tags - } - - /** - * Check the given value for a symbol encoding a NULL or UNDEFINED value in - * the CBOR stream. - * - * @static - * @param {any} val - the value to check - * @returns {any} the corrected value - * - * @example - * myDecoder.on('data', function(val) { - * val = Decoder.nullcheck(val); - * ... - * }); - */ - static nullcheck(val) { - switch (val) { - case SYMS.NULL: - return null - case SYMS.UNDEFINED: - return undefined - case NOT_FOUND: - throw new Error('Value not found') - default: - return val - } - } - - /** - * Decode the first CBOR item in the input, synchronously. This will throw an - * exception if the input is not valid CBOR. - * - * @static - * @param {(string|Buffer)} input - * @param {object} [options={encoding: 'hex'}] - * @param {string} [options.encoding: 'hex'] - The encoding of the input. - * Ignored if input is a Buffer. - * @returns {any} - the decoded value - */ - static decodeFirstSync(input, options) { - options = options || { encoding: 'hex' } - let opts = {} - let encod - switch (typeof options) { - case 'string': - encod = options - break - case 'object': - opts = utils.extend({}, options) - encod = opts.encoding - delete opts.encoding - break - } - const c = new Decoder(opts) - const s = new NoFilter( - input, - encod != null ? encod : utils.guessEncoding(input)) - const parser = c._parse() - let state = parser.next() - while (!state.done) { - const b = s.read(state.value) - if ((b == null) || (b.length !== state.value)) { - throw new Error('Insufficient data') - } - state = parser.next(b) - } - return Decoder.nullcheck(state.value) - } - - /** - * Decode all of the CBOR items in the input into an array. This will throw - * an exception if the input is not valid CBOR; a zero-length input will - * return an empty array. - * - * @static - * @param {(string|Buffer)} input - * @param {(string|Object)} [options={encoding: 'hex'}] - * @param {string} [options.encoding: 'hex'] - The encoding of the input. - * Ignored if input is a Buffer. - * @returns {Array} - Array of all found items - */ - static decodeAllSync(input, options) { - options = options || { encoding: 'hex' } - let opts = {} - let encod - switch (typeof options) { - case 'string': - encod = options - break - case 'object': - opts = utils.extend({}, options) - encod = opts.encoding - delete opts.encoding - } - const c = new Decoder(opts) - const s = new NoFilter( - input, - encod != null ? encod : utils.guessEncoding(input)) - const res = [] - while (s.length > 0) { - const parser = c._parse() - let state = parser.next() - while (!state.done) { - const b = s.read(state.value) - if ((b == null) || (b.length !== state.value)) { - throw new Error('Insufficient data') - } - state = parser.next(b) - } - res.push(Decoder.nullcheck(state.value)) - } - return res - } - - /** - * @callback decodeCallback - * @param {Error} error - if one was generated - * @param {any} value - the decoded value - */ - - /** - * Decode the first CBOR item in the input. This will error if there are more - * bytes left over at the end, and optionally if there were no valid CBOR - * bytes in the input. Emits the {Decoder.NOT_FOUND} Symbol in the callback - * if no data was found and the `required` option is false. - * - * @static - * @param {(string|Buffer)} input - the input to parse - * @param {(function|string|Object)} options - * @param {string} [options.encoding: 'hex'] - The encoding of the input. - * Ignored if input is a Buffer. - * @param {decodeCallback} cb - * @returns {Promise} if no cb specified - */ - static decodeFirst(input, options, cb) { - let opts = {} - let required = false - let encod = 'hex' - switch (typeof options) { - case 'function': - cb = options - encod = utils.guessEncoding(input) - break - case 'string': - encod = options - break - case 'object': - opts = utils.extend({}, options) - encod = (opts.encoding != null) ? - opts.encoding : utils.guessEncoding(input) - delete opts.encoding - required = (opts.required != null) ? opts.required : false - delete opts.required - } - const c = new Decoder(opts) - let p - let v = NOT_FOUND - c.on('data', (val) => { - v = Decoder.nullcheck(val) - c.close() - }) - if (typeof cb === 'function') { - c.once('error', (er) => { - const u = v - v = ERROR - c.close() - return cb(er, u) - }) - c.once('end', () => { - switch (v) { - case NOT_FOUND: - if (required) { - return cb(new Error('No CBOR found')) - } else { - return cb(null, v) - } - case ERROR: - return void 0 - default: - return cb(null, v) - } - }) - } else { - p = new Promise((resolve, reject) => { - c.once('error', (er) => { - v = ERROR - c.close() - return reject(er) - }) - return c.once('end', () => { - switch (v) { - case NOT_FOUND: - if (required) { - return reject(new Error('No CBOR found')) - } else { - return resolve(v) - } - case ERROR: - return void 0 - default: - return resolve(v) - } - }) - }) - } - c.end(input, encod) - return p - } - - /** - * @callback decodeAllCallback - * @param {Error} error - if one was generated - * @param {Array} value - all of the decoded values, wrapped in an Array - */ - - /** - * Decode all of the CBOR items in the input. This will error if there are - * more bytes left over at the end. - * - * @static - * @param {(string|Buffer)} input - the input to parse - * @param {(string|Object)} options - Decoding options. - * If string, the input encoding. - * @param {decodeAllCallback} cb - * @returns {Promise} if no callback - */ - static decodeAll(input, options, cb) { - let opts = {} - let encod = 'hex' - switch (typeof options) { - case 'function': - cb = options - encod = utils.guessEncoding(input) - break - case 'string': - encod = options - break - case 'object': - opts = utils.extend({}, options) - encod = (opts.encoding != null) ? - opts.encoding : utils.guessEncoding(input) - delete opts.encoding - } - const c = new Decoder(opts) - let p - const vals = [] - c.on('data', (val) => { - return vals.push(Decoder.nullcheck(val)) - }) - if (typeof cb === 'function') { - c.on('error', cb) - c.on('end', () => cb(null, vals)) - } else { - p = new Promise((resolve, reject) => { - c.on('error', reject) - c.on('end', () => resolve(vals)) - }) - } - c.end(input, encod) - return p - } - - /** - * Stop processing - */ - close() { - this.running = false - this.__fresh = true - } - - *_parse() { - let parent = null - let depth = 0 - let val = null - while (true) { - if ((this.max_depth >= 0) && (depth > this.max_depth)) { - throw new Error('Maximum depth ' + this.max_depth + ' exceeded') - } - const octet = (yield 1)[0] - if (!this.running) { - throw new Error('Unexpected data: 0x' + (octet.toString(16))) - } - const mt = octet >> 5 - const ai = octet & 0x1f - const parent_major = (parent != null) ? parent[MAJOR] : undefined - const parent_length = (parent != null) ? parent.length : undefined - switch (ai) { - case NUMBYTES.ONE: - this.emit('more-bytes', mt, 1, parent_major, parent_length) - val = (yield 1)[0] - break - case NUMBYTES.TWO: - case NUMBYTES.FOUR: - case NUMBYTES.EIGHT: - const numbytes = 1 << (ai - 24) - this.emit('more-bytes', mt, numbytes, parent_major, parent_length) - const buf = yield numbytes - val = (mt === MT.SIMPLE_FLOAT) ? buf : utils.parseCBORint(ai, buf) - break - case 28: - case 29: - case 30: - this.running = false - throw new Error('Additional info not implemented: ' + ai) - case NUMBYTES.INDEFINITE: - val = -1 - break - default: - val = ai - } - switch (mt) { - case MT.POS_INT: - // val already decoded - break - case MT.NEG_INT: - if (val === Number.MAX_SAFE_INTEGER) { - val = NEG_MAX - } else if (val instanceof bignumber) { - val = NEG_ONE.minus(val) - } else { - val = -1 - val - } - break - case MT.BYTE_STRING: - case MT.UTF8_STRING: - switch (val) { - case 0: - this.emit('start-string', mt, val, parent_major, parent_length) - val = (mt === MT.BYTE_STRING) ? Buffer.allocUnsafe(0) : '' - break - case -1: - this.emit('start', mt, SYMS.STREAM, parent_major, parent_length) - parent = parentBufferStream(parent, mt) - depth++ - continue - default: - this.emit('start-string', mt, val, parent_major, parent_length) - val = yield val - if (mt === MT.UTF8_STRING) { - val = val.toString('utf-8') - } - } - break - case MT.ARRAY: - case MT.MAP: - switch (val) { - case 0: - val = (mt === MT.MAP) ? {} : [] - break - case -1: - this.emit('start', mt, SYMS.STREAM, parent_major, parent_length) - parent = parentArray(parent, mt, -1) - depth++ - continue - default: - this.emit('start', mt, val, parent_major, parent_length) - parent = parentArray(parent, mt, val * (mt - 3)) - depth++ - continue - } - break - case MT.TAG: - this.emit('start', mt, val, parent_major, parent_length) - parent = parentArray(parent, mt, 1) - parent.push(val) - depth++ - continue - case MT.SIMPLE_FLOAT: - if (typeof val === 'number') { - val = Simple.decode(val, parent != null) - } else { - val = utils.parseCBORfloat(val) - } - } - this.emit('value', val, parent_major, parent_length, ai) - let again = false - while (parent != null) { - switch (false) { - case val !== SYMS.BREAK: - parent[COUNT] = 1 - break - case !Array.isArray(parent): - parent.push(val) - break - case !(parent instanceof NoFilter): - const pm = parent[MAJOR] - if ((pm != null) && (pm !== mt)) { - this.running = false - throw new Error('Invalid major type in indefinite encoding') - } - parent.write(val) - } - if ((--parent[COUNT]) !== 0) { - again = true - break - } - --depth - delete parent[COUNT] - this.emit('stop', parent[MAJOR]) - - if (Array.isArray(parent)) { - switch (parent[MAJOR]) { - case MT.ARRAY: - val = parent - break - case MT.MAP: - let allstrings = true - if ((parent.length % 2) !== 0) { - throw new Error('Invalid map length: ' + parent.length) - } - for (let i = 0, len = parent.length; i < len; i += 2) { - if (typeof parent[i] !== 'string') { - allstrings = false - break - } - } - if (allstrings) { - val = {} - for (let i = 0, len = parent.length; i < len; i += 2) { - val[parent[i]] = parent[i + 1] - } - } else { - val = new Map - for (let i = 0, len = parent.length; i < len; i += 2) { - val.set(parent[i], parent[i + 1]) - } - } - break - case MT.TAG: - const t = new Tagged(parent[0], parent[1]) - val = t.convert(this.tags) - break - } - } else if (parent instanceof NoFilter) { - switch (parent[MAJOR]) { - case MT.BYTE_STRING: - val = parent.slice() - break - case MT.UTF8_STRING: - val = parent.toString('utf-8') - break - } - } - - const old = parent - parent = parent[SYMS.PARENT] - delete old[SYMS.PARENT] - delete old[MAJOR] - } - if (!again) { - return val - } - } - } -} - -Decoder.NOT_FOUND = NOT_FOUND -module.exports = Decoder - -}).call(this,require("buffer").Buffer) -},{"../vendor/binary-parse-stream":17,"./constants":9,"./simple":14,"./tagged":15,"./utils":16,"bignumber.js":3,"buffer":6,"nofilter":50}],11:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const stream = require('stream') -const util = require('util') -const Decoder = require('./decoder') -const Simple = require('./simple') -const utils = require('./utils') -const constants = require('./constants') -const bignumber = require('bignumber.js') -const NoFilter = require('nofilter') - -const MT = constants.MT -const SYMS = constants.SYMS - -/** - * Output the diagnostic format from a stream of CBOR bytes. - * - * @extends {stream.Transform} - */ -class Diagnose extends stream.Transform { - - /** - * Creates an instance of Diagnose. - * - * @param {Object} [options={}] - options for creation - * @param {string} [options.separator='\n'] - output between detected objects - * @param {bool} [options.stream_errors=false] - put error info into the - * output stream - * @param {number} [options.max_depth=-1] - -1 for "until you run out of - * memory". Set this to a finite positive number for un-trusted inputs. - * Most standard inputs won't nest more than 100 or so levels; I've tested - * into the millions before running out of memory. - */ - constructor(options) { - options = options || {} - const separator = (options.separator != null) ? options.separator : '\n' - delete options.separator - const stream_errors = (options.stream_errors != null) ? - options.stream_errors : false - delete options.stream_errors - options.readableObjectMode = false - options.writableObjectMode = false - super(options) - - this.float_bytes = -1 - this.separator = separator - this.stream_errors = stream_errors - this.parser = new Decoder(options) - this.parser.on('more-bytes', this._on_more.bind(this)) - this.parser.on('value', this._on_value.bind(this)) - this.parser.on('start', this._on_start.bind(this)) - this.parser.on('stop', this._on_stop.bind(this)) - this.parser.on('data', this._on_data.bind(this)) - this.parser.on('error', this._on_error.bind(this)) - } - - _transform(fresh, encoding, cb) { - return this.parser.write(fresh, encoding, cb) - } - - _flush(cb) { - return this.parser._flush((er) => { - if (this.stream_errors) { - this._on_error(er) - return cb() - } else { - return cb(er) - } - }) - } - - /** - * Convenience function to return a string in diagnostic format. - * - * @param {(Buffer|string)} input - the CBOR bytes to format - * @param {string} [encoding='hex'] - the encoding of input, ignored if - * input is Buffer - * @param {commentCallback} cb - callback - * @returns {Promise} if callback not specified - */ - static diagnose(input, encoding, cb) { - if (input == null) { - throw new Error('input required') - } - let opts = {} - let encod = 'hex' - switch (typeof encoding) { - case 'function': - cb = encoding - encod = utils.guessEncoding(input) - break - case 'object': - opts = utils.extend({}, encoding) - encod = (opts.encoding != null) ? - opts.encoding : utils.guessEncoding(input) - delete opts.encoding - break - default: - encod = (encoding != null) ? encoding : 'hex' - } - const bs = new NoFilter - const d = new Diagnose(opts) - let p = null - if (typeof cb === 'function') { - d.on('end', () => cb(null, bs.toString('utf8'))) - d.on('error', cb) - } else { - p = new Promise((resolve, reject) => { - d.on('end', () => resolve(bs.toString('utf8'))) - return d.on('error', reject) - }) - } - d.pipe(bs) - d.end(input, encod) - return p - } - - _on_error(er) { - if (this.stream_errors) { - return this.push(er.toString()) - } else { - return this.emit('error', er) - } - } - - _on_more(mt, len, parent_mt, pos) { - if (mt === MT.SIMPLE_FLOAT) { - return this.float_bytes = (function() { - switch (len) { - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - } - })() - } - } - - _fore(parent_mt, pos) { - switch (parent_mt) { - case MT.BYTE_STRING: - case MT.UTF8_STRING: - case MT.ARRAY: - if (pos > 0) { - return this.push(', ') - } - break - case MT.MAP: - if (pos > 0) { - if (pos % 2) { - return this.push(': ') - } else { - return this.push(', ') - } - } - } - } - - _on_value(val, parent_mt, pos) { - if (val === SYMS.BREAK) { - return - } - this._fore(parent_mt, pos) - return this.push((function() { - switch (false) { - case val !== SYMS.NULL: - return 'null' - case val !== SYMS.UNDEFINED: - return 'undefined' - case typeof val !== 'string': - return JSON.stringify(val) - case !(this.float_bytes > 0): - const fb = this.float_bytes - this.float_bytes = -1 - return (util.inspect(val)) + '_' + fb - case !Buffer.isBuffer(val): - return 'h\'' + (val.toString('hex')) + '\'' - case !(val instanceof bignumber): - return val.toString() - default: - return util.inspect(val) - } - }).call(this)) - } - - _on_start(mt, tag, parent_mt, pos) { - this._fore(parent_mt, pos) - this.push((function() { - switch (mt) { - case MT.TAG: - return tag + '(' - case MT.ARRAY: - return '[' - case MT.MAP: - return '{' - case MT.BYTE_STRING: - case MT.UTF8_STRING: - return '(' - default: - // istanbul ignore next - throw new Error('Unknown diagnostic type: ' + mt) - } - })()) - if (tag === SYMS.STREAM) { - return this.push('_ ') - } - } - - _on_stop(mt) { - return this.push((function() { - switch (mt) { - case MT.TAG: - return ')' - case MT.ARRAY: - return ']' - case MT.MAP: - return '}' - case MT.BYTE_STRING: - case MT.UTF8_STRING: - return ')' - default: - // istanbul ignore next - throw new Error('Unknown diagnostic type: ' + mt) - } - })()) - } - - _on_data() { - return this.push(this.separator) - } -} - -module.exports = Diagnose - -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":47,"./constants":9,"./decoder":10,"./simple":14,"./utils":16,"bignumber.js":3,"nofilter":50,"stream":72,"util":78}],12:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const stream = require('stream') -const url = require('url') -const bignumber = require('bignumber.js') -const NoFilter = require('nofilter') -const Tagged = require('./tagged') -const Simple = require('./simple') -const utils = require('./utils') - -const constants = require('./constants') -const MT = constants.MT -const NUMBYTES = constants.NUMBYTES -const SHIFT32 = constants.SHIFT32 -const SYMS = constants.SYMS -const TAG = constants.TAG -const HALF = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.TWO -const FLOAT = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.FOUR -const DOUBLE = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.EIGHT -const TRUE = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.TRUE -const FALSE = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.FALSE -const UNDEFINED = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.UNDEFINED -const NULL = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.NULL - -const MAXINT_BN = new bignumber('0x20000000000000') -const BUF_NAN = Buffer.from('f97e00', 'hex') -const BUF_INF_NEG = Buffer.from('f9fc00', 'hex') -const BUF_INF_POS = Buffer.from('f97c00', 'hex') -const BUF_NEG_ZERO = Buffer.from('f98000', 'hex') -const LOOP_DETECT = Symbol('CBOR_LOOP_DETECT') - -/** - * Transform JavaScript values into CBOR bytes. The `Writable` side of - * the stream is in object mode. - * - * @extends {stream.Transform} - */ -class Encoder extends stream.Transform { - - /** - * Creates an instance of Encoder. - * - * @param {Object} [options={}] - options for the encoder - * @param {any[]} [options.genTypes=[]] - array of pairs of `type`, - * `function(Encoder)` for semantic types to be encoded. Not needed - * for Array, Date, Buffer, Map, RegExp, Set, Url, or bignumber. - * @param {boolean} [options.canonical=false] - should the output be - * canonicalized - * @param {boolean|Symbol} [options.detectLoops=false] - should object loops - * be detected? This will currently modify the encoded object graph - * by adding a Symbol property to each object. If this bothers you, - * call `removeLoopDetectors` on the encoded object when done. Do not - * encode the same object twice on the same encoder, without calling - * `removeLoopDetectors` in between. - * @param {("number"|"float"|"int"|"string")} [options.dateType="number"] - - * how should dates be encoded? "number" means float or int, if no - * fractional seconds. - */ - constructor(options) { - options = options || {} - options.readableObjectMode = false - options.writableObjectMode = true - super(options) - - this.canonical = options.canonical - this.dateType = (options.dateType != null) ? - options.dateType.toLowerCase() : 'number' - - // new Symbol for each instance. Note: means we can't re-use the same - // encoder and encoded object - if (typeof(options.detectLoops) === 'symbol') { - this.detectLoops = options.detectLoops - } else { - this.detectLoops = !!options.detectLoops ? Symbol('CBOR_DETECT') : null - } - - this.semanticTypes = [ - Array, this._pushArray, - Date, this._pushDate, - Buffer, this._pushBuffer, - Map, this._pushMap, - NoFilter, this._pushNoFilter, - RegExp, this._pushRegexp, - Set, this._pushSet, - url.Url, this._pushUrl, - bignumber, this._pushBigNumber - ] - - const addTypes = options.genTypes || [] - for (let i = 0, len = addTypes.length; i < len; i += 2) { - this.addSemanticType(addTypes[i], addTypes[i + 1]) - } - } - - _transform(fresh, encoding, cb) { - const ret = this.pushAny(fresh) - // Old transformers might not return bool. undefined !== false - return cb((ret === false) ? new Error('Push Error') : undefined) - } - - _flush(cb) { - return cb() - } - - /** - * @callback encodeFunction - * @param {Encoder} encoder - the encoder to serialize into. Call "write" - * on the encoder as needed. - * @return {bool} - true on success, else false - */ - - /** - * Add an encoding function to the list of supported semantic types. This is - * useful for objects for which you can't add an encodeCBOR method - * - * @param {any} type - * @param {any} fun - * @returns {encodeFunction} - */ - addSemanticType(type, fun) { - for (let i = 0, len = this.semanticTypes.length; i < len; i += 2) { - const typ = this.semanticTypes[i] - if (typ === type) { - const old = this.semanticTypes[i + 1] - this.semanticTypes[i + 1] = fun - return old - } - } - this.semanticTypes.push(type, fun) - return null - } - - _pushUInt8(val) { - const b = Buffer.allocUnsafe(1) - b.writeUInt8(val) - return this.push(b) - } - - _pushUInt16BE(val) { - const b = Buffer.allocUnsafe(2) - b.writeUInt16BE(val) - return this.push(b) - } - - _pushUInt32BE(val) { - const b = Buffer.allocUnsafe(4) - b.writeUInt32BE(val) - return this.push(b) - } - - _pushDoubleBE(val) { - const b = Buffer.allocUnsafe(8) - b.writeDoubleBE(val) - return this.push(b) - } - - _pushNaN() { - return this.push(BUF_NAN) - } - - _pushInfinity(obj) { - const half = (obj < 0) ? BUF_INF_NEG : BUF_INF_POS - return this.push(half) - } - - _pushFloat(obj) { - if (this.canonical) { - // TODO: is this enough slower to hide behind canonical? - // It's certainly enough of a hack (see utils.parseHalf) - - // From section 3.9: - // If a protocol allows for IEEE floats, then additional canonicalization - // rules might need to be added. One example rule might be to have all - // floats start as a 64-bit float, then do a test conversion to a 32-bit - // float; if the result is the same numeric value, use the shorter value - // and repeat the process with a test conversion to a 16-bit float. (This - // rule selects 16-bit float for positive and negative Infinity as well.) - - // which seems pretty much backwards to me. - const b2 = Buffer.allocUnsafe(2) - if (utils.writeHalf(b2, obj)) { - if (utils.parseHalf(b2) === obj) { - return this._pushUInt8(HALF) && this.push(b2) - } - } - const b4 = Buffer.allocUnsafe(4) - b4.writeFloatBE(obj) - if (b4.readFloatBE(0) === obj) { - return this._pushUInt8(FLOAT) && this.push(b4) - } - } - - return this._pushUInt8(DOUBLE) && this._pushDoubleBE(obj) - } - - _pushInt(obj, mt, orig) { - const m = mt << 5 - switch (false) { - case !(obj < 24): - return this._pushUInt8(m | obj) - case !(obj <= 0xff): - return this._pushUInt8(m | NUMBYTES.ONE) && this._pushUInt8(obj) - case !(obj <= 0xffff): - return this._pushUInt8(m | NUMBYTES.TWO) && this._pushUInt16BE(obj) - case !(obj <= 0xffffffff): - return this._pushUInt8(m | NUMBYTES.FOUR) && this._pushUInt32BE(obj) - case !(obj <= Number.MAX_SAFE_INTEGER): - return this._pushUInt8(m | NUMBYTES.EIGHT) && - this._pushUInt32BE(Math.floor(obj / SHIFT32)) && - this._pushUInt32BE(obj % SHIFT32) - default: - if (mt === MT.NEG_INT) { - return this._pushFloat(orig) - } else { - return this._pushFloat(obj) - } - } - } - - _pushIntNum(obj) { - if (Object.is(obj, -0)) { - return this.push(BUF_NEG_ZERO) - } - - if (obj < 0) { - return this._pushInt(-obj - 1, MT.NEG_INT, obj) - } else { - return this._pushInt(obj, MT.POS_INT) - } - } - - _pushNumber(obj) { - switch (false) { - case !isNaN(obj): - return this._pushNaN(obj) - case isFinite(obj): - return this._pushInfinity(obj) - case Math.round(obj) !== obj: - return this._pushIntNum(obj) - default: - return this._pushFloat(obj) - } - } - - _pushString(obj) { - const len = Buffer.byteLength(obj, 'utf8') - return this._pushInt(len, MT.UTF8_STRING) && this.push(obj, 'utf8') - } - - _pushBoolean(obj) { - return this._pushUInt8(obj ? TRUE : FALSE) - } - - _pushUndefined(obj) { - return this._pushUInt8(UNDEFINED) - } - - _pushNull(obj) { - return this._pushUInt8(NULL) - } - - _pushArray(gen, obj) { - const len = obj.length - if (!gen._pushInt(len, MT.ARRAY)) { - return false - } - for (let j = 0; j < len; j++) { - if (!gen.pushAny(obj[j])) { - return false - } - } - return true - } - - _pushTag(tag) { - return this._pushInt(tag, MT.TAG) - } - - _pushDate(gen, obj) { - switch (gen.dateType) { - case 'string': - return gen._pushTag(TAG.DATE_STRING) && - gen._pushString(obj.toISOString()) - case 'int': - case 'integer': - return gen._pushTag(TAG.DATE_EPOCH) && - gen._pushIntNum(Math.round(obj / 1000)) - case 'float': - // force float - return gen._pushTag(TAG.DATE_EPOCH) && - gen._pushFloat(obj / 1000) - case 'number': - default: - // if we happen to have an integral number of seconds, - // use integer. Otherwise, use float. - return gen._pushTag(TAG.DATE_EPOCH) && - gen.pushAny(obj / 1000) - } - } - - _pushBuffer(gen, obj) { - return gen._pushInt(obj.length, MT.BYTE_STRING) && gen.push(obj) - } - - _pushNoFilter(gen, obj) { - return gen._pushBuffer(gen, obj.slice()) - } - - _pushRegexp(gen, obj) { - return gen._pushTag(TAG.REGEXP) && gen.pushAny(obj.source) - } - - _pushSet(gen, obj) { - if (!gen._pushInt(obj.size, MT.ARRAY)) { - return false - } - for (const x of obj) { - if (!gen.pushAny(x)) { - return false - } - } - return true - } - - _pushUrl(gen, obj) { - return gen._pushTag(TAG.URI) && gen.pushAny(obj.format()) - } - - _pushBigint(obj) { - let tag = TAG.POS_BIGINT - if (obj.isNegative()) { - obj = obj.negated().minus(1) - tag = TAG.NEG_BIGINT - } - let str = obj.toString(16) - if (str.length % 2) { - str = '0' + str - } - const buf = Buffer.from(str, 'hex') - return this._pushTag(tag) && this._pushBuffer(this, buf) - } - - _pushBigNumber(gen, obj) { - if (obj.isNaN()) { - return gen._pushNaN() - } - if (!obj.isFinite()) { - return gen._pushInfinity(obj.isNegative() ? -Infinity : Infinity) - } - if (obj.isInteger()) { - return gen._pushBigint(obj) - } - if (!(gen._pushTag(TAG.DECIMAL_FRAC) && - gen._pushInt(2, MT.ARRAY))) { - return false - } - - const dec = obj.decimalPlaces() - const slide = obj.times(new bignumber(10).pow(dec)) - if (!gen._pushIntNum(-dec)) { - return false - } - if (slide.abs().isLessThan(MAXINT_BN)) { - return gen._pushIntNum(slide.toNumber()) - } else { - return gen._pushBigint(slide) - } - } - - _pushMap(gen, obj) { - if (!gen._pushInt(obj.size, MT.MAP)) { - return false - } - // memoizing the cbor only helps in certain cases, and hurts in most - // others. Just avoid it. - if (gen.canonical) { - // keep the key/value pairs together, so we don't have to do odd - // gets with object keys later - const entries = [] - // iterator. If we drop support for node4, use ... - for (const e of obj.entries()) { - entries.push(e) - } - entries.sort((a, b) => { - // a, b are both entries of [key, value] - const a_cbor = Encoder.encode(a[0]) - const b_cbor = Encoder.encode(b[0]) - return a_cbor.compare(b_cbor) - }) - for (const kv of entries) { - if (!(gen.pushAny(kv[0]) && gen.pushAny(kv[1]))) { - return false - } - } - } else { - for (const kv of obj) { - if (!(gen.pushAny(kv[0]) && gen.pushAny(kv[1]))) { - return false - } - } - } - return true - } - - removeLoopDetectors(obj) { - if (!this.detectLoops || (typeof(obj) !== 'object') || !obj) { - return false - } - const dl = obj[LOOP_DETECT] - if (!dl || (dl !== this.detectLoops)) { - // ironically, use loop marking to detect loops on removal as well - return false - } - delete obj[LOOP_DETECT] - if (Array.isArray(obj)) { - for (const i of obj) { - this.removeLoopDetectors(i) - } - } else { - for (const k in obj) { - this.removeLoopDetectors(obj[k]) - } - } - return true - } - - _pushObject(obj) { - if (!obj) { - return this._pushNull(obj) - } - if (this.detectLoops) { - if (obj[LOOP_DETECT] === this.detectLoops) { - throw new Error('Loop detected while CBOR encoding') - } else { - obj[LOOP_DETECT] = this.detectLoops - } - } - const f = obj.encodeCBOR - if (typeof f === 'function') { - return f.call(obj, this) - } - for (let i = 0, len1 = this.semanticTypes.length; i < len1; i += 2) { - const typ = this.semanticTypes[i] - if (obj instanceof typ) { - return this.semanticTypes[i + 1].call(obj, this, obj) - } - } - const keys = Object.keys(obj) - const cbor_keys = {} - if (this.canonical) { - // note: this can't be a normal sort, because 'b' needs to sort before - // 'aa' - keys.sort((a, b) => { - // Always strings, so don't bother to pass options. - // hold on to the cbor versions, since there's no need - // to encode more than once - const a_cbor = cbor_keys[a] || (cbor_keys[a] = Encoder.encode(a)) - const b_cbor = cbor_keys[b] || (cbor_keys[b] = Encoder.encode(b)) - - return a_cbor.compare(b_cbor) - }) - } - if (!this._pushInt(keys.length, MT.MAP)) { - return false - } - let ck - for (let j = 0, len2 = keys.length; j < len2; j++) { - const k = keys[j] - if (this.canonical && ((ck = cbor_keys[k]))) { - if (!this.push(ck)) { // already a Buffer - return false - } - } else { - if (!this._pushString(k)) { - return false - } - } - if (!this.pushAny(obj[k])) { - return false - } - } - - return true - } - - /** - * Push any supported type onto the encoded stream - * - * @param {any} obj - * @returns {boolean} true on success - */ - pushAny(obj) { - switch (typeof obj) { - case 'number': - return this._pushNumber(obj) - case 'string': - return this._pushString(obj) - case 'boolean': - return this._pushBoolean(obj) - case 'undefined': - return this._pushUndefined(obj) - case 'object': - return this._pushObject(obj) - case 'symbol': - switch (obj) { - case SYMS.NULL: - return this._pushNull(null) - case SYMS.UNDEFINED: - return this._pushUndefined(void 0) - // TODO: Add pluggable support for other symbols - default: - throw new Error('Unknown symbol: ' + obj.toString()) - } - default: - throw new Error( - 'Unknown type: ' + typeof obj + ', ' + - (!!obj ? obj.toString() : '')) - } - } - - /* backwards-compat wrapper */ - _pushAny(obj) { - // TODO: write deprecation warning - return this.pushAny(obj) - } - - _encodeAll(objs) { - const bs = new NoFilter() - this.pipe(bs) - for (const o of objs) { - if (typeof o === 'undefined') { - this._pushUndefined() - } else if (o === null) { - this._pushNull(null) - } else { - this.write(o) - } - } - this.end() - return bs.read() - } - - /** - * Encode one or more JavaScript objects, and return a Buffer containing the - * CBOR bytes. - * - * @param {...any} objs - the objects to encode - * @returns {Buffer} - the encoded objects - */ - static encode() { - const objs = Array.prototype.slice.apply(arguments) - return new Encoder()._encodeAll(objs) - } - - /** - * Encode one or more JavaScript objects canonically (slower!), and return - * a Buffer containing the CBOR bytes. - * - * @param {...any} objs - the objects to encode - * @returns {Buffer} - the encoded objects - */ - static encodeCanonical() { - const objs = Array.prototype.slice.apply(arguments) - return new Encoder({canonical: true})._encodeAll(objs) - } - - /** - * Encode one JavaScript object using the given options. - * - * @static - * @param {any} obj - the object to encode - * @param {Object?} options - passed to the Encoder constructor - * @returns {Buffer} - the encoded objects - */ - static encodeOne(obj, options) { - return new Encoder(options)._encodeAll([obj]) - } -} - -module.exports = Encoder - -}).call(this,require("buffer").Buffer) -},{"./constants":9,"./simple":14,"./tagged":15,"./utils":16,"bignumber.js":3,"buffer":6,"nofilter":50,"stream":72,"url":74}],13:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const encoder = require('./encoder') -const decoder = require('./decoder') -const constants = require('./constants') -const MT = constants.MT - -/** - * Wrapper around a JavaScript Map object that allows the keys to be - * any complex type. The base Map object allows this, but will only - * compare the keys by identity, not by value. CborMap translates keys - * to CBOR first (and base64's them to ensure by-value comparison). - * - * This is not a subclass of Object, because it would be tough to get - * the semantics to be an exact match. - * - * @class CborMap - * @extends {Map} - */ -class CborMap extends Map { - /** - * Creates an instance of CborMap. - * @param {Iterable>} args An Array or other iterable object - * whose elements are key-value pairs (arrays with two elements, e.g. - * [[ 1, 'one' ],[ 2, 'two' ]]). Each key-value pair is added - * to the new CborMap; null values are treated as undefined. - */ - constructor(iterable) { - super(iterable) - } - - /** - * @private - */ - static _encode(key) { - return encoder.encodeCanonical(key).toString('base64') - } - - /** - * @private - */ - static _decode(key) { - return decoder.decodeFirstSync(key, 'base64') - } - - /** - * Retrieve a specified element. - * - * @param {any} key The key identifying the element to retrieve. - * Can be any type, which will be serialized into CBOR and compared by - * value. - * @returns {any} The element if it exists, or undefined. - */ - get(key) { - return super.get(CborMap._encode(key)) - } - - /** - * Adds or updates an element with a specified key and value. - * - * @param {any} key The key identifying the element to store. - * Can be any type, which will be serialized into CBOR and compared by - * value. - * @param {any} val The element to store - */ - set(key, val) { - return super.set(CborMap._encode(key), val) - } - - /** - * Removes the specified element. - * - * @param {any} key The key identifying the element to delete. - * Can be any type, which will be serialized into CBOR and compared by - * value. - * @returns {boolean} - */ - delete(key) { - return super.delete(CborMap._encode(key)) - } - - /** - * Does an element with the specified key exist? - * - * @param {any} key The key identifying the element to check. - * Can be any type, which will be serialized into CBOR and compared by - * value. - * @returns {boolean} - */ - has(key) { - return super.has(CborMap._encode(key)) - } - - /** - * Returns a new Iterator object that contains the keys for each element - * in the Map object in insertion order. The keys are decoded into their - * original format. - * - * @returns {Iterator} - */ - *keys() { - for (const k of super.keys()) { - yield CborMap._decode(k) - } - } - - /** - * Returns a new Iterator object that contains the [key, value] pairs for - * each element in the Map object in insertion order. - * - * @returns {Iterator.>} - */ - *entries() { - for (const kv of super.entries()) { - yield [CborMap._decode(kv[0]), kv[1]] - } - } - - /** - * Returns a new Iterator object that contains the [key, value] pairs for - * each element in the Map object in insertion order. - * - * @returns {Iterator.>} - */ - [Symbol.iterator]() { - return this.entries() - } - - /** - * Executes a provided function once per each key/value pair in the Map - * object, in insertion order. - * - * @param {function(any, any, CborMap)} fun Function to execute for each - * element, which takes a value, a key, and the Map being traversed. - * @param {any} thisArg Value to use as this when executing callback - */ - forEach(fun, thisArg) { - if (typeof(fun) !== 'function') { - throw new TypeError('Must be function') - } - for (const kv of super.entries()) { - fun.call(this, kv[1], CborMap._decode(kv[0]), this) - } - } - - /** - * Push the simple value onto the CBOR stream - * - * @param {cbor.Encoder} gen The generator to push onto - * @returns {boolean} true on success - */ - encodeCBOR(gen) { - if (!gen._pushInt(this.size, MT.MAP)) { - return false - } - if (gen.canonical) { - const entries = Array.from(super.entries()) - .map((kv) => [Buffer.from(kv[0], 'base64'), kv[1]]) - entries.sort((a, b) => a[0].compare(b[0])) - for (const kv of entries) { - if (!(gen.push(kv[0]) && gen.pushAny(kv[1]))) { - return false - } - } - } else { - for (const kv of super.entries()) { - if (!(gen.push(Buffer.from(kv[0], 'base64')) && gen.pushAny(kv[1]))) { - return false - } - } - } - return true - } -} - -module.exports = CborMap -}).call(this,require("buffer").Buffer) -},{"./constants":9,"./decoder":10,"./encoder":12,"buffer":6}],14:[function(require,module,exports){ -'use strict' - -const util = require('util') -const constants = require('./constants') -const MT = constants.MT -const SIMPLE = constants.SIMPLE -const SYMS = constants.SYMS - -/** - * A CBOR Simple Value that does not map onto a known constant. - */ -class Simple { - /** - * Creates an instance of Simple. - * - * @param {integer} value - the simple value's integer value - */ - constructor(value) { - if (typeof value !== 'number') { - throw new Error('Invalid Simple type: ' + (typeof value)) - } - if ((value < 0) || (value > 255) || ((value|0) !== value)) { - throw new Error('value must be a small positive integer: ' + value) - } - this.value = value - } - - /** - * Debug string for simple value - * - * @returns {string} simple(value) - */ - toString() { - return 'simple(' + this.value + ')' - } - - /** - * Debug string for simple value - * - * @returns {string} simple(value) - */ - [util.inspect.custom](depth, opts) { - return 'simple(' + this.value + ')' - } - - /** - * Debug string for simple value (backward-compatibility version) - * - * @returns {string} simple(value) - */ - inspect(depth, opts) { - return 'simple(' + this.value + ')' - } - - /** - * Push the simple value onto the CBOR stream - * - * @param {cbor.Encoder} gen The generator to push onto - */ - encodeCBOR(gen) { - return gen._pushInt(this.value, MT.SIMPLE_FLOAT) - } - - /** - * Is the given object a Simple? - * - * @param {any} obj - object to test - * @returns {bool} - is it Simple? - */ - static isSimple(obj) { - return obj instanceof Simple - } - - /** - * Decode from the CBOR additional information into a JavaScript value. - * If the CBOR item has no parent, return a "safe" symbol instead of - * `null` or `undefined`, so that the value can be passed through a - * stream in object mode. - * - * @param {number} val - the CBOR additional info to convert - * @param {bool} has_parent - Does the CBOR item have a parent? - * @returns {(null|undefined|bool|Symbol)} - the decoded value - */ - static decode(val, has_parent) { - if (has_parent == null) { - has_parent = true - } - switch (val) { - case SIMPLE.FALSE: - return false - case SIMPLE.TRUE: - return true - case SIMPLE.NULL: - if (has_parent) { - return null - } else { - return SYMS.NULL - } - case SIMPLE.UNDEFINED: - if (has_parent) { - return void 0 - } else { - return SYMS.UNDEFINED - } - case -1: - if (!has_parent) { - throw new Error('Invalid BREAK') - } - return SYMS.BREAK - default: - return new Simple(val) - } - } -} - -module.exports = Simple - -},{"./constants":9,"util":78}],15:[function(require,module,exports){ -'use strict' - -const bignumber = require('bignumber.js') -const utils = require('./utils') -const url = require('url') - -const MINUS_ONE = new bignumber(-1) -const TEN = new bignumber(10) -const TWO = new bignumber(2) - -/** - * A CBOR tagged item, where the tag does not have semantics specified at the - * moment, or those semantics threw an error during parsing. Typically this will - * be an extension point you're not yet expecting. - */ -class Tagged { - - /** - * Creates an instance of Tagged. - * - * @param {number} tag - the number of the tag - * @param {any} value - the value inside the tag - * @param {Error} err - the error that was thrown parsing the tag, or null - */ - constructor(tag, value, err) { - this.tag = tag - this.value = value - this.err = err - if (typeof this.tag !== 'number') { - throw new Error('Invalid tag type (' + (typeof this.tag) + ')') - } - if ((this.tag < 0) || ((this.tag | 0) !== this.tag)) { - throw new Error('Tag must be a positive integer: ' + this.tag) - } - } - - /** - * Convert to a String - * - * @returns {string} string of the form '1(2)' - */ - toString() { - return `${this.tag}(${JSON.stringify(this.value)})` - } - - /** - * Push the simple value onto the CBOR stream - * - * @param {cbor.Encoder} gen The generator to push onto - */ - encodeCBOR(gen) { - gen._pushTag(this.tag) - return gen.pushAny(this.value) - } - - /** - * If we have a converter for this type, do the conversion. Some converters - * are built-in. Additional ones can be passed in. If you want to remove - * a built-in converter, pass a converter in whose value is 'null' instead - * of a function. - * - * @param {Object} converters - keys in the object are a tag number, the value - * is a function that takes the decoded CBOR and returns a JavaScript value - * of the appropriate type. Throw an exception in the function on errors. - * @returns {any} - the converted item - */ - convert(converters) { - let f = converters != null ? converters[this.tag] : void 0 - if (typeof f !== 'function') { - f = Tagged['_tag_' + this.tag] - if (typeof f !== 'function') { - return this - } - } - try { - return f.call(Tagged, this.value) - } catch (error) { - this.err = error - return this - } - } - - static _tag_0(v) { - return new Date(v) - } - - static _tag_1(v) { - return new Date(v * 1000) - } - - static _tag_2(v) { - return utils.bufferToBignumber(v) - } - - static _tag_3(v) { - return MINUS_ONE.minus(utils.bufferToBignumber(v)) - } - - static _tag_4(v) { - return TEN.pow(v[0]).times(v[1]) - } - - static _tag_5(v) { - return TWO.pow(v[0]).times(v[1]) - } - - static _tag_32(v) { - return url.parse(v) - } - - static _tag_35(v) { - return new RegExp(v) - } -} - -module.exports = Tagged - -},{"./utils":16,"bignumber.js":3,"url":74}],16:[function(require,module,exports){ -(function (process,Buffer){ -'use strict' - -const fs = require('fs') -const stream = require('stream') -const bignumber = require('bignumber.js') - -const constants = require('./constants') -const NUMBYTES = constants.NUMBYTES -const SHIFT32 = constants.SHIFT32 -const MAX_SAFE_HIGH = 0x1fffff - -exports.parseCBORint = function(ai, buf) { - switch (ai) { - case NUMBYTES.ONE: - return buf.readUInt8(0) - case NUMBYTES.TWO: - return buf.readUInt16BE(0) - case NUMBYTES.FOUR: - return buf.readUInt32BE(0) - case NUMBYTES.EIGHT: - const f = buf.readUInt32BE(0) - const g = buf.readUInt32BE(4) - if (f > MAX_SAFE_HIGH) { - return new bignumber(f).times(SHIFT32).plus(g) - } else { - return (f * SHIFT32) + g - } - default: - throw new Error('Invalid additional info for int: ' + ai) - } -} - -exports.writeHalf = function writeHalf(buf, half) { - // assume 0, -0, NaN, Infinity, and -Infinity have already been caught - - // HACK: everyone settle in. This isn't going to be pretty. - // Translate cn-cbor's C code (from Carsten Borman): - - // uint32_t be32; - // uint16_t be16, u16; - // union { - // float f; - // uint32_t u; - // } u32; - // u32.f = float_val; - - const u32 = Buffer.allocUnsafe(4) - u32.writeFloatBE(half) - const u = u32.readUInt32BE(0) - - // if ((u32.u & 0x1FFF) == 0) { /* worth trying half */ - - // hildjj: If the lower 13 bits are 0, - // we won't lose anything in the conversion - if ((u & 0x1FFF) !== 0) { - return false - } - - // int s16 = (u32.u >> 16) & 0x8000; - // int exp = (u32.u >> 23) & 0xff; - // int mant = u32.u & 0x7fffff; - - let s16 = (u >> 16) & 0x8000 // top bit is sign - const exp = (u >> 23) & 0xff // then 5 bits of exponent - const mant = u & 0x7fffff - - // if (exp == 0 && mant == 0) - // ; /* 0.0, -0.0 */ - - // hildjj: zeros already handled. Assert if you don't believe me. - - // else if (exp >= 113 && exp <= 142) /* normalized */ - // s16 += ((exp - 112) << 10) + (mant >> 13); - - if ((exp >= 113) && (exp <= 142)) { - s16 += ((exp - 112) << 10) + (mant >> 13) - } else if ((exp >= 103) && (exp < 113)) { - // else if (exp >= 103 && exp < 113) { /* denorm, exp16 = 0 */ - // if (mant & ((1 << (126 - exp)) - 1)) - // goto float32; /* loss of precision */ - // s16 += ((mant + 0x800000) >> (126 - exp)); - - if (mant & ((1 << (126 - exp)) - 1)) { - return false - } - s16 += ((mant + 0x800000) >> (126 - exp)) - } else { - // } else if (exp == 255 && mant == 0) { /* Inf */ - // s16 += 0x7c00; - - // hildjj: Infinity already handled - - // } else - // goto float32; /* loss of range */ - - return false - } - - // ensure_writable(3); - // u16 = s16; - // be16 = hton16p((const uint8_t*)&u16); - buf.writeUInt16BE(s16) - return true -} - -exports.parseHalf = function parseHalf(buf) { - const sign = buf[0] & 0x80 ? -1 : 1 - const exp = (buf[0] & 0x7C) >> 2 - const mant = ((buf[0] & 0x03) << 8) | buf[1] - if (!exp) { - return sign * 5.9604644775390625e-8 * mant - } else if (exp === 0x1f) { - return sign * (mant ? 0 / 0 : 2e308) - } else { - return sign * Math.pow(2, exp - 25) * (1024 + mant) - } -} - -exports.parseCBORfloat = function parseCBORfloat(buf) { - switch (buf.length) { - case 2: - return exports.parseHalf(buf) - case 4: - return buf.readFloatBE(0) - case 8: - return buf.readDoubleBE(0) - default: - throw new Error('Invalid float size: ' + buf.length) - } -} - -exports.hex = function hex(s) { - return Buffer.from(s.replace(/^0x/, ''), 'hex') -} - -exports.bin = function bin(s) { - s = s.replace(/\s/g, '') - let start = 0 - let end = (s.length % 8) || 8 - const chunks = [] - while (end <= s.length) { - chunks.push(parseInt(s.slice(start, end), 2)) - start = end - end += 8 - } - return Buffer.from(chunks) -} - -exports.extend = function extend() { - let old = arguments[0] - const adds = (2 <= arguments.length) ? - Array.prototype.slice.call(arguments, 1) : [] - const len = adds.length - if (old == null) { - old = {} - } - for (let j = 0; j < len; j++) { - const a = adds[j] - for (const k in a) { - const v = a[k] - old[k] = v - } - } - return old -} - -exports.arrayEqual = function arrayEqual(a, b) { - if ((a == null) && (b == null)) { - return true - } - if ((a == null) || (b == null)) { - return false - } - return (a.length === b.length) && a.every((elem, i) => elem === b[i]) -} - -exports.bufferEqual = function bufferEqual(a, b) { - if ((a == null) && (b == null)) { - return true - } - if ((a == null) || (b == null)) { - return false - } - if (!(Buffer.isBuffer(a) && Buffer.isBuffer(b) && (a.length === b.length))) { - return false - } - const len = a.length - let ret = true - let i - let j - for (i = j = 0; j < len; i = ++j) { - const byte = a[i] - ret &= b[i] === byte - } - return !!ret -} - -exports.bufferToBignumber = function bufferToBignumber(buf) { - return new bignumber(buf.toString('hex'), 16) -} - -exports.DeHexStream = class DeHexStream extends stream.Readable { - constructor(hex) { - super() - hex = hex.replace(/^0x/, '') - if (hex) { - this.push(Buffer.from(hex, 'hex')) - } - this.push(null) - } -} - -exports.HexStream = class HexStream extends stream.Transform { - constructor(options) { - super(options) - } - - _transform(fresh, encoding, cb) { - this.push(fresh.toString('hex')) - return cb() - } -} - -function printError(er) { - if (er != null) { - return console.log(er) - } -} - -exports.streamFiles = function streamFiles(files, streamFunc, cb) { - if (cb == null) { - cb = printError - } - const f = files.shift() - if (!f) { - return cb() - } - const sf = streamFunc() - sf.on('end', () => exports.streamFiles(files, streamFunc, cb)) - sf.on('error', cb) - const s = (f === '-') ? - process.stdin : (f instanceof stream.Stream) ? f : fs.createReadStream(f) - s.on('error', cb) - return s.pipe(sf) -} - -exports.guessEncoding = function guessEncoding(input) { - switch (false) { - case typeof input !== 'string': - return 'hex' - case !Buffer.isBuffer(input): - return undefined - default: - throw new Error('Unknown input type') - } -} - -}).call(this,require('_process'),require("buffer").Buffer) -},{"./constants":9,"_process":52,"bignumber.js":3,"buffer":6,"fs":4,"stream":72}],17:[function(require,module,exports){ -// Tweaked version of nathan7's binary-parse-stream -// (see https://github.com/nathan7/binary-parse-stream) -// Uses NoFilter instead of the readable in the original. Removes -// the ability to read -1, which was odd and un-needed. -// License for binary-parse-stream: MIT - -'use strict'; -exports = module.exports = BinaryParseStream -var Stream = require('stream') - , TransformStream = Stream.Transform - , inherits = require('util').inherits - , NoFilter = require('nofilter') - -exports.One = -1 - -inherits(BinaryParseStream, TransformStream) -function BinaryParseStream(options) { - TransformStream.call(this, options) - this._writableState.objectMode = false - this._readableState.objectMode = true - - this.bs = new NoFilter() - this.__restart() -} - -BinaryParseStream.prototype._transform = function(fresh, encoding, cb) { var self = this - this.bs.write(fresh) - - while (this.bs.length >= this.__needed) { - var ret - , chunk = this.__needed === null - ? undefined - : this.bs.read(this.__needed) - - try { ret = this.__parser.next(chunk) } - catch (e) { - return cb(e) } - - if (this.__needed) - this.__fresh = false - - if (!ret.done) - this.__needed = ret.value | 0 - else { - this.push(ret.value) - this.__restart() - } - } - - return cb() -} - -BinaryParseStream.prototype.__restart = function() { - this.__needed = null - this.__parser = this._parse() - this.__fresh = true -} - -BinaryParseStream.prototype._flush = function(cb) { - cb(this.__fresh - ? null - : new Error('unexpected end of input')) -} - -},{"nofilter":50,"stream":72,"util":78}],18:[function(require,module,exports){ -(function (Buffer){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// NOTE: These type checking functions intentionally don't use `instanceof` -// because it is fragile and can be easily faked with `Object.create()`. - -function isArray(arg) { - if (Array.isArray) { - return Array.isArray(arg); - } - return objectToString(arg) === '[object Array]'; -} -exports.isArray = isArray; - -function isBoolean(arg) { - return typeof arg === 'boolean'; -} -exports.isBoolean = isBoolean; - -function isNull(arg) { - return arg === null; -} -exports.isNull = isNull; - -function isNullOrUndefined(arg) { - return arg == null; -} -exports.isNullOrUndefined = isNullOrUndefined; - -function isNumber(arg) { - return typeof arg === 'number'; -} -exports.isNumber = isNumber; - -function isString(arg) { - return typeof arg === 'string'; -} -exports.isString = isString; - -function isSymbol(arg) { - return typeof arg === 'symbol'; -} -exports.isSymbol = isSymbol; - -function isUndefined(arg) { - return arg === void 0; -} -exports.isUndefined = isUndefined; - -function isRegExp(re) { - return objectToString(re) === '[object RegExp]'; -} -exports.isRegExp = isRegExp; - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} -exports.isObject = isObject; - -function isDate(d) { - return objectToString(d) === '[object Date]'; -} -exports.isDate = isDate; - -function isError(e) { - return (objectToString(e) === '[object Error]' || e instanceof Error); -} -exports.isError = isError; - -function isFunction(arg) { - return typeof arg === 'function'; -} -exports.isFunction = isFunction; - -function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; -} -exports.isPrimitive = isPrimitive; - -exports.isBuffer = Buffer.isBuffer; - -function objectToString(o) { - return Object.prototype.toString.call(o); -} - -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":47}],19:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc1').default; - -},{"./es6/crc1":30}],20:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16').default; - -},{"./es6/crc16":31}],21:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16ccitt').default; - -},{"./es6/crc16ccitt":32}],22:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16kermit').default; - -},{"./es6/crc16kermit":33}],23:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16modbus').default; - -},{"./es6/crc16modbus":34}],24:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16xmodem').default; - -},{"./es6/crc16xmodem":35}],25:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc24').default; - -},{"./es6/crc24":36}],26:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc32').default; - -},{"./es6/crc32":37}],27:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc8').default; - -},{"./es6/crc8":38}],28:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc81wire').default; - -},{"./es6/crc81wire":39}],29:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crcjam').default; - -},{"./es6/crcjam":40}],30:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var crc1 = (0, _define_crc2.default)('crc1', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = ~~previous; - var accum = 0; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - accum += byte; - } - - crc += accum % 256; - return crc % 256; -}); - -exports.default = crc1; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],31:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c` -// prettier-ignore -var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc16 = (0, _define_crc2.default)('crc-16', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = ~~previous; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; - } - - return crc; -}); - -exports.default = crc16; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],32:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=ccitt --generate=c` -// prettier-ignore -var TABLE = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc16ccitt = (0, _define_crc2.default)('ccitt', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc >> 8 ^ byte) & 0xff] ^ crc << 8) & 0xffff; - } - - return crc; -}); - -exports.default = crc16ccitt; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],33:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c` -// prettier-ignore -var TABLE = [0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc16kermit = (0, _define_crc2.default)('kermit', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0x0000; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; - } - - return crc; -}); - -exports.default = crc16kermit; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],34:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16-modbus --generate=c` -// prettier-ignore -var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc16modbus = (0, _define_crc2.default)('crc-16-modbus', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; - } - - return crc; -}); - -exports.default = crc16modbus; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],35:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var crc16xmodem = (0, _define_crc2.default)('xmodem', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0x0; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - var code = crc >>> 8 & 0xff; - - code ^= byte & 0xff; - code ^= code >>> 4; - crc = crc << 8 & 0xffff; - crc ^= code; - code = code << 5 & 0xffff; - crc ^= code; - code = code << 7 & 0xffff; - crc ^= code; - } - - return crc; -}); - -exports.default = crc16xmodem; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],36:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-drive --model=crc-24 --generate=c` -// prettier-ignore -var TABLE = [0x000000, 0x864cfb, 0x8ad50d, 0x0c99f6, 0x93e6e1, 0x15aa1a, 0x1933ec, 0x9f7f17, 0xa18139, 0x27cdc2, 0x2b5434, 0xad18cf, 0x3267d8, 0xb42b23, 0xb8b2d5, 0x3efe2e, 0xc54e89, 0x430272, 0x4f9b84, 0xc9d77f, 0x56a868, 0xd0e493, 0xdc7d65, 0x5a319e, 0x64cfb0, 0xe2834b, 0xee1abd, 0x685646, 0xf72951, 0x7165aa, 0x7dfc5c, 0xfbb0a7, 0x0cd1e9, 0x8a9d12, 0x8604e4, 0x00481f, 0x9f3708, 0x197bf3, 0x15e205, 0x93aefe, 0xad50d0, 0x2b1c2b, 0x2785dd, 0xa1c926, 0x3eb631, 0xb8faca, 0xb4633c, 0x322fc7, 0xc99f60, 0x4fd39b, 0x434a6d, 0xc50696, 0x5a7981, 0xdc357a, 0xd0ac8c, 0x56e077, 0x681e59, 0xee52a2, 0xe2cb54, 0x6487af, 0xfbf8b8, 0x7db443, 0x712db5, 0xf7614e, 0x19a3d2, 0x9fef29, 0x9376df, 0x153a24, 0x8a4533, 0x0c09c8, 0x00903e, 0x86dcc5, 0xb822eb, 0x3e6e10, 0x32f7e6, 0xb4bb1d, 0x2bc40a, 0xad88f1, 0xa11107, 0x275dfc, 0xdced5b, 0x5aa1a0, 0x563856, 0xd074ad, 0x4f0bba, 0xc94741, 0xc5deb7, 0x43924c, 0x7d6c62, 0xfb2099, 0xf7b96f, 0x71f594, 0xee8a83, 0x68c678, 0x645f8e, 0xe21375, 0x15723b, 0x933ec0, 0x9fa736, 0x19ebcd, 0x8694da, 0x00d821, 0x0c41d7, 0x8a0d2c, 0xb4f302, 0x32bff9, 0x3e260f, 0xb86af4, 0x2715e3, 0xa15918, 0xadc0ee, 0x2b8c15, 0xd03cb2, 0x567049, 0x5ae9bf, 0xdca544, 0x43da53, 0xc596a8, 0xc90f5e, 0x4f43a5, 0x71bd8b, 0xf7f170, 0xfb6886, 0x7d247d, 0xe25b6a, 0x641791, 0x688e67, 0xeec29c, 0x3347a4, 0xb50b5f, 0xb992a9, 0x3fde52, 0xa0a145, 0x26edbe, 0x2a7448, 0xac38b3, 0x92c69d, 0x148a66, 0x181390, 0x9e5f6b, 0x01207c, 0x876c87, 0x8bf571, 0x0db98a, 0xf6092d, 0x7045d6, 0x7cdc20, 0xfa90db, 0x65efcc, 0xe3a337, 0xef3ac1, 0x69763a, 0x578814, 0xd1c4ef, 0xdd5d19, 0x5b11e2, 0xc46ef5, 0x42220e, 0x4ebbf8, 0xc8f703, 0x3f964d, 0xb9dab6, 0xb54340, 0x330fbb, 0xac70ac, 0x2a3c57, 0x26a5a1, 0xa0e95a, 0x9e1774, 0x185b8f, 0x14c279, 0x928e82, 0x0df195, 0x8bbd6e, 0x872498, 0x016863, 0xfad8c4, 0x7c943f, 0x700dc9, 0xf64132, 0x693e25, 0xef72de, 0xe3eb28, 0x65a7d3, 0x5b59fd, 0xdd1506, 0xd18cf0, 0x57c00b, 0xc8bf1c, 0x4ef3e7, 0x426a11, 0xc426ea, 0x2ae476, 0xaca88d, 0xa0317b, 0x267d80, 0xb90297, 0x3f4e6c, 0x33d79a, 0xb59b61, 0x8b654f, 0x0d29b4, 0x01b042, 0x87fcb9, 0x1883ae, 0x9ecf55, 0x9256a3, 0x141a58, 0xefaaff, 0x69e604, 0x657ff2, 0xe33309, 0x7c4c1e, 0xfa00e5, 0xf69913, 0x70d5e8, 0x4e2bc6, 0xc8673d, 0xc4fecb, 0x42b230, 0xddcd27, 0x5b81dc, 0x57182a, 0xd154d1, 0x26359f, 0xa07964, 0xace092, 0x2aac69, 0xb5d37e, 0x339f85, 0x3f0673, 0xb94a88, 0x87b4a6, 0x01f85d, 0x0d61ab, 0x8b2d50, 0x145247, 0x921ebc, 0x9e874a, 0x18cbb1, 0xe37b16, 0x6537ed, 0x69ae1b, 0xefe2e0, 0x709df7, 0xf6d10c, 0xfa48fa, 0x7c0401, 0x42fa2f, 0xc4b6d4, 0xc82f22, 0x4e63d9, 0xd11cce, 0x575035, 0x5bc9c3, 0xdd8538]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc24 = (0, _define_crc2.default)('crc-24', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0xb704ce; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc >> 16 ^ byte) & 0xff] ^ crc << 8) & 0xffffff; - } - - return crc; -}); - -exports.default = crc24; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],37:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c` -// prettier-ignore -var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc32 = (0, _define_crc2.default)('crc-32', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = previous === 0 ? 0 : ~~previous ^ -1; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; - } - - return crc ^ -1; -}); - -exports.default = crc32; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],38:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=crc-8 --generate=c` -// prettier-ignore -var TABLE = [0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc8 = (0, _define_crc2.default)('crc-8', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = ~~previous; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = TABLE[(crc ^ byte) & 0xff] & 0xff; - } - - return crc; -}); - -exports.default = crc8; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],39:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c` -// prettier-ignore -var TABLE = [0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62, 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff, 0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07, 0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a, 0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24, 0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9, 0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd, 0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50, 0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee, 0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73, 0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5, 0x8b, 0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16, 0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8, 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc81wire = (0, _define_crc2.default)('dallas-1-wire', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = ~~previous; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = TABLE[(crc ^ byte) & 0xff] & 0xff; - } - - return crc; -}); - -exports.default = crc81wire; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],40:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=jam --generate=c` -// prettier-ignore -var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crcjam = (0, _define_crc2.default)('jam', function (buf) { - var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; - - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = previous === 0 ? 0 : ~~previous; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; - } - - return crc; -}); - -exports.default = crcjam; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],41:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var createBuffer = _buffer.Buffer.from && _buffer.Buffer.alloc && _buffer.Buffer.allocUnsafe && _buffer.Buffer.allocUnsafeSlow ? _buffer.Buffer.from : // support for Node < 5.10 -function (val) { - return new _buffer.Buffer(val); -}; - -exports.default = createBuffer; - -},{"buffer":6}],42:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (model, calc) { - var fn = function fn(buf, previous) { - return calc(buf, previous) >>> 0; - }; - fn.signed = calc; - fn.unsigned = fn; - fn.model = model; - - return fn; -}; - -},{}],43:[function(require,module,exports){ -'use strict'; - -module.exports = { - crc1: require('./crc1'), - crc8: require('./crc8'), - crc81wire: require('./crc8_1wire'), - crc16: require('./crc16'), - crc16ccitt: require('./crc16_ccitt'), - crc16modbus: require('./crc16_modbus'), - crc16xmodem: require('./crc16_xmodem'), - crc16kermit: require('./crc16_kermit'), - crc24: require('./crc24'), - crc32: require('./crc32'), - crcjam: require('./crcjam') -}; - -},{"./crc1":19,"./crc16":20,"./crc16_ccitt":21,"./crc16_kermit":22,"./crc16_modbus":23,"./crc16_xmodem":24,"./crc24":25,"./crc32":26,"./crc8":27,"./crc8_1wire":28,"./crcjam":29}],44:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; - -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; - -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; - -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; -} - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} - -function isUndefined(arg) { - return arg === void 0; -} - -},{}],45:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} - -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} - -},{}],46:[function(require,module,exports){ -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} - -},{}],47:[function(require,module,exports){ -/*! - * Determine if an object is a Buffer - * - * @author Feross Aboukhadijeh - * @license MIT - */ - -// The _isBuffer check is for Safari 5-7 support, because it's missing -// Object.prototype.constructor. Remove this eventually -module.exports = function (obj) { - return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) -} - -function isBuffer (obj) { - return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) -} - -// For Node v0.10 support. Remove this eventually. -function isSlowBuffer (obj) { - return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) -} - -},{}],48:[function(require,module,exports){ -var toString = {}.toString; - -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; -}; - -},{}],49:[function(require,module,exports){ -/* - A JavaScript implementation of the SHA family of hashes, as - defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding - HMAC implementation as defined in FIPS PUB 198a - - Copyright Brian Turek 2008-2017 - Distributed under the BSD License - See http://caligatio.github.com/jsSHA/ for more information - - Several functions taken from Paul Johnston -*/ -'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; -b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> -5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); -}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> -6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); -if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, -"");if(-1!==k&&k 0) && (om !== _this._readableState.objectMode)) { - throw new Error('Do not switch objectMode in the middle of the stream'); - } - _this._readableState.objectMode = om; - return _this._writableState.objectMode = om; - }; - })(this)); - } - if (inp != null) { - this.end(inp, inpE); - } - } - - NoFilter.isNoFilter = function(obj) { - return obj instanceof this; - }; - - NoFilter.compare = function(nf1, nf2) { - if (!(nf1 instanceof this)) { - throw new TypeError('Arguments must be NoFilters'); - } - if (nf1 === nf2) { - return 0; - } else { - return nf1.compare(nf2); - } - }; - - NoFilter.concat = function(list, length) { - var bufs; - if (!Array.isArray(list)) { - throw new TypeError('list argument must be an Array of NoFilters'); - } - if ((list.length === 0) || (length === 0)) { - return new Buffer(0); - } - if (length == null) { - length = list.reduce(function(tot, nf) { - if (!(nf instanceof NoFilter)) { - throw new TypeError('list argument must be an Array of NoFilters'); - } - return tot + nf.length; - }, 0); - } - bufs = list.map(function(nf) { - if (!(nf instanceof NoFilter)) { - throw new TypeError('list argument must be an Array of NoFilters'); - } - if (nf._readableState.objectMode) { - throw new Error('NoFilter may not be in object mode for concat'); - } - return nf.slice(); - }); - return Buffer.concat(bufs, length); - }; - - NoFilter.prototype._transform = function(chunk, encoding, callback) { - if (!this._readableState.objectMode && !Buffer.isBuffer(chunk)) { - chunk = new Buffer(chunk, encoding); - } - this.push(chunk); - return callback(); - }; - - NoFilter.prototype._bufArray = function() { - var b, bufs; - bufs = this._readableState.buffer; - if (!Array.isArray(bufs)) { - b = bufs.head; - bufs = []; - while (b != null) { - bufs.push(b.data); - b = b.next; - } - } - return bufs; - }; - - NoFilter.prototype.read = function(size) { - var buf; - buf = NoFilter.__super__.read.call(this, size); - if (buf != null) { - this.emit('read', buf); - } - return buf; - }; - - NoFilter.prototype.promise = function(cb) { - var done; - done = false; - return new Promise((function(_this) { - return function(resolve, reject) { - _this.on('finish', function() { - var data; - data = _this.read(); - if ((cb != null) && !done) { - done = true; - cb(null, data); - } - return resolve(data); - }); - return _this.on('error', function(er) { - if ((cb != null) && !done) { - done = true; - cb(er); - } - return reject(er); - }); - }; - })(this)); - }; - - NoFilter.prototype.compare = function(other) { - if (!(other instanceof NoFilter)) { - throw new TypeError('Arguments must be NoFilters'); - } - if (this._readableState.objectMode || other._readableState.objectMode) { - throw new Error('Must not be in object mode to compare'); - } - if (this === other) { - return 0; - } else { - return this.slice().compare(other.slice()); - } - }; - - NoFilter.prototype.equals = function(other) { - return this.compare(other) === 0; - }; - - NoFilter.prototype.slice = function(start, end) { - var b, bufs; - if (this._readableState.objectMode) { - return this._bufArray().slice(start, end); - } else { - bufs = this._bufArray(); - switch (bufs.length) { - case 0: - return new Buffer(0); - case 1: - return bufs[0].slice(start, end); - default: - b = Buffer.concat(bufs); - return b.slice(start, end); - } - } - }; - - NoFilter.prototype.get = function(index) { - return this.slice()[index]; - }; - - NoFilter.prototype.toJSON = function() { - var b; - b = this.slice(); - if (Buffer.isBuffer(b)) { - return b.toJSON(); - } else { - return b; - } - }; - - NoFilter.prototype.toString = function(encoding, start, end) { - return this.slice().toString(encoding, start, end); - }; - - NoFilter.prototype.inspect = function(depth, options) { - var bufs, hex; - bufs = this._bufArray(); - hex = bufs.map(function(b) { - if (Buffer.isBuffer(b)) { - if (options != null ? options.stylize : void 0) { - return options.stylize(b.toString('hex'), 'string'); - } else { - return b.toString('hex'); - } - } else { - return util.inspect(b, options); - } - }).join(', '); - return this.constructor.name + " [" + hex + "]"; - }; - - _read_gen = function(meth, len) { - return function(val) { - var b; - b = this.read(len); - if (!Buffer.isBuffer(b)) { - return null; - } - return b[meth].call(b, 0, true); - }; - }; - - _write_gen = function(meth, len) { - return function(val) { - var b; - b = new Buffer(len); - b[meth].call(b, val, 0, true); - return this.push(b); - }; - }; - - NoFilter.prototype.writeUInt8 = _write_gen('writeUInt8', 1); - - NoFilter.prototype.writeUInt16LE = _write_gen('writeUInt16LE', 2); - - NoFilter.prototype.writeUInt16BE = _write_gen('writeUInt16BE', 2); - - NoFilter.prototype.writeUInt32LE = _write_gen('writeUInt32LE', 4); - - NoFilter.prototype.writeUInt32BE = _write_gen('writeUInt32BE', 4); - - NoFilter.prototype.writeInt8 = _write_gen('writeInt8', 1); - - NoFilter.prototype.writeInt16LE = _write_gen('writeInt16LE', 2); - - NoFilter.prototype.writeInt16BE = _write_gen('writeInt16BE', 2); - - NoFilter.prototype.writeInt32LE = _write_gen('writeInt32LE', 4); - - NoFilter.prototype.writeInt32BE = _write_gen('writeInt32BE', 4); - - NoFilter.prototype.writeFloatLE = _write_gen('writeFloatLE', 4); - - NoFilter.prototype.writeFloatBE = _write_gen('writeFloatBE', 4); - - NoFilter.prototype.writeDoubleLE = _write_gen('writeDoubleLE', 8); - - NoFilter.prototype.writeDoubleBE = _write_gen('writeDoubleBE', 8); - - NoFilter.prototype.readUInt8 = _read_gen('readUInt8', 1); - - NoFilter.prototype.readUInt16LE = _read_gen('readUInt16LE', 2); - - NoFilter.prototype.readUInt16BE = _read_gen('readUInt16BE', 2); - - NoFilter.prototype.readUInt32LE = _read_gen('readUInt32LE', 4); - - NoFilter.prototype.readUInt32BE = _read_gen('readUInt32BE', 4); - - NoFilter.prototype.readInt8 = _read_gen('readInt8', 1); - - NoFilter.prototype.readInt16LE = _read_gen('readInt16LE', 2); - - NoFilter.prototype.readInt16BE = _read_gen('readInt16BE', 2); - - NoFilter.prototype.readInt32LE = _read_gen('readInt32LE', 4); - - NoFilter.prototype.readInt32BE = _read_gen('readInt32BE', 4); - - NoFilter.prototype.readFloatLE = _read_gen('readFloatLE', 4); - - NoFilter.prototype.readFloatBE = _read_gen('readFloatBE', 4); - - NoFilter.prototype.readDoubleLE = _read_gen('readDoubleLE', 8); - - NoFilter.prototype.readDoubleBE = _read_gen('readDoubleBE', 8); - - get = function(props) { - var getter, name, results; - results = []; - for (name in props) { - getter = props[name]; - results.push(NoFilter.prototype.__defineGetter__(name, getter)); - } - return results; - }; - - get({ - length: function() { - return this._readableState.length; - } - }); - - return NoFilter; - - })(stream.Transform); - -}).call(this); - - - -}).call(this,require("buffer").Buffer) -},{"buffer":6,"stream":72,"util":78}],51:[function(require,module,exports){ -(function (process){ -'use strict'; - -if (!process.version || - process.version.indexOf('v0.') === 0 || - process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { - module.exports = { nextTick: nextTick }; -} else { - module.exports = process -} - -function nextTick(fn, arg1, arg2, arg3) { - if (typeof fn !== 'function') { - throw new TypeError('"callback" argument must be a function'); - } - var len = arguments.length; - var args, i; - switch (len) { - case 0: - case 1: - return process.nextTick(fn); - case 2: - return process.nextTick(function afterTickOne() { - fn.call(null, arg1); - }); - case 3: - return process.nextTick(function afterTickTwo() { - fn.call(null, arg1, arg2); - }); - case 4: - return process.nextTick(function afterTickThree() { - fn.call(null, arg1, arg2, arg3); - }); - default: - args = new Array(len - 1); - i = 0; - while (i < args.length) { - args[i++] = arguments[i]; - } - return process.nextTick(function afterTick() { - fn.apply(null, args); - }); - } -} - - -}).call(this,require('_process')) -},{"_process":52}],52:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],53:[function(require,module,exports){ -(function (global){ -/*! https://mths.be/punycode v1.4.1 by @mathias */ -;(function(root) { - - /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports && - !exports.nodeType && exports; - var freeModule = typeof module == 'object' && module && - !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; - if ( - freeGlobal.global === freeGlobal || - freeGlobal.window === freeGlobal || - freeGlobal.self === freeGlobal - ) { - root = freeGlobal; - } - - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, - - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' - - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators - - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, - - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, - - /** Temporary variable */ - key; - - /*--------------------------------------------------------------------------*/ - - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw new RangeError(errors[type]); - } - - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - var result = []; - while (length--) { - result[length] = fn(array[length]); - } - return result; - } - - /** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; - } - - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } - - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } - - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } - - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } - - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } - - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - /** Cached calculation results */ - baseMinusT; - - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. - - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } - - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } - - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. - - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { - - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { - - if (index >= inputLength) { - error('invalid-input'); - } - - digit = basicToDigit(input.charCodeAt(index++)); - - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } - - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - - if (digit < t) { - break; - } - - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } - - w *= baseMinusT; - - } - - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); - - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } - - n += floor(i / out); - i %= out; - - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); - - } - - return ucs2encode(output); - } - - /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; - - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); - - // Cache the length - inputLength = input.length; - - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; - - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } - - handledCPCount = basicLength = output.length; - - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. - - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } - - // Main encoding loop: - while (handledCPCount < inputLength) { - - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } - - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } - - delta += (m - n) * handledCPCountPlusOne; - n = m; - - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } - - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } - - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } - - ++delta; - ++n; - - } - return output.join(''); - } - - /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(input) { - return mapDomain(input, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } - - /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ - function toASCII(input) { - return mapDomain(input, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } - - /*--------------------------------------------------------------------------*/ - - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.4.1', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode - }; - - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define('punycode', function() { - return punycode; - }); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { - // in Node.js, io.js, or RingoJS v0.8.0+ - freeModule.exports = punycode; - } else { - // in Narwhal or RingoJS v0.7.0- - for (key in punycode) { - punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); - } - } - } else { - // in Rhino or a web browser - root.punycode = punycode; - } - -}(this)); - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],54:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -'use strict'; - -// If obj.hasOwnProperty has been overridden, then calling -// obj.hasOwnProperty(prop) will break. -// See: https://github.com/joyent/node/issues/1707 -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -module.exports = function(qs, sep, eq, options) { - sep = sep || '&'; - eq = eq || '='; - var obj = {}; - - if (typeof qs !== 'string' || qs.length === 0) { - return obj; - } - - var regexp = /\+/g; - qs = qs.split(sep); - - var maxKeys = 1000; - if (options && typeof options.maxKeys === 'number') { - maxKeys = options.maxKeys; - } - - var len = qs.length; - // maxKeys <= 0 means that we should not limit keys count - if (maxKeys > 0 && len > maxKeys) { - len = maxKeys; - } - - for (var i = 0; i < len; ++i) { - var x = qs[i].replace(regexp, '%20'), - idx = x.indexOf(eq), - kstr, vstr, k, v; - - if (idx >= 0) { - kstr = x.substr(0, idx); - vstr = x.substr(idx + 1); - } else { - kstr = x; - vstr = ''; - } - - k = decodeURIComponent(kstr); - v = decodeURIComponent(vstr); - - if (!hasOwnProperty(obj, k)) { - obj[k] = v; - } else if (isArray(obj[k])) { - obj[k].push(v); - } else { - obj[k] = [obj[k], v]; - } - } - - return obj; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -},{}],55:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -'use strict'; - -var stringifyPrimitive = function(v) { - switch (typeof v) { - case 'string': - return v; - - case 'boolean': - return v ? 'true' : 'false'; - - case 'number': - return isFinite(v) ? v : ''; - - default: - return ''; - } -}; - -module.exports = function(obj, sep, eq, name) { - sep = sep || '&'; - eq = eq || '='; - if (obj === null) { - obj = undefined; - } - - if (typeof obj === 'object') { - return map(objectKeys(obj), function(k) { - var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; - if (isArray(obj[k])) { - return map(obj[k], function(v) { - return ks + encodeURIComponent(stringifyPrimitive(v)); - }).join(sep); - } else { - return ks + encodeURIComponent(stringifyPrimitive(obj[k])); - } - }).join(sep); - - } - - if (!name) return ''; - return encodeURIComponent(stringifyPrimitive(name)) + eq + - encodeURIComponent(stringifyPrimitive(obj)); -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -function map (xs, f) { - if (xs.map) return xs.map(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - res.push(f(xs[i], i)); - } - return res; -} - -var objectKeys = Object.keys || function (obj) { - var res = []; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); - } - return res; -}; - -},{}],56:[function(require,module,exports){ -'use strict'; - -exports.decode = exports.parse = require('./decode'); -exports.encode = exports.stringify = require('./encode'); - -},{"./decode":54,"./encode":55}],57:[function(require,module,exports){ -module.exports = require('./lib/_stream_duplex.js'); - -},{"./lib/_stream_duplex.js":58}],58:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// a duplex stream is just a stream that is both readable and writable. -// Since JS doesn't have multiple prototypal inheritance, this class -// prototypally inherits from Readable, and then parasitically from -// Writable. - -'use strict'; - -/**/ - -var pna = require('process-nextick-args'); -/**/ - -/**/ -var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) { - keys.push(key); - }return keys; -}; -/**/ - -module.exports = Duplex; - -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -var Readable = require('./_stream_readable'); -var Writable = require('./_stream_writable'); - -util.inherits(Duplex, Readable); - -{ - // avoid scope creep, the keys array can then be collected - var keys = objectKeys(Writable.prototype); - for (var v = 0; v < keys.length; v++) { - var method = keys[v]; - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; - } -} - -function Duplex(options) { - if (!(this instanceof Duplex)) return new Duplex(options); - - Readable.call(this, options); - Writable.call(this, options); - - if (options && options.readable === false) this.readable = false; - - if (options && options.writable === false) this.writable = false; - - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; - - this.once('end', onend); -} - -Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function () { - return this._writableState.highWaterMark; - } -}); - -// the no-half-open enforcer -function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) return; - - // no more data can be written. - // But allow more writes to happen in this tick. - pna.nextTick(onEndNT, this); -} - -function onEndNT(self) { - self.end(); -} - -Object.defineProperty(Duplex.prototype, 'destroyed', { - get: function () { - if (this._readableState === undefined || this._writableState === undefined) { - return false; - } - return this._readableState.destroyed && this._writableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (this._readableState === undefined || this._writableState === undefined) { - return; - } - - // backward compatibility, the user is explicitly - // managing destroyed - this._readableState.destroyed = value; - this._writableState.destroyed = value; - } -}); - -Duplex.prototype._destroy = function (err, cb) { - this.push(null); - this.end(); - - pna.nextTick(cb, err); -}; -},{"./_stream_readable":60,"./_stream_writable":62,"core-util-is":18,"inherits":46,"process-nextick-args":51}],59:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// a passthrough stream. -// basically just the most minimal sort of Transform stream. -// Every written chunk gets output as-is. - -'use strict'; - -module.exports = PassThrough; - -var Transform = require('./_stream_transform'); - -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -util.inherits(PassThrough, Transform); - -function PassThrough(options) { - if (!(this instanceof PassThrough)) return new PassThrough(options); - - Transform.call(this, options); -} - -PassThrough.prototype._transform = function (chunk, encoding, cb) { - cb(null, chunk); -}; -},{"./_stream_transform":61,"core-util-is":18,"inherits":46}],60:[function(require,module,exports){ -(function (process,global){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -'use strict'; - -/**/ - -var pna = require('process-nextick-args'); -/**/ - -module.exports = Readable; - -/**/ -var isArray = require('isarray'); -/**/ - -/**/ -var Duplex; -/**/ - -Readable.ReadableState = ReadableState; - -/**/ -var EE = require('events').EventEmitter; - -var EElistenerCount = function (emitter, type) { - return emitter.listeners(type).length; -}; -/**/ - -/**/ -var Stream = require('./internal/streams/stream'); -/**/ - -/**/ - -var Buffer = require('safe-buffer').Buffer; -var OurUint8Array = global.Uint8Array || function () {}; -function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); -} -function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; -} - -/**/ - -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -/**/ -var debugUtil = require('util'); -var debug = void 0; -if (debugUtil && debugUtil.debuglog) { - debug = debugUtil.debuglog('stream'); -} else { - debug = function () {}; -} -/**/ - -var BufferList = require('./internal/streams/BufferList'); -var destroyImpl = require('./internal/streams/destroy'); -var StringDecoder; - -util.inherits(Readable, Stream); - -var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; - -function prependListener(emitter, event, fn) { - // Sadly this is not cacheable as some libraries bundle their own - // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); - - // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; -} - -function ReadableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); - - options = options || {}; - - // Duplex streams are both readable and writable, but share - // the same options object. - // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream. - // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; - - // object stream flag. Used to make read(n) ignore n and to - // make all the buffer merging and length checks go away - this.objectMode = !!options.objectMode; - - if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; - - // the point at which it stops calling _read() to fill the buffer - // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var readableHwm = options.readableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; - - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); - - // A linked list is used to store data chunks instead of an array because the - // linked list can remove elements from the beginning faster than - // array.shift() - this.buffer = new BufferList(); - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - this.endEmitted = false; - this.reading = false; - - // a flag to be able to tell if the event 'readable'/'data' is emitted - // immediately, or on a later tick. We set this to true at first, because - // any actions that shouldn't happen until "later" should generally also - // not happen before the first read call. - this.sync = true; - - // whenever we return null, then we set a flag to say - // that we're awaiting a 'readable' event emission. - this.needReadable = false; - this.emittedReadable = false; - this.readableListening = false; - this.resumeScheduled = false; - - // has it been destroyed - this.destroyed = false; - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; - - // if true, a maybeReadMore has been scheduled - this.readingMore = false; - - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; - } -} - -function Readable(options) { - Duplex = Duplex || require('./_stream_duplex'); - - if (!(this instanceof Readable)) return new Readable(options); - - this._readableState = new ReadableState(options, this); - - // legacy - this.readable = true; - - if (options) { - if (typeof options.read === 'function') this._read = options.read; - - if (typeof options.destroy === 'function') this._destroy = options.destroy; - } - - Stream.call(this); -} - -Object.defineProperty(Readable.prototype, 'destroyed', { - get: function () { - if (this._readableState === undefined) { - return false; - } - return this._readableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (!this._readableState) { - return; - } - - // backward compatibility, the user is explicitly - // managing destroyed - this._readableState.destroyed = value; - } -}); - -Readable.prototype.destroy = destroyImpl.destroy; -Readable.prototype._undestroy = destroyImpl.undestroy; -Readable.prototype._destroy = function (err, cb) { - this.push(null); - cb(err); -}; - -// Manually shove something into the read() buffer. -// This returns true if the highWaterMark has not been hit yet, -// similar to how Writable.write() returns true if you should -// write() some more. -Readable.prototype.push = function (chunk, encoding) { - var state = this._readableState; - var skipChunkCheck; - - if (!state.objectMode) { - if (typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = Buffer.from(chunk, encoding); - encoding = ''; - } - skipChunkCheck = true; - } - } else { - skipChunkCheck = true; - } - - return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); -}; - -// Unshift should *always* be something directly out of read() -Readable.prototype.unshift = function (chunk) { - return readableAddChunk(this, chunk, null, true, false); -}; - -function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { - var state = stream._readableState; - if (chunk === null) { - state.reading = false; - onEofChunk(stream, state); - } else { - var er; - if (!skipChunkCheck) er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { - chunk = _uint8ArrayToBuffer(chunk); - } - - if (addToFront) { - if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); - } else if (state.ended) { - stream.emit('error', new Error('stream.push() after EOF')); - } else { - state.reading = false; - if (state.decoder && !encoding) { - chunk = state.decoder.write(chunk); - if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); - } else { - addChunk(stream, state, chunk, false); - } - } - } else if (!addToFront) { - state.reading = false; - } - } - - return needMoreData(state); -} - -function addChunk(stream, state, chunk, addToFront) { - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); - } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); - - if (state.needReadable) emitReadable(stream); - } - maybeReadMore(stream, state); -} - -function chunkInvalid(state, chunk) { - var er; - if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; -} - -// if it's past the high water mark, we can push in some more. -// Also, if we have no data yet, we can stand some -// more bytes. This is to work around cases where hwm=0, -// such as the repl. Also, if the push() triggered a -// readable event, and the user called read(largeNumber) such that -// needReadable was set, then we ought to push more, so that another -// 'readable' event will be triggered. -function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); -} - -Readable.prototype.isPaused = function () { - return this._readableState.flowing === false; -}; - -// backwards compatibility. -Readable.prototype.setEncoding = function (enc) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; -}; - -// Don't raise the hwm > 8MB -var MAX_HWM = 0x800000; -function computeNewHighWaterMark(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - // Get the next highest power of 2 to prevent increasing hwm excessively in - // tiny amounts - n--; - n |= n >>> 1; - n |= n >>> 2; - n |= n >>> 4; - n |= n >>> 8; - n |= n >>> 16; - n++; - } - return n; -} - -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function howMuchToRead(n, state) { - if (n <= 0 || state.length === 0 && state.ended) return 0; - if (state.objectMode) return 1; - if (n !== n) { - // Only flow one buffer at a time - if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; - } - // If we're asking for more than the current hwm, then raise the hwm. - if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) return n; - // Don't have enough - if (!state.ended) { - state.needReadable = true; - return 0; - } - return state.length; -} - -// you can override either this method, or the async _read(n) below. -Readable.prototype.read = function (n) { - debug('read', n); - n = parseInt(n, 10); - var state = this._readableState; - var nOrig = n; - - if (n !== 0) state.emittedReadable = false; - - // if we're doing read(0) to trigger a readable event, but we - // already have a bunch of data in the buffer, then just trigger - // the 'readable' event and move on. - if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { - debug('read: emitReadable', state.length, state.ended); - if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); - return null; - } - - n = howMuchToRead(n, state); - - // if we've ended, and we're now clear, then finish it up. - if (n === 0 && state.ended) { - if (state.length === 0) endReadable(this); - return null; - } - - // All the actual chunk generation logic needs to be - // *below* the call to _read. The reason is that in certain - // synthetic stream cases, such as passthrough streams, _read - // may be a completely synchronous operation which may change - // the state of the read buffer, providing enough data when - // before there was *not* enough. - // - // So, the steps are: - // 1. Figure out what the state of things will be after we do - // a read from the buffer. - // - // 2. If that resulting state will trigger a _read, then call _read. - // Note that this may be asynchronous, or synchronous. Yes, it is - // deeply ugly to write APIs this way, but that still doesn't mean - // that the Readable class should behave improperly, as streams are - // designed to be sync/async agnostic. - // Take note if the _read call is sync or async (ie, if the read call - // has returned yet), so that we know whether or not it's safe to emit - // 'readable' etc. - // - // 3. Actually pull the requested chunks out of the buffer and return. - - // if we need a readable event, then we need to do some reading. - var doRead = state.needReadable; - debug('need readable', doRead); - - // if we currently have less than the highWaterMark, then also read some - if (state.length === 0 || state.length - n < state.highWaterMark) { - doRead = true; - debug('length less than watermark', doRead); - } - - // however, if we've ended, then there's no point, and if we're already - // reading, then it's unnecessary. - if (state.ended || state.reading) { - doRead = false; - debug('reading or ended', doRead); - } else if (doRead) { - debug('do read'); - state.reading = true; - state.sync = true; - // if the length is currently zero, then we *need* a readable event. - if (state.length === 0) state.needReadable = true; - // call internal read method - this._read(state.highWaterMark); - state.sync = false; - // If _read pushed data synchronously, then `reading` will be false, - // and we need to re-evaluate how much data we can return to the user. - if (!state.reading) n = howMuchToRead(nOrig, state); - } - - var ret; - if (n > 0) ret = fromList(n, state);else ret = null; - - if (ret === null) { - state.needReadable = true; - n = 0; - } else { - state.length -= n; - } - - if (state.length === 0) { - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true; - - // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended) endReadable(this); - } - - if (ret !== null) this.emit('data', ret); - - return ret; -}; - -function onEofChunk(stream, state) { - if (state.ended) return; - if (state.decoder) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) { - state.buffer.push(chunk); - state.length += state.objectMode ? 1 : chunk.length; - } - } - state.ended = true; - - // emit 'readable' now to make sure it gets picked up. - emitReadable(stream); -} - -// Don't emit readable right away in sync mode, because this can trigger -// another read() call => stack overflow. This way, it might trigger -// a nextTick recursion warning, but that's not so bad. -function emitReadable(stream) { - var state = stream._readableState; - state.needReadable = false; - if (!state.emittedReadable) { - debug('emitReadable', state.flowing); - state.emittedReadable = true; - if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); - } -} - -function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); -} - -// at this point, the user has presumably seen the 'readable' event, -// and called read() to consume some data. that may have triggered -// in turn another _read(n) call, in which case reading = true if -// it's in progress. -// However, if we're not ended, or reading, and the length < hwm, -// then go ahead and try to read some more preemptively. -function maybeReadMore(stream, state) { - if (!state.readingMore) { - state.readingMore = true; - pna.nextTick(maybeReadMore_, stream, state); - } -} - -function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { - debug('maybeReadMore read 0'); - stream.read(0); - if (len === state.length) - // didn't get any data, stop spinning. - break;else len = state.length; - } - state.readingMore = false; -} - -// abstract method. to be overridden in specific implementation classes. -// call cb(er, data) where data is <= n in length. -// for virtual (non-string, non-buffer) streams, "length" is somewhat -// arbitrary, and perhaps not very meaningful. -Readable.prototype._read = function (n) { - this.emit('error', new Error('_read() is not implemented')); -}; - -Readable.prototype.pipe = function (dest, pipeOpts) { - var src = this; - var state = this._readableState; - - switch (state.pipesCount) { - case 0: - state.pipes = dest; - break; - case 1: - state.pipes = [state.pipes, dest]; - break; - default: - state.pipes.push(dest); - break; - } - state.pipesCount += 1; - debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - - var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); - - dest.on('unpipe', onunpipe); - function onunpipe(readable, unpipeInfo) { - debug('onunpipe'); - if (readable === src) { - if (unpipeInfo && unpipeInfo.hasUnpiped === false) { - unpipeInfo.hasUnpiped = true; - cleanup(); - } - } - } - - function onend() { - debug('onend'); - dest.end(); - } - - // when the dest drains, it reduces the awaitDrain counter - // on the source. This would be more elegant with a .once() - // handler in flow(), but adding and removing repeatedly is - // too slow. - var ondrain = pipeOnDrain(src); - dest.on('drain', ondrain); - - var cleanedUp = false; - function cleanup() { - debug('cleanup'); - // cleanup event handlers once the pipe is broken - dest.removeListener('close', onclose); - dest.removeListener('finish', onfinish); - dest.removeListener('drain', ondrain); - dest.removeListener('error', onerror); - dest.removeListener('unpipe', onunpipe); - src.removeListener('end', onend); - src.removeListener('end', unpipe); - src.removeListener('data', ondata); - - cleanedUp = true; - - // if the reader is waiting for a drain event from this - // specific writer, then it would cause it to never start - // flowing again. - // So, if this is awaiting a drain, then we just call it now. - // If we don't know, then assume that we are waiting for one. - if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); - } - - // If the user pushes more data while we're writing to dest then we'll end up - // in ondata again. However, we only want to increase awaitDrain once because - // dest will only emit one 'drain' event for the multiple writes. - // => Introduce a guard on increasing awaitDrain. - var increasedAwaitDrain = false; - src.on('data', ondata); - function ondata(chunk) { - debug('ondata'); - increasedAwaitDrain = false; - var ret = dest.write(chunk); - if (false === ret && !increasedAwaitDrain) { - // If the user unpiped during `dest.write()`, it is possible - // to get stuck in a permanently paused state if that write - // also returned false. - // => Check whether `dest` is still a piping destination. - if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', src._readableState.awaitDrain); - src._readableState.awaitDrain++; - increasedAwaitDrain = true; - } - src.pause(); - } - } - - // if the dest has an error, then stop piping into it. - // however, don't suppress the throwing behavior for this. - function onerror(er) { - debug('onerror', er); - unpipe(); - dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); - } - - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror); - - // Both close and finish should trigger unpipe, but only once. - function onclose() { - dest.removeListener('finish', onfinish); - unpipe(); - } - dest.once('close', onclose); - function onfinish() { - debug('onfinish'); - dest.removeListener('close', onclose); - unpipe(); - } - dest.once('finish', onfinish); - - function unpipe() { - debug('unpipe'); - src.unpipe(dest); - } - - // tell the dest that it's being piped to - dest.emit('pipe', src); - - // start the flow if it hasn't been started already. - if (!state.flowing) { - debug('pipe resume'); - src.resume(); - } - - return dest; -}; - -function pipeOnDrain(src) { - return function () { - var state = src._readableState; - debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) state.awaitDrain--; - if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { - state.flowing = true; - flow(src); - } - }; -} - -Readable.prototype.unpipe = function (dest) { - var state = this._readableState; - var unpipeInfo = { hasUnpiped: false }; - - // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) return this; - - // just one destination. most common case. - if (state.pipesCount === 1) { - // passed in one, but it's not the right one. - if (dest && dest !== state.pipes) return this; - - if (!dest) dest = state.pipes; - - // got a match. - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - if (dest) dest.emit('unpipe', this, unpipeInfo); - return this; - } - - // slow case. multiple pipe destinations. - - if (!dest) { - // remove all. - var dests = state.pipes; - var len = state.pipesCount; - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - - for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this, unpipeInfo); - }return this; - } - - // try to find the right one. - var index = indexOf(state.pipes, dest); - if (index === -1) return this; - - state.pipes.splice(index, 1); - state.pipesCount -= 1; - if (state.pipesCount === 1) state.pipes = state.pipes[0]; - - dest.emit('unpipe', this, unpipeInfo); - - return this; -}; - -// set up data events if they are asked for -// Ensure readable listeners eventually get something -Readable.prototype.on = function (ev, fn) { - var res = Stream.prototype.on.call(this, ev, fn); - - if (ev === 'data') { - // Start flowing on next tick if stream isn't explicitly paused - if (this._readableState.flowing !== false) this.resume(); - } else if (ev === 'readable') { - var state = this._readableState; - if (!state.endEmitted && !state.readableListening) { - state.readableListening = state.needReadable = true; - state.emittedReadable = false; - if (!state.reading) { - pna.nextTick(nReadingNextTick, this); - } else if (state.length) { - emitReadable(this); - } - } - } - - return res; -}; -Readable.prototype.addListener = Readable.prototype.on; - -function nReadingNextTick(self) { - debug('readable nexttick read 0'); - self.read(0); -} - -// pause() and resume() are remnants of the legacy readable stream API -// If the user uses them, then switch into old mode. -Readable.prototype.resume = function () { - var state = this._readableState; - if (!state.flowing) { - debug('resume'); - state.flowing = true; - resume(this, state); - } - return this; -}; - -function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - pna.nextTick(resume_, stream, state); - } -} - -function resume_(stream, state) { - if (!state.reading) { - debug('resume read 0'); - stream.read(0); - } - - state.resumeScheduled = false; - state.awaitDrain = 0; - stream.emit('resume'); - flow(stream); - if (state.flowing && !state.reading) stream.read(0); -} - -Readable.prototype.pause = function () { - debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { - debug('pause'); - this._readableState.flowing = false; - this.emit('pause'); - } - return this; -}; - -function flow(stream) { - var state = stream._readableState; - debug('flow', state.flowing); - while (state.flowing && stream.read() !== null) {} -} - -// wrap an old-style stream as the async data source. -// This is *not* part of the readable stream interface. -// It is an ugly unfortunate mess of history. -Readable.prototype.wrap = function (stream) { - var _this = this; - - var state = this._readableState; - var paused = false; - - stream.on('end', function () { - debug('wrapped end'); - if (state.decoder && !state.ended) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) _this.push(chunk); - } - - _this.push(null); - }); - - stream.on('data', function (chunk) { - debug('wrapped data'); - if (state.decoder) chunk = state.decoder.write(chunk); - - // don't skip over falsy values in objectMode - if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; - - var ret = _this.push(chunk); - if (!ret) { - paused = true; - stream.pause(); - } - }); - - // proxy all the other methods. - // important when wrapping filters and duplexes. - for (var i in stream) { - if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function (method) { - return function () { - return stream[method].apply(stream, arguments); - }; - }(i); - } - } - - // proxy certain important events. - for (var n = 0; n < kProxyEvents.length; n++) { - stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); - } - - // when we try to consume some more bytes, simply unpause the - // underlying stream. - this._read = function (n) { - debug('wrapped _read', n); - if (paused) { - paused = false; - stream.resume(); - } - }; - - return this; -}; - -Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function () { - return this._readableState.highWaterMark; - } -}); - -// exposed for testing purposes only. -Readable._fromList = fromList; - -// Pluck off n bytes from an array of buffers. -// Length is the combined lengths of all the buffers in the list. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromList(n, state) { - // nothing buffered - if (state.length === 0) return null; - - var ret; - if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { - // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); - state.buffer.clear(); - } else { - // read part of list - ret = fromListPartial(n, state.buffer, state.decoder); - } - - return ret; -} - -// Extracts only enough buffered data to satisfy the amount requested. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - // slice is the same for buffers and strings - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - // first chunk is a perfect match - ret = list.shift(); - } else { - // result spans more than one buffer - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); - } - return ret; -} - -// Copies a specified amount of characters from the list of buffered data -// chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; -} - -// Copies a specified amount of bytes from the list of buffered data chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBuffer(n, list) { - var ret = Buffer.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; -} - -function endReadable(stream) { - var state = stream._readableState; - - // If we get here before consuming all the bytes, then that is a - // bug in node. Should never happen. - if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); - - if (!state.endEmitted) { - state.ended = true; - pna.nextTick(endReadableNT, state, stream); - } -} - -function endReadableNT(state, stream) { - // Check that we didn't get one last unshift. - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit('end'); - } -} - -function indexOf(xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) return i; - } - return -1; -} -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":58,"./internal/streams/BufferList":63,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":52,"core-util-is":18,"events":44,"inherits":46,"isarray":48,"process-nextick-args":51,"safe-buffer":71,"string_decoder/":66,"util":4}],61:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// a transform stream is a readable/writable stream where you do -// something with the data. Sometimes it's called a "filter", -// but that's not a great name for it, since that implies a thing where -// some bits pass through, and others are simply ignored. (That would -// be a valid example of a transform, of course.) -// -// While the output is causally related to the input, it's not a -// necessarily symmetric or synchronous transformation. For example, -// a zlib stream might take multiple plain-text writes(), and then -// emit a single compressed chunk some time in the future. -// -// Here's how this works: -// -// The Transform stream has all the aspects of the readable and writable -// stream classes. When you write(chunk), that calls _write(chunk,cb) -// internally, and returns false if there's a lot of pending writes -// buffered up. When you call read(), that calls _read(n) until -// there's enough pending readable data buffered up. -// -// In a transform stream, the written data is placed in a buffer. When -// _read(n) is called, it transforms the queued up data, calling the -// buffered _write cb's as it consumes chunks. If consuming a single -// written chunk would result in multiple output chunks, then the first -// outputted bit calls the readcb, and subsequent chunks just go into -// the read buffer, and will cause it to emit 'readable' if necessary. -// -// This way, back-pressure is actually determined by the reading side, -// since _read has to be called to start processing a new chunk. However, -// a pathological inflate type of transform can cause excessive buffering -// here. For example, imagine a stream where every byte of input is -// interpreted as an integer from 0-255, and then results in that many -// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in -// 1kb of data being output. In this case, you could write a very small -// amount of input, and end up with a very large amount of output. In -// such a pathological inflating mechanism, there'd be no way to tell -// the system to stop doing the transform. A single 4MB write could -// cause the system to run out of memory. -// -// However, even in such a pathological case, only a single written chunk -// would be consumed, and then the rest would wait (un-transformed) until -// the results of the previous transformed chunk were consumed. - -'use strict'; - -module.exports = Transform; - -var Duplex = require('./_stream_duplex'); - -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -util.inherits(Transform, Duplex); - -function afterTransform(er, data) { - var ts = this._transformState; - ts.transforming = false; - - var cb = ts.writecb; - - if (!cb) { - return this.emit('error', new Error('write callback called multiple times')); - } - - ts.writechunk = null; - ts.writecb = null; - - if (data != null) // single equals check for both `null` and `undefined` - this.push(data); - - cb(er); - - var rs = this._readableState; - rs.reading = false; - if (rs.needReadable || rs.length < rs.highWaterMark) { - this._read(rs.highWaterMark); - } -} - -function Transform(options) { - if (!(this instanceof Transform)) return new Transform(options); - - Duplex.call(this, options); - - this._transformState = { - afterTransform: afterTransform.bind(this), - needTransform: false, - transforming: false, - writecb: null, - writechunk: null, - writeencoding: null - }; - - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; - - // we have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - this._readableState.sync = false; - - if (options) { - if (typeof options.transform === 'function') this._transform = options.transform; - - if (typeof options.flush === 'function') this._flush = options.flush; - } - - // When the writable side finishes, then flush out anything remaining. - this.on('prefinish', prefinish); -} - -function prefinish() { - var _this = this; - - if (typeof this._flush === 'function') { - this._flush(function (er, data) { - done(_this, er, data); - }); - } else { - done(this, null, null); - } -} - -Transform.prototype.push = function (chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); -}; - -// This is the part where you do stuff! -// override this function in implementation classes. -// 'chunk' is an input chunk. -// -// Call `push(newChunk)` to pass along transformed output -// to the readable side. You may call 'push' zero or more times. -// -// Call `cb(err)` when you are done with this chunk. If you pass -// an error, then that'll put the hurt on the whole operation. If you -// never call cb(), then you'll never get another chunk. -Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('_transform() is not implemented'); -}; - -Transform.prototype._write = function (chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); - } -}; - -// Doesn't matter what the args are here. -// _transform does all the work. -// That we got here means that the readable side wants more data. -Transform.prototype._read = function (n) { - var ts = this._transformState; - - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { - ts.transforming = true; - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; - } -}; - -Transform.prototype._destroy = function (err, cb) { - var _this2 = this; - - Duplex.prototype._destroy.call(this, err, function (err2) { - cb(err2); - _this2.emit('close'); - }); -}; - -function done(stream, er, data) { - if (er) return stream.emit('error', er); - - if (data != null) // single equals check for both `null` and `undefined` - stream.push(data); - - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); - - if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); - - return stream.push(null); -} -},{"./_stream_duplex":58,"core-util-is":18,"inherits":46}],62:[function(require,module,exports){ -(function (process,global,setImmediate){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// A bit simpler than readable streams. -// Implement an async ._write(chunk, encoding, cb), and it'll handle all -// the drain event emission and buffering. - -'use strict'; - -/**/ - -var pna = require('process-nextick-args'); -/**/ - -module.exports = Writable; - -/* */ -function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - this.next = null; -} - -// It seems a linked list but it is not -// there will be only 2 of these for each stream -function CorkedRequest(state) { - var _this = this; - - this.next = null; - this.entry = null; - this.finish = function () { - onCorkedFinish(_this, state); - }; -} -/* */ - -/**/ -var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; -/**/ - -/**/ -var Duplex; -/**/ - -Writable.WritableState = WritableState; - -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -/**/ -var internalUtil = { - deprecate: require('util-deprecate') -}; -/**/ - -/**/ -var Stream = require('./internal/streams/stream'); -/**/ - -/**/ - -var Buffer = require('safe-buffer').Buffer; -var OurUint8Array = global.Uint8Array || function () {}; -function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); -} -function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; -} - -/**/ - -var destroyImpl = require('./internal/streams/destroy'); - -util.inherits(Writable, Stream); - -function nop() {} - -function WritableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); - - options = options || {}; - - // Duplex streams are both readable and writable, but share - // the same options object. - // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream. - // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; - - // object stream flag to indicate whether or not this stream - // contains buffers or objects. - this.objectMode = !!options.objectMode; - - if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; - - // the point at which write() starts returning false - // Note: 0 is a valid value, means that we always return false if - // the entire buffer is not flushed immediately on write() - var hwm = options.highWaterMark; - var writableHwm = options.writableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; - - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); - - // if _final has been called - this.finalCalled = false; - - // drain event flag. - this.needDrain = false; - // at the start of calling end() - this.ending = false; - // when end() has been called, and returned - this.ended = false; - // when 'finish' is emitted - this.finished = false; - - // has it been destroyed - this.destroyed = false; - - // should we decode strings into buffers before passing to _write? - // this is here so that some node-core streams can optimize string - // handling at a lower level. - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - - // not an actual buffer we keep track of, but a measurement - // of how much we're waiting to get pushed to some underlying - // socket or file. - this.length = 0; - - // a flag to see when we're in the middle of a write. - this.writing = false; - - // when true all writes will be buffered until .uncork() call - this.corked = 0; - - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - this.sync = true; - - // a flag to know if we're processing previously buffered items, which - // may call the _write() callback in the same tick, so that we don't - // end up in an overlapped onwrite situation. - this.bufferProcessing = false; - - // the callback that's passed to _write(chunk,cb) - this.onwrite = function (er) { - onwrite(stream, er); - }; - - // the callback that the user supplies to write(chunk,encoding,cb) - this.writecb = null; - - // the amount that is being written when _write is called. - this.writelen = 0; - - this.bufferedRequest = null; - this.lastBufferedRequest = null; - - // number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; - - // emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams - this.prefinished = false; - - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; - - // count buffered requests - this.bufferedRequestCount = 0; - - // allocate the first CorkedRequest, there is always - // one allocated and free to use, and we maintain at most two - this.corkedRequestsFree = new CorkedRequest(this); -} - -WritableState.prototype.getBuffer = function getBuffer() { - var current = this.bufferedRequest; - var out = []; - while (current) { - out.push(current); - current = current.next; - } - return out; -}; - -(function () { - try { - Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function () { - return this.getBuffer(); - }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') - }); - } catch (_) {} -})(); - -// Test _writableState for inheritance to account for Duplex streams, -// whose prototype chain only points to Readable. -var realHasInstance; -if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { - realHasInstance = Function.prototype[Symbol.hasInstance]; - Object.defineProperty(Writable, Symbol.hasInstance, { - value: function (object) { - if (realHasInstance.call(this, object)) return true; - if (this !== Writable) return false; - - return object && object._writableState instanceof WritableState; - } - }); -} else { - realHasInstance = function (object) { - return object instanceof this; - }; -} - -function Writable(options) { - Duplex = Duplex || require('./_stream_duplex'); - - // Writable ctor is applied to Duplexes, too. - // `realHasInstance` is necessary because using plain `instanceof` - // would return false, as no `_writableState` property is attached. - - // Trying to use the custom `instanceof` for Writable here will also break the - // Node.js LazyTransform implementation, which has a non-trivial getter for - // `_writableState` that would lead to infinite recursion. - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new Writable(options); - } - - this._writableState = new WritableState(options, this); - - // legacy. - this.writable = true; - - if (options) { - if (typeof options.write === 'function') this._write = options.write; - - if (typeof options.writev === 'function') this._writev = options.writev; - - if (typeof options.destroy === 'function') this._destroy = options.destroy; - - if (typeof options.final === 'function') this._final = options.final; - } - - Stream.call(this); -} - -// Otherwise people can pipe Writable streams, which is just wrong. -Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe, not readable')); -}; - -function writeAfterEnd(stream, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - pna.nextTick(cb, er); -} - -// Checks that a user-supplied chunk is valid, especially for the particular -// mode the stream is in. Currently this means that `null` is never accepted -// and undefined/non-string values are only allowed in object mode. -function validChunk(stream, state, chunk, cb) { - var valid = true; - var er = false; - - if (chunk === null) { - er = new TypeError('May not write null values to stream'); - } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - if (er) { - stream.emit('error', er); - pna.nextTick(cb, er); - valid = false; - } - return valid; -} - -Writable.prototype.write = function (chunk, encoding, cb) { - var state = this._writableState; - var ret = false; - var isBuf = !state.objectMode && _isUint8Array(chunk); - - if (isBuf && !Buffer.isBuffer(chunk)) { - chunk = _uint8ArrayToBuffer(chunk); - } - - if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } - - if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - - if (typeof cb !== 'function') cb = nop; - - if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); - } - - return ret; -}; - -Writable.prototype.cork = function () { - var state = this._writableState; - - state.corked++; -}; - -Writable.prototype.uncork = function () { - var state = this._writableState; - - if (state.corked) { - state.corked--; - - if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); - } -}; - -Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { - // node::ParseEncoding() requires lower case. - if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); - this._writableState.defaultEncoding = encoding; - return this; -}; - -function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = Buffer.from(chunk, encoding); - } - return chunk; -} - -Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function () { - return this._writableState.highWaterMark; - } -}); - -// if we're already writing something, then just put this -// in the queue, and wait our turn. Otherwise, call _write -// If we return false, then we need a drain event, so set that flag. -function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { - if (!isBuf) { - var newChunk = decodeChunk(state, chunk, encoding); - if (chunk !== newChunk) { - isBuf = true; - encoding = 'buffer'; - chunk = newChunk; - } - } - var len = state.objectMode ? 1 : chunk.length; - - state.length += len; - - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. - if (!ret) state.needDrain = true; - - if (state.writing || state.corked) { - var last = state.lastBufferedRequest; - state.lastBufferedRequest = { - chunk: chunk, - encoding: encoding, - isBuf: isBuf, - callback: cb, - next: null - }; - if (last) { - last.next = state.lastBufferedRequest; - } else { - state.bufferedRequest = state.lastBufferedRequest; - } - state.bufferedRequestCount += 1; - } else { - doWrite(stream, state, false, len, chunk, encoding, cb); - } - - return ret; -} - -function doWrite(stream, state, writev, len, chunk, encoding, cb) { - state.writelen = len; - state.writecb = cb; - state.writing = true; - state.sync = true; - if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); - state.sync = false; -} - -function onwriteError(stream, state, sync, er, cb) { - --state.pendingcb; - - if (sync) { - // defer the callback if we are being called synchronously - // to avoid piling up things on the stack - pna.nextTick(cb, er); - // this can emit finish, and it will always happen - // after error - pna.nextTick(finishMaybe, stream, state); - stream._writableState.errorEmitted = true; - stream.emit('error', er); - } else { - // the caller expect this to happen before if - // it is async - cb(er); - stream._writableState.errorEmitted = true; - stream.emit('error', er); - // this can emit finish, but finish must - // always follow error - finishMaybe(stream, state); - } -} - -function onwriteStateUpdate(state) { - state.writing = false; - state.writecb = null; - state.length -= state.writelen; - state.writelen = 0; -} - -function onwrite(stream, er) { - var state = stream._writableState; - var sync = state.sync; - var cb = state.writecb; - - onwriteStateUpdate(state); - - if (er) onwriteError(stream, state, sync, er, cb);else { - // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state); - - if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { - clearBuffer(stream, state); - } - - if (sync) { - /**/ - asyncWrite(afterWrite, stream, state, finished, cb); - /**/ - } else { - afterWrite(stream, state, finished, cb); - } - } -} - -function afterWrite(stream, state, finished, cb) { - if (!finished) onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); -} - -// Must force callback to be called on nextTick, so that we don't -// emit 'drain' before the write() consumer gets the 'false' return -// value, and has a chance to attach a 'drain' listener. -function onwriteDrain(stream, state) { - if (state.length === 0 && state.needDrain) { - state.needDrain = false; - stream.emit('drain'); - } -} - -// if there's something in the buffer waiting, then process it -function clearBuffer(stream, state) { - state.bufferProcessing = true; - var entry = state.bufferedRequest; - - if (stream._writev && entry && entry.next) { - // Fast case, write everything using _writev() - var l = state.bufferedRequestCount; - var buffer = new Array(l); - var holder = state.corkedRequestsFree; - holder.entry = entry; - - var count = 0; - var allBuffers = true; - while (entry) { - buffer[count] = entry; - if (!entry.isBuf) allBuffers = false; - entry = entry.next; - count += 1; - } - buffer.allBuffers = allBuffers; - - doWrite(stream, state, true, state.length, buffer, '', holder.finish); - - // doWrite is almost always async, defer these to save a bit of time - // as the hot path ends with doWrite - state.pendingcb++; - state.lastBufferedRequest = null; - if (holder.next) { - state.corkedRequestsFree = holder.next; - holder.next = null; - } else { - state.corkedRequestsFree = new CorkedRequest(state); - } - state.bufferedRequestCount = 0; - } else { - // Slow case, write chunks one-by-one - while (entry) { - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; - - doWrite(stream, state, false, len, chunk, encoding, cb); - entry = entry.next; - state.bufferedRequestCount--; - // if we didn't call the onwrite immediately, then - // it means that we need to wait until it does. - // also, that means that the chunk and cb are currently - // being processed, so move the buffer counter past them. - if (state.writing) { - break; - } - } - - if (entry === null) state.lastBufferedRequest = null; - } - - state.bufferedRequest = entry; - state.bufferProcessing = false; -} - -Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('_write() is not implemented')); -}; - -Writable.prototype._writev = null; - -Writable.prototype.end = function (chunk, encoding, cb) { - var state = this._writableState; - - if (typeof chunk === 'function') { - cb = chunk; - chunk = null; - encoding = null; - } else if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } - - if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); - - // .end() fully uncorks - if (state.corked) { - state.corked = 1; - this.uncork(); - } - - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) endWritable(this, state, cb); -}; - -function needFinish(state) { - return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; -} -function callFinal(stream, state) { - stream._final(function (err) { - state.pendingcb--; - if (err) { - stream.emit('error', err); - } - state.prefinished = true; - stream.emit('prefinish'); - finishMaybe(stream, state); - }); -} -function prefinish(stream, state) { - if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function') { - state.pendingcb++; - state.finalCalled = true; - pna.nextTick(callFinal, stream, state); - } else { - state.prefinished = true; - stream.emit('prefinish'); - } - } -} - -function finishMaybe(stream, state) { - var need = needFinish(state); - if (need) { - prefinish(stream, state); - if (state.pendingcb === 0) { - state.finished = true; - stream.emit('finish'); - } - } - return need; -} - -function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - if (cb) { - if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); - } - state.ended = true; - stream.writable = false; -} - -function onCorkedFinish(corkReq, state, err) { - var entry = corkReq.entry; - corkReq.entry = null; - while (entry) { - var cb = entry.callback; - state.pendingcb--; - cb(err); - entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = corkReq; - } else { - state.corkedRequestsFree = corkReq; - } -} - -Object.defineProperty(Writable.prototype, 'destroyed', { - get: function () { - if (this._writableState === undefined) { - return false; - } - return this._writableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (!this._writableState) { - return; - } - - // backward compatibility, the user is explicitly - // managing destroyed - this._writableState.destroyed = value; - } -}); - -Writable.prototype.destroy = destroyImpl.destroy; -Writable.prototype._undestroy = destroyImpl.undestroy; -Writable.prototype._destroy = function (err, cb) { - this.end(); - cb(err); -}; -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) -},{"./_stream_duplex":58,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":52,"core-util-is":18,"inherits":46,"process-nextick-args":51,"safe-buffer":71,"timers":73,"util-deprecate":76}],63:[function(require,module,exports){ -'use strict'; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var Buffer = require('safe-buffer').Buffer; -var util = require('util'); - -function copyBuffer(src, target, offset) { - src.copy(target, offset); -} - -module.exports = function () { - function BufferList() { - _classCallCheck(this, BufferList); - - this.head = null; - this.tail = null; - this.length = 0; - } - - BufferList.prototype.push = function push(v) { - var entry = { data: v, next: null }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; - }; - - BufferList.prototype.unshift = function unshift(v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; - }; - - BufferList.prototype.shift = function shift() { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; - }; - - BufferList.prototype.clear = function clear() { - this.head = this.tail = null; - this.length = 0; - }; - - BufferList.prototype.join = function join(s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) { - ret += s + p.data; - }return ret; - }; - - BufferList.prototype.concat = function concat(n) { - if (this.length === 0) return Buffer.alloc(0); - if (this.length === 1) return this.head.data; - var ret = Buffer.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - copyBuffer(p.data, ret, i); - i += p.data.length; - p = p.next; - } - return ret; - }; - - return BufferList; -}(); - -if (util && util.inspect && util.inspect.custom) { - module.exports.prototype[util.inspect.custom] = function () { - var obj = util.inspect({ length: this.length }); - return this.constructor.name + ' ' + obj; - }; -} -},{"safe-buffer":71,"util":4}],64:[function(require,module,exports){ -'use strict'; - -/**/ - -var pna = require('process-nextick-args'); -/**/ - -// undocumented cb() API, needed for core, not for public API -function destroy(err, cb) { - var _this = this; - - var readableDestroyed = this._readableState && this._readableState.destroyed; - var writableDestroyed = this._writableState && this._writableState.destroyed; - - if (readableDestroyed || writableDestroyed) { - if (cb) { - cb(err); - } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { - pna.nextTick(emitErrorNT, this, err); - } - return this; - } - - // we set destroyed to true before firing error callbacks in order - // to make it re-entrance safe in case destroy() is called within callbacks - - if (this._readableState) { - this._readableState.destroyed = true; - } - - // if this is a duplex stream mark the writable part as destroyed as well - if (this._writableState) { - this._writableState.destroyed = true; - } - - this._destroy(err || null, function (err) { - if (!cb && err) { - pna.nextTick(emitErrorNT, _this, err); - if (_this._writableState) { - _this._writableState.errorEmitted = true; - } - } else if (cb) { - cb(err); - } - }); - - return this; -} - -function undestroy() { - if (this._readableState) { - this._readableState.destroyed = false; - this._readableState.reading = false; - this._readableState.ended = false; - this._readableState.endEmitted = false; - } - - if (this._writableState) { - this._writableState.destroyed = false; - this._writableState.ended = false; - this._writableState.ending = false; - this._writableState.finished = false; - this._writableState.errorEmitted = false; - } -} - -function emitErrorNT(self, err) { - self.emit('error', err); -} - -module.exports = { - destroy: destroy, - undestroy: undestroy -}; -},{"process-nextick-args":51}],65:[function(require,module,exports){ -module.exports = require('events').EventEmitter; - -},{"events":44}],66:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -'use strict'; - -/**/ - -var Buffer = require('safe-buffer').Buffer; -/**/ - -var isEncoding = Buffer.isEncoding || function (encoding) { - encoding = '' + encoding; - switch (encoding && encoding.toLowerCase()) { - case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': - return true; - default: - return false; - } -}; - -function _normalizeEncoding(enc) { - if (!enc) return 'utf8'; - var retried; - while (true) { - switch (enc) { - case 'utf8': - case 'utf-8': - return 'utf8'; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return 'utf16le'; - case 'latin1': - case 'binary': - return 'latin1'; - case 'base64': - case 'ascii': - case 'hex': - return enc; - default: - if (retried) return; // undefined - enc = ('' + enc).toLowerCase(); - retried = true; - } - } -}; - -// Do not cache `Buffer.isEncoding` when checking encoding names as some -// modules monkey-patch it to support additional encodings -function normalizeEncoding(enc) { - var nenc = _normalizeEncoding(enc); - if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); - return nenc || enc; -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. -exports.StringDecoder = StringDecoder; -function StringDecoder(encoding) { - this.encoding = normalizeEncoding(encoding); - var nb; - switch (this.encoding) { - case 'utf16le': - this.text = utf16Text; - this.end = utf16End; - nb = 4; - break; - case 'utf8': - this.fillLast = utf8FillLast; - nb = 4; - break; - case 'base64': - this.text = base64Text; - this.end = base64End; - nb = 3; - break; - default: - this.write = simpleWrite; - this.end = simpleEnd; - return; - } - this.lastNeed = 0; - this.lastTotal = 0; - this.lastChar = Buffer.allocUnsafe(nb); -} - -StringDecoder.prototype.write = function (buf) { - if (buf.length === 0) return ''; - var r; - var i; - if (this.lastNeed) { - r = this.fillLast(buf); - if (r === undefined) return ''; - i = this.lastNeed; - this.lastNeed = 0; - } else { - i = 0; - } - if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); - return r || ''; -}; - -StringDecoder.prototype.end = utf8End; - -// Returns only complete characters in a Buffer -StringDecoder.prototype.text = utf8Text; - -// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer -StringDecoder.prototype.fillLast = function (buf) { - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); - this.lastNeed -= buf.length; -}; - -// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a -// continuation byte. If an invalid byte is detected, -2 is returned. -function utf8CheckByte(byte) { - if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; - return byte >> 6 === 0x02 ? -1 : -2; -} - -// Checks at most 3 bytes at the end of a Buffer in order to detect an -// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) -// needed to complete the UTF-8 character (if applicable) are returned. -function utf8CheckIncomplete(self, buf, i) { - var j = buf.length - 1; - if (j < i) return 0; - var nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 1; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 2; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) { - if (nb === 2) nb = 0;else self.lastNeed = nb - 3; - } - return nb; - } - return 0; -} - -// Validates as many continuation bytes for a multi-byte UTF-8 character as -// needed or are available. If we see a non-continuation byte where we expect -// one, we "replace" the validated continuation bytes we've seen so far with -// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding -// behavior. The continuation byte check is included three times in the case -// where all of the continuation bytes for a character exist in the same buffer. -// It is also done this way as a slight performance increase instead of using a -// loop. -function utf8CheckExtraBytes(self, buf, p) { - if ((buf[0] & 0xC0) !== 0x80) { - self.lastNeed = 0; - return '\ufffd'; - } - if (self.lastNeed > 1 && buf.length > 1) { - if ((buf[1] & 0xC0) !== 0x80) { - self.lastNeed = 1; - return '\ufffd'; - } - if (self.lastNeed > 2 && buf.length > 2) { - if ((buf[2] & 0xC0) !== 0x80) { - self.lastNeed = 2; - return '\ufffd'; - } - } - } -} - -// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. -function utf8FillLast(buf) { - var p = this.lastTotal - this.lastNeed; - var r = utf8CheckExtraBytes(this, buf, p); - if (r !== undefined) return r; - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, p, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, p, 0, buf.length); - this.lastNeed -= buf.length; -} - -// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a -// partial character, the character's bytes are buffered until the required -// number of bytes are available. -function utf8Text(buf, i) { - var total = utf8CheckIncomplete(this, buf, i); - if (!this.lastNeed) return buf.toString('utf8', i); - this.lastTotal = total; - var end = buf.length - (total - this.lastNeed); - buf.copy(this.lastChar, 0, end); - return buf.toString('utf8', i, end); -} - -// For UTF-8, a replacement character is added when ending on a partial -// character. -function utf8End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + '\ufffd'; - return r; -} - -// UTF-16LE typically needs two bytes per character, but even if we have an even -// number of bytes available, we need to check if we end on a leading/high -// surrogate. In that case, we need to wait for the next two bytes in order to -// decode the last character properly. -function utf16Text(buf, i) { - if ((buf.length - i) % 2 === 0) { - var r = buf.toString('utf16le', i); - if (r) { - var c = r.charCodeAt(r.length - 1); - if (c >= 0xD800 && c <= 0xDBFF) { - this.lastNeed = 2; - this.lastTotal = 4; - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - return r.slice(0, -1); - } - } - return r; - } - this.lastNeed = 1; - this.lastTotal = 2; - this.lastChar[0] = buf[buf.length - 1]; - return buf.toString('utf16le', i, buf.length - 1); -} - -// For UTF-16LE we do not explicitly append special replacement characters if we -// end on a partial character, we simply let v8 handle that. -function utf16End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) { - var end = this.lastTotal - this.lastNeed; - return r + this.lastChar.toString('utf16le', 0, end); - } - return r; -} - -function base64Text(buf, i) { - var n = (buf.length - i) % 3; - if (n === 0) return buf.toString('base64', i); - this.lastNeed = 3 - n; - this.lastTotal = 3; - if (n === 1) { - this.lastChar[0] = buf[buf.length - 1]; - } else { - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - } - return buf.toString('base64', i, buf.length - n); -} - -function base64End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); - return r; -} - -// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) -function simpleWrite(buf) { - return buf.toString(this.encoding); -} - -function simpleEnd(buf) { - return buf && buf.length ? this.write(buf) : ''; -} -},{"safe-buffer":71}],67:[function(require,module,exports){ -module.exports = require('./readable').PassThrough - -},{"./readable":68}],68:[function(require,module,exports){ -exports = module.exports = require('./lib/_stream_readable.js'); -exports.Stream = exports; -exports.Readable = exports; -exports.Writable = require('./lib/_stream_writable.js'); -exports.Duplex = require('./lib/_stream_duplex.js'); -exports.Transform = require('./lib/_stream_transform.js'); -exports.PassThrough = require('./lib/_stream_passthrough.js'); - -},{"./lib/_stream_duplex.js":58,"./lib/_stream_passthrough.js":59,"./lib/_stream_readable.js":60,"./lib/_stream_transform.js":61,"./lib/_stream_writable.js":62}],69:[function(require,module,exports){ -module.exports = require('./readable').Transform - -},{"./readable":68}],70:[function(require,module,exports){ -module.exports = require('./lib/_stream_writable.js'); - -},{"./lib/_stream_writable.js":62}],71:[function(require,module,exports){ -/* eslint-disable node/no-deprecated-api */ -var buffer = require('buffer') -var Buffer = buffer.Buffer - -// alternative to using Object.keys for old browsers -function copyProps (src, dst) { - for (var key in src) { - dst[key] = src[key] - } -} -if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer -} else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer -} - -function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) -} - -// Copy static methods from Buffer -copyProps(Buffer, SafeBuffer) - -SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) -} - -SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) - } - return buf -} - -SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) -} - -SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return buffer.SlowBuffer(size) -} - -},{"buffer":6}],72:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -module.exports = Stream; - -var EE = require('events').EventEmitter; -var inherits = require('inherits'); - -inherits(Stream, EE); -Stream.Readable = require('readable-stream/readable.js'); -Stream.Writable = require('readable-stream/writable.js'); -Stream.Duplex = require('readable-stream/duplex.js'); -Stream.Transform = require('readable-stream/transform.js'); -Stream.PassThrough = require('readable-stream/passthrough.js'); - -// Backwards-compat with node 0.4.x -Stream.Stream = Stream; - - - -// old-style streams. Note that the pipe method (the only relevant -// part of this class) is overridden in the Readable class. - -function Stream() { - EE.call(this); -} - -Stream.prototype.pipe = function(dest, options) { - var source = this; - - function ondata(chunk) { - if (dest.writable) { - if (false === dest.write(chunk) && source.pause) { - source.pause(); - } - } - } - - source.on('data', ondata); - - function ondrain() { - if (source.readable && source.resume) { - source.resume(); - } - } - - dest.on('drain', ondrain); - - // If the 'end' option is not supplied, dest.end() will be called when - // source gets the 'end' or 'close' events. Only dest.end() once. - if (!dest._isStdio && (!options || options.end !== false)) { - source.on('end', onend); - source.on('close', onclose); - } - - var didOnEnd = false; - function onend() { - if (didOnEnd) return; - didOnEnd = true; - - dest.end(); - } - - - function onclose() { - if (didOnEnd) return; - didOnEnd = true; - - if (typeof dest.destroy === 'function') dest.destroy(); - } - - // don't leave dangling pipes when there are errors. - function onerror(er) { - cleanup(); - if (EE.listenerCount(this, 'error') === 0) { - throw er; // Unhandled stream error in pipe. - } - } - - source.on('error', onerror); - dest.on('error', onerror); - - // remove all the event listeners that were added. - function cleanup() { - source.removeListener('data', ondata); - dest.removeListener('drain', ondrain); - - source.removeListener('end', onend); - source.removeListener('close', onclose); - - source.removeListener('error', onerror); - dest.removeListener('error', onerror); - - source.removeListener('end', cleanup); - source.removeListener('close', cleanup); - - dest.removeListener('close', cleanup); - } - - source.on('end', cleanup); - source.on('close', cleanup); - - dest.on('close', cleanup); - - dest.emit('pipe', source); - - // Allow for unix-like usage: A.pipe(B).pipe(C) - return dest; -}; - -},{"events":44,"inherits":46,"readable-stream/duplex.js":57,"readable-stream/passthrough.js":67,"readable-stream/readable.js":68,"readable-stream/transform.js":69,"readable-stream/writable.js":70}],73:[function(require,module,exports){ -(function (setImmediate,clearImmediate){ -var nextTick = require('process/browser.js').nextTick; -var apply = Function.prototype.apply; -var slice = Array.prototype.slice; -var immediateIds = {}; -var nextImmediateId = 0; - -// DOM APIs, for completeness - -exports.setTimeout = function() { - return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); -}; -exports.setInterval = function() { - return new Timeout(apply.call(setInterval, window, arguments), clearInterval); -}; -exports.clearTimeout = -exports.clearInterval = function(timeout) { timeout.close(); }; - -function Timeout(id, clearFn) { - this._id = id; - this._clearFn = clearFn; -} -Timeout.prototype.unref = Timeout.prototype.ref = function() {}; -Timeout.prototype.close = function() { - this._clearFn.call(window, this._id); -}; - -// Does not start the time, just sets up the members needed. -exports.enroll = function(item, msecs) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = msecs; -}; - -exports.unenroll = function(item) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = -1; -}; - -exports._unrefActive = exports.active = function(item) { - clearTimeout(item._idleTimeoutId); - - var msecs = item._idleTimeout; - if (msecs >= 0) { - item._idleTimeoutId = setTimeout(function onTimeout() { - if (item._onTimeout) - item._onTimeout(); - }, msecs); - } -}; - -// That's not how node.js implements it but the exposed api is the same. -exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { - var id = nextImmediateId++; - var args = arguments.length < 2 ? false : slice.call(arguments, 1); - - immediateIds[id] = true; - - nextTick(function onNextTick() { - if (immediateIds[id]) { - // fn.call() is faster so we optimize for the common use-case - // @see http://jsperf.com/call-apply-segu - if (args) { - fn.apply(null, args); - } else { - fn.call(null); - } - // Prevent ids from leaking - exports.clearImmediate(id); - } - }); - - return id; -}; - -exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { - delete immediateIds[id]; -}; -}).call(this,require("timers").setImmediate,require("timers").clearImmediate) -},{"process/browser.js":52,"timers":73}],74:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -'use strict'; - -var punycode = require('punycode'); -var util = require('./util'); - -exports.parse = urlParse; -exports.resolve = urlResolve; -exports.resolveObject = urlResolveObject; -exports.format = urlFormat; - -exports.Url = Url; - -function Url() { - this.protocol = null; - this.slashes = null; - this.auth = null; - this.host = null; - this.port = null; - this.hostname = null; - this.hash = null; - this.search = null; - this.query = null; - this.pathname = null; - this.path = null; - this.href = null; -} - -// Reference: RFC 3986, RFC 1808, RFC 2396 - -// define these here so at least they only have to be -// compiled once on the first module load. -var protocolPattern = /^([a-z0-9.+-]+:)/i, - portPattern = /:[0-9]*$/, - - // Special case for a simple path URL - simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, - - // RFC 2396: characters reserved for delimiting URLs. - // We actually just auto-escape these. - delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], - - // RFC 2396: characters not allowed for various reasons. - unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), - - // Allowed by RFCs, but cause of XSS attacks. Always escape these. - autoEscape = ['\''].concat(unwise), - // Characters that are never ever allowed in a hostname. - // Note that any invalid chars are also handled, but these - // are the ones that are *expected* to be seen, so we fast-path - // them. - nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), - hostEndingChars = ['/', '?', '#'], - hostnameMaxLen = 255, - hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, - hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, - // protocols that can allow "unsafe" and "unwise" chars. - unsafeProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that never have a hostname. - hostlessProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that always contain a // bit. - slashedProtocol = { - 'http': true, - 'https': true, - 'ftp': true, - 'gopher': true, - 'file': true, - 'http:': true, - 'https:': true, - 'ftp:': true, - 'gopher:': true, - 'file:': true - }, - querystring = require('querystring'); - -function urlParse(url, parseQueryString, slashesDenoteHost) { - if (url && util.isObject(url) && url instanceof Url) return url; - - var u = new Url; - u.parse(url, parseQueryString, slashesDenoteHost); - return u; -} - -Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { - if (!util.isString(url)) { - throw new TypeError("Parameter 'url' must be a string, not " + typeof url); - } - - // Copy chrome, IE, opera backslash-handling behavior. - // Back slashes before the query string get converted to forward slashes - // See: https://code.google.com/p/chromium/issues/detail?id=25916 - var queryIndex = url.indexOf('?'), - splitter = - (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', - uSplit = url.split(splitter), - slashRegex = /\\/g; - uSplit[0] = uSplit[0].replace(slashRegex, '/'); - url = uSplit.join(splitter); - - var rest = url; - - // trim before proceeding. - // This is to support parse stuff like " http://foo.com \n" - rest = rest.trim(); - - if (!slashesDenoteHost && url.split('#').length === 1) { - // Try fast path regexp - var simplePath = simplePathPattern.exec(rest); - if (simplePath) { - this.path = rest; - this.href = rest; - this.pathname = simplePath[1]; - if (simplePath[2]) { - this.search = simplePath[2]; - if (parseQueryString) { - this.query = querystring.parse(this.search.substr(1)); - } else { - this.query = this.search.substr(1); - } - } else if (parseQueryString) { - this.search = ''; - this.query = {}; - } - return this; - } - } - - var proto = protocolPattern.exec(rest); - if (proto) { - proto = proto[0]; - var lowerProto = proto.toLowerCase(); - this.protocol = lowerProto; - rest = rest.substr(proto.length); - } - - // figure out if it's got a host - // user@server is *always* interpreted as a hostname, and url - // resolution will treat //foo/bar as host=foo,path=bar because that's - // how the browser resolves relative URLs. - if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { - var slashes = rest.substr(0, 2) === '//'; - if (slashes && !(proto && hostlessProtocol[proto])) { - rest = rest.substr(2); - this.slashes = true; - } - } - - if (!hostlessProtocol[proto] && - (slashes || (proto && !slashedProtocol[proto]))) { - - // there's a hostname. - // the first instance of /, ?, ;, or # ends the host. - // - // If there is an @ in the hostname, then non-host chars *are* allowed - // to the left of the last @ sign, unless some host-ending character - // comes *before* the @-sign. - // URLs are obnoxious. - // - // ex: - // http://a@b@c/ => user:a@b host:c - // http://a@b?@c => user:a host:c path:/?@c - - // v0.12 TODO(isaacs): This is not quite how Chrome does things. - // Review our test case against browsers more comprehensively. - - // find the first instance of any hostEndingChars - var hostEnd = -1; - for (var i = 0; i < hostEndingChars.length; i++) { - var hec = rest.indexOf(hostEndingChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } - - // at this point, either we have an explicit point where the - // auth portion cannot go past, or the last @ char is the decider. - var auth, atSign; - if (hostEnd === -1) { - // atSign can be anywhere. - atSign = rest.lastIndexOf('@'); - } else { - // atSign must be in auth portion. - // http://a@b/c@d => host:b auth:a path:/c@d - atSign = rest.lastIndexOf('@', hostEnd); - } - - // Now we have a portion which is definitely the auth. - // Pull that off. - if (atSign !== -1) { - auth = rest.slice(0, atSign); - rest = rest.slice(atSign + 1); - this.auth = decodeURIComponent(auth); - } - - // the host is the remaining to the left of the first non-host char - hostEnd = -1; - for (var i = 0; i < nonHostChars.length; i++) { - var hec = rest.indexOf(nonHostChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } - // if we still have not hit it, then the entire thing is a host. - if (hostEnd === -1) - hostEnd = rest.length; - - this.host = rest.slice(0, hostEnd); - rest = rest.slice(hostEnd); - - // pull out port. - this.parseHost(); - - // we've indicated that there is a hostname, - // so even if it's empty, it has to be present. - this.hostname = this.hostname || ''; - - // if hostname begins with [ and ends with ] - // assume that it's an IPv6 address. - var ipv6Hostname = this.hostname[0] === '[' && - this.hostname[this.hostname.length - 1] === ']'; - - // validate a little. - if (!ipv6Hostname) { - var hostparts = this.hostname.split(/\./); - for (var i = 0, l = hostparts.length; i < l; i++) { - var part = hostparts[i]; - if (!part) continue; - if (!part.match(hostnamePartPattern)) { - var newpart = ''; - for (var j = 0, k = part.length; j < k; j++) { - if (part.charCodeAt(j) > 127) { - // we replace non-ASCII char with a temporary placeholder - // we need this to make sure size of hostname is not - // broken by replacing non-ASCII by nothing - newpart += 'x'; - } else { - newpart += part[j]; - } - } - // we test again with ASCII char only - if (!newpart.match(hostnamePartPattern)) { - var validParts = hostparts.slice(0, i); - var notHost = hostparts.slice(i + 1); - var bit = part.match(hostnamePartStart); - if (bit) { - validParts.push(bit[1]); - notHost.unshift(bit[2]); - } - if (notHost.length) { - rest = '/' + notHost.join('.') + rest; - } - this.hostname = validParts.join('.'); - break; - } - } - } - } - - if (this.hostname.length > hostnameMaxLen) { - this.hostname = ''; - } else { - // hostnames are always lower case. - this.hostname = this.hostname.toLowerCase(); - } - - if (!ipv6Hostname) { - // IDNA Support: Returns a punycoded representation of "domain". - // It only converts parts of the domain name that - // have non-ASCII characters, i.e. it doesn't matter if - // you call it with a domain that already is ASCII-only. - this.hostname = punycode.toASCII(this.hostname); - } - - var p = this.port ? ':' + this.port : ''; - var h = this.hostname || ''; - this.host = h + p; - this.href += this.host; - - // strip [ and ] from the hostname - // the host field still retains them, though - if (ipv6Hostname) { - this.hostname = this.hostname.substr(1, this.hostname.length - 2); - if (rest[0] !== '/') { - rest = '/' + rest; - } - } - } - - // now rest is set to the post-host stuff. - // chop off any delim chars. - if (!unsafeProtocol[lowerProto]) { - - // First, make 100% sure that any "autoEscape" chars get - // escaped, even if encodeURIComponent doesn't think they - // need to be. - for (var i = 0, l = autoEscape.length; i < l; i++) { - var ae = autoEscape[i]; - if (rest.indexOf(ae) === -1) - continue; - var esc = encodeURIComponent(ae); - if (esc === ae) { - esc = escape(ae); - } - rest = rest.split(ae).join(esc); - } - } - - - // chop off from the tail first. - var hash = rest.indexOf('#'); - if (hash !== -1) { - // got a fragment string. - this.hash = rest.substr(hash); - rest = rest.slice(0, hash); - } - var qm = rest.indexOf('?'); - if (qm !== -1) { - this.search = rest.substr(qm); - this.query = rest.substr(qm + 1); - if (parseQueryString) { - this.query = querystring.parse(this.query); - } - rest = rest.slice(0, qm); - } else if (parseQueryString) { - // no query string, but parseQueryString still requested - this.search = ''; - this.query = {}; - } - if (rest) this.pathname = rest; - if (slashedProtocol[lowerProto] && - this.hostname && !this.pathname) { - this.pathname = '/'; - } - - //to support http.request - if (this.pathname || this.search) { - var p = this.pathname || ''; - var s = this.search || ''; - this.path = p + s; - } - - // finally, reconstruct the href based on what has been validated. - this.href = this.format(); - return this; -}; - -// format a parsed object into a url string -function urlFormat(obj) { - // ensure it's an object, and not a string url. - // If it's an obj, this is a no-op. - // this way, you can call url_format() on strings - // to clean up potentially wonky urls. - if (util.isString(obj)) obj = urlParse(obj); - if (!(obj instanceof Url)) return Url.prototype.format.call(obj); - return obj.format(); -} - -Url.prototype.format = function() { - var auth = this.auth || ''; - if (auth) { - auth = encodeURIComponent(auth); - auth = auth.replace(/%3A/i, ':'); - auth += '@'; - } - - var protocol = this.protocol || '', - pathname = this.pathname || '', - hash = this.hash || '', - host = false, - query = ''; - - if (this.host) { - host = auth + this.host; - } else if (this.hostname) { - host = auth + (this.hostname.indexOf(':') === -1 ? - this.hostname : - '[' + this.hostname + ']'); - if (this.port) { - host += ':' + this.port; - } - } - - if (this.query && - util.isObject(this.query) && - Object.keys(this.query).length) { - query = querystring.stringify(this.query); - } - - var search = this.search || (query && ('?' + query)) || ''; - - if (protocol && protocol.substr(-1) !== ':') protocol += ':'; - - // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. - // unless they had them to begin with. - if (this.slashes || - (!protocol || slashedProtocol[protocol]) && host !== false) { - host = '//' + (host || ''); - if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; - } else if (!host) { - host = ''; - } - - if (hash && hash.charAt(0) !== '#') hash = '#' + hash; - if (search && search.charAt(0) !== '?') search = '?' + search; - - pathname = pathname.replace(/[?#]/g, function(match) { - return encodeURIComponent(match); - }); - search = search.replace('#', '%23'); - - return protocol + host + pathname + search + hash; -}; - -function urlResolve(source, relative) { - return urlParse(source, false, true).resolve(relative); -} - -Url.prototype.resolve = function(relative) { - return this.resolveObject(urlParse(relative, false, true)).format(); -}; - -function urlResolveObject(source, relative) { - if (!source) return relative; - return urlParse(source, false, true).resolveObject(relative); -} - -Url.prototype.resolveObject = function(relative) { - if (util.isString(relative)) { - var rel = new Url(); - rel.parse(relative, false, true); - relative = rel; - } - - var result = new Url(); - var tkeys = Object.keys(this); - for (var tk = 0; tk < tkeys.length; tk++) { - var tkey = tkeys[tk]; - result[tkey] = this[tkey]; - } - - // hash is always overridden, no matter what. - // even href="" will remove it. - result.hash = relative.hash; - - // if the relative url is empty, then there's nothing left to do here. - if (relative.href === '') { - result.href = result.format(); - return result; - } - - // hrefs like //foo/bar always cut to the protocol. - if (relative.slashes && !relative.protocol) { - // take everything except the protocol from relative - var rkeys = Object.keys(relative); - for (var rk = 0; rk < rkeys.length; rk++) { - var rkey = rkeys[rk]; - if (rkey !== 'protocol') - result[rkey] = relative[rkey]; - } - - //urlParse appends trailing / to urls like http://www.example.com - if (slashedProtocol[result.protocol] && - result.hostname && !result.pathname) { - result.path = result.pathname = '/'; - } - - result.href = result.format(); - return result; - } - - if (relative.protocol && relative.protocol !== result.protocol) { - // if it's a known url protocol, then changing - // the protocol does weird things - // first, if it's not file:, then we MUST have a host, - // and if there was a path - // to begin with, then we MUST have a path. - // if it is file:, then the host is dropped, - // because that's known to be hostless. - // anything else is assumed to be absolute. - if (!slashedProtocol[relative.protocol]) { - var keys = Object.keys(relative); - for (var v = 0; v < keys.length; v++) { - var k = keys[v]; - result[k] = relative[k]; - } - result.href = result.format(); - return result; - } - - result.protocol = relative.protocol; - if (!relative.host && !hostlessProtocol[relative.protocol]) { - var relPath = (relative.pathname || '').split('/'); - while (relPath.length && !(relative.host = relPath.shift())); - if (!relative.host) relative.host = ''; - if (!relative.hostname) relative.hostname = ''; - if (relPath[0] !== '') relPath.unshift(''); - if (relPath.length < 2) relPath.unshift(''); - result.pathname = relPath.join('/'); - } else { - result.pathname = relative.pathname; - } - result.search = relative.search; - result.query = relative.query; - result.host = relative.host || ''; - result.auth = relative.auth; - result.hostname = relative.hostname || relative.host; - result.port = relative.port; - // to support http.request - if (result.pathname || result.search) { - var p = result.pathname || ''; - var s = result.search || ''; - result.path = p + s; - } - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; - } - - var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), - isRelAbs = ( - relative.host || - relative.pathname && relative.pathname.charAt(0) === '/' - ), - mustEndAbs = (isRelAbs || isSourceAbs || - (result.host && relative.pathname)), - removeAllDots = mustEndAbs, - srcPath = result.pathname && result.pathname.split('/') || [], - relPath = relative.pathname && relative.pathname.split('/') || [], - psychotic = result.protocol && !slashedProtocol[result.protocol]; - - // if the url is a non-slashed url, then relative - // links like ../.. should be able - // to crawl up to the hostname, as well. This is strange. - // result.protocol has already been set by now. - // Later on, put the first path part into the host field. - if (psychotic) { - result.hostname = ''; - result.port = null; - if (result.host) { - if (srcPath[0] === '') srcPath[0] = result.host; - else srcPath.unshift(result.host); - } - result.host = ''; - if (relative.protocol) { - relative.hostname = null; - relative.port = null; - if (relative.host) { - if (relPath[0] === '') relPath[0] = relative.host; - else relPath.unshift(relative.host); - } - relative.host = null; - } - mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); - } - - if (isRelAbs) { - // it's absolute. - result.host = (relative.host || relative.host === '') ? - relative.host : result.host; - result.hostname = (relative.hostname || relative.hostname === '') ? - relative.hostname : result.hostname; - result.search = relative.search; - result.query = relative.query; - srcPath = relPath; - // fall through to the dot-handling below. - } else if (relPath.length) { - // it's relative - // throw away the existing file, and take the new path instead. - if (!srcPath) srcPath = []; - srcPath.pop(); - srcPath = srcPath.concat(relPath); - result.search = relative.search; - result.query = relative.query; - } else if (!util.isNullOrUndefined(relative.search)) { - // just pull out the search. - // like href='?foo'. - // Put this after the other two cases because it simplifies the booleans - if (psychotic) { - result.hostname = result.host = srcPath.shift(); - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } - } - result.search = relative.search; - result.query = relative.query; - //to support http.request - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.href = result.format(); - return result; - } - - if (!srcPath.length) { - // no path at all. easy. - // we've already handled the other stuff above. - result.pathname = null; - //to support http.request - if (result.search) { - result.path = '/' + result.search; - } else { - result.path = null; - } - result.href = result.format(); - return result; - } - - // if a url ENDs in . or .., then it must get a trailing slash. - // however, if it ends in anything else non-slashy, - // then it must NOT get a trailing slash. - var last = srcPath.slice(-1)[0]; - var hasTrailingSlash = ( - (result.host || relative.host || srcPath.length > 1) && - (last === '.' || last === '..') || last === ''); - - // strip single dots, resolve double dots to parent dir - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = srcPath.length; i >= 0; i--) { - last = srcPath[i]; - if (last === '.') { - srcPath.splice(i, 1); - } else if (last === '..') { - srcPath.splice(i, 1); - up++; - } else if (up) { - srcPath.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (!mustEndAbs && !removeAllDots) { - for (; up--; up) { - srcPath.unshift('..'); - } - } - - if (mustEndAbs && srcPath[0] !== '' && - (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { - srcPath.unshift(''); - } - - if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { - srcPath.push(''); - } - - var isAbsolute = srcPath[0] === '' || - (srcPath[0] && srcPath[0].charAt(0) === '/'); - - // put the host back - if (psychotic) { - result.hostname = result.host = isAbsolute ? '' : - srcPath.length ? srcPath.shift() : ''; - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } - } - - mustEndAbs = mustEndAbs || (result.host && srcPath.length); - - if (mustEndAbs && !isAbsolute) { - srcPath.unshift(''); - } - - if (!srcPath.length) { - result.pathname = null; - result.path = null; - } else { - result.pathname = srcPath.join('/'); - } - - //to support request.http - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.auth = relative.auth || result.auth; - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; -}; - -Url.prototype.parseHost = function() { - var host = this.host; - var port = portPattern.exec(host); - if (port) { - port = port[0]; - if (port !== ':') { - this.port = port.substr(1); - } - host = host.substr(0, host.length - port.length); - } - if (host) this.hostname = host; -}; - -},{"./util":75,"punycode":53,"querystring":56}],75:[function(require,module,exports){ -'use strict'; - -module.exports = { - isString: function(arg) { - return typeof(arg) === 'string'; - }, - isObject: function(arg) { - return typeof(arg) === 'object' && arg !== null; - }, - isNull: function(arg) { - return arg === null; - }, - isNullOrUndefined: function(arg) { - return arg == null; - } -}; - -},{}],76:[function(require,module,exports){ -(function (global){ - -/** - * Module exports. - */ - -module.exports = deprecate; - -/** - * Mark that a method should not be used. - * Returns a modified function which warns once by default. - * - * If `localStorage.noDeprecation = true` is set, then it is a no-op. - * - * If `localStorage.throwDeprecation = true` is set, then deprecated functions - * will throw an Error when invoked. - * - * If `localStorage.traceDeprecation = true` is set, then deprecated functions - * will invoke `console.trace()` instead of `console.error()`. - * - * @param {Function} fn - the function to deprecate - * @param {String} msg - the string to print to the console when `fn` is invoked - * @returns {Function} a new "deprecated" version of `fn` - * @api public - */ - -function deprecate (fn, msg) { - if (config('noDeprecation')) { - return fn; - } - - var warned = false; - function deprecated() { - if (!warned) { - if (config('throwDeprecation')) { - throw new Error(msg); - } else if (config('traceDeprecation')) { - console.trace(msg); - } else { - console.warn(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } - - return deprecated; -} - -/** - * Checks `localStorage` for boolean values for the given `name`. - * - * @param {String} name - * @returns {Boolean} - * @api private - */ - -function config (name) { - // accessing global.localStorage can trigger a DOMException in sandboxed iframes - try { - if (!global.localStorage) return false; - } catch (_) { - return false; - } - var val = global.localStorage[name]; - if (null == val) return false; - return String(val).toLowerCase() === 'true'; -} - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],77:[function(require,module,exports){ -module.exports = function isBuffer(arg) { - return arg && typeof arg === 'object' - && typeof arg.copy === 'function' - && typeof arg.fill === 'function' - && typeof arg.readUInt8 === 'function'; -} -},{}],78:[function(require,module,exports){ -(function (process,global){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -var formatRegExp = /%[sdj%]/g; -exports.format = function(f) { - if (!isString(f)) { - var objects = []; - for (var i = 0; i < arguments.length; i++) { - objects.push(inspect(arguments[i])); - } - return objects.join(' '); - } - - var i = 1; - var args = arguments; - var len = args.length; - var str = String(f).replace(formatRegExp, function(x) { - if (x === '%%') return '%'; - if (i >= len) return x; - switch (x) { - case '%s': return String(args[i++]); - case '%d': return Number(args[i++]); - case '%j': - try { - return JSON.stringify(args[i++]); - } catch (_) { - return '[Circular]'; - } - default: - return x; - } - }); - for (var x = args[i]; i < len; x = args[++i]) { - if (isNull(x) || !isObject(x)) { - str += ' ' + x; - } else { - str += ' ' + inspect(x); - } - } - return str; -}; - - -// Mark that a method should not be used. -// Returns a modified function which warns once by default. -// If --no-deprecation is set, then it is a no-op. -exports.deprecate = function(fn, msg) { - // Allow for deprecating things in the process of starting up. - if (isUndefined(global.process)) { - return function() { - return exports.deprecate(fn, msg).apply(this, arguments); - }; - } - - if (process.noDeprecation === true) { - return fn; - } - - var warned = false; - function deprecated() { - if (!warned) { - if (process.throwDeprecation) { - throw new Error(msg); - } else if (process.traceDeprecation) { - console.trace(msg); - } else { - console.error(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } - - return deprecated; -}; - - -var debugs = {}; -var debugEnviron; -exports.debuglog = function(set) { - if (isUndefined(debugEnviron)) - debugEnviron = process.env.NODE_DEBUG || ''; - set = set.toUpperCase(); - if (!debugs[set]) { - if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { - var pid = process.pid; - debugs[set] = function() { - var msg = exports.format.apply(exports, arguments); - console.error('%s %d: %s', set, pid, msg); - }; - } else { - debugs[set] = function() {}; - } - } - return debugs[set]; -}; - - -/** - * Echos the value of a value. Trys to print the value out - * in the best way possible given the different types. - * - * @param {Object} obj The object to print out. - * @param {Object} opts Optional options object that alters the output. - */ -/* legacy: obj, showHidden, depth, colors*/ -function inspect(obj, opts) { - // default options - var ctx = { - seen: [], - stylize: stylizeNoColor - }; - // legacy... - if (arguments.length >= 3) ctx.depth = arguments[2]; - if (arguments.length >= 4) ctx.colors = arguments[3]; - if (isBoolean(opts)) { - // legacy... - ctx.showHidden = opts; - } else if (opts) { - // got an "options" object - exports._extend(ctx, opts); - } - // set default options - if (isUndefined(ctx.showHidden)) ctx.showHidden = false; - if (isUndefined(ctx.depth)) ctx.depth = 2; - if (isUndefined(ctx.colors)) ctx.colors = false; - if (isUndefined(ctx.customInspect)) ctx.customInspect = true; - if (ctx.colors) ctx.stylize = stylizeWithColor; - return formatValue(ctx, obj, ctx.depth); -} -exports.inspect = inspect; - - -// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics -inspect.colors = { - 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'inverse' : [7, 27], - 'white' : [37, 39], - 'grey' : [90, 39], - 'black' : [30, 39], - 'blue' : [34, 39], - 'cyan' : [36, 39], - 'green' : [32, 39], - 'magenta' : [35, 39], - 'red' : [31, 39], - 'yellow' : [33, 39] -}; - -// Don't use 'blue' not visible on cmd.exe -inspect.styles = { - 'special': 'cyan', - 'number': 'yellow', - 'boolean': 'yellow', - 'undefined': 'grey', - 'null': 'bold', - 'string': 'green', - 'date': 'magenta', - // "name": intentionally not styling - 'regexp': 'red' -}; - - -function stylizeWithColor(str, styleType) { - var style = inspect.styles[styleType]; - - if (style) { - return '\u001b[' + inspect.colors[style][0] + 'm' + str + - '\u001b[' + inspect.colors[style][1] + 'm'; - } else { - return str; - } -} - - -function stylizeNoColor(str, styleType) { - return str; -} - - -function arrayToHash(array) { - var hash = {}; - - array.forEach(function(val, idx) { - hash[val] = true; - }); - - return hash; -} - - -function formatValue(ctx, value, recurseTimes) { - // Provide a hook for user-specified inspect functions. - // Check that value is an object with an inspect function on it - if (ctx.customInspect && - value && - isFunction(value.inspect) && - // Filter out the util module, it's inspect function is special - value.inspect !== exports.inspect && - // Also filter out any prototype objects using the circular check. - !(value.constructor && value.constructor.prototype === value)) { - var ret = value.inspect(recurseTimes, ctx); - if (!isString(ret)) { - ret = formatValue(ctx, ret, recurseTimes); - } - return ret; - } - - // Primitive types cannot have properties - var primitive = formatPrimitive(ctx, value); - if (primitive) { - return primitive; - } - - // Look up the keys of the object. - var keys = Object.keys(value); - var visibleKeys = arrayToHash(keys); - - if (ctx.showHidden) { - keys = Object.getOwnPropertyNames(value); - } - - // IE doesn't make error fields non-enumerable - // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx - if (isError(value) - && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { - return formatError(value); - } - - // Some type of object without properties can be shortcutted. - if (keys.length === 0) { - if (isFunction(value)) { - var name = value.name ? ': ' + value.name : ''; - return ctx.stylize('[Function' + name + ']', 'special'); - } - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } - if (isDate(value)) { - return ctx.stylize(Date.prototype.toString.call(value), 'date'); - } - if (isError(value)) { - return formatError(value); - } - } - - var base = '', array = false, braces = ['{', '}']; - - // Make Array say that they are Array - if (isArray(value)) { - array = true; - braces = ['[', ']']; - } - - // Make functions say that they are functions - if (isFunction(value)) { - var n = value.name ? ': ' + value.name : ''; - base = ' [Function' + n + ']'; - } - - // Make RegExps say that they are RegExps - if (isRegExp(value)) { - base = ' ' + RegExp.prototype.toString.call(value); - } - - // Make dates with properties first say the date - if (isDate(value)) { - base = ' ' + Date.prototype.toUTCString.call(value); - } - - // Make error with message first say the error - if (isError(value)) { - base = ' ' + formatError(value); - } - - if (keys.length === 0 && (!array || value.length == 0)) { - return braces[0] + base + braces[1]; - } - - if (recurseTimes < 0) { - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } else { - return ctx.stylize('[Object]', 'special'); - } - } - - ctx.seen.push(value); - - var output; - if (array) { - output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); - } else { - output = keys.map(function(key) { - return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); - }); - } - - ctx.seen.pop(); - - return reduceToSingleString(output, base, braces); -} - - -function formatPrimitive(ctx, value) { - if (isUndefined(value)) - return ctx.stylize('undefined', 'undefined'); - if (isString(value)) { - var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; - return ctx.stylize(simple, 'string'); - } - if (isNumber(value)) - return ctx.stylize('' + value, 'number'); - if (isBoolean(value)) - return ctx.stylize('' + value, 'boolean'); - // For some reason typeof null is "object", so special case here. - if (isNull(value)) - return ctx.stylize('null', 'null'); -} - - -function formatError(value) { - return '[' + Error.prototype.toString.call(value) + ']'; -} - - -function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { - var output = []; - for (var i = 0, l = value.length; i < l; ++i) { - if (hasOwnProperty(value, String(i))) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - String(i), true)); - } else { - output.push(''); - } - } - keys.forEach(function(key) { - if (!key.match(/^\d+$/)) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); - } - }); - return output; -} - - -function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { - var name, str, desc; - desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; - if (desc.get) { - if (desc.set) { - str = ctx.stylize('[Getter/Setter]', 'special'); - } else { - str = ctx.stylize('[Getter]', 'special'); - } - } else { - if (desc.set) { - str = ctx.stylize('[Setter]', 'special'); - } - } - if (!hasOwnProperty(visibleKeys, key)) { - name = '[' + key + ']'; - } - if (!str) { - if (ctx.seen.indexOf(desc.value) < 0) { - if (isNull(recurseTimes)) { - str = formatValue(ctx, desc.value, null); - } else { - str = formatValue(ctx, desc.value, recurseTimes - 1); - } - if (str.indexOf('\n') > -1) { - if (array) { - str = str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n').substr(2); - } else { - str = '\n' + str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n'); - } - } - } else { - str = ctx.stylize('[Circular]', 'special'); - } - } - if (isUndefined(name)) { - if (array && key.match(/^\d+$/)) { - return str; - } - name = JSON.stringify('' + key); - if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { - name = name.substr(1, name.length - 2); - name = ctx.stylize(name, 'name'); - } else { - name = name.replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'"); - name = ctx.stylize(name, 'string'); - } - } - - return name + ': ' + str; -} - - -function reduceToSingleString(output, base, braces) { - var numLinesEst = 0; - var length = output.reduce(function(prev, cur) { - numLinesEst++; - if (cur.indexOf('\n') >= 0) numLinesEst++; - return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; - }, 0); - - if (length > 60) { - return braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; - } - - return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; -} - - -// NOTE: These type checking functions intentionally don't use `instanceof` -// because it is fragile and can be easily faked with `Object.create()`. -function isArray(ar) { - return Array.isArray(ar); -} -exports.isArray = isArray; - -function isBoolean(arg) { - return typeof arg === 'boolean'; -} -exports.isBoolean = isBoolean; - -function isNull(arg) { - return arg === null; -} -exports.isNull = isNull; - -function isNullOrUndefined(arg) { - return arg == null; -} -exports.isNullOrUndefined = isNullOrUndefined; - -function isNumber(arg) { - return typeof arg === 'number'; -} -exports.isNumber = isNumber; - -function isString(arg) { - return typeof arg === 'string'; -} -exports.isString = isString; - -function isSymbol(arg) { - return typeof arg === 'symbol'; -} -exports.isSymbol = isSymbol; - -function isUndefined(arg) { - return arg === void 0; -} -exports.isUndefined = isUndefined; - -function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; -} -exports.isRegExp = isRegExp; - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} -exports.isObject = isObject; - -function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; -} -exports.isDate = isDate; - -function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); -} -exports.isError = isError; - -function isFunction(arg) { - return typeof arg === 'function'; -} -exports.isFunction = isFunction; - -function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; -} -exports.isPrimitive = isPrimitive; - -exports.isBuffer = require('./support/isBuffer'); - -function objectToString(o) { - return Object.prototype.toString.call(o); -} - - -function pad(n) { - return n < 10 ? '0' + n.toString(10) : n.toString(10); -} - - -var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', - 'Oct', 'Nov', 'Dec']; - -// 26 Feb 16:19:34 -function timestamp() { - var d = new Date(); - var time = [pad(d.getHours()), - pad(d.getMinutes()), - pad(d.getSeconds())].join(':'); - return [d.getDate(), months[d.getMonth()], time].join(' '); -} - - -// log is just a thin wrapper to console.log that prepends a timestamp -exports.log = function() { - console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); -}; - - -/** - * Inherit the prototype methods from one constructor into another. - * - * The Function.prototype.inherits from lang.js rewritten as a standalone - * function (not on Function.prototype). NOTE: If this file is to be loaded - * during bootstrapping this function needs to be rewritten using some native - * functions as prototype setup using normal JavaScript does not work as - * expected during bootstrapping (see mirror.js in r114903). - * - * @param {function} ctor Constructor function which needs to inherit the - * prototype. - * @param {function} superCtor Constructor function to inherit prototype from. - */ -exports.inherits = require('inherits'); - -exports._extend = function(origin, add) { - // Don't do anything if add isn't an object - if (!add || !isObject(add)) return origin; - - var keys = Object.keys(add); - var i = keys.length; - while (i--) { - origin[keys[i]] = add[keys[i]]; - } - return origin; -}; - -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":77,"_process":52,"inherits":46}],79:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); -var base58 = require('./crypto/base58'); - -const bs58 = require('bs58'); -const CRC = require('crc'); -const cbor = require('cbor'); -const Tagged = cbor.Tagged; - -function getDecoded(address) { - try { - var decoded = bs58.decode(address); - return decoded = cbor.decode(decoded); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } -} - -module.exports = { - isValidAddress: function (address) { - var decoded = getDecoded(address); - - if (!decoded || (!Array.isArray(decoded) && decoded.length != 2)) { - return false; - } - - var [tagged, validCrc] = decoded; - if (!tagged instanceof Tagged) { - return false; - } - if (typeof (validCrc) != 'number') { - return false; - } - - // not sure what this is - if (tagged.tag != 24) { - return false; - } - - // get crc of the payload - let crc = CRC.crc32(tagged.value); - - return crc == validCrc; - } -}; - -},{"./crypto/base58":81,"./crypto/utils":86,"bs58":5,"cbor":7,"crc":43}],80:[function(require,module,exports){ -var base58 = require('./crypto/base58'); -var segwit = require('./crypto/segwit_addr'); -var cryptoUtils = require('./crypto/utils'); - -var DEFAULT_NETWORK_TYPE = 'prod'; - -function getDecoded(address) { - try { - return base58.decode(address); - } catch (e) { - // if decoding fails, assume invalid address - return null; - } -} - -function getChecksum(hashFunction, payload) { - // Each currency may implement different hashing algorithm - switch (hashFunction) { - case 'blake256': - return cryptoUtils.blake256Checksum(payload); - break; - case 'sha256': - default: - return cryptoUtils.sha256Checksum(payload); - } -} - -function getAddressType(address, currency) { - currency = currency || {}; - // should be 25 bytes per btc address spec and 26 decred - var expectedLength = currency.expectedLength || 25; - var hashFunction = currency.hashFunction || 'sha256'; - var decoded = getDecoded(address); - - if (decoded) { - var length = decoded.length; - - if (length !== expectedLength) { - return null; - } - - var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), - body = cryptoUtils.toHex(decoded.slice(0, length - 4)), - goodChecksum = getChecksum(hashFunction, body); - - return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; - } - - return null; -} - -function isValidP2PKHandP2SHAddress(address, currency, networkType) { - networkType = networkType || DEFAULT_NETWORK_TYPE; - - var correctAddressTypes; - var addressType = getAddressType(address, currency); - - if (addressType) { - if (networkType === 'prod' || networkType === 'testnet') { - correctAddressTypes = currency.addressTypes[networkType] - } else { - correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); - } - - return correctAddressTypes.indexOf(addressType) >= 0; - } - - return false; -} - -module.exports = { - isValidAddress: function (address, currency, networkType) { - return isValidP2PKHandP2SHAddress(address, currency, networkType) || segwit.isValidAddress(address); - } -}; - -},{"./crypto/base58":81,"./crypto/segwit_addr":84,"./crypto/utils":86}],81:[function(require,module,exports){ -// Base58 encoding/decoding -// Originally written by Mike Hearn for BitcoinJ -// Copyright (c) 2011 Google Inc -// Ported to JavaScript by Stefan Thomas -// Merged Buffer refactorings from base58-native by Stephen Pair -// Copyright (c) 2013 BitPay Inc - -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; -var ALPHABET_MAP = {}; -for (var i = 0; i < ALPHABET.length; ++i) { - ALPHABET_MAP[ALPHABET.charAt(i)] = i; -} -var BASE = ALPHABET.length; - -module.exports = { - decode: function(string) { - if (string.length === 0) return []; - - var i, j, bytes = [0]; - for (i = 0; i < string.length; ++i) { - var c = string[i]; - if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character'); - - for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE - bytes[0] += ALPHABET_MAP[c]; - - var carry = 0; - for (j = 0; j < bytes.length; ++j) { - bytes[j] += carry; - carry = bytes[j] >> 8; - bytes[j] &= 0xff - } - - while (carry) { - bytes.push(carry & 0xff); - carry >>= 8; - } - } - // deal with leading zeros - for (i = 0; string[i] === '1' && i < string.length - 1; ++i){ - bytes.push(0); - } - - return bytes.reverse(); - } -}; - -},{}],82:[function(require,module,exports){ -// Copyright (c) 2017 Pieter Wuille -// -// 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. - -var CHARSET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'; -var GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]; - -module.exports = { - decode: decode, - encode: encode, -}; - - -function polymod (values) { - var chk = 1; - for (var p = 0; p < values.length; ++p) { - var top = chk >> 25; - chk = (chk & 0x1ffffff) << 5 ^ values[p]; - for (var i = 0; i < 5; ++i) { - if ((top >> i) & 1) { - chk ^= GENERATOR[i]; - } - } - } - return chk; -} - -function hrpExpand (hrp) { - var ret = []; - var p; - for (p = 0; p < hrp.length; ++p) { - ret.push(hrp.charCodeAt(p) >> 5); - } - ret.push(0); - for (p = 0; p < hrp.length; ++p) { - ret.push(hrp.charCodeAt(p) & 31); - } - return ret; -} - -function verifyChecksum (hrp, data) { - return polymod(hrpExpand(hrp).concat(data)) === 1; -} - -function createChecksum (hrp, data) { - var values = hrpExpand(hrp).concat(data).concat([0, 0, 0, 0, 0, 0]); - var mod = polymod(values) ^ 1; - var ret = []; - for (var p = 0; p < 6; ++p) { - ret.push((mod >> 5 * (5 - p)) & 31); - } - return ret; -} - -function encode (hrp, data) { - var combined = data.concat(createChecksum(hrp, data)); - var ret = hrp + '1'; - for (var p = 0; p < combined.length; ++p) { - ret += CHARSET.charAt(combined[p]); - } - return ret; -} - -function decode (bechString) { - var p; - var has_lower = false; - var has_upper = false; - for (p = 0; p < bechString.length; ++p) { - if (bechString.charCodeAt(p) < 33 || bechString.charCodeAt(p) > 126) { - return null; - } - if (bechString.charCodeAt(p) >= 97 && bechString.charCodeAt(p) <= 122) { - has_lower = true; - } - if (bechString.charCodeAt(p) >= 65 && bechString.charCodeAt(p) <= 90) { - has_upper = true; - } - } - if (has_lower && has_upper) { - return null; - } - bechString = bechString.toLowerCase(); - var pos = bechString.lastIndexOf('1'); - if (pos < 1 || pos + 7 > bechString.length || bechString.length > 90) { - return null; - } - var hrp = bechString.substring(0, pos); - var data = []; - for (p = pos + 1; p < bechString.length; ++p) { - var d = CHARSET.indexOf(bechString.charAt(p)); - if (d === -1) { - return null; - } - data.push(d); - } - if (!verifyChecksum(hrp, data)) { - return null; - } - return {hrp: hrp, data: data.slice(0, data.length - 6)}; -} - -},{}],83:[function(require,module,exports){ -(function (Buffer){ -'use strict'; - -/** - * Credits to https://github.com/cryptocoinjs/blake-hash - */ -Blake256.sigma = [ - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], - [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], - [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], - [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], - [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] -] - -Blake256.u256 = [ - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 -] - -Blake256.padding = new Buffer([ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -]) - -Blake256.prototype._length_carry = function (arr) { - for (var j = 0; j < arr.length; ++j) { - if (arr[j] < 0x0100000000) break - arr[j] -= 0x0100000000 - arr[j + 1] += 1 - } -} - -Blake256.prototype.update = function (data, encoding) { - data = new Buffer(data, encoding); - var block = this._block - var offset = 0 - - while (this._blockOffset + data.length - offset >= block.length) { - for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] - - this._length[0] += block.length * 8 - this._length_carry(this._length) - - this._compress() - this._blockOffset = 0 - } - - while (offset < data.length) block[this._blockOffset++] = data[offset++] - return this; -} - -var zo = new Buffer([0x01]) -var oo = new Buffer([0x81]) - -function rot (x, n) { - return ((x << (32 - n)) | (x >>> n)) >>> 0 -} - -function g (v, m, i, a, b, c, d, e) { - var sigma = Blake256.sigma - var u256 = Blake256.u256 - - v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 16) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 12) - v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 - v[d] = rot(v[d] ^ v[a], 8) - v[c] = (v[c] + v[d]) >>> 0 - v[b] = rot(v[b] ^ v[c], 7) -} - -function Blake256 () { - this._h = [ - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 - ] - - this._s = [0, 0, 0, 0] - - this._block = new Buffer(64) - this._blockOffset = 0 - this._length = [0, 0] - - this._nullt = false - - this._zo = zo - this._oo = oo -} - -Blake256.prototype._compress = function () { - var u256 = Blake256.u256 - var v = new Array(16) - var m = new Array(16) - var i - - for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) - for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 - for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 - for (i = 12; i < 16; ++i) v[i] = u256[i - 8] - - if (!this._nullt) { - v[12] = (v[12] ^ this._length[0]) >>> 0 - v[13] = (v[13] ^ this._length[0]) >>> 0 - v[14] = (v[14] ^ this._length[1]) >>> 0 - v[15] = (v[15] ^ this._length[1]) >>> 0 - } - - for (i = 0; i < 14; ++i) { - /* column step */ - g(v, m, i, 0, 4, 8, 12, 0) - g(v, m, i, 1, 5, 9, 13, 2) - g(v, m, i, 2, 6, 10, 14, 4) - g(v, m, i, 3, 7, 11, 15, 6) - /* diagonal step */ - g(v, m, i, 0, 5, 10, 15, 8) - g(v, m, i, 1, 6, 11, 12, 10) - g(v, m, i, 2, 7, 8, 13, 12) - g(v, m, i, 3, 4, 9, 14, 14) - } - - for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 - for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 -} - -Blake256.prototype._padding = function () { - var lo = this._length[0] + this._blockOffset * 8 - var hi = this._length[1] - if (lo >= 0x0100000000) { - lo -= 0x0100000000 - hi += 1 - } - - var msglen = new Buffer(8) - msglen.writeUInt32BE(hi, 0) - msglen.writeUInt32BE(lo, 4) - - if (this._blockOffset === 55) { - this._length[0] -= 8 - this.update(this._oo) - } else { - if (this._blockOffset < 55) { - if (this._blockOffset === 0) this._nullt = true - this._length[0] -= (55 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) - } else { - this._length[0] -= (64 - this._blockOffset) * 8 - this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) - this._length[0] -= 55 * 8 - this.update(Blake256.padding.slice(1, 1 + 55)) - this._nullt = true - } - - this.update(this._zo) - this._length[0] -= 8 - } - - this._length[0] -= 64 - this.update(msglen) -} - -Blake256.prototype.digest = function (encoding) { - this._padding() - - var buffer = new Buffer(32) - for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) - return buffer.toString(encoding); -} - -module.exports = Blake256; -}).call(this,require("buffer").Buffer) -},{"buffer":6}],84:[function(require,module,exports){ -// Copyright (c) 2017 Pieter Wuille -// -// 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. - -var bech32 = require('./bech32'); - -function convertbits (data, frombits, tobits, pad) { - var acc = 0; - var bits = 0; - var ret = []; - var maxv = (1 << tobits) - 1; - for (var p = 0; p < data.length; ++p) { - var value = data[p]; - if (value < 0 || (value >> frombits) !== 0) { - return null; - } - acc = (acc << frombits) | value; - bits += frombits; - while (bits >= tobits) { - bits -= tobits; - ret.push((acc >> bits) & maxv); - } - } - if (pad) { - if (bits > 0) { - ret.push((acc << (tobits - bits)) & maxv); - } - } else if (bits >= frombits || ((acc << (tobits - bits)) & maxv)) { - return null; - } - return ret; -} - -function decode (hrp, addr) { - var dec = bech32.decode(addr); - if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) { - return null; - } - var res = convertbits(dec.data.slice(1), 5, 8, false); - if (res === null || res.length < 2 || res.length > 40) { - return null; - } - if (dec.data[0] === 0 && res.length !== 20 && res.length !== 32) { - return null; - } - return {version: dec.data[0], program: res}; -} - -function encode (hrp, version, program) { - var ret = bech32.encode(hrp, [version].concat(convertbits(program, 8, 5, true))); - if (decode(hrp, ret) === null) { - return null; - } - return ret; -} - -function isValidAddress(address) { - var hrp = 'bc'; - var ret = decode(hrp, address); - - if (ret === null) { - hrp = 'tb'; - ret = decode(hrp, address); - } - - if (ret === null) { - return false; - } - - var recreate = encode(hrp, ret.version, ret.program); - return recreate === address.toLowerCase(); -} - -module.exports = { - encode: encode, - decode: decode, - isValidAddress: isValidAddress, -}; - -},{"./bech32":82}],85:[function(require,module,exports){ -(function (process,global){ -/** - * [js-sha3]{@link https://github.com/emn178/js-sha3} - * - * @version 0.7.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2015-2017 - * @license MIT - */ -/*jslint bitwise: true */ -'use strict'; - -var ERROR = 'input is invalid type'; -var WINDOW = typeof window === 'object'; -var root = WINDOW ? window : {}; -if (root.JS_SHA3_NO_WINDOW) { - WINDOW = false; -} -var WEB_WORKER = !WINDOW && typeof self === 'object'; -var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; -if (NODE_JS) { - root = global; -} else if (WEB_WORKER) { - root = self; -} -var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; -var HEX_CHARS = '0123456789abcdef'.split(''); -var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; -var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; -var KECCAK_PADDING = [1, 256, 65536, 16777216]; -var PADDING = [6, 1536, 393216, 100663296]; -var SHIFT = [0, 8, 16, 24]; -var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, - 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, - 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, - 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, - 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; -var BITS = [224, 256, 384, 512]; -var SHAKE_BITS = [128, 256]; -var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; -var CSHAKE_BYTEPAD = { - '128': 168, - '256': 136 -}; - -if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { - Array.isArray = function (obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; - }; -} - -if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { - ArrayBuffer.isView = function (obj) { - return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; - }; -} - -var createOutputMethod = function (bits, padding, outputType) { - return function (message) { - return new Keccak(bits, padding, bits).update(message)[outputType](); - }; -}; - -var createShakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits) { - return new Keccak(bits, padding, outputBits).update(message)[outputType](); - }; -}; - -var createCshakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits, n, s) { - return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); - }; -}; - -var createKmacOutputMethod = function (bits, padding, outputType) { - return function (key, message, outputBits, s) { - return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); - }; -}; - -var createOutputMethods = function (method, createMethod, bits, padding) { - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createMethod(bits, padding, type); - } - return method; -}; - -var createMethod = function (bits, padding) { - var method = createOutputMethod(bits, padding, 'hex'); - method.create = function () { - return new Keccak(bits, padding, bits); - }; - method.update = function (message) { - return method.create().update(message); - }; - return createOutputMethods(method, createOutputMethod, bits, padding); -}; - -var createShakeMethod = function (bits, padding) { - var method = createShakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits) { - return new Keccak(bits, padding, outputBits); - }; - method.update = function (message, outputBits) { - return method.create(outputBits).update(message); - }; - return createOutputMethods(method, createShakeOutputMethod, bits, padding); -}; - -var createCshakeMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createCshakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits, n, s) { - if (!n && !s) { - return methods['shake' + bits].create(outputBits); - } else { - return new Keccak(bits, padding, outputBits).bytepad([n, s], w); - } - }; - method.update = function (message, outputBits, n, s) { - return method.create(outputBits, n, s).update(message); - }; - return createOutputMethods(method, createCshakeOutputMethod, bits, padding); -}; - -var createKmacMethod = function (bits, padding) { - var w = CSHAKE_BYTEPAD[bits]; - var method = createKmacOutputMethod(bits, padding, 'hex'); - method.create = function (key, outputBits, s) { - return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); - }; - method.update = function (key, message, outputBits, s) { - return method.create(key, outputBits, s).update(message); - }; - return createOutputMethods(method, createKmacOutputMethod, bits, padding); -}; - -var algorithms = [ - { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, - { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, - { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, - { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, - { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } -]; - -var methods = {}, methodNames = []; - -for (var i = 0; i < algorithms.length; ++i) { - var algorithm = algorithms[i]; - var bits = algorithm.bits; - for (var j = 0; j < bits.length; ++j) { - var methodName = algorithm.name + '_' + bits[j]; - methodNames.push(methodName); - methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); - if (algorithm.name !== 'sha3') { - var newMethodName = algorithm.name + bits[j]; - methodNames.push(newMethodName); - methods[newMethodName] = methods[methodName]; - } - } -} - -function Keccak(bits, padding, outputBits) { - this.blocks = []; - this.s = []; - this.padding = padding; - this.outputBits = outputBits; - this.reset = true; - this.finalized = false; - this.block = 0; - this.start = 0; - this.blockCount = (1600 - (bits << 1)) >> 5; - this.byteCount = this.blockCount << 2; - this.outputBlocks = outputBits >> 5; - this.extraBytes = (outputBits & 31) >> 3; - - for (var i = 0; i < 50; ++i) { - this.s[i] = 0; - } -} - -Keccak.prototype.update = function (message) { - if (this.finalized) { - return; - } - var notString, type = typeof message; - if (type !== 'string') { - if (type === 'object') { - if (message === null) { - throw ERROR; - } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } else if (!Array.isArray(message)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var blocks = this.blocks, byteCount = this.byteCount, length = message.length, - blockCount = this.blockCount, index = 0, s = this.s, i, code; - - while (index < length) { - if (this.reset) { - this.reset = false; - blocks[0] = this.block; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - if (notString) { - for (i = this.start; index < length && i < byteCount; ++index) { - blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; - } - } else { - for (i = this.start; index < length && i < byteCount; ++index) { - code = message.charCodeAt(index); - if (code < 0x80) { - blocks[i >> 2] |= code << SHIFT[i++ & 3]; - } else if (code < 0x800) { - blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else if (code < 0xd800 || code >= 0xe000) { - blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); - blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - } - } - this.lastByteIndex = i; - if (i >= byteCount) { - this.start = i - byteCount; - this.block = blocks[blockCount]; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); - this.reset = true; - } else { - this.start = i; - } - } - return this; -}; - -Keccak.prototype.encode = function (x, right) { - var o = x & 255, n = 1; - var bytes = [o]; - x = x >> 8; - o = x & 255; - while (o > 0) { - bytes.unshift(o); - x = x >> 8; - o = x & 255; - ++n; - } - if (right) { - bytes.push(n); - } else { - bytes.unshift(n); - } - this.update(bytes); - return bytes.length; -}; - -Keccak.prototype.encodeString = function (str) { - var notString, type = typeof str; - if (type !== 'string') { - if (type === 'object') { - if (str === null) { - throw ERROR; - } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { - str = new Uint8Array(str); - } else if (!Array.isArray(str)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { - throw ERROR; - } - } - } else { - throw ERROR; - } - notString = true; - } - var bytes = 0, length = str.length; - if (notString) { - bytes = length; - } else { - for (var i = 0; i < str.length; ++i) { - var code = str.charCodeAt(i); - if (code < 0x80) { - bytes += 1; - } else if (code < 0x800) { - bytes += 2; - } else if (code < 0xd800 || code >= 0xe000) { - bytes += 3; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); - bytes += 4; - } - } - } - bytes += this.encode(bytes * 8); - this.update(str); - return bytes; -}; - -Keccak.prototype.bytepad = function (strs, w) { - var bytes = this.encode(w); - for (var i = 0; i < strs.length; ++i) { - bytes += this.encodeString(strs[i]); - } - var paddingBytes = w - bytes % w; - var zeros = []; - zeros.length = paddingBytes; - this.update(zeros); - return this; -}; - -Keccak.prototype.finalize = function () { - if (this.finalized) { - return; - } - this.finalized = true; - var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; - blocks[i >> 2] |= this.padding[i & 3]; - if (this.lastByteIndex === this.byteCount) { - blocks[0] = blocks[blockCount]; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - blocks[blockCount - 1] |= 0x80000000; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); -}; - -Keccak.prototype.toString = Keccak.prototype.hex = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var hex = '', block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + - HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + - HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + - HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; - } - if (j % blockCount === 0) { - f(s); - i = 0; - } - } - if (extraBytes) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; - if (extraBytes > 1) { - hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; - } - if (extraBytes > 2) { - hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; - } - } - return hex; -}; - -Keccak.prototype.arrayBuffer = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var bytes = this.outputBits >> 3; - var buffer; - if (extraBytes) { - buffer = new ArrayBuffer((outputBlocks + 1) << 2); - } else { - buffer = new ArrayBuffer(bytes); - } - var array = new Uint32Array(buffer); - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - array[j] = s[i]; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - array[i] = s[i]; - buffer = buffer.slice(0, bytes); - } - return buffer; -}; - -Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; - -Keccak.prototype.digest = Keccak.prototype.array = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var array = [], offset, block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - array[offset + 1] = (block >> 8) & 0xFF; - array[offset + 2] = (block >> 16) & 0xFF; - array[offset + 3] = (block >> 24) & 0xFF; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - if (extraBytes > 1) { - array[offset + 1] = (block >> 8) & 0xFF; - } - if (extraBytes > 2) { - array[offset + 2] = (block >> 16) & 0xFF; - } - } - return array; -}; - -function Kmac(bits, padding, outputBits) { - Keccak.call(this, bits, padding, outputBits); -} - -Kmac.prototype = new Keccak(); - -Kmac.prototype.finalize = function () { - this.encode(this.outputBits, true); - return Keccak.prototype.finalize.call(this); -}; - -var f = function (s) { - var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, - b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, - b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, - b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; - for (n = 0; n < 48; n += 2) { - c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; - c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; - c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; - c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; - c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; - c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; - c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; - c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; - c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; - c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; - - h = c8 ^ ((c2 << 1) | (c3 >>> 31)); - l = c9 ^ ((c3 << 1) | (c2 >>> 31)); - s[0] ^= h; - s[1] ^= l; - s[10] ^= h; - s[11] ^= l; - s[20] ^= h; - s[21] ^= l; - s[30] ^= h; - s[31] ^= l; - s[40] ^= h; - s[41] ^= l; - h = c0 ^ ((c4 << 1) | (c5 >>> 31)); - l = c1 ^ ((c5 << 1) | (c4 >>> 31)); - s[2] ^= h; - s[3] ^= l; - s[12] ^= h; - s[13] ^= l; - s[22] ^= h; - s[23] ^= l; - s[32] ^= h; - s[33] ^= l; - s[42] ^= h; - s[43] ^= l; - h = c2 ^ ((c6 << 1) | (c7 >>> 31)); - l = c3 ^ ((c7 << 1) | (c6 >>> 31)); - s[4] ^= h; - s[5] ^= l; - s[14] ^= h; - s[15] ^= l; - s[24] ^= h; - s[25] ^= l; - s[34] ^= h; - s[35] ^= l; - s[44] ^= h; - s[45] ^= l; - h = c4 ^ ((c8 << 1) | (c9 >>> 31)); - l = c5 ^ ((c9 << 1) | (c8 >>> 31)); - s[6] ^= h; - s[7] ^= l; - s[16] ^= h; - s[17] ^= l; - s[26] ^= h; - s[27] ^= l; - s[36] ^= h; - s[37] ^= l; - s[46] ^= h; - s[47] ^= l; - h = c6 ^ ((c0 << 1) | (c1 >>> 31)); - l = c7 ^ ((c1 << 1) | (c0 >>> 31)); - s[8] ^= h; - s[9] ^= l; - s[18] ^= h; - s[19] ^= l; - s[28] ^= h; - s[29] ^= l; - s[38] ^= h; - s[39] ^= l; - s[48] ^= h; - s[49] ^= l; - - b0 = s[0]; - b1 = s[1]; - b32 = (s[11] << 4) | (s[10] >>> 28); - b33 = (s[10] << 4) | (s[11] >>> 28); - b14 = (s[20] << 3) | (s[21] >>> 29); - b15 = (s[21] << 3) | (s[20] >>> 29); - b46 = (s[31] << 9) | (s[30] >>> 23); - b47 = (s[30] << 9) | (s[31] >>> 23); - b28 = (s[40] << 18) | (s[41] >>> 14); - b29 = (s[41] << 18) | (s[40] >>> 14); - b20 = (s[2] << 1) | (s[3] >>> 31); - b21 = (s[3] << 1) | (s[2] >>> 31); - b2 = (s[13] << 12) | (s[12] >>> 20); - b3 = (s[12] << 12) | (s[13] >>> 20); - b34 = (s[22] << 10) | (s[23] >>> 22); - b35 = (s[23] << 10) | (s[22] >>> 22); - b16 = (s[33] << 13) | (s[32] >>> 19); - b17 = (s[32] << 13) | (s[33] >>> 19); - b48 = (s[42] << 2) | (s[43] >>> 30); - b49 = (s[43] << 2) | (s[42] >>> 30); - b40 = (s[5] << 30) | (s[4] >>> 2); - b41 = (s[4] << 30) | (s[5] >>> 2); - b22 = (s[14] << 6) | (s[15] >>> 26); - b23 = (s[15] << 6) | (s[14] >>> 26); - b4 = (s[25] << 11) | (s[24] >>> 21); - b5 = (s[24] << 11) | (s[25] >>> 21); - b36 = (s[34] << 15) | (s[35] >>> 17); - b37 = (s[35] << 15) | (s[34] >>> 17); - b18 = (s[45] << 29) | (s[44] >>> 3); - b19 = (s[44] << 29) | (s[45] >>> 3); - b10 = (s[6] << 28) | (s[7] >>> 4); - b11 = (s[7] << 28) | (s[6] >>> 4); - b42 = (s[17] << 23) | (s[16] >>> 9); - b43 = (s[16] << 23) | (s[17] >>> 9); - b24 = (s[26] << 25) | (s[27] >>> 7); - b25 = (s[27] << 25) | (s[26] >>> 7); - b6 = (s[36] << 21) | (s[37] >>> 11); - b7 = (s[37] << 21) | (s[36] >>> 11); - b38 = (s[47] << 24) | (s[46] >>> 8); - b39 = (s[46] << 24) | (s[47] >>> 8); - b30 = (s[8] << 27) | (s[9] >>> 5); - b31 = (s[9] << 27) | (s[8] >>> 5); - b12 = (s[18] << 20) | (s[19] >>> 12); - b13 = (s[19] << 20) | (s[18] >>> 12); - b44 = (s[29] << 7) | (s[28] >>> 25); - b45 = (s[28] << 7) | (s[29] >>> 25); - b26 = (s[38] << 8) | (s[39] >>> 24); - b27 = (s[39] << 8) | (s[38] >>> 24); - b8 = (s[48] << 14) | (s[49] >>> 18); - b9 = (s[49] << 14) | (s[48] >>> 18); - - s[0] = b0 ^ (~b2 & b4); - s[1] = b1 ^ (~b3 & b5); - s[10] = b10 ^ (~b12 & b14); - s[11] = b11 ^ (~b13 & b15); - s[20] = b20 ^ (~b22 & b24); - s[21] = b21 ^ (~b23 & b25); - s[30] = b30 ^ (~b32 & b34); - s[31] = b31 ^ (~b33 & b35); - s[40] = b40 ^ (~b42 & b44); - s[41] = b41 ^ (~b43 & b45); - s[2] = b2 ^ (~b4 & b6); - s[3] = b3 ^ (~b5 & b7); - s[12] = b12 ^ (~b14 & b16); - s[13] = b13 ^ (~b15 & b17); - s[22] = b22 ^ (~b24 & b26); - s[23] = b23 ^ (~b25 & b27); - s[32] = b32 ^ (~b34 & b36); - s[33] = b33 ^ (~b35 & b37); - s[42] = b42 ^ (~b44 & b46); - s[43] = b43 ^ (~b45 & b47); - s[4] = b4 ^ (~b6 & b8); - s[5] = b5 ^ (~b7 & b9); - s[14] = b14 ^ (~b16 & b18); - s[15] = b15 ^ (~b17 & b19); - s[24] = b24 ^ (~b26 & b28); - s[25] = b25 ^ (~b27 & b29); - s[34] = b34 ^ (~b36 & b38); - s[35] = b35 ^ (~b37 & b39); - s[44] = b44 ^ (~b46 & b48); - s[45] = b45 ^ (~b47 & b49); - s[6] = b6 ^ (~b8 & b0); - s[7] = b7 ^ (~b9 & b1); - s[16] = b16 ^ (~b18 & b10); - s[17] = b17 ^ (~b19 & b11); - s[26] = b26 ^ (~b28 & b20); - s[27] = b27 ^ (~b29 & b21); - s[36] = b36 ^ (~b38 & b30); - s[37] = b37 ^ (~b39 & b31); - s[46] = b46 ^ (~b48 & b40); - s[47] = b47 ^ (~b49 & b41); - s[8] = b8 ^ (~b0 & b2); - s[9] = b9 ^ (~b1 & b3); - s[18] = b18 ^ (~b10 & b12); - s[19] = b19 ^ (~b11 & b13); - s[28] = b28 ^ (~b20 & b22); - s[29] = b29 ^ (~b21 & b23); - s[38] = b38 ^ (~b30 & b32); - s[39] = b39 ^ (~b31 & b33); - s[48] = b48 ^ (~b40 & b42); - s[49] = b49 ^ (~b41 & b43); - - s[0] ^= RC[n]; - s[1] ^= RC[n + 1]; - } -}; - -module.exports = methods; - -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":52}],86:[function(require,module,exports){ -var jsSHA = require('jssha/src/sha256'); -var Blake256 = require('./blake256'); -var keccak256 = require('./sha3')['keccak256']; - -function numberToHex (number) { - var hex = Math.round(number).toString(16); - if(hex.length === 1) { - hex = '0' + hex; - } - return hex; -} - -module.exports = { - toHex: function (arrayOfBytes) { - var hex = ''; - for(var i = 0; i < arrayOfBytes.length; i++) { - hex += numberToHex(arrayOfBytes[i]); - } - return hex; - }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX'); - sha.update(hexString); - return sha.getHash('HEX'); - }, - sha256Checksum: function (payload) { - return this.sha256(this.sha256(payload)).substr(0, 8); - }, - blake256: function (hexString) { - return new Blake256().update(hexString, 'hex').digest('hex'); - }, - blake256Checksum: function (payload) { - return this.blake256(this.blake256(payload)).substr(0, 8); - }, - keccak256: function (hexString) { - return keccak256(hexString); - } -}; - -},{"./blake256":83,"./sha3":85,"jssha/src/sha256":49}],87:[function(require,module,exports){ -var XRPValidator = require('./ripple_validator'); -var ETHValidator = require('./ethereum_validator'); -var BTCValidator = require('./bitcoin_validator'); -var ADAValidator = require('./ada_validator'); - -// defines P2PKH and P2SH address types for standard (prod) and testnet networks -var CURRENCIES = [{ - name: 'bitcoin', - symbol: 'btc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'bitcoincash', - symbol: 'bch', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'litecoin', - symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']}, - validator: BTCValidator -},{ - name: 'peercoin', - symbol: 'ppc', - addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'dogecoin', - symbol: 'doge', - addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']}, - validator: BTCValidator -},{ - name: 'beavercoin', - symbol: 'bvc', - addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']}, - validator: BTCValidator, -},{ - name: 'freicoin', - symbol: 'frc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'protoshares', - symbol: 'pts', - addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'megacoin', - symbol: 'mec', - addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'primecoin', - symbol: 'xpm', - addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'auroracoin', - symbol: 'aur', - addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'namecoin', - symbol: 'nmc', - addressTypes: {prod: ['34'], testnet: []}, - validator: BTCValidator -},{ - name: 'biocoin', - symbol: 'bio', - addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'garlicoin', - symbol: 'grlc', - addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'vertcoin', - symbol: 'vtc', - addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'bitcoingold', - symbol: 'btg', - addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'komodo', - symbol: 'kmd', - addressTypes: {prod: ['3c', '55'], testnet: ['0','5']}, - validator: BTCValidator -},{ - name: 'bitcoinz', - symbol: 'btcz', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, - validator: BTCValidator -},{ - name: 'bitcoinprivate', - symbol: 'btcp', - expectedLength: 26, - addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']}, - validator: BTCValidator -},{ - name: 'hush', - symbol: 'hush', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, - validator: BTCValidator -},{ - name: 'snowgem', - symbol: 'sng', - expectedLength: 26, - addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']}, - validator: BTCValidator -},{ - name: 'zcash', - symbol: 'zec', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, - validator: BTCValidator -},{ - name: 'zclassic', - symbol: 'zcl', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, - validator: BTCValidator -},{ - name: 'zencash', - symbol: 'zen', - expectedLength: 26, - addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']}, - validator: BTCValidator -},{ - name: 'votecoin', - symbol: 'vot', - expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, - validator: BTCValidator -},{ - name: 'decred', - symbol: 'dcr', - addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, - hashFunction: 'blake256', - expectedLength: 26, - validator: BTCValidator -},{ - name: 'digibyte', - symbol: 'dgb', - addressTypes: {prod: ['1e'], testnet: []}, - validator: BTCValidator -},{ - name: 'ethereum', - symbol: 'eth', - validator: ETHValidator, -},{ - name: 'etherzero', - symbol: 'etz', - validator: ETHValidator, -},{ - name: 'ethereumclassic', - symbol: 'etc', - validator: ETHValidator, -},{ - name: 'callisto', - symbol: 'clo', - validator: ETHValidator, -},{ - name: 'ripple', - symbol: 'xrp', - validator: XRPValidator, -},{ - name: 'dash', - symbol: 'dash', - addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']}, - validator: BTCValidator -},{ - name: 'neo', - symbol: 'neo', - addressTypes: {prod: ['17'], testnet: []}, - validator: BTCValidator -},{ - name: 'neogas', - symbol: 'gas', - addressTypes: {prod: ['17'], testnet: []}, - validator: BTCValidator -},{ - name: 'qtum', - symbol: 'qtum', - addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, - validator: BTCValidator -},{ - name: 'bankex', - symbol: 'bkx', - validator: ETHValidator -},{ - name: 'cardano', - symbol: 'ada', - validator: ADAValidator -}]; - - -module.exports = { - getByNameOrSymbol: function (currencyNameOrSymbol) { - var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); - for (var i = 0; i < CURRENCIES.length; i++) { - var currency = CURRENCIES[i]; - if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { - return currency; - } - } - return null; - } -}; - -},{"./ada_validator":79,"./bitcoin_validator":80,"./ethereum_validator":88,"./ripple_validator":89}],88:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); - -module.exports = { - isValidAddress: function (address) { - if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { - // Check if it has the basic requirements of an address - return false; - } - - if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { - // If it's all small caps or all all caps, return true - return true; - } - - // Otherwise check each case - return this.verifyChecksum(address); - }, - verifyChecksum: function (address) { - // Check each case - address = address.replace('0x',''); - - var addressHash = cryptoUtils.keccak256(address.toLowerCase()); - - for (var i = 0; i < 40; i++ ) { - // The nth letter should be uppercase if the nth digit of casemap is 1 - if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || - (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { - return false; - } - } - - return true; - } -}; - -},{"./crypto/utils":86}],89:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); -var baseX = require('base-x'); - -var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; - -var codec = baseX(ALLOWED_CHARS); -var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); - -module.exports = { - /** - * ripple address validation - */ - isValidAddress: function (address) { - if (regexp.test(address)) { - return this.verifyChecksum(address); - } - - return false; - }, - - verifyChecksum: function (address) { - var bytes = codec.decode(address); - var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); - var checksum = cryptoUtils.toHex(bytes.slice(-4)); - - return computedChecksum === checksum - } -}; - -},{"./crypto/utils":86,"base-x":1}],90:[function(require,module,exports){ -var currencies = require('./currencies'); - -var DEFAULT_CURRENCY_NAME = 'bitcoin'; - -module.exports = { - validate: function (address, currencyNameOrSymbol, networkType) { - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); - - if (currency.validator) { - return currency.validator.isValidAddress(address, currency, networkType); - } - - throw new Error('Missing validator for currency: ' + currencyNameOrSymbol); - }, -}; - -},{"./currencies":87}]},{},[90])(90) -}); diff --git a/package.json b/package.json index 5781c794..dfcd8267 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "qtum", "altcoin", "bankex", + "monero", "segwit", "crypto", "address", diff --git a/src/crypto/biginteger.js b/src/crypto/biginteger.js new file mode 100644 index 00000000..9d2e1fb7 --- /dev/null +++ b/src/crypto/biginteger.js @@ -0,0 +1,1450 @@ +/* + JavaScript BigInteger library version 0.9.1 + http://silentmatt.com/biginteger/ + Copyright (c) 2009 Matthew Crumley + Copyright (c) 2010,2011 by John Tobey + Licensed under the MIT license. + Support for arbitrary internal representation base was added by + Vitaly Magerya. +*/ + +/* + File: biginteger.js + Exports: + +*/ +(function(exports) { + "use strict"; + /* + Class: BigInteger + An arbitrarily-large integer. + objects should be considered immutable. None of the "built-in" + methods modify *this* or their arguments. All properties should be + considered private. + All the methods of instances can be called "statically". The + static versions are convenient if you don't already have a + object. + As an example, these calls are equivalent. + > BigInteger(4).multiply(5); // returns BigInteger(20); + > BigInteger.multiply(4, 5); // returns BigInteger(20); + > var a = 42; + > var a = BigInteger.toJSValue("0b101010"); // Not completely useless... + */ + + var CONSTRUCT = {}; // Unique token to call "private" version of constructor + + /* + Constructor: BigInteger() + Convert a value to a . + Although is the constructor for objects, it is + best not to call it as a constructor. If *n* is a object, it is + simply returned as-is. Otherwise, is equivalent to + without a radix argument. + > var n0 = BigInteger(); // Same as + > var n1 = BigInteger("123"); // Create a new with value 123 + > var n2 = BigInteger(123); // Create a new with value 123 + > var n3 = BigInteger(n2); // Return n2, unchanged + The constructor form only takes an array and a sign. *n* must be an + array of numbers in little-endian order, where each digit is between 0 + and BigInteger.base. The second parameter sets the sign: -1 for + negative, +1 for positive, or 0 for zero. The array is *not copied and + may be modified*. If the array contains only zeros, the sign parameter + is ignored and is forced to zero. + > new BigInteger([5], -1): create a new BigInteger with value -5 + Parameters: + n - Value to convert to a . + Returns: + A value. + See Also: + , + */ + function BigInteger(n, s, token) { + + if (token !== CONSTRUCT) { + if (n instanceof BigInteger) { + return n; + } + else if (typeof n === "undefined") { + return ZERO; + } + return BigInteger.parse(n); + } + + n = n || []; // Provide the nullary constructor for subclasses. + while (n.length && !n[n.length - 1]) { + --n.length; + } + this._d = n; + this._s = n.length ? (s || 1) : 0; + } + + BigInteger._construct = function(n, s) { + return new BigInteger(n, s, CONSTRUCT); + }; + + // Base-10 speedup hacks in parse, toString, exp10 and log functions + // require base to be a power of 10. 10^7 is the largest such power + // that won't cause a precision loss when digits are multiplied. + var BigInteger_base = 10000000; + var BigInteger_base_log10 = 7; + + BigInteger.base = BigInteger_base; + BigInteger.base_log10 = BigInteger_base_log10; + + var ZERO = new BigInteger([], 0, CONSTRUCT); + // Constant: ZERO + // 0. + BigInteger.ZERO = ZERO; + + var ONE = new BigInteger([1], 1, CONSTRUCT); + // Constant: ONE + // 1. + BigInteger.ONE = ONE; + + var M_ONE = new BigInteger(ONE._d, -1, CONSTRUCT); + // Constant: M_ONE + // -1. + BigInteger.M_ONE = M_ONE; + + // Constant: _0 + // Shortcut for . + BigInteger._0 = ZERO; + + // Constant: _1 + // Shortcut for . + BigInteger._1 = ONE; + + /* + Constant: small + Array of from 0 to 36. + These are used internally for parsing, but useful when you need a "small" + . + See Also: + , , <_0>, <_1> + */ + BigInteger.small = [ + ZERO, + ONE, + /* Assuming BigInteger_base > 36 */ + new BigInteger( [2], 1, CONSTRUCT), + new BigInteger( [3], 1, CONSTRUCT), + new BigInteger( [4], 1, CONSTRUCT), + new BigInteger( [5], 1, CONSTRUCT), + new BigInteger( [6], 1, CONSTRUCT), + new BigInteger( [7], 1, CONSTRUCT), + new BigInteger( [8], 1, CONSTRUCT), + new BigInteger( [9], 1, CONSTRUCT), + new BigInteger([10], 1, CONSTRUCT), + new BigInteger([11], 1, CONSTRUCT), + new BigInteger([12], 1, CONSTRUCT), + new BigInteger([13], 1, CONSTRUCT), + new BigInteger([14], 1, CONSTRUCT), + new BigInteger([15], 1, CONSTRUCT), + new BigInteger([16], 1, CONSTRUCT), + new BigInteger([17], 1, CONSTRUCT), + new BigInteger([18], 1, CONSTRUCT), + new BigInteger([19], 1, CONSTRUCT), + new BigInteger([20], 1, CONSTRUCT), + new BigInteger([21], 1, CONSTRUCT), + new BigInteger([22], 1, CONSTRUCT), + new BigInteger([23], 1, CONSTRUCT), + new BigInteger([24], 1, CONSTRUCT), + new BigInteger([25], 1, CONSTRUCT), + new BigInteger([26], 1, CONSTRUCT), + new BigInteger([27], 1, CONSTRUCT), + new BigInteger([28], 1, CONSTRUCT), + new BigInteger([29], 1, CONSTRUCT), + new BigInteger([30], 1, CONSTRUCT), + new BigInteger([31], 1, CONSTRUCT), + new BigInteger([32], 1, CONSTRUCT), + new BigInteger([33], 1, CONSTRUCT), + new BigInteger([34], 1, CONSTRUCT), + new BigInteger([35], 1, CONSTRUCT), + new BigInteger([36], 1, CONSTRUCT) + ]; + + // Used for parsing/radix conversion + BigInteger.digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""); + + /* + Method: toString + Convert a to a string. + When *base* is greater than 10, letters are upper case. + Parameters: + base - Optional base to represent the number in (default is base 10). + Must be between 2 and 36 inclusive, or an Error will be thrown. + Returns: + The string representation of the . + */ + BigInteger.prototype.toString = function(base) { + base = +base || 10; + if (base < 2 || base > 36) { + throw new Error("illegal radix " + base + "."); + } + if (this._s === 0) { + return "0"; + } + if (base === 10) { + var str = this._s < 0 ? "-" : ""; + str += this._d[this._d.length - 1].toString(); + for (var i = this._d.length - 2; i >= 0; i--) { + var group = this._d[i].toString(); + while (group.length < BigInteger_base_log10) group = '0' + group; + str += group; + } + return str; + } + else { + var numerals = BigInteger.digits; + base = BigInteger.small[base]; + var sign = this._s; + + var n = this.abs(); + var digits = []; + var digit; + + while (n._s !== 0) { + var divmod = n.divRem(base); + n = divmod[0]; + digit = divmod[1]; + // TODO: This could be changed to unshift instead of reversing at the end. + // Benchmark both to compare speeds. + digits.push(numerals[digit.valueOf()]); + } + return (sign < 0 ? "-" : "") + digits.reverse().join(""); + } + }; + + // Verify strings for parsing + BigInteger.radixRegex = [ + /^$/, + /^$/, + /^[01]*$/, + /^[012]*$/, + /^[0-3]*$/, + /^[0-4]*$/, + /^[0-5]*$/, + /^[0-6]*$/, + /^[0-7]*$/, + /^[0-8]*$/, + /^[0-9]*$/, + /^[0-9aA]*$/, + /^[0-9abAB]*$/, + /^[0-9abcABC]*$/, + /^[0-9a-dA-D]*$/, + /^[0-9a-eA-E]*$/, + /^[0-9a-fA-F]*$/, + /^[0-9a-gA-G]*$/, + /^[0-9a-hA-H]*$/, + /^[0-9a-iA-I]*$/, + /^[0-9a-jA-J]*$/, + /^[0-9a-kA-K]*$/, + /^[0-9a-lA-L]*$/, + /^[0-9a-mA-M]*$/, + /^[0-9a-nA-N]*$/, + /^[0-9a-oA-O]*$/, + /^[0-9a-pA-P]*$/, + /^[0-9a-qA-Q]*$/, + /^[0-9a-rA-R]*$/, + /^[0-9a-sA-S]*$/, + /^[0-9a-tA-T]*$/, + /^[0-9a-uA-U]*$/, + /^[0-9a-vA-V]*$/, + /^[0-9a-wA-W]*$/, + /^[0-9a-xA-X]*$/, + /^[0-9a-yA-Y]*$/, + /^[0-9a-zA-Z]*$/ + ]; + + /* + Function: parse + Parse a string into a . + *base* is optional but, if provided, must be from 2 to 36 inclusive. If + *base* is not provided, it will be guessed based on the leading characters + of *s* as follows: + - "0x" or "0X": *base* = 16 + - "0c" or "0C": *base* = 8 + - "0b" or "0B": *base* = 2 + - else: *base* = 10 + If no base is provided, or *base* is 10, the number can be in exponential + form. For example, these are all valid: + > BigInteger.parse("1e9"); // Same as "1000000000" + > BigInteger.parse("1.234*10^3"); // Same as 1234 + > BigInteger.parse("56789 * 10 ** -2"); // Same as 567 + If any characters fall outside the range defined by the radix, an exception + will be thrown. + Parameters: + s - The string to parse. + base - Optional radix (default is to guess based on *s*). + Returns: + a instance. + */ + BigInteger.parse = function(s, base) { + // Expands a number in exponential form to decimal form. + // expandExponential("-13.441*10^5") === "1344100"; + // expandExponential("1.12300e-1") === "0.112300"; + // expandExponential(1000000000000000000000000000000) === "1000000000000000000000000000000"; + function expandExponential(str) { + str = str.replace(/\s*[*xX]\s*10\s*(\^|\*\*)\s*/, "e"); + + return str.replace(/^([+\-])?(\d+)\.?(\d*)[eE]([+\-]?\d+)$/, function(x, s, n, f, c) { + c = +c; + var l = c < 0; + var i = n.length + c; + x = (l ? n : f).length; + c = ((c = Math.abs(c)) >= x ? c - x + l : 0); + var z = (new Array(c + 1)).join("0"); + var r = n + f; + return (s || "") + (l ? r = z + r : r += z).substr(0, i += l ? z.length : 0) + (i < r.length ? "." + r.substr(i) : ""); + }); + } + + s = s.toString(); + if (typeof base === "undefined" || +base === 10) { + s = expandExponential(s); + } + + var prefixRE; + if (typeof base === "undefined") { + prefixRE = '0[xcb]'; + } + else if (base == 16) { + prefixRE = '0x'; + } + else if (base == 8) { + prefixRE = '0c'; + } + else if (base == 2) { + prefixRE = '0b'; + } + else { + prefixRE = ''; + } + var parts = new RegExp('^([+\\-]?)(' + prefixRE + ')?([0-9a-z]*)(?:\\.\\d*)?$', 'i').exec(s); + if (parts) { + var sign = parts[1] || "+"; + var baseSection = parts[2] || ""; + var digits = parts[3] || ""; + + if (typeof base === "undefined") { + // Guess base + if (baseSection === "0x" || baseSection === "0X") { // Hex + base = 16; + } + else if (baseSection === "0c" || baseSection === "0C") { // Octal + base = 8; + } + else if (baseSection === "0b" || baseSection === "0B") { // Binary + base = 2; + } + else { + base = 10; + } + } + else if (base < 2 || base > 36) { + throw new Error("Illegal radix " + base + "."); + } + + base = +base; + + // Check for digits outside the range + if (!(BigInteger.radixRegex[base].test(digits))) { + throw new Error("Bad digit for radix " + base); + } + + // Strip leading zeros, and convert to array + digits = digits.replace(/^0+/, "").split(""); + if (digits.length === 0) { + return ZERO; + } + + // Get the sign (we know it's not zero) + sign = (sign === "-") ? -1 : 1; + + // Optimize 10 + if (base == 10) { + var d = []; + while (digits.length >= BigInteger_base_log10) { + d.push(parseInt(digits.splice(digits.length-BigInteger.base_log10, BigInteger.base_log10).join(''), 10)); + } + d.push(parseInt(digits.join(''), 10)); + return new BigInteger(d, sign, CONSTRUCT); + } + + // Do the conversion + var d = ZERO; + base = BigInteger.small[base]; + var small = BigInteger.small; + for (var i = 0; i < digits.length; i++) { + d = d.multiply(base).add(small[parseInt(digits[i], 36)]); + } + return new BigInteger(d._d, sign, CONSTRUCT); + } + else { + throw new Error("Invalid BigInteger format: " + s); + } + }; + + /* + Function: add + Add two . + Parameters: + n - The number to add to *this*. Will be converted to a . + Returns: + The numbers added together. + See Also: + , , , + */ + BigInteger.prototype.add = function(n) { + if (this._s === 0) { + return BigInteger(n); + } + + n = BigInteger(n); + if (n._s === 0) { + return this; + } + if (this._s !== n._s) { + n = n.negate(); + return this.subtract(n); + } + + var a = this._d; + var b = n._d; + var al = a.length; + var bl = b.length; + var sum = new Array(Math.max(al, bl) + 1); + var size = Math.min(al, bl); + var carry = 0; + var digit; + + for (var i = 0; i < size; i++) { + digit = a[i] + b[i] + carry; + sum[i] = digit % BigInteger_base; + carry = (digit / BigInteger_base) | 0; + } + if (bl > al) { + a = b; + al = bl; + } + for (i = size; carry && i < al; i++) { + digit = a[i] + carry; + sum[i] = digit % BigInteger_base; + carry = (digit / BigInteger_base) | 0; + } + if (carry) { + sum[i] = carry; + } + + for ( ; i < al; i++) { + sum[i] = a[i]; + } + + return new BigInteger(sum, this._s, CONSTRUCT); + }; + + /* + Function: negate + Get the additive inverse of a . + Returns: + A with the same magnatude, but with the opposite sign. + See Also: + + */ + BigInteger.prototype.negate = function() { + return new BigInteger(this._d, (-this._s) | 0, CONSTRUCT); + }; + + /* + Function: abs + Get the absolute value of a . + Returns: + A with the same magnatude, but always positive (or zero). + See Also: + + */ + BigInteger.prototype.abs = function() { + return (this._s < 0) ? this.negate() : this; + }; + + /* + Function: subtract + Subtract two . + Parameters: + n - The number to subtract from *this*. Will be converted to a . + Returns: + The *n* subtracted from *this*. + See Also: + , , , + */ + BigInteger.prototype.subtract = function(n) { + if (this._s === 0) { + return BigInteger(n).negate(); + } + + n = BigInteger(n); + if (n._s === 0) { + return this; + } + if (this._s !== n._s) { + n = n.negate(); + return this.add(n); + } + + var m = this; + // negative - negative => -|a| - -|b| => -|a| + |b| => |b| - |a| + if (this._s < 0) { + m = new BigInteger(n._d, 1, CONSTRUCT); + n = new BigInteger(this._d, 1, CONSTRUCT); + } + + // Both are positive => a - b + var sign = m.compareAbs(n); + if (sign === 0) { + return ZERO; + } + else if (sign < 0) { + // swap m and n + var t = n; + n = m; + m = t; + } + + // a > b + var a = m._d; + var b = n._d; + var al = a.length; + var bl = b.length; + var diff = new Array(al); // al >= bl since a > b + var borrow = 0; + var i; + var digit; + + for (i = 0; i < bl; i++) { + digit = a[i] - borrow - b[i]; + if (digit < 0) { + digit += BigInteger_base; + borrow = 1; + } + else { + borrow = 0; + } + diff[i] = digit; + } + for (i = bl; i < al; i++) { + digit = a[i] - borrow; + if (digit < 0) { + digit += BigInteger_base; + } + else { + diff[i++] = digit; + break; + } + diff[i] = digit; + } + for ( ; i < al; i++) { + diff[i] = a[i]; + } + + return new BigInteger(diff, sign, CONSTRUCT); + }; + + (function() { + function addOne(n, sign) { + var a = n._d; + var sum = a.slice(); + var carry = true; + var i = 0; + + while (true) { + var digit = (a[i] || 0) + 1; + sum[i] = digit % BigInteger_base; + if (digit <= BigInteger_base - 1) { + break; + } + ++i; + } + + return new BigInteger(sum, sign, CONSTRUCT); + } + + function subtractOne(n, sign) { + var a = n._d; + var sum = a.slice(); + var borrow = true; + var i = 0; + + while (true) { + var digit = (a[i] || 0) - 1; + if (digit < 0) { + sum[i] = digit + BigInteger_base; + } + else { + sum[i] = digit; + break; + } + ++i; + } + + return new BigInteger(sum, sign, CONSTRUCT); + } + + /* + Function: next + Get the next (add one). + Returns: + *this* + 1. + See Also: + , + */ + BigInteger.prototype.next = function() { + switch (this._s) { + case 0: + return ONE; + case -1: + return subtractOne(this, -1); + // case 1: + default: + return addOne(this, 1); + } + }; + + /* + Function: prev + Get the previous (subtract one). + Returns: + *this* - 1. + See Also: + , + */ + BigInteger.prototype.prev = function() { + switch (this._s) { + case 0: + return M_ONE; + case -1: + return addOne(this, -1); + // case 1: + default: + return subtractOne(this, 1); + } + }; + })(); + + /* + Function: compareAbs + Compare the absolute value of two . + Calling is faster than calling twice, then . + Parameters: + n - The number to compare to *this*. Will be converted to a . + Returns: + -1, 0, or +1 if *|this|* is less than, equal to, or greater than *|n|*. + See Also: + , + */ + BigInteger.prototype.compareAbs = function(n) { + if (this === n) { + return 0; + } + + if (!(n instanceof BigInteger)) { + if (!isFinite(n)) { + return(isNaN(n) ? n : -1); + } + n = BigInteger(n); + } + + if (this._s === 0) { + return (n._s !== 0) ? -1 : 0; + } + if (n._s === 0) { + return 1; + } + + var l = this._d.length; + var nl = n._d.length; + if (l < nl) { + return -1; + } + else if (l > nl) { + return 1; + } + + var a = this._d; + var b = n._d; + for (var i = l-1; i >= 0; i--) { + if (a[i] !== b[i]) { + return a[i] < b[i] ? -1 : 1; + } + } + + return 0; + }; + + /* + Function: compare + Compare two . + Parameters: + n - The number to compare to *this*. Will be converted to a . + Returns: + -1, 0, or +1 if *this* is less than, equal to, or greater than *n*. + See Also: + , , , + */ + BigInteger.prototype.compare = function(n) { + if (this === n) { + return 0; + } + + n = BigInteger(n); + + if (this._s === 0) { + return -n._s; + } + + if (this._s === n._s) { // both positive or both negative + var cmp = this.compareAbs(n); + return cmp * this._s; + } + else { + return this._s; + } + }; + + /* + Function: isUnit + Return true iff *this* is either 1 or -1. + Returns: + true if *this* compares equal to or . + See Also: + , , , , , + , + */ + BigInteger.prototype.isUnit = function() { + return this === ONE || + this === M_ONE || + (this._d.length === 1 && this._d[0] === 1); + }; + + /* + Function: multiply + Multiply two . + Parameters: + n - The number to multiply *this* by. Will be converted to a + . + Returns: + The numbers multiplied together. + See Also: + , , , + */ + BigInteger.prototype.multiply = function(n) { + // TODO: Consider adding Karatsuba multiplication for large numbers + if (this._s === 0) { + return ZERO; + } + + n = BigInteger(n); + if (n._s === 0) { + return ZERO; + } + if (this.isUnit()) { + if (this._s < 0) { + return n.negate(); + } + return n; + } + if (n.isUnit()) { + if (n._s < 0) { + return this.negate(); + } + return this; + } + if (this === n) { + return this.square(); + } + + var r = (this._d.length >= n._d.length); + var a = (r ? this : n)._d; // a will be longer than b + var b = (r ? n : this)._d; + var al = a.length; + var bl = b.length; + + var pl = al + bl; + var partial = new Array(pl); + var i; + for (i = 0; i < pl; i++) { + partial[i] = 0; + } + + for (i = 0; i < bl; i++) { + var carry = 0; + var bi = b[i]; + var jlimit = al + i; + var digit; + for (var j = i; j < jlimit; j++) { + digit = partial[j] + bi * a[j - i] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = (digit % BigInteger_base) | 0; + } + if (carry) { + digit = partial[j] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = digit % BigInteger_base; + } + } + return new BigInteger(partial, this._s * n._s, CONSTRUCT); + }; + + // Multiply a BigInteger by a single-digit native number + // Assumes that this and n are >= 0 + // This is not really intended to be used outside the library itself + BigInteger.prototype.multiplySingleDigit = function(n) { + if (n === 0 || this._s === 0) { + return ZERO; + } + if (n === 1) { + return this; + } + + var digit; + if (this._d.length === 1) { + digit = this._d[0] * n; + if (digit >= BigInteger_base) { + return new BigInteger([(digit % BigInteger_base)|0, + (digit / BigInteger_base)|0], 1, CONSTRUCT); + } + return new BigInteger([digit], 1, CONSTRUCT); + } + + if (n === 2) { + return this.add(this); + } + if (this.isUnit()) { + return new BigInteger([n], 1, CONSTRUCT); + } + + var a = this._d; + var al = a.length; + + var pl = al + 1; + var partial = new Array(pl); + for (var i = 0; i < pl; i++) { + partial[i] = 0; + } + + var carry = 0; + for (var j = 0; j < al; j++) { + digit = n * a[j] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = (digit % BigInteger_base) | 0; + } + if (carry) { + partial[j] = carry; + } + + return new BigInteger(partial, 1, CONSTRUCT); + }; + + /* + Function: square + Multiply a by itself. + This is slightly faster than regular multiplication, since it removes the + duplicated multiplcations. + Returns: + > this.multiply(this) + See Also: + + */ + BigInteger.prototype.square = function() { + // Normally, squaring a 10-digit number would take 100 multiplications. + // Of these 10 are unique diagonals, of the remaining 90 (100-10), 45 are repeated. + // This procedure saves (N*(N-1))/2 multiplications, (e.g., 45 of 100 multiplies). + // Based on code by Gary Darby, Intellitech Systems Inc., www.DelphiForFun.org + + if (this._s === 0) { + return ZERO; + } + if (this.isUnit()) { + return ONE; + } + + var digits = this._d; + var length = digits.length; + var imult1 = new Array(length + length + 1); + var product, carry, k; + var i; + + // Calculate diagonal + for (i = 0; i < length; i++) { + k = i * 2; + product = digits[i] * digits[i]; + carry = (product / BigInteger_base) | 0; + imult1[k] = product % BigInteger_base; + imult1[k + 1] = carry; + } + + // Calculate repeating part + for (i = 0; i < length; i++) { + carry = 0; + k = i * 2 + 1; + for (var j = i + 1; j < length; j++, k++) { + product = digits[j] * digits[i] * 2 + imult1[k] + carry; + carry = (product / BigInteger_base) | 0; + imult1[k] = product % BigInteger_base; + } + k = length + i; + var digit = carry + imult1[k]; + carry = (digit / BigInteger_base) | 0; + imult1[k] = digit % BigInteger_base; + imult1[k + 1] += carry; + } + + return new BigInteger(imult1, 1, CONSTRUCT); + }; + + /* + Function: quotient + Divide two and truncate towards zero. + throws an exception if *n* is zero. + Parameters: + n - The number to divide *this* by. Will be converted to a . + Returns: + The *this* / *n*, truncated to an integer. + See Also: + , , , , + */ + BigInteger.prototype.quotient = function(n) { + return this.divRem(n)[0]; + }; + + /* + Function: divide + Deprecated synonym for . + */ + BigInteger.prototype.divide = BigInteger.prototype.quotient; + + /* + Function: remainder + Calculate the remainder of two . + throws an exception if *n* is zero. + Parameters: + n - The remainder after *this* is divided *this* by *n*. Will be + converted to a . + Returns: + *this* % *n*. + See Also: + , + */ + BigInteger.prototype.remainder = function(n) { + return this.divRem(n)[1]; + }; + + /* + Function: divRem + Calculate the integer quotient and remainder of two . + throws an exception if *n* is zero. + Parameters: + n - The number to divide *this* by. Will be converted to a . + Returns: + A two-element array containing the quotient and the remainder. + > a.divRem(b) + is exactly equivalent to + > [a.quotient(b), a.remainder(b)] + except it is faster, because they are calculated at the same time. + See Also: + , + */ + BigInteger.prototype.divRem = function(n) { + n = BigInteger(n); + if (n._s === 0) { + throw new Error("Divide by zero"); + } + if (this._s === 0) { + return [ZERO, ZERO]; + } + if (n._d.length === 1) { + return this.divRemSmall(n._s * n._d[0]); + } + + // Test for easy cases -- |n1| <= |n2| + switch (this.compareAbs(n)) { + case 0: // n1 == n2 + return [this._s === n._s ? ONE : M_ONE, ZERO]; + case -1: // |n1| < |n2| + return [ZERO, this]; + } + + var sign = this._s * n._s; + var a = n.abs(); + var b_digits = this._d; + var b_index = b_digits.length; + var digits = n._d.length; + var quot = []; + var guess; + + var part = new BigInteger([], 0, CONSTRUCT); + + while (b_index) { + part._d.unshift(b_digits[--b_index]); + part = new BigInteger(part._d, 1, CONSTRUCT); + + if (part.compareAbs(n) < 0) { + quot.push(0); + continue; + } + if (part._s === 0) { + guess = 0; + } + else { + var xlen = part._d.length, ylen = a._d.length; + var highx = part._d[xlen-1]*BigInteger_base + part._d[xlen-2]; + var highy = a._d[ylen-1]*BigInteger_base + a._d[ylen-2]; + if (part._d.length > a._d.length) { + // The length of part._d can either match a._d length, + // or exceed it by one. + highx = (highx+1)*BigInteger_base; + } + guess = Math.ceil(highx/highy); + } + do { + var check = a.multiplySingleDigit(guess); + if (check.compareAbs(part) <= 0) { + break; + } + guess--; + } while (guess); + + quot.push(guess); + if (!guess) { + continue; + } + var diff = part.subtract(check); + part._d = diff._d.slice(); + } + + return [new BigInteger(quot.reverse(), sign, CONSTRUCT), + new BigInteger(part._d, this._s, CONSTRUCT)]; + }; + + // Throws an exception if n is outside of (-BigInteger.base, -1] or + // [1, BigInteger.base). It's not necessary to call this, since the + // other division functions will call it if they are able to. + BigInteger.prototype.divRemSmall = function(n) { + var r; + n = +n; + if (n === 0) { + throw new Error("Divide by zero"); + } + + var n_s = n < 0 ? -1 : 1; + var sign = this._s * n_s; + n = Math.abs(n); + + if (n < 1 || n >= BigInteger_base) { + throw new Error("Argument out of range"); + } + + if (this._s === 0) { + return [ZERO, ZERO]; + } + + if (n === 1 || n === -1) { + return [(sign === 1) ? this.abs() : new BigInteger(this._d, sign, CONSTRUCT), ZERO]; + } + + // 2 <= n < BigInteger_base + + // divide a single digit by a single digit + if (this._d.length === 1) { + var q = new BigInteger([(this._d[0] / n) | 0], 1, CONSTRUCT); + r = new BigInteger([(this._d[0] % n) | 0], 1, CONSTRUCT); + if (sign < 0) { + q = q.negate(); + } + if (this._s < 0) { + r = r.negate(); + } + return [q, r]; + } + + var digits = this._d.slice(); + var quot = new Array(digits.length); + var part = 0; + var diff = 0; + var i = 0; + var guess; + + while (digits.length) { + part = part * BigInteger_base + digits[digits.length - 1]; + if (part < n) { + quot[i++] = 0; + digits.pop(); + diff = BigInteger_base * diff + part; + continue; + } + if (part === 0) { + guess = 0; + } + else { + guess = (part / n) | 0; + } + + var check = n * guess; + diff = part - check; + quot[i++] = guess; + if (!guess) { + digits.pop(); + continue; + } + + digits.pop(); + part = diff; + } + + r = new BigInteger([diff], 1, CONSTRUCT); + if (this._s < 0) { + r = r.negate(); + } + return [new BigInteger(quot.reverse(), sign, CONSTRUCT), r]; + }; + + /* + Function: isEven + Return true iff *this* is divisible by two. + Note that is even. + Returns: + true if *this* is even, false otherwise. + See Also: + + */ + BigInteger.prototype.isEven = function() { + var digits = this._d; + return this._s === 0 || digits.length === 0 || (digits[0] % 2) === 0; + }; + + /* + Function: isOdd + Return true iff *this* is not divisible by two. + Returns: + true if *this* is odd, false otherwise. + See Also: + + */ + BigInteger.prototype.isOdd = function() { + return !this.isEven(); + }; + + /* + Function: sign + Get the sign of a . + Returns: + * -1 if *this* < 0 + * 0 if *this* == 0 + * +1 if *this* > 0 + See Also: + , , , , + */ + BigInteger.prototype.sign = function() { + return this._s; + }; + + /* + Function: isPositive + Return true iff *this* > 0. + Returns: + true if *this*.compare() == 1. + See Also: + , , , , , + */ + BigInteger.prototype.isPositive = function() { + return this._s > 0; + }; + + /* + Function: isNegative + Return true iff *this* < 0. + Returns: + true if *this*.compare() == -1. + See Also: + , , , , , + */ + BigInteger.prototype.isNegative = function() { + return this._s < 0; + }; + + /* + Function: isZero + Return true iff *this* == 0. + Returns: + true if *this*.compare() == 0. + See Also: + , , , , + */ + BigInteger.prototype.isZero = function() { + return this._s === 0; + }; + + /* + Function: exp10 + Multiply a by a power of 10. + This is equivalent to, but faster than + > if (n >= 0) { + > return this.multiply(BigInteger("1e" + n)); + > } + > else { // n <= 0 + > return this.quotient(BigInteger("1e" + -n)); + > } + Parameters: + n - The power of 10 to multiply *this* by. *n* is converted to a + javascipt number and must be no greater than + (0x7FFFFFFF), or an exception will be thrown. + Returns: + *this* * (10 ** *n*), truncated to an integer if necessary. + See Also: + , + */ + BigInteger.prototype.exp10 = function(n) { + n = +n; + if (n === 0) { + return this; + } + if (Math.abs(n) > Number(MAX_EXP)) { + throw new Error("exponent too large in BigInteger.exp10"); + } + // Optimization for this == 0. This also keeps us from having to trim zeros in the positive n case + if (this._s === 0) { + return ZERO; + } + if (n > 0) { + var k = new BigInteger(this._d.slice(), this._s, CONSTRUCT); + + for (; n >= BigInteger_base_log10; n -= BigInteger_base_log10) { + k._d.unshift(0); + } + if (n == 0) + return k; + k._s = 1; + k = k.multiplySingleDigit(Math.pow(10, n)); + return (this._s < 0 ? k.negate() : k); + } else if (-n >= this._d.length*BigInteger_base_log10) { + return ZERO; + } else { + var k = new BigInteger(this._d.slice(), this._s, CONSTRUCT); + + for (n = -n; n >= BigInteger_base_log10; n -= BigInteger_base_log10) { + k._d.shift(); + } + return (n == 0) ? k : k.divRemSmall(Math.pow(10, n))[0]; + } + }; + + /* + Function: pow + Raise a to a power. + In this implementation, 0**0 is 1. + Parameters: + n - The exponent to raise *this* by. *n* must be no greater than + (0x7FFFFFFF), or an exception will be thrown. + Returns: + *this* raised to the *nth* power. + See Also: + + */ + BigInteger.prototype.pow = function(n) { + if (this.isUnit()) { + if (this._s > 0) { + return this; + } + else { + return BigInteger(n).isOdd() ? this : this.negate(); + } + } + + n = BigInteger(n); + if (n._s === 0) { + return ONE; + } + else if (n._s < 0) { + if (this._s === 0) { + throw new Error("Divide by zero"); + } + else { + return ZERO; + } + } + if (this._s === 0) { + return ZERO; + } + if (n.isUnit()) { + return this; + } + + if (n.compareAbs(MAX_EXP) > 0) { + throw new Error("exponent too large in BigInteger.pow"); + } + var x = this; + var aux = ONE; + var two = BigInteger.small[2]; + + while (n.isPositive()) { + if (n.isOdd()) { + aux = aux.multiply(x); + if (n.isUnit()) { + return aux; + } + } + x = x.square(); + n = n.quotient(two); + } + + return aux; + }; + + /* + Function: modPow + Raise a to a power (mod m). + Because it is reduced by a modulus, is not limited by + like . + Parameters: + exponent - The exponent to raise *this* by. Must be positive. + modulus - The modulus. + Returns: + *this* ^ *exponent* (mod *modulus*). + See Also: + , + */ + BigInteger.prototype.modPow = function(exponent, modulus) { + var result = ONE; + var base = this; + + while (exponent.isPositive()) { + if (exponent.isOdd()) { + result = result.multiply(base).remainder(modulus); + } + + exponent = exponent.quotient(BigInteger.small[2]); + if (exponent.isPositive()) { + base = base.square().remainder(modulus); + } + } + + return result; + }; + + /* + Function: log + Get the natural logarithm of a as a native JavaScript number. + This is equivalent to + > Math.log(this.toJSValue()) + but handles values outside of the native number range. + Returns: + log( *this* ) + See Also: + + */ + BigInteger.prototype.log = function() { + switch (this._s) { + case 0: return -Infinity; + case -1: return NaN; + default: // Fall through. + } + + var l = this._d.length; + + if (l*BigInteger_base_log10 < 30) { + return Math.log(this.valueOf()); + } + + var N = Math.ceil(30/BigInteger_base_log10); + var firstNdigits = this._d.slice(l - N); + return Math.log((new BigInteger(firstNdigits, 1, CONSTRUCT)).valueOf()) + (l - N) * Math.log(BigInteger_base); + }; + + /* + Function: valueOf + Convert a to a native JavaScript integer. + This is called automatically by JavaScipt to convert a to a + native value. + Returns: + > parseInt(this.toString(), 10) + See Also: + , + */ + BigInteger.prototype.valueOf = function() { + return parseInt(this.toString(), 10); + }; + + /* + Function: toJSValue + Convert a to a native JavaScript integer. + This is the same as valueOf, but more explicitly named. + Returns: + > parseInt(this.toString(), 10) + See Also: + , + */ + BigInteger.prototype.toJSValue = function() { + return parseInt(this.toString(), 10); + }; + + + /* + Function: lowVal + Author: Lucas Jones + */ + BigInteger.prototype.lowVal = function () { + return this._d[0] || 0; + }; + + var MAX_EXP = BigInteger(0x7FFFFFFF); + // Constant: MAX_EXP + // The largest exponent allowed in and (0x7FFFFFFF or 2147483647). + BigInteger.MAX_EXP = MAX_EXP; + + (function() { + function makeUnary(fn) { + return function(a) { + return fn.call(BigInteger(a)); + }; + } + + function makeBinary(fn) { + return function(a, b) { + return fn.call(BigInteger(a), BigInteger(b)); + }; + } + + function makeTrinary(fn) { + return function(a, b, c) { + return fn.call(BigInteger(a), BigInteger(b), BigInteger(c)); + }; + } + + (function() { + var i, fn; + var unary = "toJSValue,isEven,isOdd,sign,isZero,isNegative,abs,isUnit,square,negate,isPositive,toString,next,prev,log".split(","); + var binary = "compare,remainder,divRem,subtract,add,quotient,divide,multiply,pow,compareAbs".split(","); + var trinary = ["modPow"]; + + for (i = 0; i < unary.length; i++) { + fn = unary[i]; + BigInteger[fn] = makeUnary(BigInteger.prototype[fn]); + } + + for (i = 0; i < binary.length; i++) { + fn = binary[i]; + BigInteger[fn] = makeBinary(BigInteger.prototype[fn]); + } + + for (i = 0; i < trinary.length; i++) { + fn = trinary[i]; + BigInteger[fn] = makeTrinary(BigInteger.prototype[fn]); + } + + BigInteger.exp10 = function(x, n) { + return BigInteger(x).exp10(n); + }; + })(); + })(); + + exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt + })(typeof exports !== 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/crypto/cnBase58.js b/src/crypto/cnBase58.js new file mode 100644 index 00000000..5c3b59d4 --- /dev/null +++ b/src/crypto/cnBase58.js @@ -0,0 +1,226 @@ +var JSBigInt = require('./biginteger')['JSBigInt']; + +/** +Copyright (c) 2017, moneroexamples + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Parts of the project are originally copyright (c) 2014-2017, MyMonero.com +*/ + +var cnBase58 = (function () { + var b58 = {}; + + var alphabet_str = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + var alphabet = []; + for (var i = 0; i < alphabet_str.length; i++) { + alphabet.push(alphabet_str.charCodeAt(i)); + } + var encoded_block_sizes = [0, 2, 3, 5, 6, 7, 9, 10, 11]; + + var alphabet_size = alphabet.length; + var full_block_size = 8; + var full_encoded_block_size = 11; + + var UINT64_MAX = new JSBigInt(2).pow(64); + + function hextobin(hex) { + if (hex.length % 2 !== 0) throw "Hex string has invalid length!"; + var res = new Uint8Array(hex.length / 2); + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); + } + return res; + } + + function bintohex(bin) { + var out = []; + for (var i = 0; i < bin.length; ++i) { + out.push(("0" + bin[i].toString(16)).slice(-2)); + } + return out.join(""); + } + + function strtobin(str) { + var res = new Uint8Array(str.length); + for (var i = 0; i < str.length; i++) { + res[i] = str.charCodeAt(i); + } + return res; + } + + function bintostr(bin) { + var out = []; + for (var i = 0; i < bin.length; i++) { + out.push(String.fromCharCode(bin[i])); + } + return out.join(""); + } + + function uint8_be_to_64(data) { + if (data.length < 1 || data.length > 8) { + throw "Invalid input length"; + } + var res = JSBigInt.ZERO; + var twopow8 = new JSBigInt(2).pow(8); + var i = 0; + switch (9 - data.length) { + case 1: + res = res.add(data[i++]); + case 2: + res = res.multiply(twopow8).add(data[i++]); + case 3: + res = res.multiply(twopow8).add(data[i++]); + case 4: + res = res.multiply(twopow8).add(data[i++]); + case 5: + res = res.multiply(twopow8).add(data[i++]); + case 6: + res = res.multiply(twopow8).add(data[i++]); + case 7: + res = res.multiply(twopow8).add(data[i++]); + case 8: + res = res.multiply(twopow8).add(data[i++]); + break; + default: + throw "Impossible condition"; + } + return res; + } + + function uint64_to_8be(num, size) { + var res = new Uint8Array(size); + if (size < 1 || size > 8) { + throw "Invalid input length"; + } + var twopow8 = new JSBigInt(2).pow(8); + for (var i = size - 1; i >= 0; i--) { + res[i] = num.remainder(twopow8).toJSValue(); + num = num.divide(twopow8); + } + return res; + } + + b58.encode_block = function (data, buf, index) { + if (data.length < 1 || data.length > full_encoded_block_size) { + throw "Invalid block length: " + data.length; + } + var num = uint8_be_to_64(data); + var i = encoded_block_sizes[data.length] - 1; + // while num > 0 + while (num.compare(0) === 1) { + var div = num.divRem(alphabet_size); + // remainder = num % alphabet_size + var remainder = div[1]; + // num = num / alphabet_size + num = div[0]; + buf[index + i] = alphabet[remainder.toJSValue()]; + i--; + } + return buf; + }; + + b58.encode = function (hex) { + var data = hextobin(hex); + if (data.length === 0) { + return ""; + } + var full_block_count = Math.floor(data.length / full_block_size); + var last_block_size = data.length % full_block_size; + var res_size = full_block_count * full_encoded_block_size + encoded_block_sizes[last_block_size]; + + var res = new Uint8Array(res_size); + var i; + for (i = 0; i < res_size; ++i) { + res[i] = alphabet[0]; + } + for (i = 0; i < full_block_count; i++) { + res = b58.encode_block(data.subarray(i * full_block_size, i * full_block_size + full_block_size), res, i * full_encoded_block_size); + } + if (last_block_size > 0) { + res = b58.encode_block(data.subarray(full_block_count * full_block_size, full_block_count * full_block_size + last_block_size), res, full_block_count * full_encoded_block_size) + } + return bintostr(res); + }; + + b58.decode_block = function (data, buf, index) { + if (data.length < 1 || data.length > full_encoded_block_size) { + throw "Invalid block length: " + data.length; + } + + var res_size = encoded_block_sizes.indexOf(data.length); + if (res_size <= 0) { + throw "Invalid block size"; + } + var res_num = new JSBigInt(0); + var order = new JSBigInt(1); + for (var i = data.length - 1; i >= 0; i--) { + var digit = alphabet.indexOf(data[i]); + if (digit < 0) { + throw "Invalid symbol"; + } + var product = order.multiply(digit).add(res_num); + // if product > UINT64_MAX + if (product.compare(UINT64_MAX) === 1) { + throw "Overflow"; + } + res_num = product; + order = order.multiply(alphabet_size); + } + if (res_size < full_block_size && (new JSBigInt(2).pow(8 * res_size).compare(res_num) <= 0)) { + throw "Overflow 2"; + } + buf.set(uint64_to_8be(res_num, res_size), index); + return buf; + }; + + b58.decode = function (enc) { + enc = strtobin(enc); + if (enc.length === 0) { + return ""; + } + var full_block_count = Math.floor(enc.length / full_encoded_block_size); + var last_block_size = enc.length % full_encoded_block_size; + var last_block_decoded_size = encoded_block_sizes.indexOf(last_block_size); + if (last_block_decoded_size < 0) { + throw "Invalid encoded length"; + } + var data_size = full_block_count * full_block_size + last_block_decoded_size; + var data = new Uint8Array(data_size); + for (var i = 0; i < full_block_count; i++) { + data = b58.decode_block(enc.subarray(i * full_encoded_block_size, i * full_encoded_block_size + full_encoded_block_size), data, i * full_block_size); + } + if (last_block_size > 0) { + data = b58.decode_block(enc.subarray(full_block_count * full_encoded_block_size, full_block_count * full_encoded_block_size + last_block_size), data, full_block_count * full_block_size); + } + return bintohex(data); + }; + + return b58; +})(); +module.exports = cnBase58; \ No newline at end of file diff --git a/src/crypto/utils.js b/src/crypto/utils.js index 0d824c99..3cc39bdf 100644 --- a/src/crypto/utils.js +++ b/src/crypto/utils.js @@ -34,5 +34,8 @@ module.exports = { }, keccak256: function (hexString) { return keccak256(hexString); + }, + keccak256Checksum: function (payload) { + return keccak256(payload).toString().substr(0, 8); } }; diff --git a/src/currencies.js b/src/currencies.js index b79c2c88..a9220582 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -2,6 +2,7 @@ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); var ADAValidator = require('./ada_validator'); +var XMRValidator = require('./monero_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -197,6 +198,12 @@ var CURRENCIES = [{ name: 'cardano', symbol: 'ada', validator: ADAValidator +},{ + name: 'monero', + symbol: 'xmr', + addressTypes: {prod: ['18'], testnet: ['53']}, + iAddressTypes: {prod: ['19'], testnet: ['54']}, + validator: XMRValidator }]; diff --git a/src/monero_validator.js b/src/monero_validator.js new file mode 100644 index 00000000..3b7473a0 --- /dev/null +++ b/src/monero_validator.js @@ -0,0 +1,60 @@ +var cryptoUtils = require('./crypto/utils'); +var cnBase58 = require('./crypto/cnBase58'); + +var DEFAULT_NETWORK_TYPE = 'prod'; +var addressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$'); +var integratedAddressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$'); + +function validateNetwork(decoded, currency, networkType, addressType){ + var network = currency.addressTypes; + if(addressType == 'integrated'){ + network = currency.iAddressTypes; + } + + switch(networkType){ + case 'prod': + return parseInt(decoded.substr(0,2), 16) == network.prod[0]; + case 'testnet': + return parseInt(decoded.substr(0,2), 16) == network.testnet[0]; + case 'both': + return parseInt(decoded.substr(0,2), 16) == network.prod[0] || parseInt(decoded.substr(0,2), 16) == network.testnet[0]; + default: + return false; + } +} + +function hextobin(hex) { + if (hex.length % 2 !== 0) return null; + var res = new Uint8Array(hex.length / 2); + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); + } + return res; +} + +module.exports = { + isValidAddress: function (address, currency, networkType) { + networkType = networkType || DEFAULT_NETWORK_TYPE; + var addressType = 'standard'; + if(!addressRegTest.test(address)){ + if(integratedAddressRegTest.test(address)){ + addressType = 'integrated'; + } + else{ + return false; + } + } + + var decodedAddrStr = cnBase58.decode(address); + if(!decodedAddrStr) + return false; + + if(!validateNetwork(decodedAddrStr, currency, networkType, addressType)) + return false; + + var addrChecksum = decodedAddrStr.slice(-8); + var hashChecksum = cryptoUtils.keccak256Checksum(hextobin(decodedAddrStr.slice(0, -8))); + + return addrChecksum === hashChecksum; + } +}; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 4b3db01b..7f71f67d 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -362,6 +362,16 @@ describe('WAValidator.validate()', function () { valid('Ae2tdPwUPEZKmwoy3AU3cXb5Chnasj6mvVNxV1H11997q3VW5ihbSfQwGpm', 'ada'); valid('4swhHtxKapQbj3TZEipgtp7NQzcRWDYqCxXYoPQWjGyHmhxS1w1TjUEszCQT1sQucGwmPQMYdv1FYs3d51KgoubviPBf', 'cardano'); }); + + it('should return true for correct monero addresses', function () { + valid('47zQ5LAivg6hNCgijXSEFVLX7mke1bgM6YGLFaANDoJbgXDymcAAZvvMNt2PmMpqEe5qRy2zyfMYXdwpmdyitiFh84xnPG2', 'monero'); + valid('48bWuoDG75CXMDHbmPEvUF2hm1vLDic7ZJ7hqRkL65QR9p13AQAX4eEACXNk4YP115Q4KRVZnAvmMBHrcGfv9FvKPZnH6vH', 'XMR'); + valid('A2be3UvzMtkJtxRYgcCbQt2y7Rp2eLVGqNTWfZeankrWimSMM4y7uMP6B9oAZaHsXTj8KFSerkSkkVRuEuEca9QM8VhxCNU', 'monero', 'testnet'); + + //integrated addresses + valid('4Gd4DLiXzBmbVX2FZZ3Cvu6fUaWACup1qDowprUCje1kSP4FmbftiJMSfV8kWZXNqmVwj4m52xqtgFNUudVmsmGkGvkLcCibWfVUfUFVB7', 'monero'); + valid('4J5sF94AzXgFgx8LuWc9dcWkJkGkD3cL3L2AuhX6QA9jFvSxxj6QhHqHXqM2b2Go7G8RyDzEbHxYd9G26XUUbuJChipEyBz9fENMU2Ua9b', 'XMR'); + }); }); describe('invalid results', function () { @@ -561,5 +571,15 @@ describe('WAValidator.validate()', function () { //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); }); + it('should return false for incorrect monero addresses', function () { + commonTests('monero'); + invalid('4AWygwA3hHNE4e4Yr9PtRWJiorXTjZkCi57g4ExYzfXDFFQ8DRFEFyui1dLqVknpqQjGUBdTMbgaFAZaDbrVHdk3GAKBZ3E', 'monero'); + invalid('44643dtxcxjgMWEQLo6mh1c4d9Zxx9GbgK9hEj9iGSiFEryCkbwHyJ3JqxZJRqeC3Hb7ZBLKq5NkaJwR1x95EYnR1bTgN6d', 'xmr'); + invalid('A17N9ztrxjQD3v3JJtHGvHVnq6BAbujDNEuensB6PFwBYFpkjAicih8hDtX76HBuEag5NeaCuMZmRMe6eE5NMRGxFTQn8nJ', 'monero', 'testnet'); + + //integrated + invalid('4LNSCKNSTPNbJYkyAEgL966eHJHLDHiq1PpwKoiFBybcSqNGYfLBJApC62uQEeGAFxfYEd29uXBBrJFo7DhKqFVNi3GhmN79EtD5dgycYz', 'monero'); + invalid('4JpzTwf3i1GeCV76beVr19179oa8j1L8xNSC1bXMtAxxdf4aTTLqubL8EvXfQmUGKt9MMigFtKy91VtoTTSfg1LU7LocPruT6KcGC9RKJV', 'xmr'); + }); }); }); From 8f7610d7cda512fbd4c49364fb437df35c230848 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 26 Oct 2018 00:24:44 +0200 Subject: [PATCH 054/108] added coins. mainly eth tokens --- src/currencies.js | 138 +++++++++++++++++++++++++++---- src/wallet_address_validator.js | 2 +- test/wallet_address_validator.js | 58 ++++++++++++- 3 files changed, 177 insertions(+), 21 deletions(-) diff --git a/src/currencies.js b/src/currencies.js index a9220582..38fed86e 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -146,26 +146,35 @@ var CURRENCIES = [{ expectedLength: 26, validator: BTCValidator },{ - name: 'digibyte', - symbol: 'dgb', - addressTypes: {prod: ['1e'], testnet: []}, + name: 'gamecredits', + symbol: 'game', + addressTypes: {prod: ['26', '05'], testnet: []}, validator: BTCValidator },{ - name: 'ethereum', - symbol: 'eth', - validator: ETHValidator, + name: 'pivx', + symbol: 'pivx', + addressTypes: {prod: ['1e', '0d'], testnet: []}, + validator: BTCValidator },{ - name: 'etherzero', - symbol: 'etz', - validator: ETHValidator, + name: 'SolarCoin', + symbol: 'slr', + addressTypes: {prod: ['12', '05'], testnet: []}, + validator: BTCValidator },{ - name: 'ethereumclassic', - symbol: 'etc', - validator: ETHValidator, + name: 'MonaCoin', + symbol: 'mona', + addressTypes: {prod: ['32', '37'], testnet: []}, + validator: BTCValidator },{ - name: 'callisto', - symbol: 'clo', - validator: ETHValidator, + name: 'digibyte', + symbol: 'dgb', + addressTypes: {prod: ['1e'], testnet: []}, + validator: BTCValidator +},{ + name: 'Tether', + symbol: 'usdt', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator },{ name: 'ripple', symbol: 'xrp', @@ -190,6 +199,22 @@ var CURRENCIES = [{ symbol: 'qtum', addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, validator: BTCValidator +},{ + name: 'ethereum', + symbol: 'eth', + validator: ETHValidator, +},{ + name: 'etherzero', + symbol: 'etz', + validator: ETHValidator, +},{ + name: 'ethereumclassic', + symbol: 'etc', + validator: ETHValidator, +},{ + name: 'callisto', + symbol: 'clo', + validator: ETHValidator, },{ name: 'bankex', symbol: 'bkx', @@ -204,6 +229,82 @@ var CURRENCIES = [{ addressTypes: {prod: ['18'], testnet: ['53']}, iAddressTypes: {prod: ['19'], testnet: ['54']}, validator: XMRValidator +},{ + name: 'Aragon', + symbol: 'ant', + validator: ETHValidator +},{ + name: 'Basic Attention Token', + symbol: 'bat', + validator: ETHValidator +},{ + name: 'Bancor', + symbol: 'bnt', + validator: ETHValidator +},{ + name: 'cvc', + symbol: 'Civic', + validator: ETHValidator +},{ + name: 'dnt', + symbol: 'District0x', + validator: ETHValidator +},{ + name: 'Gnosis', + symbol: 'gno', + validator: ETHValidator +},{ + name: 'Golem', + symbol: 'gnt', + validator: ETHValidator +},{ + name: 'Matchpool', + symbol: 'gup', + validator: ETHValidator +},{ + name: 'Melon', + symbol: 'mln', + validator: ETHValidator +},{ + name: 'Numeraire', + symbol: 'nmr', + validator: ETHValidator +},{ + name: 'OmiseGO', + symbol: 'omg', + validator: ETHValidator +},{ + name: 'TenX', + symbol: 'pay', + validator: ETHValidator +},{ + name: 'Ripio Credit Network', + symbol: 'rcn', + validator: ETHValidator +},{ + name: 'Augur', + symbol: 'rep', + validator: ETHValidator +},{ + name: 'Status', + symbol: 'snt', + validator: ETHValidator +},{ + name: 'Swarm City', + symbol: 'swt', + validator: ETHValidator +},{ + name: 'TrueUSD', + symbol: 'tusd', + validator: ETHValidator +},{ + name: 'Wings', + symbol: 'wings', + validator: ETHValidator +},{ + name: '0x', + symbol: 'zrx', + validator: ETHValidator }]; @@ -212,10 +313,15 @@ module.exports = { var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); for (var i = 0; i < CURRENCIES.length; i++) { var currency = CURRENCIES[i]; - if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { + if(currency.name.toLowerCase() === nameOrSymbol || currency.symbol.toLowerCase() === nameOrSymbol) { return currency; } } return null; } }; + + +CURRENCIES.forEach(c => console.log(c.symbol)); + + diff --git a/src/wallet_address_validator.js b/src/wallet_address_validator.js index 7ffecf8d..47c4e95c 100644 --- a/src/wallet_address_validator.js +++ b/src/wallet_address_validator.js @@ -6,7 +6,7 @@ module.exports = { validate: function (address, currencyNameOrSymbol, networkType) { var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); - if (currency.validator) { + if (currency && currency.validator) { return currency.validator.isValidAddress(address, currency, networkType); } diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 7f71f67d..940ac148 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -6,13 +6,13 @@ var chai = isNode ? require('chai') : window.chai, var WAValidator = isNode ? require('../src/wallet_address_validator') : window.WAValidator; function valid (address, currency, networkType) { - var result = WAValidator.validate(address, currency, networkType); - expect(result).to.be.true; + var valid = WAValidator.validate(address, currency, networkType); + expect({ address, currency, valid }).to.deep.equal({address, currency, valid: true}); } function invalid (address, currency, networkType) { - var result = WAValidator.validate(address, currency, networkType); - expect(result).to.be.false; + var valid = WAValidator.validate(address, currency, networkType); + expect({ address, currency, valid }).to.deep.equal({address, currency, valid: false}); } describe('WAValidator.validate()', function () { @@ -277,6 +277,8 @@ describe('WAValidator.validate()', function () { valid('XcY4WJ6Z2Q8w7vcYER1JypC8s2oa3SQ1b1', 'DASH'); valid('XqMkVUZnqe3w4xvgdZRtZoe7gMitDudGs4', 'dash'); valid('yPv7h2i8v3dJjfSH4L3x91JSJszjdbsJJA', 'dash', 'testnet'); + valid('XoAAqv3oUYZ6xRjX3brfbf9PotrGanS6Th', 'dash'); + valid('yP5oXZQXBfBf9FyfZDpFiKDypxuNUKUV2E', 'dash', 'testnet'); }); it('should return true for correct neo addresses', function () { @@ -372,6 +374,36 @@ describe('WAValidator.validate()', function () { valid('4Gd4DLiXzBmbVX2FZZ3Cvu6fUaWACup1qDowprUCje1kSP4FmbftiJMSfV8kWZXNqmVwj4m52xqtgFNUudVmsmGkGvkLcCibWfVUfUFVB7', 'monero'); valid('4J5sF94AzXgFgx8LuWc9dcWkJkGkD3cL3L2AuhX6QA9jFvSxxj6QhHqHXqM2b2Go7G8RyDzEbHxYd9G26XUUbuJChipEyBz9fENMU2Ua9b', 'XMR'); }); + + it('should return true for correct gamecredits addresses', function () { + valid('GU5BBtW9gxSKvAknvFi9yUaXKUNW9zUN2p', 'game'); + valid('GYxQMVzP6YpzX59QNRYqmJeHNtUMYSZPri', 'game'); + }); + + it('should return true for correct monacoin addresses', function () { + valid('MMN1Q1aRVUzanmg9DJjcRYzQSJQoBeQPui', 'mona'); + valid('PFMzNYnBm5X4c9qJkJPkfgdCyd9fuuy2vT', 'mona'); + valid('PCtN7VUYHW8w4g59BaphrfPs8g7pNgAzxn', 'mona'); + valid('MXCcYFGRmsd4d3CcQugFiqG8uarj5tVu76', 'mona'); + valid('MNK1pGsBf9WdoE54fZM9VFhkeYHW6VUf2u', 'mona'); + }); + + it('should return true for correct pivx addresses', function () { + valid('DJXFW9oJJBUX7QKrG6GKvmTs63MYKzwtpZ', 'pivx'); + valid('DEaYb8EHQgyKvX6VXDS3DZQautJrHBmK3T', 'pivx'); + valid('DDeCGR3QSgqsBxVR23bJvteiyYE34ZmxAc', 'pivx'); + valid('DSqQM8DPpBHHoZXHgRdwmaf6hZPEoZcFkh', 'pivx'); + }); + + it('should return true for correct solarcoin addresses', function () { + valid('8VxVLzwB26E2YZZ82o1NcQe96QSM2z6GwW', 'slr'); + valid('8YW5qcTjeyqX5kESsqu2BUdXiedgssegtQ', 'SolarCoin'); + }); + + it('should return true for correct tether addresses', function () { + valid('3MbYQMMmSkC3AgWkj9FMo5LsPTW1zBTwXL', 'usdt'); + valid('1KdXaqcBeoMAFVAPwTmYvDbEq6RnvNPF6J', 'tether'); + }); }); describe('invalid results', function () { @@ -455,6 +487,22 @@ describe('WAValidator.validate()', function () { commonTests('decred'); }); + it('should return false for incorrect gamecredits addresses', function () { + commonTests('game'); + }); + + it('should return false for incorrect monacoin addresses', function () { + commonTests('mona'); + }); + + it('should return false for incorrect solarcoin addresses', function () { + commonTests('slr'); + }); + + it('should return false for incorrect usdt addresses', function () { + commonTests('usdt'); + }); + it('should return false for incorrect bankex addresses', function () { invalid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'bankex'); invalid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd', 'BKX'); @@ -581,5 +629,7 @@ describe('WAValidator.validate()', function () { invalid('4LNSCKNSTPNbJYkyAEgL966eHJHLDHiq1PpwKoiFBybcSqNGYfLBJApC62uQEeGAFxfYEd29uXBBrJFo7DhKqFVNi3GhmN79EtD5dgycYz', 'monero'); invalid('4JpzTwf3i1GeCV76beVr19179oa8j1L8xNSC1bXMtAxxdf4aTTLqubL8EvXfQmUGKt9MMigFtKy91VtoTTSfg1LU7LocPruT6KcGC9RKJV', 'xmr'); }); + + }); }); From f35ae1fbd209d82ce2b2f8495a8659450aabb267 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 26 Oct 2018 00:29:21 +0200 Subject: [PATCH 055/108] added expanse --- src/currencies.js | 4 ++++ test/wallet_address_validator.js | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/currencies.js b/src/currencies.js index 38fed86e..a03c537f 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -305,6 +305,10 @@ var CURRENCIES = [{ name: '0x', symbol: 'zrx', validator: ETHValidator +},{ + name: 'Expanse', + symbol: 'exp', + validator: ETHValidator }]; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 940ac148..ed9553fa 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -403,7 +403,12 @@ describe('WAValidator.validate()', function () { it('should return true for correct tether addresses', function () { valid('3MbYQMMmSkC3AgWkj9FMo5LsPTW1zBTwXL', 'usdt'); valid('1KdXaqcBeoMAFVAPwTmYvDbEq6RnvNPF6J', 'tether'); - }); + }); + + it('should return true for correct expanse addresses', function () { + valid('0xbab463743603a253bdf1f84975b1a9517505ae05', 'exp'); + valid('0x5d0777cb5d6977873904864c6ab531f4b3261f0b', 'expanse'); + }); }); describe('invalid results', function () { @@ -499,6 +504,14 @@ describe('WAValidator.validate()', function () { commonTests('slr'); }); + it('should return false for incorrect tether addresses', function () { + commonTests('usdt'); + }); + + it('should return false for incorrect expanse addresses', function () { + commonTests('exp'); + }); + it('should return false for incorrect usdt addresses', function () { commonTests('usdt'); }); From 0176370d56b9cbb68305733e8a4bc268eeaa854a Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 26 Oct 2018 00:47:49 +0200 Subject: [PATCH 056/108] clean up. --- dist/wallet-address-validator.js | 17495 +++++++++++++++++++++++++ dist/wallet-address-validator.min.js | 1 + src/ada_validator.js | 17 +- src/currencies.js | 3 - 4 files changed, 17503 insertions(+), 13 deletions(-) create mode 100644 dist/wallet-address-validator.min.js diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index e69de29b..f11c293f 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -0,0 +1,17495 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0) { + digits.push(carry % BASE) + carry = (carry / BASE) | 0 + } + } + + var string = '' + + // deal with leading zeros + for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER + // convert digits to a string + for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] + + return string + } + + function decodeUnsafe (string) { + if (typeof string !== 'string') throw new TypeError('Expected String') + if (string.length === 0) return Buffer.allocUnsafe(0) + + var bytes = [0] + for (var i = 0; i < string.length; i++) { + var value = ALPHABET_MAP[string[i]] + if (value === undefined) return + + for (var j = 0, carry = value; j < bytes.length; ++j) { + carry += bytes[j] * BASE + bytes[j] = carry & 0xff + carry >>= 8 + } + + while (carry > 0) { + bytes.push(carry & 0xff) + carry >>= 8 + } + } + + // deal with leading zeros + for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { + bytes.push(0) + } + + return Buffer.from(bytes.reverse()) + } + + function decode (string) { + var buffer = decodeUnsafe(string) + if (buffer) return buffer + + throw new Error('Non-base' + BASE + ' character') + } + + return { + encode: encode, + decodeUnsafe: decodeUnsafe, + decode: decode + } +} + +},{"safe-buffer":71}],2:[function(require,module,exports){ +'use strict' + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + for (var i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') +} + +},{}],3:[function(require,module,exports){ +;(function (globalObject) { + 'use strict'; + +/* + * bignumber.js v7.2.1 + * A JavaScript library for arbitrary-precision arithmetic. + * https://github.com/MikeMcl/bignumber.js + * Copyright (c) 2018 Michael Mclaughlin + * MIT Licensed. + * + * BigNumber.prototype methods | BigNumber methods + * | + * absoluteValue abs | clone + * comparedTo | config set + * decimalPlaces dp | DECIMAL_PLACES + * dividedBy div | ROUNDING_MODE + * dividedToIntegerBy idiv | EXPONENTIAL_AT + * exponentiatedBy pow | RANGE + * integerValue | CRYPTO + * isEqualTo eq | MODULO_MODE + * isFinite | POW_PRECISION + * isGreaterThan gt | FORMAT + * isGreaterThanOrEqualTo gte | ALPHABET + * isInteger | isBigNumber + * isLessThan lt | maximum max + * isLessThanOrEqualTo lte | minimum min + * isNaN | random + * isNegative | + * isPositive | + * isZero | + * minus | + * modulo mod | + * multipliedBy times | + * negated | + * plus | + * precision sd | + * shiftedBy | + * squareRoot sqrt | + * toExponential | + * toFixed | + * toFormat | + * toFraction | + * toJSON | + * toNumber | + * toPrecision | + * toString | + * valueOf | + * + */ + + + var BigNumber, + isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, + + mathceil = Math.ceil, + mathfloor = Math.floor, + + bignumberError = '[BigNumber Error] ', + tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ', + + BASE = 1e14, + LOG_BASE = 14, + MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1 + // MAX_INT32 = 0x7fffffff, // 2^31 - 1 + POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], + SQRT_BASE = 1e7, + + // EDITABLE + // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and + // the arguments to toExponential, toFixed, toFormat, and toPrecision. + MAX = 1E9; // 0 to MAX_INT32 + + + /* + * Create and return a BigNumber constructor. + */ + function clone(configObject) { + var div, convertBase, parseNumeric, + P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null }, + ONE = new BigNumber(1), + + + //----------------------------- EDITABLE CONFIG DEFAULTS ------------------------------- + + + // The default values below must be integers within the inclusive ranges stated. + // The values can also be changed at run-time using BigNumber.set. + + // The maximum number of decimal places for operations involving division. + DECIMAL_PLACES = 20, // 0 to MAX + + // The rounding mode used when rounding to the above decimal places, and when using + // toExponential, toFixed, toFormat and toPrecision, and round (default value). + // UP 0 Away from zero. + // DOWN 1 Towards zero. + // CEIL 2 Towards +Infinity. + // FLOOR 3 Towards -Infinity. + // HALF_UP 4 Towards nearest neighbour. If equidistant, up. + // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. + // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. + // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. + // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. + ROUNDING_MODE = 4, // 0 to 8 + + // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS] + + // The exponent value at and beneath which toString returns exponential notation. + // Number type: -7 + TO_EXP_NEG = -7, // 0 to -MAX + + // The exponent value at and above which toString returns exponential notation. + // Number type: 21 + TO_EXP_POS = 21, // 0 to MAX + + // RANGE : [MIN_EXP, MAX_EXP] + + // The minimum exponent value, beneath which underflow to zero occurs. + // Number type: -324 (5e-324) + MIN_EXP = -1e7, // -1 to -MAX + + // The maximum exponent value, above which overflow to Infinity occurs. + // Number type: 308 (1.7976931348623157e+308) + // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow. + MAX_EXP = 1e7, // 1 to MAX + + // Whether to use cryptographically-secure random number generation, if available. + CRYPTO = false, // true or false + + // The modulo mode used when calculating the modulus: a mod n. + // The quotient (q = a / n) is calculated according to the corresponding rounding mode. + // The remainder (r) is calculated as: r = a - n * q. + // + // UP 0 The remainder is positive if the dividend is negative, else is negative. + // DOWN 1 The remainder has the same sign as the dividend. + // This modulo mode is commonly known as 'truncated division' and is + // equivalent to (a % n) in JavaScript. + // FLOOR 3 The remainder has the same sign as the divisor (Python %). + // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function. + // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). + // The remainder is always positive. + // + // The truncated division, floored division, Euclidian division and IEEE 754 remainder + // modes are commonly used for the modulus operation. + // Although the other rounding modes can also be used, they may not give useful results. + MODULO_MODE = 1, // 0 to 9 + + // 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 + + // The format specification used by the BigNumber.prototype.toFormat method. + FORMAT = { + decimalSeparator: '.', + groupSeparator: ',', + groupSize: 3, + secondaryGroupSize: 0, + fractionGroupSeparator: '\xA0', // non-breaking space + fractionGroupSize: 0 + }, + + // The alphabet used for base conversion. + // It must be at least 2 characters long, with no '.' or repeated character. + // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' + ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'; + + + //------------------------------------------------------------------------------------------ + + + // CONSTRUCTOR + + + /* + * The BigNumber constructor and exported function. + * Create and return a new instance of a BigNumber object. + * + * n {number|string|BigNumber} A numeric value. + * [b] {number} The base of n. Integer, 2 to ALPHABET.length inclusive. + */ + function BigNumber(n, b) { + var alphabet, c, caseChanged, e, i, isNum, len, str, + x = this; + + // Enable constructor usage without new. + if (!(x instanceof BigNumber)) { + + // Don't throw on constructor call without new (#81). + // '[BigNumber Error] Constructor call without new: {n}' + //throw Error(bignumberError + ' Constructor call without new: ' + n); + return new BigNumber(n, b); + } + + if (b == null) { + + // Duplicate. + if (n instanceof BigNumber) { + x.s = n.s; + x.e = n.e; + x.c = (n = n.c) ? n.slice() : n; + return; + } + + isNum = typeof n == 'number'; + + if (isNum && n * 0 == 0) { + + // Use `1 / n` to handle minus zero also. + x.s = 1 / n < 0 ? (n = -n, -1) : 1; + + // Faster path for integers. + if (n === ~~n) { + for (e = 0, i = n; i >= 10; i /= 10, e++); + x.e = e; + x.c = [n]; + return; + } + + str = n + ''; + } else { + if (!isNumeric.test(str = n + '')) return parseNumeric(x, str, isNum); + x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1; + } + + // Decimal point? + if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); + + // Exponential form? + if ((i = str.search(/e/i)) > 0) { + + // Determine exponent. + if (e < 0) e = i; + e += +str.slice(i + 1); + str = str.substring(0, i); + } else if (e < 0) { + + // Integer. + e = str.length; + } + + } else { + + // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' + intCheck(b, 2, ALPHABET.length, 'Base'); + str = n + ''; + + // Allow exponential notation to be used with base 10 argument, while + // also rounding to DECIMAL_PLACES as with other bases. + if (b == 10) { + x = new BigNumber(n instanceof BigNumber ? n : str); + return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE); + } + + isNum = typeof n == 'number'; + + if (isNum) { + + // Avoid potential interpretation of Infinity and NaN as base 44+ values. + if (n * 0 != 0) return parseNumeric(x, str, isNum, b); + + x.s = 1 / n < 0 ? (str = str.slice(1), -1) : 1; + + // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' + if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) { + throw Error + (tooManyDigits + n); + } + + // Prevent later check for length on converted number. + isNum = false; + } else { + x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1; + } + + alphabet = ALPHABET.slice(0, b); + e = i = 0; + + // Check that str is a valid base b number. + // Don't use RegExp so alphabet can contain special characters. + for (len = str.length; i < len; i++) { + if (alphabet.indexOf(c = str.charAt(i)) < 0) { + if (c == '.') { + + // If '.' is not the first character and it has not be found before. + if (i > e) { + e = len; + continue; + } + } else if (!caseChanged) { + + // Allow e.g. hexadecimal 'FF' as well as 'ff'. + if (str == str.toUpperCase() && (str = str.toLowerCase()) || + str == str.toLowerCase() && (str = str.toUpperCase())) { + caseChanged = true; + i = -1; + e = 0; + continue; + } + } + + return parseNumeric(x, n + '', isNum, b); + } + } + + str = convertBase(str, b, 10, x.s); + + // Decimal point? + if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); + else e = str.length; + } + + // Determine leading zeros. + for (i = 0; str.charCodeAt(i) === 48; i++); + + // Determine trailing zeros. + for (len = str.length; str.charCodeAt(--len) === 48;); + + str = str.slice(i, ++len); + + if (str) { + len -= i; + + // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' + if (isNum && BigNumber.DEBUG && + len > 15 && (n > MAX_SAFE_INTEGER || n !== mathfloor(n))) { + throw Error + (tooManyDigits + (x.s * n)); + } + + e = e - i - 1; + + // Overflow? + if (e > MAX_EXP) { + + // Infinity. + x.c = x.e = null; + + // Underflow? + } else if (e < MIN_EXP) { + + // Zero. + x.c = [x.e = 0]; + } else { + x.e = e; + x.c = []; + + // Transform base + + // e is the base 10 exponent. + // i is where to slice str to get the first element of the coefficient array. + i = (e + 1) % LOG_BASE; + if (e < 0) i += LOG_BASE; + + if (i < len) { + if (i) x.c.push(+str.slice(0, i)); + + for (len -= LOG_BASE; i < len;) { + x.c.push(+str.slice(i, i += LOG_BASE)); + } + + str = str.slice(i); + i = LOG_BASE - str.length; + } else { + i -= len; + } + + for (; i--; str += '0'); + x.c.push(+str); + } + } else { + + // Zero. + x.c = [x.e = 0]; + } + } + + + // CONSTRUCTOR PROPERTIES + + + BigNumber.clone = clone; + + BigNumber.ROUND_UP = 0; + BigNumber.ROUND_DOWN = 1; + BigNumber.ROUND_CEIL = 2; + BigNumber.ROUND_FLOOR = 3; + BigNumber.ROUND_HALF_UP = 4; + BigNumber.ROUND_HALF_DOWN = 5; + BigNumber.ROUND_HALF_EVEN = 6; + BigNumber.ROUND_HALF_CEIL = 7; + BigNumber.ROUND_HALF_FLOOR = 8; + BigNumber.EUCLID = 9; + + + /* + * Configure infrequently-changing library-wide settings. + * + * Accept an object with the following optional properties (if the value of a property is + * a number, it must be an integer within the inclusive range stated): + * + * DECIMAL_PLACES {number} 0 to MAX + * ROUNDING_MODE {number} 0 to 8 + * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX] + * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX] + * CRYPTO {boolean} true or false + * 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 '.'. + * FORMAT {object} An object with some of the following properties: + * decimalSeparator {string} + * groupSeparator {string} + * groupSize {number} + * secondaryGroupSize {number} + * fractionGroupSeparator {string} + * fractionGroupSize {number} + * + * (The values assigned to the above FORMAT object properties are not checked for validity.) + * + * E.g. + * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 }) + * + * Ignore properties/parameters set to null or undefined, except for ALPHABET. + * + * Return an object with the properties current values. + */ + BigNumber.config = BigNumber.set = function (obj) { + var p, v; + + if (obj != null) { + + if (typeof obj == 'object') { + + // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive. + // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) { + v = obj[p]; + intCheck(v, 0, MAX, p); + DECIMAL_PLACES = v; + } + + // ROUNDING_MODE {number} Integer, 0 to 8 inclusive. + // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) { + v = obj[p]; + intCheck(v, 0, 8, p); + ROUNDING_MODE = v; + } + + // EXPONENTIAL_AT {number|number[]} + // Integer, -MAX to MAX inclusive or + // [integer -MAX to 0 inclusive, 0 to MAX inclusive]. + // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) { + v = obj[p]; + if (isArray(v)) { + intCheck(v[0], -MAX, 0, p); + intCheck(v[1], 0, MAX, p); + TO_EXP_NEG = v[0]; + TO_EXP_POS = v[1]; + } else { + intCheck(v, -MAX, MAX, p); + TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v); + } + } + + // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or + // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive]. + // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}' + if (obj.hasOwnProperty(p = 'RANGE')) { + v = obj[p]; + if (isArray(v)) { + intCheck(v[0], -MAX, -1, p); + intCheck(v[1], 1, MAX, p); + MIN_EXP = v[0]; + MAX_EXP = v[1]; + } else { + intCheck(v, -MAX, MAX, p); + if (v) { + MIN_EXP = -(MAX_EXP = v < 0 ? -v : v); + } else { + throw Error + (bignumberError + p + ' cannot be zero: ' + v); + } + } + } + + // CRYPTO {boolean} true or false. + // '[BigNumber Error] CRYPTO not true or false: {v}' + // '[BigNumber Error] crypto unavailable' + if (obj.hasOwnProperty(p = 'CRYPTO')) { + v = obj[p]; + if (v === !!v) { + if (v) { + if (typeof crypto != 'undefined' && crypto && + (crypto.getRandomValues || crypto.randomBytes)) { + CRYPTO = v; + } else { + CRYPTO = !v; + throw Error + (bignumberError + 'crypto unavailable'); + } + } else { + CRYPTO = v; + } + } else { + throw Error + (bignumberError + p + ' not true or false: ' + v); + } + } + + // MODULO_MODE {number} Integer, 0 to 9 inclusive. + // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'MODULO_MODE')) { + v = obj[p]; + intCheck(v, 0, 9, p); + MODULO_MODE = v; + } + + // POW_PRECISION {number} Integer, 0 to MAX inclusive. + // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'POW_PRECISION')) { + v = obj[p]; + intCheck(v, 0, MAX, p); + POW_PRECISION = v; + } + + // FORMAT {object} + // '[BigNumber Error] FORMAT not an object: {v}' + if (obj.hasOwnProperty(p = 'FORMAT')) { + v = obj[p]; + if (typeof v == 'object') FORMAT = v; + else throw Error + (bignumberError + p + ' not an object: ' + v); + } + + // ALPHABET {string} + // '[BigNumber Error] ALPHABET invalid: {v}' + if (obj.hasOwnProperty(p = 'ALPHABET')) { + v = obj[p]; + + // Disallow if only one character, or contains '.' or a repeated character. + if (typeof v == 'string' && !/^.$|\.|(.).*\1/.test(v)) { + ALPHABET = v; + } else { + throw Error + (bignumberError + p + ' invalid: ' + v); + } + } + + } else { + + // '[BigNumber Error] Object expected: {v}' + throw Error + (bignumberError + 'Object expected: ' + obj); + } + } + + return { + DECIMAL_PLACES: DECIMAL_PLACES, + ROUNDING_MODE: ROUNDING_MODE, + EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS], + RANGE: [MIN_EXP, MAX_EXP], + CRYPTO: CRYPTO, + MODULO_MODE: MODULO_MODE, + POW_PRECISION: POW_PRECISION, + FORMAT: FORMAT, + ALPHABET: ALPHABET + }; + }; + + + /* + * Return true if v is a BigNumber instance, otherwise return false. + * + * v {any} + */ + BigNumber.isBigNumber = function (v) { + return v instanceof BigNumber || v && v._isBigNumber === true || false; + }; + + + /* + * Return a new BigNumber whose value is the maximum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.maximum = BigNumber.max = function () { + return maxOrMin(arguments, P.lt); + }; + + + /* + * Return a new BigNumber whose value is the minimum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.minimum = BigNumber.min = function () { + return maxOrMin(arguments, P.gt); + }; + + + /* + * Return a new BigNumber with a random value equal to or greater than 0 and less than 1, + * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing + * zeros are produced). + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}' + * '[BigNumber Error] crypto unavailable' + */ + BigNumber.random = (function () { + var pow2_53 = 0x20000000000000; + + // Return a 53 bit integer n, where 0 <= n < 9007199254740992. + // Check if Math.random() produces more than 32 bits of randomness. + // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits. + // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1. + var random53bitInt = (Math.random() * pow2_53) & 0x1fffff + ? function () { return mathfloor(Math.random() * pow2_53); } + : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) + + (Math.random() * 0x800000 | 0); }; + + return function (dp) { + var a, b, e, k, v, + i = 0, + c = [], + rand = new BigNumber(ONE); + + if (dp == null) dp = DECIMAL_PLACES; + else intCheck(dp, 0, MAX); + + k = mathceil(dp / LOG_BASE); + + if (CRYPTO) { + + // Browsers supporting crypto.getRandomValues. + if (crypto.getRandomValues) { + + a = crypto.getRandomValues(new Uint32Array(k *= 2)); + + for (; i < k;) { + + // 53 bits: + // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2) + // 11111 11111111 11111111 11111111 11100000 00000000 00000000 + // ((Math.pow(2, 32) - 1) >>> 11).toString(2) + // 11111 11111111 11111111 + // 0x20000 is 2^21. + v = a[i] * 0x20000 + (a[i + 1] >>> 11); + + // Rejection sampling: + // 0 <= v < 9007199254740992 + // Probability that v >= 9e15, is + // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251 + if (v >= 9e15) { + b = crypto.getRandomValues(new Uint32Array(2)); + a[i] = b[0]; + a[i + 1] = b[1]; + } else { + + // 0 <= v <= 8999999999999999 + // 0 <= (v % 1e14) <= 99999999999999 + c.push(v % 1e14); + i += 2; + } + } + i = k / 2; + + // Node.js supporting crypto.randomBytes. + } else if (crypto.randomBytes) { + + // buffer + a = crypto.randomBytes(k *= 7); + + for (; i < k;) { + + // 0x1000000000000 is 2^48, 0x10000000000 is 2^40 + // 0x100000000 is 2^32, 0x1000000 is 2^24 + // 11111 11111111 11111111 11111111 11111111 11111111 11111111 + // 0 <= v < 9007199254740992 + v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) + + (a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) + + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6]; + + if (v >= 9e15) { + crypto.randomBytes(7).copy(a, i); + } else { + + // 0 <= (v % 1e14) <= 99999999999999 + c.push(v % 1e14); + i += 7; + } + } + i = k / 7; + } else { + CRYPTO = false; + throw Error + (bignumberError + 'crypto unavailable'); + } + } + + // Use Math.random. + if (!CRYPTO) { + + for (; i < k;) { + v = random53bitInt(); + if (v < 9e15) c[i++] = v % 1e14; + } + } + + k = c[--i]; + dp %= LOG_BASE; + + // Convert trailing digits to zeros according to dp. + if (k && dp) { + v = POWS_TEN[LOG_BASE - dp]; + c[i] = mathfloor(k / v) * v; + } + + // Remove trailing elements which are zero. + for (; c[i] === 0; c.pop(), i--); + + // Zero? + if (i < 0) { + c = [e = 0]; + } else { + + // Remove leading elements which are zero and adjust exponent accordingly. + for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE); + + // Count the digits of the first element of c to determine leading zeros, and... + for (i = 1, v = c[0]; v >= 10; v /= 10, i++); + + // adjust the exponent accordingly. + if (i < LOG_BASE) e -= LOG_BASE - i; + } + + rand.e = e; + rand.c = c; + return rand; + }; + })(); + + + // PRIVATE FUNCTIONS + + + // Called by BigNumber and BigNumber.prototype.toString. + convertBase = (function () { + var decimal = '0123456789'; + + /* + * Convert string of baseIn to an array of numbers of baseOut. + * Eg. toBaseOut('255', 10, 16) returns [15, 15]. + * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5]. + */ + function toBaseOut(str, baseIn, baseOut, alphabet) { + var j, + arr = [0], + arrL, + i = 0, + len = str.length; + + for (; i < len;) { + for (arrL = arr.length; arrL--; arr[arrL] *= baseIn); + + arr[0] += alphabet.indexOf(str.charAt(i++)); + + for (j = 0; j < arr.length; j++) { + + if (arr[j] > baseOut - 1) { + if (arr[j + 1] == null) arr[j + 1] = 0; + arr[j + 1] += arr[j] / baseOut | 0; + arr[j] %= baseOut; + } + } + } + + return arr.reverse(); + } + + // Convert a numeric string of baseIn to a numeric string of baseOut. + // If the caller is toString, we are converting from base 10 to baseOut. + // If the caller is BigNumber, we are converting from baseIn to base 10. + return function (str, baseIn, baseOut, sign, callerIsToString) { + var alphabet, d, e, k, r, x, xc, y, + i = str.indexOf('.'), + dp = DECIMAL_PLACES, + rm = ROUNDING_MODE; + + // Non-integer. + if (i >= 0) { + k = POW_PRECISION; + + // Unlimited precision. + POW_PRECISION = 0; + str = str.replace('.', ''); + y = new BigNumber(baseIn); + x = y.pow(str.length - i); + POW_PRECISION = k; + + // Convert str as if an integer, then restore the fraction part by dividing the + // result by its base raised to a power. + + y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'), + 10, baseOut, decimal); + y.e = y.c.length; + } + + // Convert the number as integer. + + xc = toBaseOut(str, baseIn, baseOut, callerIsToString + ? (alphabet = ALPHABET, decimal) + : (alphabet = decimal, ALPHABET)); + + // xc now represents str as an integer and converted to baseOut. e is the exponent. + e = k = xc.length; + + // Remove trailing zeros. + for (; xc[--k] == 0; xc.pop()); + + // Zero? + if (!xc[0]) return alphabet.charAt(0); + + // Does str represent an integer? If so, no need for the division. + if (i < 0) { + --e; + } else { + x.c = xc; + x.e = e; + + // The sign is needed for correct rounding. + x.s = sign; + x = div(x, y, dp, rm, baseOut); + xc = x.c; + r = x.r; + e = x.e; + } + + // xc now represents str converted to baseOut. + + // THe index of the rounding digit. + d = e + dp + 1; + + // The rounding digit: the digit to the right of the digit that may be rounded up. + i = xc[d]; + + // Look at the rounding digits and mode to determine whether to round up. + + k = baseOut / 2; + r = r || d < 0 || xc[d + 1] != null; + + r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) + : i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 || + rm == (x.s < 0 ? 8 : 7)); + + // If the index of the rounding digit is not greater than zero, or xc represents + // zero, then the result of the base conversion is zero or, if rounding up, a value + // such as 0.00001. + if (d < 1 || !xc[0]) { + + // 1^-dp or 0 + str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) + : alphabet.charAt(0); + } else { + + // Truncate xc to the required number of decimal places. + xc.length = d; + + // Round up? + if (r) { + + // Rounding up may mean the previous digit has to be rounded up and so on. + for (--baseOut; ++xc[--d] > baseOut;) { + xc[d] = 0; + + if (!d) { + ++e; + xc = [1].concat(xc); + } + } + } + + // Determine trailing zeros. + for (k = xc.length; !xc[--k];); + + // E.g. [4, 11, 15] becomes 4bf. + for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++])); + + // Add leading zeros, decimal point and trailing zeros as required. + str = toFixedPoint(str, e, alphabet.charAt(0)); + } + + // The caller will add the sign. + return str; + }; + })(); + + + // Perform division in the specified base. Called by div and convertBase. + div = (function () { + + // Assume non-zero x and k. + function multiply(x, k, base) { + var m, temp, xlo, xhi, + carry = 0, + i = x.length, + klo = k % SQRT_BASE, + khi = k / SQRT_BASE | 0; + + for (x = x.slice(); i--;) { + xlo = x[i] % SQRT_BASE; + xhi = x[i] / SQRT_BASE | 0; + m = khi * xlo + xhi * klo; + temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry; + carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi; + x[i] = temp % base; + } + + if (carry) x = [carry].concat(x); + + return x; + } + + function compare(a, b, aL, bL) { + var i, cmp; + + if (aL != bL) { + cmp = aL > bL ? 1 : -1; + } else { + + for (i = cmp = 0; i < aL; i++) { + + if (a[i] != b[i]) { + cmp = a[i] > b[i] ? 1 : -1; + break; + } + } + } + + return cmp; + } + + function subtract(a, b, aL, base) { + var i = 0; + + // Subtract b from a. + for (; aL--;) { + a[aL] -= i; + i = a[aL] < b[aL] ? 1 : 0; + a[aL] = i * base + a[aL] - b[aL]; + } + + // Remove leading zeros. + for (; !a[0] && a.length > 1; a.splice(0, 1)); + } + + // x: dividend, y: divisor. + return function (x, y, dp, rm, base) { + var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, + yL, yz, + s = x.s == y.s ? 1 : -1, + xc = x.c, + yc = y.c; + + // Either NaN, Infinity or 0? + if (!xc || !xc[0] || !yc || !yc[0]) { + + return new BigNumber( + + // Return NaN if either NaN, or both Infinity or 0. + !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : + + // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0. + xc && xc[0] == 0 || !yc ? s * 0 : s / 0 + ); + } + + q = new BigNumber(s); + qc = q.c = []; + e = x.e - y.e; + s = dp + e + 1; + + if (!base) { + base = BASE; + e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE); + s = s / LOG_BASE | 0; + } + + // Result exponent may be one less then the current value of e. + // The coefficients of the BigNumbers from convertBase may have trailing zeros. + for (i = 0; yc[i] == (xc[i] || 0); i++); + + if (yc[i] > (xc[i] || 0)) e--; + + if (s < 0) { + qc.push(1); + more = true; + } else { + xL = xc.length; + yL = yc.length; + i = 0; + s += 2; + + // Normalise xc and yc so highest order digit of yc is >= base / 2. + + n = mathfloor(base / (yc[0] + 1)); + + // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1. + // if (n > 1 || n++ == 1 && yc[0] < base / 2) { + if (n > 1) { + yc = multiply(yc, n, base); + xc = multiply(xc, n, base); + yL = yc.length; + xL = xc.length; + } + + xi = yL; + rem = xc.slice(0, yL); + remL = rem.length; + + // Add zeros to make remainder as long as divisor. + for (; remL < yL; rem[remL++] = 0); + yz = yc.slice(); + yz = [0].concat(yz); + yc0 = yc[0]; + if (yc[1] >= base / 2) yc0++; + // Not necessary, but to prevent trial digit n > base, when using base 3. + // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15; + + do { + n = 0; + + // Compare divisor and remainder. + cmp = compare(yc, rem, yL, remL); + + // If divisor < remainder. + if (cmp < 0) { + + // Calculate trial digit, n. + + rem0 = rem[0]; + if (yL != remL) rem0 = rem0 * base + (rem[1] || 0); + + // n is how many times the divisor goes into the current remainder. + n = mathfloor(rem0 / yc0); + + // Algorithm: + // product = divisor multiplied by trial digit (n). + // Compare product and remainder. + // If product is greater than remainder: + // Subtract divisor from product, decrement trial digit. + // Subtract product from remainder. + // If product was less than remainder at the last compare: + // Compare new remainder and divisor. + // If remainder is greater than divisor: + // Subtract divisor from remainder, increment trial digit. + + if (n > 1) { + + // n may be > base only when base is 3. + if (n >= base) n = base - 1; + + // product = divisor * trial digit. + prod = multiply(yc, n, base); + prodL = prod.length; + remL = rem.length; + + // Compare product and remainder. + // If product > remainder then trial digit n too high. + // n is 1 too high about 5% of the time, and is not known to have + // ever been more than 1 too high. + while (compare(prod, rem, prodL, remL) == 1) { + n--; + + // Subtract divisor from product. + subtract(prod, yL < prodL ? yz : yc, prodL, base); + prodL = prod.length; + cmp = 1; + } + } else { + + // n is 0 or 1, cmp is -1. + // If n is 0, there is no need to compare yc and rem again below, + // so change cmp to 1 to avoid it. + // If n is 1, leave cmp as -1, so yc and rem are compared again. + if (n == 0) { + + // divisor < remainder, so n must be at least 1. + cmp = n = 1; + } + + // product = divisor + prod = yc.slice(); + prodL = prod.length; + } + + if (prodL < remL) prod = [0].concat(prod); + + // Subtract product from remainder. + subtract(rem, prod, remL, base); + remL = rem.length; + + // If product was < remainder. + if (cmp == -1) { + + // Compare divisor and new remainder. + // If divisor < new remainder, subtract divisor from remainder. + // Trial digit n too low. + // n is 1 too low about 5% of the time, and very rarely 2 too low. + while (compare(yc, rem, yL, remL) < 1) { + n++; + + // Subtract divisor from remainder. + subtract(rem, yL < remL ? yz : yc, remL, base); + remL = rem.length; + } + } + } else if (cmp === 0) { + n++; + rem = [0]; + } // else cmp === 1 and n will be 0 + + // Add the next digit, n, to the result array. + qc[i++] = n; + + // Update the remainder. + if (rem[0]) { + rem[remL++] = xc[xi] || 0; + } else { + rem = [xc[xi]]; + remL = 1; + } + } while ((xi++ < xL || rem[0] != null) && s--); + + more = rem[0] != null; + + // Leading zero? + if (!qc[0]) qc.splice(0, 1); + } + + if (base == BASE) { + + // To calculate q.e, first get the number of digits of qc[0]. + for (i = 1, s = qc[0]; s >= 10; s /= 10, i++); + + round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more); + + // Caller is convertBase. + } else { + q.e = e; + q.r = +more; + } + + return q; + }; + })(); + + + /* + * Return a string representing the value of BigNumber n in fixed-point or exponential + * notation rounded to the specified decimal places or significant digits. + * + * n: a BigNumber. + * i: the index of the last digit required (i.e. the digit that may be rounded up). + * rm: the rounding mode. + * id: 1 (toExponential) or 2 (toPrecision). + */ + function format(n, i, rm, id) { + var c0, e, ne, len, str; + + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + + if (!n.c) return n.toString(); + + c0 = n.c[0]; + ne = n.e; + + if (i == null) { + str = coeffToString(n.c); + str = id == 1 || id == 2 && ne <= TO_EXP_NEG + ? toExponential(str, ne) + : toFixedPoint(str, ne, '0'); + } else { + n = round(new BigNumber(n), i, rm); + + // n.e may have changed if the value was rounded up. + e = n.e; + + str = coeffToString(n.c); + len = str.length; + + // toPrecision returns exponential notation if the number of significant digits + // specified is less than the number of digits necessary to represent the integer + // part of the value in fixed-point notation. + + // Exponential notation. + if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) { + + // Append zeros? + for (; len < i; str += '0', len++); + str = toExponential(str, e); + + // Fixed-point notation. + } else { + i -= ne; + str = toFixedPoint(str, e, '0'); + + // Append zeros? + if (e + 1 > len) { + if (--i > 0) for (str += '.'; i--; str += '0'); + } else { + i += e - len; + if (i > 0) { + if (e + 1 == len) str += '.'; + for (; i--; str += '0'); + } + } + } + } + + return n.s < 0 && c0 ? '-' + str : str; + } + + + // Handle BigNumber.max and BigNumber.min. + function maxOrMin(args, method) { + var m, n, + i = 0; + + if (isArray(args[0])) args = args[0]; + m = new BigNumber(args[0]); + + for (; ++i < args.length;) { + n = new BigNumber(args[i]); + + // If any number is NaN, return NaN. + if (!n.s) { + m = n; + break; + } else if (method.call(m, n)) { + m = n; + } + } + + return m; + } + + + /* + * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP. + * Called by minus, plus and times. + */ + function normalise(n, c, e) { + var i = 1, + j = c.length; + + // Remove trailing zeros. + for (; !c[--j]; c.pop()); + + // Calculate the base 10 exponent. First get the number of digits of c[0]. + for (j = c[0]; j >= 10; j /= 10, i++); + + // Overflow? + if ((e = i + e * LOG_BASE - 1) > MAX_EXP) { + + // Infinity. + n.c = n.e = null; + + // Underflow? + } else if (e < MIN_EXP) { + + // Zero. + n.c = [n.e = 0]; + } else { + n.e = e; + n.c = c; + } + + return n; + } + + + // Handle values that fail the validity test in BigNumber. + parseNumeric = (function () { + var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, + dotAfter = /^([^.]+)\.$/, + dotBefore = /^\.([^.]+)$/, + isInfinityOrNaN = /^-?(Infinity|NaN)$/, + whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g; + + return function (x, str, isNum, b) { + var base, + s = isNum ? str : str.replace(whitespaceOrPlus, ''); + + // No exception on ±Infinity or NaN. + if (isInfinityOrNaN.test(s)) { + x.s = isNaN(s) ? null : s < 0 ? -1 : 1; + x.c = x.e = null; + } else { + if (!isNum) { + + // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i + s = s.replace(basePrefix, function (m, p1, p2) { + base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8; + return !b || b == base ? p1 : m; + }); + + if (b) { + base = b; + + // E.g. '1.' to '1', '.1' to '0.1' + s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1'); + } + + if (str != s) return new BigNumber(s, base); + } + + // '[BigNumber Error] Not a number: {n}' + // '[BigNumber Error] Not a base {b} number: {n}' + if (BigNumber.DEBUG) { + throw Error + (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str); + } + + // NaN + x.c = x.e = x.s = null; + } + } + })(); + + + /* + * Round x to sd significant digits using rounding mode rm. Check for over/under-flow. + * If r is truthy, it is known that there are more digits after the rounding digit. + */ + function round(x, sd, rm, r) { + var d, i, j, k, n, ni, rd, + xc = x.c, + pows10 = POWS_TEN; + + // if x is not Infinity or NaN... + if (xc) { + + // rd is the rounding digit, i.e. the digit after the digit that may be rounded up. + // n is a base 1e14 number, the value of the element of array x.c containing rd. + // ni is the index of n within x.c. + // d is the number of digits of n. + // i is the index of rd within n including leading zeros. + // j is the actual index of rd within n (if < 0, rd is a leading zero). + out: { + + // Get the number of digits of the first element of xc. + for (d = 1, k = xc[0]; k >= 10; k /= 10, d++); + i = sd - d; + + // If the rounding digit is in the first element of xc... + if (i < 0) { + i += LOG_BASE; + j = sd; + n = xc[ni = 0]; + + // Get the rounding digit at index j of n. + rd = n / pows10[d - j - 1] % 10 | 0; + } else { + ni = mathceil((i + 1) / LOG_BASE); + + if (ni >= xc.length) { + + if (r) { + + // Needed by sqrt. + for (; xc.length <= ni; xc.push(0)); + n = rd = 0; + d = 1; + i %= LOG_BASE; + j = i - LOG_BASE + 1; + } else { + break out; + } + } else { + n = k = xc[ni]; + + // Get the number of digits of n. + for (d = 1; k >= 10; k /= 10, d++); + + // Get the index of rd within n. + i %= LOG_BASE; + + // Get the index of rd within n, adjusted for leading zeros. + // The number of leading zeros of n is given by LOG_BASE - d. + j = i - LOG_BASE + d; + + // Get the rounding digit at index j of n. + rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0; + } + } + + r = r || sd < 0 || + + // Are there any non-zero digits after the rounding digit? + // The expression n % pows10[d - j - 1] returns all digits of n to the right + // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714. + xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]); + + r = rm < 4 + ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) + : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && + + // Check whether the digit to the left of the rounding digit is odd. + ((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 || + rm == (x.s < 0 ? 8 : 7)); + + if (sd < 1 || !xc[0]) { + xc.length = 0; + + if (r) { + + // Convert sd to decimal places. + sd -= x.e + 1; + + // 1, 0.1, 0.01, 0.001, 0.0001 etc. + xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE]; + x.e = -sd || 0; + } else { + + // Zero. + xc[0] = x.e = 0; + } + + return x; + } + + // Remove excess digits. + if (i == 0) { + xc.length = ni; + k = 1; + ni--; + } else { + xc.length = ni + 1; + k = pows10[LOG_BASE - i]; + + // E.g. 56700 becomes 56000 if 7 is the rounding digit. + // j > 0 means i > number of leading zeros of n. + xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0; + } + + // Round up? + if (r) { + + for (; ;) { + + // If the digit to be rounded up is in the first element of xc... + if (ni == 0) { + + // i will be the length of xc[0] before k is added. + for (i = 1, j = xc[0]; j >= 10; j /= 10, i++); + j = xc[0] += k; + for (k = 1; j >= 10; j /= 10, k++); + + // if i != k the length has increased. + if (i != k) { + x.e++; + if (xc[0] == BASE) xc[0] = 1; + } + + break; + } else { + xc[ni] += k; + if (xc[ni] != BASE) break; + xc[ni--] = 0; + k = 1; + } + } + } + + // Remove trailing zeros. + for (i = xc.length; xc[--i] === 0; xc.pop()); + } + + // Overflow? Infinity. + if (x.e > MAX_EXP) { + x.c = x.e = null; + + // Underflow? Zero. + } else if (x.e < MIN_EXP) { + x.c = [x.e = 0]; + } + } + + return x; + } + + + // PROTOTYPE/INSTANCE METHODS + + + /* + * Return a new BigNumber whose value is the absolute value of this BigNumber. + */ + P.absoluteValue = P.abs = function () { + var x = new BigNumber(this); + if (x.s < 0) x.s = 1; + return x; + }; + + + /* + * Return + * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b), + * -1 if the value of this BigNumber is less than the value of BigNumber(y, b), + * 0 if they have the same value, + * or null if the value of either is NaN. + */ + P.comparedTo = function (y, b) { + return compare(this, new BigNumber(y, b)); + }; + + + /* + * If dp is undefined or null or true or false, return the number of decimal places of the + * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. + * + * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this + * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or + * ROUNDING_MODE if rm is omitted. + * + * [dp] {number} Decimal places: integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.decimalPlaces = P.dp = function (dp, rm) { + var c, n, v, + x = this; + + if (dp != null) { + intCheck(dp, 0, MAX); + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + + return round(new BigNumber(x), dp + x.e + 1, rm); + } + + if (!(c = x.c)) return null; + n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE; + + // Subtract the number of trailing zeros of the last number. + if (v = c[v]) for (; v % 10 == 0; v /= 10, n--); + if (n < 0) n = 0; + + return n; + }; + + + /* + * n / 0 = I + * n / N = N + * n / I = 0 + * 0 / n = 0 + * 0 / 0 = N + * 0 / N = N + * 0 / I = 0 + * N / n = N + * N / 0 = N + * N / N = N + * N / I = N + * I / n = I + * I / 0 = I + * I / N = N + * I / I = N + * + * Return a new BigNumber whose value is the value of this BigNumber divided by the value of + * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE. + */ + P.dividedBy = P.div = function (y, b) { + return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE); + }; + + + /* + * Return a new BigNumber whose value is the integer part of dividing the value of this + * BigNumber by the value of BigNumber(y, b). + */ + P.dividedToIntegerBy = P.idiv = function (y, b) { + return div(this, new BigNumber(y, b), 0, 1); + }; + + + /* + * Return a BigNumber whose value is the value of this BigNumber exponentiated by n. + * + * If m is present, return the result modulo m. + * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE. + * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE. + * + * The modular power operation works efficiently when x, n, and m are integers, otherwise it + * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0. + * + * n {number|string|BigNumber} The exponent. An integer. + * [m] {number|string|BigNumber} The modulus. + * + * '[BigNumber Error] Exponent not an integer: {n}' + */ + P.exponentiatedBy = P.pow = function (n, m) { + var half, isModExp, k, more, nIsBig, nIsNeg, nIsOdd, y, + x = this; + + n = new BigNumber(n); + + // Allow NaN and ±Infinity, but not other non-integers. + if (n.c && !n.isInteger()) { + throw Error + (bignumberError + 'Exponent not an integer: ' + n); + } + + if (m != null) m = new BigNumber(m); + + // Exponent of MAX_SAFE_INTEGER is 15. + nIsBig = n.e > 14; + + // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0. + if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) { + + // The sign of the result of pow when x is negative depends on the evenness of n. + // If +n overflows to ±Infinity, the evenness of n would be not be known. + y = new BigNumber(Math.pow(+x.valueOf(), nIsBig ? 2 - isOdd(n) : +n)); + return m ? y.mod(m) : y; + } + + nIsNeg = n.s < 0; + + if (m) { + + // x % m returns NaN if abs(m) is zero, or m is NaN. + if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN); + + isModExp = !nIsNeg && x.isInteger() && m.isInteger(); + + if (isModExp) x = x.mod(m); + + // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15. + // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15. + } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 + // [1, 240000000] + ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 + // [80000000000000] [99999750000000] + : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) { + + // If x is negative and n is odd, k = -0, else k = 0. + k = x.s < 0 && isOdd(n) ? -0 : 0; + + // If x >= 1, k = ±Infinity. + if (x.e > -1) k = 1 / k; + + // If n is negative return ±0, else return ±Infinity. + return new BigNumber(nIsNeg ? 1 / k : k); + + } else if (POW_PRECISION) { + + // Truncating each coefficient array to a length of k after each multiplication + // equates to truncating significant digits to POW_PRECISION + [28, 41], + // i.e. there will be a minimum of 28 guard digits retained. + k = mathceil(POW_PRECISION / LOG_BASE + 2); + } + + if (nIsBig) { + half = new BigNumber(0.5); + nIsOdd = isOdd(n); + } else { + nIsOdd = n % 2; + } + + if (nIsNeg) n.s = 1; + + y = new BigNumber(ONE); + + // Performs 54 loop iterations for n of 9007199254740991. + for (; ;) { + + if (nIsOdd) { + y = y.times(x); + if (!y.c) break; + + if (k) { + if (y.c.length > k) y.c.length = k; + } else if (isModExp) { + y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m)); + } + } + + if (nIsBig) { + n = n.times(half); + round(n, n.e + 1, 1); + if (!n.c[0]) break; + nIsBig = n.e > 14; + nIsOdd = isOdd(n); + } else { + n = mathfloor(n / 2); + if (!n) break; + nIsOdd = n % 2; + } + + x = x.times(x); + + if (k) { + if (x.c && x.c.length > k) x.c.length = k; + } else if (isModExp) { + x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m)); + } + } + + if (isModExp) return y; + if (nIsNeg) y = ONE.div(y); + + return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y; + }; + + + /* + * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer + * using rounding mode rm, or ROUNDING_MODE if rm is omitted. + * + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}' + */ + P.integerValue = function (rm) { + var n = new BigNumber(this); + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + return round(n, n.e + 1, rm); + }; + + + /* + * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b), + * otherwise return false. + */ + P.isEqualTo = P.eq = function (y, b) { + return compare(this, new BigNumber(y, b)) === 0; + }; + + + /* + * Return true if the value of this BigNumber is a finite number, otherwise return false. + */ + P.isFinite = function () { + return !!this.c; + }; + + + /* + * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b), + * otherwise return false. + */ + P.isGreaterThan = P.gt = function (y, b) { + return compare(this, new BigNumber(y, b)) > 0; + }; + + + /* + * Return true if the value of this BigNumber is greater than or equal to the value of + * BigNumber(y, b), otherwise return false. + */ + P.isGreaterThanOrEqualTo = P.gte = function (y, b) { + return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0; + + }; + + + /* + * Return true if the value of this BigNumber is an integer, otherwise return false. + */ + P.isInteger = function () { + return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2; + }; + + + /* + * Return true if the value of this BigNumber is less than the value of BigNumber(y, b), + * otherwise return false. + */ + P.isLessThan = P.lt = function (y, b) { + return compare(this, new BigNumber(y, b)) < 0; + }; + + + /* + * Return true if the value of this BigNumber is less than or equal to the value of + * BigNumber(y, b), otherwise return false. + */ + P.isLessThanOrEqualTo = P.lte = function (y, b) { + return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0; + }; + + + /* + * Return true if the value of this BigNumber is NaN, otherwise return false. + */ + P.isNaN = function () { + return !this.s; + }; + + + /* + * Return true if the value of this BigNumber is negative, otherwise return false. + */ + P.isNegative = function () { + return this.s < 0; + }; + + + /* + * Return true if the value of this BigNumber is positive, otherwise return false. + */ + P.isPositive = function () { + return this.s > 0; + }; + + + /* + * Return true if the value of this BigNumber is 0 or -0, otherwise return false. + */ + P.isZero = function () { + return !!this.c && this.c[0] == 0; + }; + + + /* + * n - 0 = n + * n - N = N + * n - I = -I + * 0 - n = -n + * 0 - 0 = 0 + * 0 - N = N + * 0 - I = -I + * N - n = N + * N - 0 = N + * N - N = N + * N - I = N + * I - n = I + * I - 0 = I + * I - N = N + * I - I = N + * + * Return a new BigNumber whose value is the value of this BigNumber minus the value of + * BigNumber(y, b). + */ + P.minus = function (y, b) { + var i, j, t, xLTy, + x = this, + a = x.s; + + y = new BigNumber(y, b); + b = y.s; + + // Either NaN? + if (!a || !b) return new BigNumber(NaN); + + // Signs differ? + if (a != b) { + y.s = -b; + return x.plus(y); + } + + var xe = x.e / LOG_BASE, + ye = y.e / LOG_BASE, + xc = x.c, + yc = y.c; + + if (!xe || !ye) { + + // Either Infinity? + if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN); + + // Either zero? + if (!xc[0] || !yc[0]) { + + // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. + return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x : + + // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity + ROUNDING_MODE == 3 ? -0 : 0); + } + } + + xe = bitFloor(xe); + ye = bitFloor(ye); + xc = xc.slice(); + + // Determine which is the bigger number. + if (a = xe - ye) { + + if (xLTy = a < 0) { + a = -a; + t = xc; + } else { + ye = xe; + t = yc; + } + + t.reverse(); + + // Prepend zeros to equalise exponents. + for (b = a; b--; t.push(0)); + t.reverse(); + } else { + + // Exponents equal. Check digit by digit. + j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b; + + for (a = b = 0; b < j; b++) { + + if (xc[b] != yc[b]) { + xLTy = xc[b] < yc[b]; + break; + } + } + } + + // x < y? Point xc to the array of the bigger number. + if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s; + + b = (j = yc.length) - (i = xc.length); + + // Append zeros to xc if shorter. + // No need to add zeros to yc if shorter as subtract only needs to start at yc.length. + if (b > 0) for (; b--; xc[i++] = 0); + b = BASE - 1; + + // Subtract yc from xc. + for (; j > a;) { + + if (xc[--j] < yc[j]) { + for (i = j; i && !xc[--i]; xc[i] = b); + --xc[i]; + xc[j] += BASE; + } + + xc[j] -= yc[j]; + } + + // Remove leading zeros and adjust exponent accordingly. + for (; xc[0] == 0; xc.splice(0, 1), --ye); + + // Zero? + if (!xc[0]) { + + // Following IEEE 754 (2008) 6.3, + // n - n = +0 but n - n = -0 when rounding towards -Infinity. + y.s = ROUNDING_MODE == 3 ? -1 : 1; + y.c = [y.e = 0]; + return y; + } + + // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity + // for finite x and y. + return normalise(y, xc, ye); + }; + + + /* + * n % 0 = N + * n % N = N + * n % I = n + * 0 % n = 0 + * -0 % n = -0 + * 0 % 0 = N + * 0 % N = N + * 0 % I = 0 + * N % n = N + * N % 0 = N + * N % N = N + * N % I = N + * I % n = N + * I % 0 = N + * I % N = N + * I % I = N + * + * Return a new BigNumber whose value is the value of this BigNumber modulo the value of + * BigNumber(y, b). The result depends on the value of MODULO_MODE. + */ + P.modulo = P.mod = function (y, b) { + var q, s, + x = this; + + y = new BigNumber(y, b); + + // Return NaN if x is Infinity or NaN, or y is NaN or zero. + if (!x.c || !y.s || y.c && !y.c[0]) { + return new BigNumber(NaN); + + // Return x if y is Infinity or x is zero. + } else if (!y.c || x.c && !x.c[0]) { + return new BigNumber(x); + } + + if (MODULO_MODE == 9) { + + // Euclidian division: q = sign(y) * floor(x / abs(y)) + // r = x - qy where 0 <= r < abs(y) + s = y.s; + y.s = 1; + q = div(x, y, 0, 3); + y.s = s; + q.s *= s; + } else { + q = div(x, y, 0, MODULO_MODE); + } + + y = x.minus(q.times(y)); + + // To match JavaScript %, ensure sign of zero is sign of dividend. + if (!y.c[0] && MODULO_MODE == 1) y.s = x.s; + + return y; + }; + + + /* + * n * 0 = 0 + * n * N = N + * n * I = I + * 0 * n = 0 + * 0 * 0 = 0 + * 0 * N = N + * 0 * I = N + * N * n = N + * N * 0 = N + * N * N = N + * N * I = N + * I * n = I + * I * 0 = N + * I * N = N + * I * I = I + * + * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value + * of BigNumber(y, b). + */ + P.multipliedBy = P.times = function (y, b) { + var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, + base, sqrtBase, + x = this, + xc = x.c, + yc = (y = new BigNumber(y, b)).c; + + // Either NaN, ±Infinity or ±0? + if (!xc || !yc || !xc[0] || !yc[0]) { + + // Return NaN if either is NaN, or one is 0 and the other is Infinity. + if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) { + y.c = y.e = y.s = null; + } else { + y.s *= x.s; + + // Return ±Infinity if either is ±Infinity. + if (!xc || !yc) { + y.c = y.e = null; + + // Return ±0 if either is ±0. + } else { + y.c = [0]; + y.e = 0; + } + } + + return y; + } + + e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE); + y.s *= x.s; + xcL = xc.length; + ycL = yc.length; + + // Ensure xc points to longer array and xcL to its length. + if (xcL < ycL) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i; + + // Initialise the result array with zeros. + for (i = xcL + ycL, zc = []; i--; zc.push(0)); + + base = BASE; + sqrtBase = SQRT_BASE; + + for (i = ycL; --i >= 0;) { + c = 0; + ylo = yc[i] % sqrtBase; + yhi = yc[i] / sqrtBase | 0; + + for (k = xcL, j = i + k; j > i;) { + xlo = xc[--k] % sqrtBase; + xhi = xc[k] / sqrtBase | 0; + m = yhi * xlo + xhi * ylo; + xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c; + c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi; + zc[j--] = xlo % base; + } + + zc[j] = c; + } + + if (c) { + ++e; + } else { + zc.splice(0, 1); + } + + return normalise(y, zc, e); + }; + + + /* + * Return a new BigNumber whose value is the value of this BigNumber negated, + * i.e. multiplied by -1. + */ + P.negated = function () { + var x = new BigNumber(this); + x.s = -x.s || null; + return x; + }; + + + /* + * n + 0 = n + * n + N = N + * n + I = I + * 0 + n = n + * 0 + 0 = 0 + * 0 + N = N + * 0 + I = I + * N + n = N + * N + 0 = N + * N + N = N + * N + I = N + * I + n = I + * I + 0 = I + * I + N = N + * I + I = I + * + * Return a new BigNumber whose value is the value of this BigNumber plus the value of + * BigNumber(y, b). + */ + P.plus = function (y, b) { + var t, + x = this, + a = x.s; + + y = new BigNumber(y, b); + b = y.s; + + // Either NaN? + if (!a || !b) return new BigNumber(NaN); + + // Signs differ? + if (a != b) { + y.s = -b; + return x.minus(y); + } + + var xe = x.e / LOG_BASE, + ye = y.e / LOG_BASE, + xc = x.c, + yc = y.c; + + if (!xe || !ye) { + + // Return ±Infinity if either ±Infinity. + if (!xc || !yc) return new BigNumber(a / 0); + + // Either zero? + // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. + if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0); + } + + xe = bitFloor(xe); + ye = bitFloor(ye); + xc = xc.slice(); + + // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts. + if (a = xe - ye) { + if (a > 0) { + ye = xe; + t = yc; + } else { + a = -a; + t = xc; + } + + t.reverse(); + for (; a--; t.push(0)); + t.reverse(); + } + + a = xc.length; + b = yc.length; + + // Point xc to the longer array, and b to the shorter length. + if (a - b < 0) t = yc, yc = xc, xc = t, b = a; + + // Only start adding at yc.length - 1 as the further digits of xc can be ignored. + for (a = 0; b;) { + a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0; + xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE; + } + + if (a) { + xc = [a].concat(xc); + ++ye; + } + + // No need to check for zero, as +x + +y != 0 && -x + -y != 0 + // ye = MAX_EXP + 1 possible + return normalise(y, xc, ye); + }; + + + /* + * If sd is undefined or null or true or false, return the number of significant digits of + * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. + * If sd is true include integer-part trailing zeros in the count. + * + * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this + * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or + * ROUNDING_MODE if rm is omitted. + * + * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive. + * boolean: whether to count integer-part trailing zeros: true or false. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' + */ + P.precision = P.sd = function (sd, rm) { + var c, n, v, + x = this; + + if (sd != null && sd !== !!sd) { + intCheck(sd, 1, MAX); + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + + return round(new BigNumber(x), sd, rm); + } + + if (!(c = x.c)) return null; + v = c.length - 1; + n = v * LOG_BASE + 1; + + if (v = c[v]) { + + // Subtract the number of trailing zeros of the last element. + for (; v % 10 == 0; v /= 10, n--); + + // Add the number of digits of the first element. + for (v = c[0]; v >= 10; v /= 10, n++); + } + + if (sd && x.e + 1 > n) n = x.e + 1; + + return n; + }; + + + /* + * Return a new BigNumber whose value is the value of this BigNumber shifted by k places + * (powers of 10). Shift to the right if n > 0, and to the left if n < 0. + * + * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}' + */ + P.shiftedBy = function (k) { + intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER); + return this.times('1e' + k); + }; + + + /* + * sqrt(-n) = N + * sqrt(N) = N + * sqrt(-I) = N + * sqrt(I) = I + * sqrt(0) = 0 + * sqrt(-0) = -0 + * + * Return a new BigNumber whose value is the square root of the value of this BigNumber, + * rounded according to DECIMAL_PLACES and ROUNDING_MODE. + */ + P.squareRoot = P.sqrt = function () { + var m, n, r, rep, t, + x = this, + c = x.c, + s = x.s, + e = x.e, + dp = DECIMAL_PLACES + 4, + half = new BigNumber('0.5'); + + // Negative/NaN/Infinity/zero? + if (s !== 1 || !c || !c[0]) { + return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0); + } + + // Initial estimate. + s = Math.sqrt(+x); + + // Math.sqrt underflow/overflow? + // Pass x to Math.sqrt as integer, then adjust the exponent of the result. + if (s == 0 || s == 1 / 0) { + n = coeffToString(c); + if ((n.length + e) % 2 == 0) n += '0'; + s = Math.sqrt(n); + e = bitFloor((e + 1) / 2) - (e < 0 || e % 2); + + if (s == 1 / 0) { + n = '1e' + e; + } else { + n = s.toExponential(); + n = n.slice(0, n.indexOf('e') + 1) + e; + } + + r = new BigNumber(n); + } else { + r = new BigNumber(s + ''); + } + + // Check for zero. + // r could be zero if MIN_EXP is changed after the this value was created. + // This would cause a division by zero (x/t) and hence Infinity below, which would cause + // coeffToString to throw. + if (r.c[0]) { + e = r.e; + s = e + dp; + if (s < 3) s = 0; + + // Newton-Raphson iteration. + for (; ;) { + t = r; + r = half.times(t.plus(div(x, t, dp, 1))); + + if (coeffToString(t.c ).slice(0, s) === (n = + coeffToString(r.c)).slice(0, s)) { + + // The exponent of r may here be one less than the final result exponent, + // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits + // are indexed correctly. + if (r.e < e) --s; + n = n.slice(s - 3, s + 1); + + // The 4th rounding digit may be in error by -1 so if the 4 rounding digits + // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the + // iteration. + if (n == '9999' || !rep && n == '4999') { + + // On the first iteration only, check to see if rounding up gives the + // exact result as the nines may infinitely repeat. + if (!rep) { + round(t, t.e + DECIMAL_PLACES + 2, 0); + + if (t.times(t).eq(x)) { + r = t; + break; + } + } + + dp += 4; + s += 4; + rep = 1; + } else { + + // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact + // result. If not, then there are further digits and m will be truthy. + if (!+n || !+n.slice(1) && n.charAt(0) == '5') { + + // Truncate to the first rounding digit. + round(r, r.e + DECIMAL_PLACES + 2, 1); + m = !r.times(r).eq(x); + } + + break; + } + } + } + } + + return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m); + }; + + + /* + * Return a string representing the value of this BigNumber in exponential notation and + * rounded using ROUNDING_MODE to dp fixed decimal places. + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toExponential = function (dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX); + dp++; + } + return format(this, dp, rm, 1); + }; + + + /* + * Return a string representing the value of this BigNumber in fixed-point notation rounding + * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted. + * + * Note: as with JavaScript's number type, (-0).toFixed(0) is '0', + * but e.g. (-0.00001).toFixed(0) is '-0'. + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toFixed = function (dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX); + dp = dp + this.e + 1; + } + return format(this, dp, rm); + }; + + + /* + * Return a string representing the value of this BigNumber in fixed-point notation rounded + * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties + * of the FORMAT object (see BigNumber.set). + * + * FORMAT = { + * decimalSeparator : '.', + * groupSeparator : ',', + * groupSize : 3, + * secondaryGroupSize : 0, + * fractionGroupSeparator : '\xA0', // non-breaking space + * fractionGroupSize : 0 + * }; + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toFormat = function (dp, rm) { + var str = this.toFixed(dp, rm); + + if (this.c) { + var i, + arr = str.split('.'), + g1 = +FORMAT.groupSize, + g2 = +FORMAT.secondaryGroupSize, + groupSeparator = FORMAT.groupSeparator, + intPart = arr[0], + fractionPart = arr[1], + isNeg = this.s < 0, + intDigits = isNeg ? intPart.slice(1) : intPart, + len = intDigits.length; + + if (g2) i = g1, g1 = g2, g2 = i, len -= i; + + if (g1 > 0 && len > 0) { + i = len % g1 || g1; + intPart = intDigits.substr(0, i); + + for (; i < len; i += g1) { + intPart += groupSeparator + intDigits.substr(i, g1); + } + + if (g2 > 0) intPart += groupSeparator + intDigits.slice(i); + if (isNeg) intPart = '-' + intPart; + } + + str = fractionPart + ? intPart + FORMAT.decimalSeparator + ((g2 = +FORMAT.fractionGroupSize) + ? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'), + '$&' + FORMAT.fractionGroupSeparator) + : fractionPart) + : intPart; + } + + return str; + }; + + + /* + * Return a string array representing the value of this BigNumber as a simple fraction with + * an integer numerator and an integer denominator. The denominator will be a positive + * non-zero value less than or equal to the specified maximum denominator. If a maximum + * denominator is not specified, the denominator will be the lowest value necessary to + * represent the number exactly. + * + * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator. + * + * '[BigNumber Error] Argument {not an integer|out of range} : {md}' + */ + P.toFraction = function (md) { + var arr, d, d0, d1, d2, e, exp, n, n0, n1, q, s, + x = this, + xc = x.c; + + if (md != null) { + n = new BigNumber(md); + + // Throw if md is less than one or is not an integer, unless it is Infinity. + if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) { + throw Error + (bignumberError + 'Argument ' + + (n.isInteger() ? 'out of range: ' : 'not an integer: ') + md); + } + } + + if (!xc) return x.toString(); + + d = new BigNumber(ONE); + n1 = d0 = new BigNumber(ONE); + d1 = n0 = new BigNumber(ONE); + s = coeffToString(xc); + + // Determine initial denominator. + // d is a power of 10 and the minimum max denominator that specifies the value exactly. + e = d.e = s.length - x.e - 1; + d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp]; + md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n; + + exp = MAX_EXP; + MAX_EXP = 1 / 0; + n = new BigNumber(s); + + // n0 = d1 = 0 + n0.c[0] = 0; + + for (; ;) { + q = div(n, d, 0, 1); + d2 = d0.plus(q.times(d1)); + if (d2.comparedTo(md) == 1) break; + d0 = d1; + d1 = d2; + n1 = n0.plus(q.times(d2 = n1)); + n0 = d2; + d = n.minus(q.times(d2 = d)); + n = d2; + } + + d2 = div(md.minus(d0), d1, 0, 1); + n0 = n0.plus(d2.times(n1)); + d0 = d0.plus(d2.times(d1)); + n0.s = n1.s = x.s; + e *= 2; + + // Determine which fraction is closer to x, n0/d0 or n1/d1 + arr = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo( + div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 + ? [n1.toString(), d1.toString()] + : [n0.toString(), d0.toString()]; + + MAX_EXP = exp; + return arr; + }; + + + /* + * Return the value of this BigNumber converted to a number primitive. + */ + P.toNumber = function () { + return +this; + }; + + + /* + * Return a string representing the value of this BigNumber rounded to sd significant digits + * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits + * necessary to represent the integer part of the value in fixed-point notation, then use + * exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' + */ + P.toPrecision = function (sd, rm) { + if (sd != null) intCheck(sd, 1, MAX); + return format(this, sd, rm, 2); + }; + + + /* + * Return a string representing the value of this BigNumber in base b, or base 10 if b is + * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and + * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent + * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than + * TO_EXP_NEG, return exponential notation. + * + * [b] {number} Integer, 2 to ALPHABET.length inclusive. + * + * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' + */ + P.toString = function (b) { + var str, + n = this, + s = n.s, + e = n.e; + + // Infinity or NaN? + if (e === null) { + + if (s) { + str = 'Infinity'; + if (s < 0) str = '-' + str; + } else { + str = 'NaN'; + } + } else { + str = coeffToString(n.c); + + if (b == null) { + str = e <= TO_EXP_NEG || e >= TO_EXP_POS + ? toExponential(str, e) + : toFixedPoint(str, e, '0'); + } else { + intCheck(b, 2, ALPHABET.length, 'Base'); + str = convertBase(toFixedPoint(str, e, '0'), 10, b, s, true); + } + + if (s < 0 && n.c[0]) str = '-' + str; + } + + return str; + }; + + + /* + * Return as toString, but do not accept a base argument, and include the minus sign for + * negative zero. + */ + P.valueOf = P.toJSON = function () { + var str, + n = this, + e = n.e; + + if (e === null) return n.toString(); + + str = coeffToString(n.c); + + str = e <= TO_EXP_NEG || e >= TO_EXP_POS + ? toExponential(str, e) + : toFixedPoint(str, e, '0'); + + return n.s < 0 ? '-' + str : str; + }; + + + P._isBigNumber = true; + + if (configObject != null) BigNumber.set(configObject); + + return BigNumber; + } + + + // PRIVATE HELPER FUNCTIONS + + + function bitFloor(n) { + var i = n | 0; + return n > 0 || n === i ? i : i - 1; + } + + + // Return a coefficient array as a string of base 10 digits. + function coeffToString(a) { + var s, z, + i = 1, + j = a.length, + r = a[0] + ''; + + for (; i < j;) { + s = a[i++] + ''; + z = LOG_BASE - s.length; + for (; z--; s = '0' + s); + r += s; + } + + // Determine trailing zeros. + for (j = r.length; r.charCodeAt(--j) === 48;); + return r.slice(0, j + 1 || 1); + } + + + // Compare the value of BigNumbers x and y. + function compare(x, y) { + var a, b, + xc = x.c, + yc = y.c, + i = x.s, + j = y.s, + k = x.e, + l = y.e; + + // Either NaN? + if (!i || !j) return null; + + a = xc && !xc[0]; + b = yc && !yc[0]; + + // Either zero? + if (a || b) return a ? b ? 0 : -j : i; + + // Signs differ? + if (i != j) return i; + + a = i < 0; + b = k == l; + + // Either Infinity? + if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1; + + // Compare exponents. + if (!b) return k > l ^ a ? 1 : -1; + + j = (k = xc.length) < (l = yc.length) ? k : l; + + // Compare digit by digit. + for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1; + + // Compare lengths. + return k == l ? 0 : k > l ^ a ? 1 : -1; + } + + + /* + * Check that n is a primitive number, an integer, and in range, otherwise throw. + */ + function intCheck(n, min, max, name) { + if (n < min || n > max || n !== (n < 0 ? mathceil(n) : mathfloor(n))) { + throw Error + (bignumberError + (name || 'Argument') + (typeof n == 'number' + ? n < min || n > max ? ' out of range: ' : ' not an integer: ' + : ' not a primitive number: ') + n); + } + } + + + function isArray(obj) { + return Object.prototype.toString.call(obj) == '[object Array]'; + } + + + // Assumes finite n. + function isOdd(n) { + var k = n.c.length - 1; + return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0; + } + + + function toExponential(str, e) { + return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) + + (e < 0 ? 'e' : 'e+') + e; + } + + + function toFixedPoint(str, e, z) { + var len, zs; + + // Negative exponent? + if (e < 0) { + + // Prepend zeros. + for (zs = z + '.'; ++e; zs += z); + str = zs + str; + + // Positive exponent + } else { + len = str.length; + + // Append zeros. + if (++e > len) { + for (zs = z, e -= len; --e; zs += z); + str += zs; + } else if (e < len) { + str = str.slice(0, e) + '.' + str.slice(e); + } + } + + return str; + } + + + // EXPORT + + + BigNumber = clone(); + BigNumber['default'] = BigNumber.BigNumber = BigNumber; + + // AMD. + if (typeof define == 'function' && define.amd) { + define(function () { return BigNumber; }); + + // Node.js and other environments that support module.exports. + } else if (typeof module != 'undefined' && module.exports) { + module.exports = BigNumber; + + // Browser. + } else { + if (!globalObject) { + globalObject = typeof self != 'undefined' && self ? self : window; + } + + globalObject.BigNumber = BigNumber; + } +})(this); + +},{}],4:[function(require,module,exports){ + +},{}],5:[function(require,module,exports){ +var basex = require('base-x') +var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' + +module.exports = basex(ALPHABET) + +},{"base-x":1}],6:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + +'use strict' + +var base64 = require('base64-js') +var ieee754 = require('ieee754') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} + +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } + return arr.foo() === 42 + } catch (e) { + return false + } +} + +Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.buffer + } +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.byteOffset + } +}) + +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError( + 'The "string" argument must be of type string. Received type number' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} + +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species != null && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) +} + +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + if (ArrayBuffer.isView(value)) { + return fromArrayLike(value) + } + + if (value == null) { + throw TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) + } + + if (isInstance(value, ArrayBuffer) || + (value && isInstance(value.buffer, ArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'number') { + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) + } + + var valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) + } + + var b = fromObject(value) + if (b) return b + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && + typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from( + value[Symbol.toPrimitive]('string'), encodingOrOffset, length + ) + } + + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } +} + +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf +} + +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} + +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf +} + +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } +} + +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true && + b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false +} + +Buffer.compare = function compare (a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (isInstance(buf, Uint8Array)) { + buf = Buffer.from(buf) + } + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) + } + + var len = string.length + var mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.toLocaleString = Buffer.prototype.toString + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength) + } + if (!Buffer.isBuffer(target)) { + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : Buffer.from(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass +// the `instanceof` check but they should be treated as of that type. +// See: https://github.com/feross/buffer/issues/166 +function isInstance (obj, type) { + return obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && + obj.constructor.name === type.name) +} +function numberIsNaN (obj) { + // For IE11 support + return obj !== obj // eslint-disable-line no-self-compare +} + +},{"base64-js":2,"ieee754":45}],7:[function(require,module,exports){ +'use strict' + +exports.Commented = require('./commented') +exports.Diagnose = require('./diagnose') +exports.Decoder = require('./decoder') +exports.Encoder = require('./encoder') +exports.Simple = require('./simple') +exports.Tagged = require('./tagged') +exports.Map = require('./map') + +exports.comment = exports.Commented.comment +exports.decodeAll = exports.Decoder.decodeAll +exports.decodeFirst = exports.Decoder.decodeFirst +exports.decodeAllSync = exports.Decoder.decodeAllSync +exports.decodeFirstSync = exports.Decoder.decodeFirstSync +exports.diagnose = exports.Diagnose.diagnose +exports.encode = exports.Encoder.encode +exports.encodeCanonical = exports.Encoder.encodeCanonical +exports.encodeOne = exports.Encoder.encodeOne +exports.decode = exports.Decoder.decodeFirstSync + +exports.leveldb = { + decode: exports.Decoder.decodeAllSync, + encode: exports.Encoder.encode, + buffer: true, + name: 'cbor' +} + +},{"./commented":8,"./decoder":10,"./diagnose":11,"./encoder":12,"./map":13,"./simple":14,"./tagged":15}],8:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const stream = require('stream') +const util = require('util') +const utils = require('./utils') +const Simple = require('./simple') +const Decoder = require('./decoder') +const constants = require('./constants') +const bignumber = require('bignumber.js') +const NoFilter = require('nofilter') + +const MT = constants.MT +const NUMBYTES = constants.NUMBYTES +const SYMS = constants.SYMS + +function plural(c) { + if (c > 1) { + return 's' + } else { + return '' + } +} + +/** + * Generate the expanded format of RFC 7049, section 2.2.1 + * + * @extends {stream.Transform} + */ +class Commented extends stream.Transform { + /** + * Create a CBOR commenter. + * + * @param {any} [options={}] - Stream options + * @param {bool} [options.max_depth=10] - how many times to indent the dashes + */ + constructor(options) { + options = options || {} + options.readableObjectMode = false + options.writableObjectMode = false + const max_depth = (options.max_depth != null) ? options.max_depth : 10 + delete options.max_depth + super(options) + + this.depth = 1 + this.max_depth = max_depth + this.all = new NoFilter + this.parser = new Decoder(options) + this.parser.on('value', this._on_value.bind(this)) + this.parser.on('start', this._on_start.bind(this)) + this.parser.on('start-string', this._on_start_string.bind(this)) + this.parser.on('stop', this._on_stop.bind(this)) + this.parser.on('more-bytes', this._on_more.bind(this)) + this.parser.on('error', this._on_error.bind(this)) + this.parser.on('data', this._on_data.bind(this)) + this.parser.bs.on('read', this._on_read.bind(this)) + } + + /** + * @private + */ + _transform(fresh, encoding, cb) { + this.parser.write(fresh, encoding, cb) + } + + /** + * @private + */ + _flush(cb) { + // TODO: find the test that covers this, and look at the return value + return this.parser._flush(cb) + } + + /** + * @callback commentCallback + * @param {Error} error - if one was generated + * @param {string} commented - the comment string + */ + + /** + * Comment on an input Buffer or string, creating a string passed to the + * callback. If callback not specified, a promise is returned. + * + * @static + * @param {(string|Buffer|NoFilter)} input + * @param {(string|Object|function)} options + * @param {number} [options.max_depth=10] how many times to indent the dashes + * @param {commentCallback=} cb + * @returns {Promise} if cb not specified + */ + static comment(input, options, cb) { + if (input == null) { + throw new Error('input required') + } + let encoding = (typeof input === 'string') ? 'hex' : void 0 + let max_depth = 10 + switch (typeof options) { + case 'function': + cb = options + break + case 'string': + encoding = options + break + case 'number': + max_depth = options + break + case 'object': + const ref1 = options.encoding + const ref2 = options.max_depth + encoding = (ref1 != null) ? ref1 : encoding + max_depth = (ref2 != null) ? ref2 : max_depth + break + case 'undefined': + break + default: + throw new Error('Unknown option type') + } + const bs = new NoFilter + const d = new Commented({ + max_depth: max_depth + }) + let p = null + if (typeof cb === 'function') { + d.on('end', () => { + cb(null, bs.toString('utf8')) + }) + d.on('error', cb) + } else { + p = new Promise((resolve, reject) => { + d.on('end', () => { + resolve(bs.toString('utf8')) + }) + return d.on('error', reject) + }) + } + d.pipe(bs) + d.end(input, encoding) + return p + } + + /** + * @private + */ + _on_error(er) { + return this.push('ERROR: ') && + this.push(er.toString()) && + this.push('\n') + } + + /** + * @private + */ + _on_read(buf) { + this.all.write(buf) + const hex = buf.toString('hex') + this.push(new Array(this.depth + 1).join(' ')) + this.push(hex) + let ind = (this.max_depth - this.depth) * 2 + ind -= hex.length + if (ind < 1) { + ind = 1 + } + this.push(new Array(ind + 1).join(' ')) + return this.push('-- ') + } + + /** + * @private + */ + _on_more(mt, len, parent_mt, pos) { + this.depth++ + let desc = '' + switch (mt) { + case MT.POS_INT: + desc = 'Positive number,' + break + case MT.NEG_INT: + desc = 'Negative number,' + break + case MT.ARRAY: + desc = 'Array, length' + break + case MT.MAP: + desc = 'Map, count' + break + case MT.BYTE_STRING: + desc = 'Bytes, length' + break + case MT.UTF8_STRING: + desc = 'String, length' + break + case MT.SIMPLE_FLOAT: + if (len === 1) { + desc = 'Simple value,' + } else { + desc = 'Float,' + } + break + } + return this.push(desc + ' next ' + len + ' byte' + (plural(len)) + '\n') + } + + /** + * @private + */ + _on_start_string(mt, tag, parent_mt, pos) { + this.depth++ + let desc = '' + switch (mt) { + case MT.BYTE_STRING: + desc = 'Bytes, length: ' + tag + break + case MT.UTF8_STRING: + desc = 'String, length: ' + (tag.toString()) + break + } + return this.push(desc + '\n') + } + + /** + * @private + */ + _on_start(mt, tag, parent_mt, pos) { + this.depth++ + if (tag !== SYMS.BREAK) { + this.push((() => { + switch (parent_mt) { + case MT.ARRAY: + return '[' + pos + '], ' + case MT.MAP: + if (pos % 2) { + return '{Val:' + (Math.floor(pos / 2)) + '}, ' + } else { + return '{Key:' + (Math.floor(pos / 2)) + '}, ' + } + } + })()) + } + this.push((() => { + switch (mt) { + case MT.TAG: + return 'Tag #' + tag + case MT.ARRAY: + if (tag === SYMS.STREAM) { + return 'Array (streaming)' + } else { + return 'Array, ' + tag + ' item' + (plural(tag)) + } + case MT.MAP: + if (tag === SYMS.STREAM) { + return 'Map (streaming)' + } else { + return 'Map, ' + tag + ' pair' + (plural(tag)) + } + case MT.BYTE_STRING: + return 'Bytes (streaming)' + case MT.UTF8_STRING: + return 'String (streaming)' + } + })()) + return this.push('\n') + } + + /** + * @private + */ + _on_stop(mt) { + return this.depth-- + } + + /** + * @private + */ + _on_value(val, parent_mt, pos, ai) { + if (val !== SYMS.BREAK) { + this.push((() => { + switch (parent_mt) { + case MT.ARRAY: + return '[' + pos + '], ' + case MT.MAP: + if (pos % 2) { + return '{Val:' + (Math.floor(pos / 2)) + '}, ' + } else { + return '{Key:' + (Math.floor(pos / 2)) + '}, ' + } + } + })()) + } + + if (val === SYMS.BREAK) { + this.push('BREAK\n') + } else if (val === SYMS.NULL) { + this.push('null\n') + } else if (val === SYMS.UNDEFINED) { + this.push('undefined\n') + } else if (typeof val === 'string') { + this.depth-- + if (val.length > 0 ) { + this.push(JSON.stringify(val)) + this.push('\n') + } + } else if (Buffer.isBuffer(val)) { + this.depth-- + if (val.length > 0) { + this.push(val.toString('hex')) + this.push('\n') + } + } else if (val instanceof bignumber) { + this.push(val.toString()) + this.push('\n') + } else { + this.push(util.inspect(val)) + this.push('\n') + } + + switch (ai) { + case NUMBYTES.ONE: + case NUMBYTES.TWO: + case NUMBYTES.FOUR: + case NUMBYTES.EIGHT: + this.depth-- + } + } + + /** + * @private + */ + _on_data() { + this.push('0x') + this.push(this.all.read().toString('hex')) + return this.push('\n') + } +} + +module.exports = Commented + +}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":47,"./constants":9,"./decoder":10,"./simple":14,"./utils":16,"bignumber.js":3,"nofilter":50,"stream":72,"util":78}],9:[function(require,module,exports){ +'use strict' + +exports.MT = { + POS_INT: 0, + NEG_INT: 1, + BYTE_STRING: 2, + UTF8_STRING: 3, + ARRAY: 4, + MAP: 5, + TAG: 6, + SIMPLE_FLOAT: 7 +} + +exports.TAG = { + DATE_STRING: 0, + DATE_EPOCH: 1, + POS_BIGINT: 2, + NEG_BIGINT: 3, + DECIMAL_FRAC: 4, + BIGFLOAT: 5, + BASE64URL_EXPECTED: 21, + BASE64_EXPECTED: 22, + BASE16_EXPECTED: 23, + CBOR: 24, + URI: 32, + BASE64URL: 33, + BASE64: 34, + REGEXP: 35, + MIME: 36 +} + +exports.NUMBYTES = { + ZERO: 0, + ONE: 24, + TWO: 25, + FOUR: 26, + EIGHT: 27, + INDEFINITE: 31 +} + +exports.SIMPLE = { + FALSE: 20, + TRUE: 21, + NULL: 22, + UNDEFINED: 23 +} + +exports.SYMS = { + NULL: Symbol('null'), + UNDEFINED: Symbol('undef'), + PARENT: Symbol('parent'), + BREAK: Symbol('break'), + STREAM: Symbol('stream') +} + +exports.SHIFT32 = Math.pow(2, 32) + +},{}],10:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const BinaryParseStream = require('../vendor/binary-parse-stream') +const Tagged = require('./tagged') +const Simple = require('./simple') +const utils = require('./utils') +const bignumber = require('bignumber.js') +const NoFilter = require('nofilter') +const constants = require('./constants') +// Do not fix this if you want to support node v4 +const MT = constants.MT +const NUMBYTES = constants.NUMBYTES +const SIMPLE = constants.SIMPLE +const SYMS = constants.SYMS + +const NEG_ONE = new bignumber(-1) +const NEG_MAX = NEG_ONE.minus( + new bignumber(Number.MAX_SAFE_INTEGER.toString(16), 16)) +const COUNT = Symbol('count') +const PENDING_KEY = Symbol('pending_key') +const MAJOR = Symbol('major type') +const ERROR = Symbol('error') +const NOT_FOUND = Symbol('not found') + +function parentArray(parent, typ, count) { + const a = [] + a[COUNT] = count + a[SYMS.PARENT] = parent + a[MAJOR] = typ + return a +} + +function parentBufferStream(parent, typ) { + const b = new NoFilter + b[SYMS.PARENT] = parent + b[MAJOR] = typ + return b +} + +/** + * Decode a stream of CBOR bytes by transforming them into equivalent + * JavaScript data. Because of the limitations of Node object streams, + * special symbols are emitted instead of NULL or UNDEFINED. Fix those + * up by calling {@link Decoder.nullcheck}. + * + * @extends {BinaryParseStream} + */ +class Decoder extends BinaryParseStream { + + /** + * Create a parsing stream. + * + * @param {object} [options={}] + * @param {number} [options.max_depth=-1] - the maximum depth to parse. + * Use -1 for "until you run out of memory". Set this to a finite + * positive number for un-trusted inputs. Most standard inputs won't nest + * more than 100 or so levels; I've tested into the millions before + * running out of memory. + * @param {object=} options.tags - mapping from tag number to function(v), + * where v is the decoded value that comes after the tag, and where the + * function returns the correctly-created value for that tag. + */ + constructor(options) { + options = options || {} + const tags = options.tags + delete options.tags + const max_depth = (options.max_depth != null) ? options.max_depth : -1 + delete options.max_depth + super(options) + + this.running = true + this.max_depth = max_depth + this.tags = tags + } + + /** + * Check the given value for a symbol encoding a NULL or UNDEFINED value in + * the CBOR stream. + * + * @static + * @param {any} val - the value to check + * @returns {any} the corrected value + * + * @example + * myDecoder.on('data', function(val) { + * val = Decoder.nullcheck(val); + * ... + * }); + */ + static nullcheck(val) { + switch (val) { + case SYMS.NULL: + return null + case SYMS.UNDEFINED: + return undefined + case NOT_FOUND: + throw new Error('Value not found') + default: + return val + } + } + + /** + * Decode the first CBOR item in the input, synchronously. This will throw an + * exception if the input is not valid CBOR. + * + * @static + * @param {(string|Buffer)} input + * @param {object} [options={encoding: 'hex'}] + * @param {string} [options.encoding: 'hex'] - The encoding of the input. + * Ignored if input is a Buffer. + * @returns {any} - the decoded value + */ + static decodeFirstSync(input, options) { + options = options || { encoding: 'hex' } + let opts = {} + let encod + switch (typeof options) { + case 'string': + encod = options + break + case 'object': + opts = utils.extend({}, options) + encod = opts.encoding + delete opts.encoding + break + } + const c = new Decoder(opts) + const s = new NoFilter( + input, + encod != null ? encod : utils.guessEncoding(input)) + const parser = c._parse() + let state = parser.next() + while (!state.done) { + const b = s.read(state.value) + if ((b == null) || (b.length !== state.value)) { + throw new Error('Insufficient data') + } + state = parser.next(b) + } + return Decoder.nullcheck(state.value) + } + + /** + * Decode all of the CBOR items in the input into an array. This will throw + * an exception if the input is not valid CBOR; a zero-length input will + * return an empty array. + * + * @static + * @param {(string|Buffer)} input + * @param {(string|Object)} [options={encoding: 'hex'}] + * @param {string} [options.encoding: 'hex'] - The encoding of the input. + * Ignored if input is a Buffer. + * @returns {Array} - Array of all found items + */ + static decodeAllSync(input, options) { + options = options || { encoding: 'hex' } + let opts = {} + let encod + switch (typeof options) { + case 'string': + encod = options + break + case 'object': + opts = utils.extend({}, options) + encod = opts.encoding + delete opts.encoding + } + const c = new Decoder(opts) + const s = new NoFilter( + input, + encod != null ? encod : utils.guessEncoding(input)) + const res = [] + while (s.length > 0) { + const parser = c._parse() + let state = parser.next() + while (!state.done) { + const b = s.read(state.value) + if ((b == null) || (b.length !== state.value)) { + throw new Error('Insufficient data') + } + state = parser.next(b) + } + res.push(Decoder.nullcheck(state.value)) + } + return res + } + + /** + * @callback decodeCallback + * @param {Error} error - if one was generated + * @param {any} value - the decoded value + */ + + /** + * Decode the first CBOR item in the input. This will error if there are more + * bytes left over at the end, and optionally if there were no valid CBOR + * bytes in the input. Emits the {Decoder.NOT_FOUND} Symbol in the callback + * if no data was found and the `required` option is false. + * + * @static + * @param {(string|Buffer)} input - the input to parse + * @param {(function|string|Object)} options + * @param {string} [options.encoding: 'hex'] - The encoding of the input. + * Ignored if input is a Buffer. + * @param {decodeCallback} cb + * @returns {Promise} if no cb specified + */ + static decodeFirst(input, options, cb) { + let opts = {} + let required = false + let encod = 'hex' + switch (typeof options) { + case 'function': + cb = options + encod = utils.guessEncoding(input) + break + case 'string': + encod = options + break + case 'object': + opts = utils.extend({}, options) + encod = (opts.encoding != null) ? + opts.encoding : utils.guessEncoding(input) + delete opts.encoding + required = (opts.required != null) ? opts.required : false + delete opts.required + } + const c = new Decoder(opts) + let p + let v = NOT_FOUND + c.on('data', (val) => { + v = Decoder.nullcheck(val) + c.close() + }) + if (typeof cb === 'function') { + c.once('error', (er) => { + const u = v + v = ERROR + c.close() + return cb(er, u) + }) + c.once('end', () => { + switch (v) { + case NOT_FOUND: + if (required) { + return cb(new Error('No CBOR found')) + } else { + return cb(null, v) + } + case ERROR: + return void 0 + default: + return cb(null, v) + } + }) + } else { + p = new Promise((resolve, reject) => { + c.once('error', (er) => { + v = ERROR + c.close() + return reject(er) + }) + return c.once('end', () => { + switch (v) { + case NOT_FOUND: + if (required) { + return reject(new Error('No CBOR found')) + } else { + return resolve(v) + } + case ERROR: + return void 0 + default: + return resolve(v) + } + }) + }) + } + c.end(input, encod) + return p + } + + /** + * @callback decodeAllCallback + * @param {Error} error - if one was generated + * @param {Array} value - all of the decoded values, wrapped in an Array + */ + + /** + * Decode all of the CBOR items in the input. This will error if there are + * more bytes left over at the end. + * + * @static + * @param {(string|Buffer)} input - the input to parse + * @param {(string|Object)} options - Decoding options. + * If string, the input encoding. + * @param {decodeAllCallback} cb + * @returns {Promise} if no callback + */ + static decodeAll(input, options, cb) { + let opts = {} + let encod = 'hex' + switch (typeof options) { + case 'function': + cb = options + encod = utils.guessEncoding(input) + break + case 'string': + encod = options + break + case 'object': + opts = utils.extend({}, options) + encod = (opts.encoding != null) ? + opts.encoding : utils.guessEncoding(input) + delete opts.encoding + } + const c = new Decoder(opts) + let p + const vals = [] + c.on('data', (val) => { + return vals.push(Decoder.nullcheck(val)) + }) + if (typeof cb === 'function') { + c.on('error', cb) + c.on('end', () => cb(null, vals)) + } else { + p = new Promise((resolve, reject) => { + c.on('error', reject) + c.on('end', () => resolve(vals)) + }) + } + c.end(input, encod) + return p + } + + /** + * Stop processing + */ + close() { + this.running = false + this.__fresh = true + } + + *_parse() { + let parent = null + let depth = 0 + let val = null + while (true) { + if ((this.max_depth >= 0) && (depth > this.max_depth)) { + throw new Error('Maximum depth ' + this.max_depth + ' exceeded') + } + const octet = (yield 1)[0] + if (!this.running) { + throw new Error('Unexpected data: 0x' + (octet.toString(16))) + } + const mt = octet >> 5 + const ai = octet & 0x1f + const parent_major = (parent != null) ? parent[MAJOR] : undefined + const parent_length = (parent != null) ? parent.length : undefined + switch (ai) { + case NUMBYTES.ONE: + this.emit('more-bytes', mt, 1, parent_major, parent_length) + val = (yield 1)[0] + break + case NUMBYTES.TWO: + case NUMBYTES.FOUR: + case NUMBYTES.EIGHT: + const numbytes = 1 << (ai - 24) + this.emit('more-bytes', mt, numbytes, parent_major, parent_length) + const buf = yield numbytes + val = (mt === MT.SIMPLE_FLOAT) ? buf : utils.parseCBORint(ai, buf) + break + case 28: + case 29: + case 30: + this.running = false + throw new Error('Additional info not implemented: ' + ai) + case NUMBYTES.INDEFINITE: + val = -1 + break + default: + val = ai + } + switch (mt) { + case MT.POS_INT: + // val already decoded + break + case MT.NEG_INT: + if (val === Number.MAX_SAFE_INTEGER) { + val = NEG_MAX + } else if (val instanceof bignumber) { + val = NEG_ONE.minus(val) + } else { + val = -1 - val + } + break + case MT.BYTE_STRING: + case MT.UTF8_STRING: + switch (val) { + case 0: + this.emit('start-string', mt, val, parent_major, parent_length) + val = (mt === MT.BYTE_STRING) ? Buffer.allocUnsafe(0) : '' + break + case -1: + this.emit('start', mt, SYMS.STREAM, parent_major, parent_length) + parent = parentBufferStream(parent, mt) + depth++ + continue + default: + this.emit('start-string', mt, val, parent_major, parent_length) + val = yield val + if (mt === MT.UTF8_STRING) { + val = val.toString('utf-8') + } + } + break + case MT.ARRAY: + case MT.MAP: + switch (val) { + case 0: + val = (mt === MT.MAP) ? {} : [] + break + case -1: + this.emit('start', mt, SYMS.STREAM, parent_major, parent_length) + parent = parentArray(parent, mt, -1) + depth++ + continue + default: + this.emit('start', mt, val, parent_major, parent_length) + parent = parentArray(parent, mt, val * (mt - 3)) + depth++ + continue + } + break + case MT.TAG: + this.emit('start', mt, val, parent_major, parent_length) + parent = parentArray(parent, mt, 1) + parent.push(val) + depth++ + continue + case MT.SIMPLE_FLOAT: + if (typeof val === 'number') { + val = Simple.decode(val, parent != null) + } else { + val = utils.parseCBORfloat(val) + } + } + this.emit('value', val, parent_major, parent_length, ai) + let again = false + while (parent != null) { + switch (false) { + case val !== SYMS.BREAK: + parent[COUNT] = 1 + break + case !Array.isArray(parent): + parent.push(val) + break + case !(parent instanceof NoFilter): + const pm = parent[MAJOR] + if ((pm != null) && (pm !== mt)) { + this.running = false + throw new Error('Invalid major type in indefinite encoding') + } + parent.write(val) + } + if ((--parent[COUNT]) !== 0) { + again = true + break + } + --depth + delete parent[COUNT] + this.emit('stop', parent[MAJOR]) + + if (Array.isArray(parent)) { + switch (parent[MAJOR]) { + case MT.ARRAY: + val = parent + break + case MT.MAP: + let allstrings = true + if ((parent.length % 2) !== 0) { + throw new Error('Invalid map length: ' + parent.length) + } + for (let i = 0, len = parent.length; i < len; i += 2) { + if (typeof parent[i] !== 'string') { + allstrings = false + break + } + } + if (allstrings) { + val = {} + for (let i = 0, len = parent.length; i < len; i += 2) { + val[parent[i]] = parent[i + 1] + } + } else { + val = new Map + for (let i = 0, len = parent.length; i < len; i += 2) { + val.set(parent[i], parent[i + 1]) + } + } + break + case MT.TAG: + const t = new Tagged(parent[0], parent[1]) + val = t.convert(this.tags) + break + } + } else if (parent instanceof NoFilter) { + switch (parent[MAJOR]) { + case MT.BYTE_STRING: + val = parent.slice() + break + case MT.UTF8_STRING: + val = parent.toString('utf-8') + break + } + } + + const old = parent + parent = parent[SYMS.PARENT] + delete old[SYMS.PARENT] + delete old[MAJOR] + } + if (!again) { + return val + } + } + } +} + +Decoder.NOT_FOUND = NOT_FOUND +module.exports = Decoder + +}).call(this,require("buffer").Buffer) +},{"../vendor/binary-parse-stream":17,"./constants":9,"./simple":14,"./tagged":15,"./utils":16,"bignumber.js":3,"buffer":6,"nofilter":50}],11:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const stream = require('stream') +const util = require('util') +const Decoder = require('./decoder') +const Simple = require('./simple') +const utils = require('./utils') +const constants = require('./constants') +const bignumber = require('bignumber.js') +const NoFilter = require('nofilter') + +const MT = constants.MT +const SYMS = constants.SYMS + +/** + * Output the diagnostic format from a stream of CBOR bytes. + * + * @extends {stream.Transform} + */ +class Diagnose extends stream.Transform { + + /** + * Creates an instance of Diagnose. + * + * @param {Object} [options={}] - options for creation + * @param {string} [options.separator='\n'] - output between detected objects + * @param {bool} [options.stream_errors=false] - put error info into the + * output stream + * @param {number} [options.max_depth=-1] - -1 for "until you run out of + * memory". Set this to a finite positive number for un-trusted inputs. + * Most standard inputs won't nest more than 100 or so levels; I've tested + * into the millions before running out of memory. + */ + constructor(options) { + options = options || {} + const separator = (options.separator != null) ? options.separator : '\n' + delete options.separator + const stream_errors = (options.stream_errors != null) ? + options.stream_errors : false + delete options.stream_errors + options.readableObjectMode = false + options.writableObjectMode = false + super(options) + + this.float_bytes = -1 + this.separator = separator + this.stream_errors = stream_errors + this.parser = new Decoder(options) + this.parser.on('more-bytes', this._on_more.bind(this)) + this.parser.on('value', this._on_value.bind(this)) + this.parser.on('start', this._on_start.bind(this)) + this.parser.on('stop', this._on_stop.bind(this)) + this.parser.on('data', this._on_data.bind(this)) + this.parser.on('error', this._on_error.bind(this)) + } + + _transform(fresh, encoding, cb) { + return this.parser.write(fresh, encoding, cb) + } + + _flush(cb) { + return this.parser._flush((er) => { + if (this.stream_errors) { + this._on_error(er) + return cb() + } else { + return cb(er) + } + }) + } + + /** + * Convenience function to return a string in diagnostic format. + * + * @param {(Buffer|string)} input - the CBOR bytes to format + * @param {string} [encoding='hex'] - the encoding of input, ignored if + * input is Buffer + * @param {commentCallback} cb - callback + * @returns {Promise} if callback not specified + */ + static diagnose(input, encoding, cb) { + if (input == null) { + throw new Error('input required') + } + let opts = {} + let encod = 'hex' + switch (typeof encoding) { + case 'function': + cb = encoding + encod = utils.guessEncoding(input) + break + case 'object': + opts = utils.extend({}, encoding) + encod = (opts.encoding != null) ? + opts.encoding : utils.guessEncoding(input) + delete opts.encoding + break + default: + encod = (encoding != null) ? encoding : 'hex' + } + const bs = new NoFilter + const d = new Diagnose(opts) + let p = null + if (typeof cb === 'function') { + d.on('end', () => cb(null, bs.toString('utf8'))) + d.on('error', cb) + } else { + p = new Promise((resolve, reject) => { + d.on('end', () => resolve(bs.toString('utf8'))) + return d.on('error', reject) + }) + } + d.pipe(bs) + d.end(input, encod) + return p + } + + _on_error(er) { + if (this.stream_errors) { + return this.push(er.toString()) + } else { + return this.emit('error', er) + } + } + + _on_more(mt, len, parent_mt, pos) { + if (mt === MT.SIMPLE_FLOAT) { + return this.float_bytes = (function() { + switch (len) { + case 2: + return 1 + case 4: + return 2 + case 8: + return 3 + } + })() + } + } + + _fore(parent_mt, pos) { + switch (parent_mt) { + case MT.BYTE_STRING: + case MT.UTF8_STRING: + case MT.ARRAY: + if (pos > 0) { + return this.push(', ') + } + break + case MT.MAP: + if (pos > 0) { + if (pos % 2) { + return this.push(': ') + } else { + return this.push(', ') + } + } + } + } + + _on_value(val, parent_mt, pos) { + if (val === SYMS.BREAK) { + return + } + this._fore(parent_mt, pos) + return this.push((function() { + switch (false) { + case val !== SYMS.NULL: + return 'null' + case val !== SYMS.UNDEFINED: + return 'undefined' + case typeof val !== 'string': + return JSON.stringify(val) + case !(this.float_bytes > 0): + const fb = this.float_bytes + this.float_bytes = -1 + return (util.inspect(val)) + '_' + fb + case !Buffer.isBuffer(val): + return 'h\'' + (val.toString('hex')) + '\'' + case !(val instanceof bignumber): + return val.toString() + default: + return util.inspect(val) + } + }).call(this)) + } + + _on_start(mt, tag, parent_mt, pos) { + this._fore(parent_mt, pos) + this.push((function() { + switch (mt) { + case MT.TAG: + return tag + '(' + case MT.ARRAY: + return '[' + case MT.MAP: + return '{' + case MT.BYTE_STRING: + case MT.UTF8_STRING: + return '(' + default: + // istanbul ignore next + throw new Error('Unknown diagnostic type: ' + mt) + } + })()) + if (tag === SYMS.STREAM) { + return this.push('_ ') + } + } + + _on_stop(mt) { + return this.push((function() { + switch (mt) { + case MT.TAG: + return ')' + case MT.ARRAY: + return ']' + case MT.MAP: + return '}' + case MT.BYTE_STRING: + case MT.UTF8_STRING: + return ')' + default: + // istanbul ignore next + throw new Error('Unknown diagnostic type: ' + mt) + } + })()) + } + + _on_data() { + return this.push(this.separator) + } +} + +module.exports = Diagnose + +}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":47,"./constants":9,"./decoder":10,"./simple":14,"./utils":16,"bignumber.js":3,"nofilter":50,"stream":72,"util":78}],12:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const stream = require('stream') +const url = require('url') +const bignumber = require('bignumber.js') +const NoFilter = require('nofilter') +const Tagged = require('./tagged') +const Simple = require('./simple') +const utils = require('./utils') + +const constants = require('./constants') +const MT = constants.MT +const NUMBYTES = constants.NUMBYTES +const SHIFT32 = constants.SHIFT32 +const SYMS = constants.SYMS +const TAG = constants.TAG +const HALF = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.TWO +const FLOAT = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.FOUR +const DOUBLE = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.EIGHT +const TRUE = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.TRUE +const FALSE = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.FALSE +const UNDEFINED = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.UNDEFINED +const NULL = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.NULL + +const MAXINT_BN = new bignumber('0x20000000000000') +const BUF_NAN = Buffer.from('f97e00', 'hex') +const BUF_INF_NEG = Buffer.from('f9fc00', 'hex') +const BUF_INF_POS = Buffer.from('f97c00', 'hex') +const BUF_NEG_ZERO = Buffer.from('f98000', 'hex') +const LOOP_DETECT = Symbol('CBOR_LOOP_DETECT') + +/** + * Transform JavaScript values into CBOR bytes. The `Writable` side of + * the stream is in object mode. + * + * @extends {stream.Transform} + */ +class Encoder extends stream.Transform { + + /** + * Creates an instance of Encoder. + * + * @param {Object} [options={}] - options for the encoder + * @param {any[]} [options.genTypes=[]] - array of pairs of `type`, + * `function(Encoder)` for semantic types to be encoded. Not needed + * for Array, Date, Buffer, Map, RegExp, Set, Url, or bignumber. + * @param {boolean} [options.canonical=false] - should the output be + * canonicalized + * @param {boolean|Symbol} [options.detectLoops=false] - should object loops + * be detected? This will currently modify the encoded object graph + * by adding a Symbol property to each object. If this bothers you, + * call `removeLoopDetectors` on the encoded object when done. Do not + * encode the same object twice on the same encoder, without calling + * `removeLoopDetectors` in between. + * @param {("number"|"float"|"int"|"string")} [options.dateType="number"] - + * how should dates be encoded? "number" means float or int, if no + * fractional seconds. + */ + constructor(options) { + options = options || {} + options.readableObjectMode = false + options.writableObjectMode = true + super(options) + + this.canonical = options.canonical + this.dateType = (options.dateType != null) ? + options.dateType.toLowerCase() : 'number' + + // new Symbol for each instance. Note: means we can't re-use the same + // encoder and encoded object + if (typeof(options.detectLoops) === 'symbol') { + this.detectLoops = options.detectLoops + } else { + this.detectLoops = !!options.detectLoops ? Symbol('CBOR_DETECT') : null + } + + this.semanticTypes = [ + Array, this._pushArray, + Date, this._pushDate, + Buffer, this._pushBuffer, + Map, this._pushMap, + NoFilter, this._pushNoFilter, + RegExp, this._pushRegexp, + Set, this._pushSet, + url.Url, this._pushUrl, + bignumber, this._pushBigNumber + ] + + const addTypes = options.genTypes || [] + for (let i = 0, len = addTypes.length; i < len; i += 2) { + this.addSemanticType(addTypes[i], addTypes[i + 1]) + } + } + + _transform(fresh, encoding, cb) { + const ret = this.pushAny(fresh) + // Old transformers might not return bool. undefined !== false + return cb((ret === false) ? new Error('Push Error') : undefined) + } + + _flush(cb) { + return cb() + } + + /** + * @callback encodeFunction + * @param {Encoder} encoder - the encoder to serialize into. Call "write" + * on the encoder as needed. + * @return {bool} - true on success, else false + */ + + /** + * Add an encoding function to the list of supported semantic types. This is + * useful for objects for which you can't add an encodeCBOR method + * + * @param {any} type + * @param {any} fun + * @returns {encodeFunction} + */ + addSemanticType(type, fun) { + for (let i = 0, len = this.semanticTypes.length; i < len; i += 2) { + const typ = this.semanticTypes[i] + if (typ === type) { + const old = this.semanticTypes[i + 1] + this.semanticTypes[i + 1] = fun + return old + } + } + this.semanticTypes.push(type, fun) + return null + } + + _pushUInt8(val) { + const b = Buffer.allocUnsafe(1) + b.writeUInt8(val) + return this.push(b) + } + + _pushUInt16BE(val) { + const b = Buffer.allocUnsafe(2) + b.writeUInt16BE(val) + return this.push(b) + } + + _pushUInt32BE(val) { + const b = Buffer.allocUnsafe(4) + b.writeUInt32BE(val) + return this.push(b) + } + + _pushDoubleBE(val) { + const b = Buffer.allocUnsafe(8) + b.writeDoubleBE(val) + return this.push(b) + } + + _pushNaN() { + return this.push(BUF_NAN) + } + + _pushInfinity(obj) { + const half = (obj < 0) ? BUF_INF_NEG : BUF_INF_POS + return this.push(half) + } + + _pushFloat(obj) { + if (this.canonical) { + // TODO: is this enough slower to hide behind canonical? + // It's certainly enough of a hack (see utils.parseHalf) + + // From section 3.9: + // If a protocol allows for IEEE floats, then additional canonicalization + // rules might need to be added. One example rule might be to have all + // floats start as a 64-bit float, then do a test conversion to a 32-bit + // float; if the result is the same numeric value, use the shorter value + // and repeat the process with a test conversion to a 16-bit float. (This + // rule selects 16-bit float for positive and negative Infinity as well.) + + // which seems pretty much backwards to me. + const b2 = Buffer.allocUnsafe(2) + if (utils.writeHalf(b2, obj)) { + if (utils.parseHalf(b2) === obj) { + return this._pushUInt8(HALF) && this.push(b2) + } + } + const b4 = Buffer.allocUnsafe(4) + b4.writeFloatBE(obj) + if (b4.readFloatBE(0) === obj) { + return this._pushUInt8(FLOAT) && this.push(b4) + } + } + + return this._pushUInt8(DOUBLE) && this._pushDoubleBE(obj) + } + + _pushInt(obj, mt, orig) { + const m = mt << 5 + switch (false) { + case !(obj < 24): + return this._pushUInt8(m | obj) + case !(obj <= 0xff): + return this._pushUInt8(m | NUMBYTES.ONE) && this._pushUInt8(obj) + case !(obj <= 0xffff): + return this._pushUInt8(m | NUMBYTES.TWO) && this._pushUInt16BE(obj) + case !(obj <= 0xffffffff): + return this._pushUInt8(m | NUMBYTES.FOUR) && this._pushUInt32BE(obj) + case !(obj <= Number.MAX_SAFE_INTEGER): + return this._pushUInt8(m | NUMBYTES.EIGHT) && + this._pushUInt32BE(Math.floor(obj / SHIFT32)) && + this._pushUInt32BE(obj % SHIFT32) + default: + if (mt === MT.NEG_INT) { + return this._pushFloat(orig) + } else { + return this._pushFloat(obj) + } + } + } + + _pushIntNum(obj) { + if (Object.is(obj, -0)) { + return this.push(BUF_NEG_ZERO) + } + + if (obj < 0) { + return this._pushInt(-obj - 1, MT.NEG_INT, obj) + } else { + return this._pushInt(obj, MT.POS_INT) + } + } + + _pushNumber(obj) { + switch (false) { + case !isNaN(obj): + return this._pushNaN(obj) + case isFinite(obj): + return this._pushInfinity(obj) + case Math.round(obj) !== obj: + return this._pushIntNum(obj) + default: + return this._pushFloat(obj) + } + } + + _pushString(obj) { + const len = Buffer.byteLength(obj, 'utf8') + return this._pushInt(len, MT.UTF8_STRING) && this.push(obj, 'utf8') + } + + _pushBoolean(obj) { + return this._pushUInt8(obj ? TRUE : FALSE) + } + + _pushUndefined(obj) { + return this._pushUInt8(UNDEFINED) + } + + _pushNull(obj) { + return this._pushUInt8(NULL) + } + + _pushArray(gen, obj) { + const len = obj.length + if (!gen._pushInt(len, MT.ARRAY)) { + return false + } + for (let j = 0; j < len; j++) { + if (!gen.pushAny(obj[j])) { + return false + } + } + return true + } + + _pushTag(tag) { + return this._pushInt(tag, MT.TAG) + } + + _pushDate(gen, obj) { + switch (gen.dateType) { + case 'string': + return gen._pushTag(TAG.DATE_STRING) && + gen._pushString(obj.toISOString()) + case 'int': + case 'integer': + return gen._pushTag(TAG.DATE_EPOCH) && + gen._pushIntNum(Math.round(obj / 1000)) + case 'float': + // force float + return gen._pushTag(TAG.DATE_EPOCH) && + gen._pushFloat(obj / 1000) + case 'number': + default: + // if we happen to have an integral number of seconds, + // use integer. Otherwise, use float. + return gen._pushTag(TAG.DATE_EPOCH) && + gen.pushAny(obj / 1000) + } + } + + _pushBuffer(gen, obj) { + return gen._pushInt(obj.length, MT.BYTE_STRING) && gen.push(obj) + } + + _pushNoFilter(gen, obj) { + return gen._pushBuffer(gen, obj.slice()) + } + + _pushRegexp(gen, obj) { + return gen._pushTag(TAG.REGEXP) && gen.pushAny(obj.source) + } + + _pushSet(gen, obj) { + if (!gen._pushInt(obj.size, MT.ARRAY)) { + return false + } + for (const x of obj) { + if (!gen.pushAny(x)) { + return false + } + } + return true + } + + _pushUrl(gen, obj) { + return gen._pushTag(TAG.URI) && gen.pushAny(obj.format()) + } + + _pushBigint(obj) { + let tag = TAG.POS_BIGINT + if (obj.isNegative()) { + obj = obj.negated().minus(1) + tag = TAG.NEG_BIGINT + } + let str = obj.toString(16) + if (str.length % 2) { + str = '0' + str + } + const buf = Buffer.from(str, 'hex') + return this._pushTag(tag) && this._pushBuffer(this, buf) + } + + _pushBigNumber(gen, obj) { + if (obj.isNaN()) { + return gen._pushNaN() + } + if (!obj.isFinite()) { + return gen._pushInfinity(obj.isNegative() ? -Infinity : Infinity) + } + if (obj.isInteger()) { + return gen._pushBigint(obj) + } + if (!(gen._pushTag(TAG.DECIMAL_FRAC) && + gen._pushInt(2, MT.ARRAY))) { + return false + } + + const dec = obj.decimalPlaces() + const slide = obj.times(new bignumber(10).pow(dec)) + if (!gen._pushIntNum(-dec)) { + return false + } + if (slide.abs().isLessThan(MAXINT_BN)) { + return gen._pushIntNum(slide.toNumber()) + } else { + return gen._pushBigint(slide) + } + } + + _pushMap(gen, obj) { + if (!gen._pushInt(obj.size, MT.MAP)) { + return false + } + // memoizing the cbor only helps in certain cases, and hurts in most + // others. Just avoid it. + if (gen.canonical) { + // keep the key/value pairs together, so we don't have to do odd + // gets with object keys later + const entries = [] + // iterator. If we drop support for node4, use ... + for (const e of obj.entries()) { + entries.push(e) + } + entries.sort((a, b) => { + // a, b are both entries of [key, value] + const a_cbor = Encoder.encode(a[0]) + const b_cbor = Encoder.encode(b[0]) + return a_cbor.compare(b_cbor) + }) + for (const kv of entries) { + if (!(gen.pushAny(kv[0]) && gen.pushAny(kv[1]))) { + return false + } + } + } else { + for (const kv of obj) { + if (!(gen.pushAny(kv[0]) && gen.pushAny(kv[1]))) { + return false + } + } + } + return true + } + + removeLoopDetectors(obj) { + if (!this.detectLoops || (typeof(obj) !== 'object') || !obj) { + return false + } + const dl = obj[LOOP_DETECT] + if (!dl || (dl !== this.detectLoops)) { + // ironically, use loop marking to detect loops on removal as well + return false + } + delete obj[LOOP_DETECT] + if (Array.isArray(obj)) { + for (const i of obj) { + this.removeLoopDetectors(i) + } + } else { + for (const k in obj) { + this.removeLoopDetectors(obj[k]) + } + } + return true + } + + _pushObject(obj) { + if (!obj) { + return this._pushNull(obj) + } + if (this.detectLoops) { + if (obj[LOOP_DETECT] === this.detectLoops) { + throw new Error('Loop detected while CBOR encoding') + } else { + obj[LOOP_DETECT] = this.detectLoops + } + } + const f = obj.encodeCBOR + if (typeof f === 'function') { + return f.call(obj, this) + } + for (let i = 0, len1 = this.semanticTypes.length; i < len1; i += 2) { + const typ = this.semanticTypes[i] + if (obj instanceof typ) { + return this.semanticTypes[i + 1].call(obj, this, obj) + } + } + const keys = Object.keys(obj) + const cbor_keys = {} + if (this.canonical) { + // note: this can't be a normal sort, because 'b' needs to sort before + // 'aa' + keys.sort((a, b) => { + // Always strings, so don't bother to pass options. + // hold on to the cbor versions, since there's no need + // to encode more than once + const a_cbor = cbor_keys[a] || (cbor_keys[a] = Encoder.encode(a)) + const b_cbor = cbor_keys[b] || (cbor_keys[b] = Encoder.encode(b)) + + return a_cbor.compare(b_cbor) + }) + } + if (!this._pushInt(keys.length, MT.MAP)) { + return false + } + let ck + for (let j = 0, len2 = keys.length; j < len2; j++) { + const k = keys[j] + if (this.canonical && ((ck = cbor_keys[k]))) { + if (!this.push(ck)) { // already a Buffer + return false + } + } else { + if (!this._pushString(k)) { + return false + } + } + if (!this.pushAny(obj[k])) { + return false + } + } + + return true + } + + /** + * Push any supported type onto the encoded stream + * + * @param {any} obj + * @returns {boolean} true on success + */ + pushAny(obj) { + switch (typeof obj) { + case 'number': + return this._pushNumber(obj) + case 'string': + return this._pushString(obj) + case 'boolean': + return this._pushBoolean(obj) + case 'undefined': + return this._pushUndefined(obj) + case 'object': + return this._pushObject(obj) + case 'symbol': + switch (obj) { + case SYMS.NULL: + return this._pushNull(null) + case SYMS.UNDEFINED: + return this._pushUndefined(void 0) + // TODO: Add pluggable support for other symbols + default: + throw new Error('Unknown symbol: ' + obj.toString()) + } + default: + throw new Error( + 'Unknown type: ' + typeof obj + ', ' + + (!!obj ? obj.toString() : '')) + } + } + + /* backwards-compat wrapper */ + _pushAny(obj) { + // TODO: write deprecation warning + return this.pushAny(obj) + } + + _encodeAll(objs) { + const bs = new NoFilter() + this.pipe(bs) + for (const o of objs) { + if (typeof o === 'undefined') { + this._pushUndefined() + } else if (o === null) { + this._pushNull(null) + } else { + this.write(o) + } + } + this.end() + return bs.read() + } + + /** + * Encode one or more JavaScript objects, and return a Buffer containing the + * CBOR bytes. + * + * @param {...any} objs - the objects to encode + * @returns {Buffer} - the encoded objects + */ + static encode() { + const objs = Array.prototype.slice.apply(arguments) + return new Encoder()._encodeAll(objs) + } + + /** + * Encode one or more JavaScript objects canonically (slower!), and return + * a Buffer containing the CBOR bytes. + * + * @param {...any} objs - the objects to encode + * @returns {Buffer} - the encoded objects + */ + static encodeCanonical() { + const objs = Array.prototype.slice.apply(arguments) + return new Encoder({canonical: true})._encodeAll(objs) + } + + /** + * Encode one JavaScript object using the given options. + * + * @static + * @param {any} obj - the object to encode + * @param {Object?} options - passed to the Encoder constructor + * @returns {Buffer} - the encoded objects + */ + static encodeOne(obj, options) { + return new Encoder(options)._encodeAll([obj]) + } +} + +module.exports = Encoder + +}).call(this,require("buffer").Buffer) +},{"./constants":9,"./simple":14,"./tagged":15,"./utils":16,"bignumber.js":3,"buffer":6,"nofilter":50,"stream":72,"url":74}],13:[function(require,module,exports){ +(function (Buffer){ +'use strict' + +const encoder = require('./encoder') +const decoder = require('./decoder') +const constants = require('./constants') +const MT = constants.MT + +/** + * Wrapper around a JavaScript Map object that allows the keys to be + * any complex type. The base Map object allows this, but will only + * compare the keys by identity, not by value. CborMap translates keys + * to CBOR first (and base64's them to ensure by-value comparison). + * + * This is not a subclass of Object, because it would be tough to get + * the semantics to be an exact match. + * + * @class CborMap + * @extends {Map} + */ +class CborMap extends Map { + /** + * Creates an instance of CborMap. + * @param {Iterable>} args An Array or other iterable object + * whose elements are key-value pairs (arrays with two elements, e.g. + * [[ 1, 'one' ],[ 2, 'two' ]]). Each key-value pair is added + * to the new CborMap; null values are treated as undefined. + */ + constructor(iterable) { + super(iterable) + } + + /** + * @private + */ + static _encode(key) { + return encoder.encodeCanonical(key).toString('base64') + } + + /** + * @private + */ + static _decode(key) { + return decoder.decodeFirstSync(key, 'base64') + } + + /** + * Retrieve a specified element. + * + * @param {any} key The key identifying the element to retrieve. + * Can be any type, which will be serialized into CBOR and compared by + * value. + * @returns {any} The element if it exists, or undefined. + */ + get(key) { + return super.get(CborMap._encode(key)) + } + + /** + * Adds or updates an element with a specified key and value. + * + * @param {any} key The key identifying the element to store. + * Can be any type, which will be serialized into CBOR and compared by + * value. + * @param {any} val The element to store + */ + set(key, val) { + return super.set(CborMap._encode(key), val) + } + + /** + * Removes the specified element. + * + * @param {any} key The key identifying the element to delete. + * Can be any type, which will be serialized into CBOR and compared by + * value. + * @returns {boolean} + */ + delete(key) { + return super.delete(CborMap._encode(key)) + } + + /** + * Does an element with the specified key exist? + * + * @param {any} key The key identifying the element to check. + * Can be any type, which will be serialized into CBOR and compared by + * value. + * @returns {boolean} + */ + has(key) { + return super.has(CborMap._encode(key)) + } + + /** + * Returns a new Iterator object that contains the keys for each element + * in the Map object in insertion order. The keys are decoded into their + * original format. + * + * @returns {Iterator} + */ + *keys() { + for (const k of super.keys()) { + yield CborMap._decode(k) + } + } + + /** + * Returns a new Iterator object that contains the [key, value] pairs for + * each element in the Map object in insertion order. + * + * @returns {Iterator.>} + */ + *entries() { + for (const kv of super.entries()) { + yield [CborMap._decode(kv[0]), kv[1]] + } + } + + /** + * Returns a new Iterator object that contains the [key, value] pairs for + * each element in the Map object in insertion order. + * + * @returns {Iterator.>} + */ + [Symbol.iterator]() { + return this.entries() + } + + /** + * Executes a provided function once per each key/value pair in the Map + * object, in insertion order. + * + * @param {function(any, any, CborMap)} fun Function to execute for each + * element, which takes a value, a key, and the Map being traversed. + * @param {any} thisArg Value to use as this when executing callback + */ + forEach(fun, thisArg) { + if (typeof(fun) !== 'function') { + throw new TypeError('Must be function') + } + for (const kv of super.entries()) { + fun.call(this, kv[1], CborMap._decode(kv[0]), this) + } + } + + /** + * Push the simple value onto the CBOR stream + * + * @param {cbor.Encoder} gen The generator to push onto + * @returns {boolean} true on success + */ + encodeCBOR(gen) { + if (!gen._pushInt(this.size, MT.MAP)) { + return false + } + if (gen.canonical) { + const entries = Array.from(super.entries()) + .map((kv) => [Buffer.from(kv[0], 'base64'), kv[1]]) + entries.sort((a, b) => a[0].compare(b[0])) + for (const kv of entries) { + if (!(gen.push(kv[0]) && gen.pushAny(kv[1]))) { + return false + } + } + } else { + for (const kv of super.entries()) { + if (!(gen.push(Buffer.from(kv[0], 'base64')) && gen.pushAny(kv[1]))) { + return false + } + } + } + return true + } +} + +module.exports = CborMap +}).call(this,require("buffer").Buffer) +},{"./constants":9,"./decoder":10,"./encoder":12,"buffer":6}],14:[function(require,module,exports){ +'use strict' + +const util = require('util') +const constants = require('./constants') +const MT = constants.MT +const SIMPLE = constants.SIMPLE +const SYMS = constants.SYMS + +/** + * A CBOR Simple Value that does not map onto a known constant. + */ +class Simple { + /** + * Creates an instance of Simple. + * + * @param {integer} value - the simple value's integer value + */ + constructor(value) { + if (typeof value !== 'number') { + throw new Error('Invalid Simple type: ' + (typeof value)) + } + if ((value < 0) || (value > 255) || ((value|0) !== value)) { + throw new Error('value must be a small positive integer: ' + value) + } + this.value = value + } + + /** + * Debug string for simple value + * + * @returns {string} simple(value) + */ + toString() { + return 'simple(' + this.value + ')' + } + + /** + * Debug string for simple value + * + * @returns {string} simple(value) + */ + [util.inspect.custom](depth, opts) { + return 'simple(' + this.value + ')' + } + + /** + * Debug string for simple value (backward-compatibility version) + * + * @returns {string} simple(value) + */ + inspect(depth, opts) { + return 'simple(' + this.value + ')' + } + + /** + * Push the simple value onto the CBOR stream + * + * @param {cbor.Encoder} gen The generator to push onto + */ + encodeCBOR(gen) { + return gen._pushInt(this.value, MT.SIMPLE_FLOAT) + } + + /** + * Is the given object a Simple? + * + * @param {any} obj - object to test + * @returns {bool} - is it Simple? + */ + static isSimple(obj) { + return obj instanceof Simple + } + + /** + * Decode from the CBOR additional information into a JavaScript value. + * If the CBOR item has no parent, return a "safe" symbol instead of + * `null` or `undefined`, so that the value can be passed through a + * stream in object mode. + * + * @param {number} val - the CBOR additional info to convert + * @param {bool} has_parent - Does the CBOR item have a parent? + * @returns {(null|undefined|bool|Symbol)} - the decoded value + */ + static decode(val, has_parent) { + if (has_parent == null) { + has_parent = true + } + switch (val) { + case SIMPLE.FALSE: + return false + case SIMPLE.TRUE: + return true + case SIMPLE.NULL: + if (has_parent) { + return null + } else { + return SYMS.NULL + } + case SIMPLE.UNDEFINED: + if (has_parent) { + return void 0 + } else { + return SYMS.UNDEFINED + } + case -1: + if (!has_parent) { + throw new Error('Invalid BREAK') + } + return SYMS.BREAK + default: + return new Simple(val) + } + } +} + +module.exports = Simple + +},{"./constants":9,"util":78}],15:[function(require,module,exports){ +'use strict' + +const bignumber = require('bignumber.js') +const utils = require('./utils') +const url = require('url') + +const MINUS_ONE = new bignumber(-1) +const TEN = new bignumber(10) +const TWO = new bignumber(2) + +/** + * A CBOR tagged item, where the tag does not have semantics specified at the + * moment, or those semantics threw an error during parsing. Typically this will + * be an extension point you're not yet expecting. + */ +class Tagged { + + /** + * Creates an instance of Tagged. + * + * @param {number} tag - the number of the tag + * @param {any} value - the value inside the tag + * @param {Error} err - the error that was thrown parsing the tag, or null + */ + constructor(tag, value, err) { + this.tag = tag + this.value = value + this.err = err + if (typeof this.tag !== 'number') { + throw new Error('Invalid tag type (' + (typeof this.tag) + ')') + } + if ((this.tag < 0) || ((this.tag | 0) !== this.tag)) { + throw new Error('Tag must be a positive integer: ' + this.tag) + } + } + + /** + * Convert to a String + * + * @returns {string} string of the form '1(2)' + */ + toString() { + return `${this.tag}(${JSON.stringify(this.value)})` + } + + /** + * Push the simple value onto the CBOR stream + * + * @param {cbor.Encoder} gen The generator to push onto + */ + encodeCBOR(gen) { + gen._pushTag(this.tag) + return gen.pushAny(this.value) + } + + /** + * If we have a converter for this type, do the conversion. Some converters + * are built-in. Additional ones can be passed in. If you want to remove + * a built-in converter, pass a converter in whose value is 'null' instead + * of a function. + * + * @param {Object} converters - keys in the object are a tag number, the value + * is a function that takes the decoded CBOR and returns a JavaScript value + * of the appropriate type. Throw an exception in the function on errors. + * @returns {any} - the converted item + */ + convert(converters) { + let f = converters != null ? converters[this.tag] : void 0 + if (typeof f !== 'function') { + f = Tagged['_tag_' + this.tag] + if (typeof f !== 'function') { + return this + } + } + try { + return f.call(Tagged, this.value) + } catch (error) { + this.err = error + return this + } + } + + static _tag_0(v) { + return new Date(v) + } + + static _tag_1(v) { + return new Date(v * 1000) + } + + static _tag_2(v) { + return utils.bufferToBignumber(v) + } + + static _tag_3(v) { + return MINUS_ONE.minus(utils.bufferToBignumber(v)) + } + + static _tag_4(v) { + return TEN.pow(v[0]).times(v[1]) + } + + static _tag_5(v) { + return TWO.pow(v[0]).times(v[1]) + } + + static _tag_32(v) { + return url.parse(v) + } + + static _tag_35(v) { + return new RegExp(v) + } +} + +module.exports = Tagged + +},{"./utils":16,"bignumber.js":3,"url":74}],16:[function(require,module,exports){ +(function (process,Buffer){ +'use strict' + +const fs = require('fs') +const stream = require('stream') +const bignumber = require('bignumber.js') + +const constants = require('./constants') +const NUMBYTES = constants.NUMBYTES +const SHIFT32 = constants.SHIFT32 +const MAX_SAFE_HIGH = 0x1fffff + +exports.parseCBORint = function(ai, buf) { + switch (ai) { + case NUMBYTES.ONE: + return buf.readUInt8(0) + case NUMBYTES.TWO: + return buf.readUInt16BE(0) + case NUMBYTES.FOUR: + return buf.readUInt32BE(0) + case NUMBYTES.EIGHT: + const f = buf.readUInt32BE(0) + const g = buf.readUInt32BE(4) + if (f > MAX_SAFE_HIGH) { + return new bignumber(f).times(SHIFT32).plus(g) + } else { + return (f * SHIFT32) + g + } + default: + throw new Error('Invalid additional info for int: ' + ai) + } +} + +exports.writeHalf = function writeHalf(buf, half) { + // assume 0, -0, NaN, Infinity, and -Infinity have already been caught + + // HACK: everyone settle in. This isn't going to be pretty. + // Translate cn-cbor's C code (from Carsten Borman): + + // uint32_t be32; + // uint16_t be16, u16; + // union { + // float f; + // uint32_t u; + // } u32; + // u32.f = float_val; + + const u32 = Buffer.allocUnsafe(4) + u32.writeFloatBE(half) + const u = u32.readUInt32BE(0) + + // if ((u32.u & 0x1FFF) == 0) { /* worth trying half */ + + // hildjj: If the lower 13 bits are 0, + // we won't lose anything in the conversion + if ((u & 0x1FFF) !== 0) { + return false + } + + // int s16 = (u32.u >> 16) & 0x8000; + // int exp = (u32.u >> 23) & 0xff; + // int mant = u32.u & 0x7fffff; + + let s16 = (u >> 16) & 0x8000 // top bit is sign + const exp = (u >> 23) & 0xff // then 5 bits of exponent + const mant = u & 0x7fffff + + // if (exp == 0 && mant == 0) + // ; /* 0.0, -0.0 */ + + // hildjj: zeros already handled. Assert if you don't believe me. + + // else if (exp >= 113 && exp <= 142) /* normalized */ + // s16 += ((exp - 112) << 10) + (mant >> 13); + + if ((exp >= 113) && (exp <= 142)) { + s16 += ((exp - 112) << 10) + (mant >> 13) + } else if ((exp >= 103) && (exp < 113)) { + // else if (exp >= 103 && exp < 113) { /* denorm, exp16 = 0 */ + // if (mant & ((1 << (126 - exp)) - 1)) + // goto float32; /* loss of precision */ + // s16 += ((mant + 0x800000) >> (126 - exp)); + + if (mant & ((1 << (126 - exp)) - 1)) { + return false + } + s16 += ((mant + 0x800000) >> (126 - exp)) + } else { + // } else if (exp == 255 && mant == 0) { /* Inf */ + // s16 += 0x7c00; + + // hildjj: Infinity already handled + + // } else + // goto float32; /* loss of range */ + + return false + } + + // ensure_writable(3); + // u16 = s16; + // be16 = hton16p((const uint8_t*)&u16); + buf.writeUInt16BE(s16) + return true +} + +exports.parseHalf = function parseHalf(buf) { + const sign = buf[0] & 0x80 ? -1 : 1 + const exp = (buf[0] & 0x7C) >> 2 + const mant = ((buf[0] & 0x03) << 8) | buf[1] + if (!exp) { + return sign * 5.9604644775390625e-8 * mant + } else if (exp === 0x1f) { + return sign * (mant ? 0 / 0 : 2e308) + } else { + return sign * Math.pow(2, exp - 25) * (1024 + mant) + } +} + +exports.parseCBORfloat = function parseCBORfloat(buf) { + switch (buf.length) { + case 2: + return exports.parseHalf(buf) + case 4: + return buf.readFloatBE(0) + case 8: + return buf.readDoubleBE(0) + default: + throw new Error('Invalid float size: ' + buf.length) + } +} + +exports.hex = function hex(s) { + return Buffer.from(s.replace(/^0x/, ''), 'hex') +} + +exports.bin = function bin(s) { + s = s.replace(/\s/g, '') + let start = 0 + let end = (s.length % 8) || 8 + const chunks = [] + while (end <= s.length) { + chunks.push(parseInt(s.slice(start, end), 2)) + start = end + end += 8 + } + return Buffer.from(chunks) +} + +exports.extend = function extend() { + let old = arguments[0] + const adds = (2 <= arguments.length) ? + Array.prototype.slice.call(arguments, 1) : [] + const len = adds.length + if (old == null) { + old = {} + } + for (let j = 0; j < len; j++) { + const a = adds[j] + for (const k in a) { + const v = a[k] + old[k] = v + } + } + return old +} + +exports.arrayEqual = function arrayEqual(a, b) { + if ((a == null) && (b == null)) { + return true + } + if ((a == null) || (b == null)) { + return false + } + return (a.length === b.length) && a.every((elem, i) => elem === b[i]) +} + +exports.bufferEqual = function bufferEqual(a, b) { + if ((a == null) && (b == null)) { + return true + } + if ((a == null) || (b == null)) { + return false + } + if (!(Buffer.isBuffer(a) && Buffer.isBuffer(b) && (a.length === b.length))) { + return false + } + const len = a.length + let ret = true + let i + let j + for (i = j = 0; j < len; i = ++j) { + const byte = a[i] + ret &= b[i] === byte + } + return !!ret +} + +exports.bufferToBignumber = function bufferToBignumber(buf) { + return new bignumber(buf.toString('hex'), 16) +} + +exports.DeHexStream = class DeHexStream extends stream.Readable { + constructor(hex) { + super() + hex = hex.replace(/^0x/, '') + if (hex) { + this.push(Buffer.from(hex, 'hex')) + } + this.push(null) + } +} + +exports.HexStream = class HexStream extends stream.Transform { + constructor(options) { + super(options) + } + + _transform(fresh, encoding, cb) { + this.push(fresh.toString('hex')) + return cb() + } +} + +function printError(er) { + if (er != null) { + return console.log(er) + } +} + +exports.streamFiles = function streamFiles(files, streamFunc, cb) { + if (cb == null) { + cb = printError + } + const f = files.shift() + if (!f) { + return cb() + } + const sf = streamFunc() + sf.on('end', () => exports.streamFiles(files, streamFunc, cb)) + sf.on('error', cb) + const s = (f === '-') ? + process.stdin : (f instanceof stream.Stream) ? f : fs.createReadStream(f) + s.on('error', cb) + return s.pipe(sf) +} + +exports.guessEncoding = function guessEncoding(input) { + switch (false) { + case typeof input !== 'string': + return 'hex' + case !Buffer.isBuffer(input): + return undefined + default: + throw new Error('Unknown input type') + } +} + +}).call(this,require('_process'),require("buffer").Buffer) +},{"./constants":9,"_process":52,"bignumber.js":3,"buffer":6,"fs":4,"stream":72}],17:[function(require,module,exports){ +// Tweaked version of nathan7's binary-parse-stream +// (see https://github.com/nathan7/binary-parse-stream) +// Uses NoFilter instead of the readable in the original. Removes +// the ability to read -1, which was odd and un-needed. +// License for binary-parse-stream: MIT + +'use strict'; +exports = module.exports = BinaryParseStream +var Stream = require('stream') + , TransformStream = Stream.Transform + , inherits = require('util').inherits + , NoFilter = require('nofilter') + +exports.One = -1 + +inherits(BinaryParseStream, TransformStream) +function BinaryParseStream(options) { + TransformStream.call(this, options) + this._writableState.objectMode = false + this._readableState.objectMode = true + + this.bs = new NoFilter() + this.__restart() +} + +BinaryParseStream.prototype._transform = function(fresh, encoding, cb) { var self = this + this.bs.write(fresh) + + while (this.bs.length >= this.__needed) { + var ret + , chunk = this.__needed === null + ? undefined + : this.bs.read(this.__needed) + + try { ret = this.__parser.next(chunk) } + catch (e) { + return cb(e) } + + if (this.__needed) + this.__fresh = false + + if (!ret.done) + this.__needed = ret.value | 0 + else { + this.push(ret.value) + this.__restart() + } + } + + return cb() +} + +BinaryParseStream.prototype.__restart = function() { + this.__needed = null + this.__parser = this._parse() + this.__fresh = true +} + +BinaryParseStream.prototype._flush = function(cb) { + cb(this.__fresh + ? null + : new Error('unexpected end of input')) +} + +},{"nofilter":50,"stream":72,"util":78}],18:[function(require,module,exports){ +(function (Buffer){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":47}],19:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc1').default; + +},{"./es6/crc1":30}],20:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16').default; + +},{"./es6/crc16":31}],21:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16ccitt').default; + +},{"./es6/crc16ccitt":32}],22:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16kermit').default; + +},{"./es6/crc16kermit":33}],23:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16modbus').default; + +},{"./es6/crc16modbus":34}],24:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc16xmodem').default; + +},{"./es6/crc16xmodem":35}],25:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc24').default; + +},{"./es6/crc24":36}],26:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc32').default; + +},{"./es6/crc32":37}],27:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc8').default; + +},{"./es6/crc8":38}],28:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crc81wire').default; + +},{"./es6/crc81wire":39}],29:[function(require,module,exports){ +'use strict'; + +module.exports = require('./es6/crcjam').default; + +},{"./es6/crcjam":40}],30:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var crc1 = (0, _define_crc2.default)('crc1', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = ~~previous; + var accum = 0; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + accum += byte; + } + + crc += accum % 256; + return crc % 256; +}); + +exports.default = crc1; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],31:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc16 = (0, _define_crc2.default)('crc-16', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = ~~previous; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; + } + + return crc; +}); + +exports.default = crc16; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],32:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=ccitt --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc16ccitt = (0, _define_crc2.default)('ccitt', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc >> 8 ^ byte) & 0xff] ^ crc << 8) & 0xffff; + } + + return crc; +}); + +exports.default = crc16ccitt; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],33:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc16kermit = (0, _define_crc2.default)('kermit', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0x0000; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; + } + + return crc; +}); + +exports.default = crc16kermit; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],34:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16-modbus --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc16modbus = (0, _define_crc2.default)('crc-16-modbus', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; + } + + return crc; +}); + +exports.default = crc16modbus; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],35:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var crc16xmodem = (0, _define_crc2.default)('xmodem', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0x0; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + var code = crc >>> 8 & 0xff; + + code ^= byte & 0xff; + code ^= code >>> 4; + crc = crc << 8 & 0xffff; + crc ^= code; + code = code << 5 & 0xffff; + crc ^= code; + code = code << 7 & 0xffff; + crc ^= code; + } + + return crc; +}); + +exports.default = crc16xmodem; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],36:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-drive --model=crc-24 --generate=c` +// prettier-ignore +var TABLE = [0x000000, 0x864cfb, 0x8ad50d, 0x0c99f6, 0x93e6e1, 0x15aa1a, 0x1933ec, 0x9f7f17, 0xa18139, 0x27cdc2, 0x2b5434, 0xad18cf, 0x3267d8, 0xb42b23, 0xb8b2d5, 0x3efe2e, 0xc54e89, 0x430272, 0x4f9b84, 0xc9d77f, 0x56a868, 0xd0e493, 0xdc7d65, 0x5a319e, 0x64cfb0, 0xe2834b, 0xee1abd, 0x685646, 0xf72951, 0x7165aa, 0x7dfc5c, 0xfbb0a7, 0x0cd1e9, 0x8a9d12, 0x8604e4, 0x00481f, 0x9f3708, 0x197bf3, 0x15e205, 0x93aefe, 0xad50d0, 0x2b1c2b, 0x2785dd, 0xa1c926, 0x3eb631, 0xb8faca, 0xb4633c, 0x322fc7, 0xc99f60, 0x4fd39b, 0x434a6d, 0xc50696, 0x5a7981, 0xdc357a, 0xd0ac8c, 0x56e077, 0x681e59, 0xee52a2, 0xe2cb54, 0x6487af, 0xfbf8b8, 0x7db443, 0x712db5, 0xf7614e, 0x19a3d2, 0x9fef29, 0x9376df, 0x153a24, 0x8a4533, 0x0c09c8, 0x00903e, 0x86dcc5, 0xb822eb, 0x3e6e10, 0x32f7e6, 0xb4bb1d, 0x2bc40a, 0xad88f1, 0xa11107, 0x275dfc, 0xdced5b, 0x5aa1a0, 0x563856, 0xd074ad, 0x4f0bba, 0xc94741, 0xc5deb7, 0x43924c, 0x7d6c62, 0xfb2099, 0xf7b96f, 0x71f594, 0xee8a83, 0x68c678, 0x645f8e, 0xe21375, 0x15723b, 0x933ec0, 0x9fa736, 0x19ebcd, 0x8694da, 0x00d821, 0x0c41d7, 0x8a0d2c, 0xb4f302, 0x32bff9, 0x3e260f, 0xb86af4, 0x2715e3, 0xa15918, 0xadc0ee, 0x2b8c15, 0xd03cb2, 0x567049, 0x5ae9bf, 0xdca544, 0x43da53, 0xc596a8, 0xc90f5e, 0x4f43a5, 0x71bd8b, 0xf7f170, 0xfb6886, 0x7d247d, 0xe25b6a, 0x641791, 0x688e67, 0xeec29c, 0x3347a4, 0xb50b5f, 0xb992a9, 0x3fde52, 0xa0a145, 0x26edbe, 0x2a7448, 0xac38b3, 0x92c69d, 0x148a66, 0x181390, 0x9e5f6b, 0x01207c, 0x876c87, 0x8bf571, 0x0db98a, 0xf6092d, 0x7045d6, 0x7cdc20, 0xfa90db, 0x65efcc, 0xe3a337, 0xef3ac1, 0x69763a, 0x578814, 0xd1c4ef, 0xdd5d19, 0x5b11e2, 0xc46ef5, 0x42220e, 0x4ebbf8, 0xc8f703, 0x3f964d, 0xb9dab6, 0xb54340, 0x330fbb, 0xac70ac, 0x2a3c57, 0x26a5a1, 0xa0e95a, 0x9e1774, 0x185b8f, 0x14c279, 0x928e82, 0x0df195, 0x8bbd6e, 0x872498, 0x016863, 0xfad8c4, 0x7c943f, 0x700dc9, 0xf64132, 0x693e25, 0xef72de, 0xe3eb28, 0x65a7d3, 0x5b59fd, 0xdd1506, 0xd18cf0, 0x57c00b, 0xc8bf1c, 0x4ef3e7, 0x426a11, 0xc426ea, 0x2ae476, 0xaca88d, 0xa0317b, 0x267d80, 0xb90297, 0x3f4e6c, 0x33d79a, 0xb59b61, 0x8b654f, 0x0d29b4, 0x01b042, 0x87fcb9, 0x1883ae, 0x9ecf55, 0x9256a3, 0x141a58, 0xefaaff, 0x69e604, 0x657ff2, 0xe33309, 0x7c4c1e, 0xfa00e5, 0xf69913, 0x70d5e8, 0x4e2bc6, 0xc8673d, 0xc4fecb, 0x42b230, 0xddcd27, 0x5b81dc, 0x57182a, 0xd154d1, 0x26359f, 0xa07964, 0xace092, 0x2aac69, 0xb5d37e, 0x339f85, 0x3f0673, 0xb94a88, 0x87b4a6, 0x01f85d, 0x0d61ab, 0x8b2d50, 0x145247, 0x921ebc, 0x9e874a, 0x18cbb1, 0xe37b16, 0x6537ed, 0x69ae1b, 0xefe2e0, 0x709df7, 0xf6d10c, 0xfa48fa, 0x7c0401, 0x42fa2f, 0xc4b6d4, 0xc82f22, 0x4e63d9, 0xd11cce, 0x575035, 0x5bc9c3, 0xdd8538]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc24 = (0, _define_crc2.default)('crc-24', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0xb704ce; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc >> 16 ^ byte) & 0xff] ^ crc << 8) & 0xffffff; + } + + return crc; +}); + +exports.default = crc24; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],37:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c` +// prettier-ignore +var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc32 = (0, _define_crc2.default)('crc-32', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = previous === 0 ? 0 : ~~previous ^ -1; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; + } + + return crc ^ -1; +}); + +exports.default = crc32; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],38:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-8 --generate=c` +// prettier-ignore +var TABLE = [0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc8 = (0, _define_crc2.default)('crc-8', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = ~~previous; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] & 0xff; + } + + return crc; +}); + +exports.default = crc8; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],39:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c` +// prettier-ignore +var TABLE = [0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62, 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff, 0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07, 0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a, 0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24, 0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9, 0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd, 0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50, 0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee, 0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73, 0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5, 0x8b, 0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16, 0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8, 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc81wire = (0, _define_crc2.default)('dallas-1-wire', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = ~~previous; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] & 0xff; + } + + return crc; +}); + +exports.default = crc81wire; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],40:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var _create_buffer = require('./create_buffer'); + +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Generated by `./pycrc.py --algorithm=table-driven --model=jam --generate=c` +// prettier-ignore +var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crcjam = (0, _define_crc2.default)('jam', function (buf) { + var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; + + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = previous === 0 ? 0 : ~~previous; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; + } + + return crc; +}); + +exports.default = crcjam; + +},{"./create_buffer":41,"./define_crc":42,"buffer":6}],41:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); + +var createBuffer = _buffer.Buffer.from && _buffer.Buffer.alloc && _buffer.Buffer.allocUnsafe && _buffer.Buffer.allocUnsafeSlow ? _buffer.Buffer.from : // support for Node < 5.10 +function (val) { + return new _buffer.Buffer(val); +}; + +exports.default = createBuffer; + +},{"buffer":6}],42:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function (model, calc) { + var fn = function fn(buf, previous) { + return calc(buf, previous) >>> 0; + }; + fn.signed = calc; + fn.unsigned = fn; + fn.model = model; + + return fn; +}; + +},{}],43:[function(require,module,exports){ +'use strict'; + +module.exports = { + crc1: require('./crc1'), + crc8: require('./crc8'), + crc81wire: require('./crc8_1wire'), + crc16: require('./crc16'), + crc16ccitt: require('./crc16_ccitt'), + crc16modbus: require('./crc16_modbus'), + crc16xmodem: require('./crc16_xmodem'), + crc16kermit: require('./crc16_kermit'), + crc24: require('./crc24'), + crc32: require('./crc32'), + crcjam: require('./crcjam') +}; + +},{"./crc1":19,"./crc16":20,"./crc16_ccitt":21,"./crc16_kermit":22,"./crc16_modbus":23,"./crc16_xmodem":24,"./crc24":25,"./crc32":26,"./crc8":27,"./crc8_1wire":28,"./crcjam":29}],44:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + +},{}],45:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + +},{}],46:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + +},{}],47:[function(require,module,exports){ +/*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh + * @license MIT + */ + +// The _isBuffer check is for Safari 5-7 support, because it's missing +// Object.prototype.constructor. Remove this eventually +module.exports = function (obj) { + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) +} + +function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +} + +// For Node v0.10 support. Remove this eventually. +function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) +} + +},{}],48:[function(require,module,exports){ +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + +},{}],49:[function(require,module,exports){ +/* + A JavaScript implementation of the SHA family of hashes, as + defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding + HMAC implementation as defined in FIPS PUB 198a + + Copyright Brian Turek 2008-2017 + Distributed under the BSD License + See http://caligatio.github.com/jsSHA/ for more information + + Several functions taken from Paul Johnston +*/ +'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; +b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> +5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); +}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> +6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==k&&k 0) && (om !== _this._readableState.objectMode)) { + throw new Error('Do not switch objectMode in the middle of the stream'); + } + _this._readableState.objectMode = om; + return _this._writableState.objectMode = om; + }; + })(this)); + } + if (inp != null) { + this.end(inp, inpE); + } + } + + NoFilter.isNoFilter = function(obj) { + return obj instanceof this; + }; + + NoFilter.compare = function(nf1, nf2) { + if (!(nf1 instanceof this)) { + throw new TypeError('Arguments must be NoFilters'); + } + if (nf1 === nf2) { + return 0; + } else { + return nf1.compare(nf2); + } + }; + + NoFilter.concat = function(list, length) { + var bufs; + if (!Array.isArray(list)) { + throw new TypeError('list argument must be an Array of NoFilters'); + } + if ((list.length === 0) || (length === 0)) { + return new Buffer(0); + } + if (length == null) { + length = list.reduce(function(tot, nf) { + if (!(nf instanceof NoFilter)) { + throw new TypeError('list argument must be an Array of NoFilters'); + } + return tot + nf.length; + }, 0); + } + bufs = list.map(function(nf) { + if (!(nf instanceof NoFilter)) { + throw new TypeError('list argument must be an Array of NoFilters'); + } + if (nf._readableState.objectMode) { + throw new Error('NoFilter may not be in object mode for concat'); + } + return nf.slice(); + }); + return Buffer.concat(bufs, length); + }; + + NoFilter.prototype._transform = function(chunk, encoding, callback) { + if (!this._readableState.objectMode && !Buffer.isBuffer(chunk)) { + chunk = new Buffer(chunk, encoding); + } + this.push(chunk); + return callback(); + }; + + NoFilter.prototype._bufArray = function() { + var b, bufs; + bufs = this._readableState.buffer; + if (!Array.isArray(bufs)) { + b = bufs.head; + bufs = []; + while (b != null) { + bufs.push(b.data); + b = b.next; + } + } + return bufs; + }; + + NoFilter.prototype.read = function(size) { + var buf; + buf = NoFilter.__super__.read.call(this, size); + if (buf != null) { + this.emit('read', buf); + } + return buf; + }; + + NoFilter.prototype.promise = function(cb) { + var done; + done = false; + return new Promise((function(_this) { + return function(resolve, reject) { + _this.on('finish', function() { + var data; + data = _this.read(); + if ((cb != null) && !done) { + done = true; + cb(null, data); + } + return resolve(data); + }); + return _this.on('error', function(er) { + if ((cb != null) && !done) { + done = true; + cb(er); + } + return reject(er); + }); + }; + })(this)); + }; + + NoFilter.prototype.compare = function(other) { + if (!(other instanceof NoFilter)) { + throw new TypeError('Arguments must be NoFilters'); + } + if (this._readableState.objectMode || other._readableState.objectMode) { + throw new Error('Must not be in object mode to compare'); + } + if (this === other) { + return 0; + } else { + return this.slice().compare(other.slice()); + } + }; + + NoFilter.prototype.equals = function(other) { + return this.compare(other) === 0; + }; + + NoFilter.prototype.slice = function(start, end) { + var b, bufs; + if (this._readableState.objectMode) { + return this._bufArray().slice(start, end); + } else { + bufs = this._bufArray(); + switch (bufs.length) { + case 0: + return new Buffer(0); + case 1: + return bufs[0].slice(start, end); + default: + b = Buffer.concat(bufs); + return b.slice(start, end); + } + } + }; + + NoFilter.prototype.get = function(index) { + return this.slice()[index]; + }; + + NoFilter.prototype.toJSON = function() { + var b; + b = this.slice(); + if (Buffer.isBuffer(b)) { + return b.toJSON(); + } else { + return b; + } + }; + + NoFilter.prototype.toString = function(encoding, start, end) { + return this.slice().toString(encoding, start, end); + }; + + NoFilter.prototype.inspect = function(depth, options) { + var bufs, hex; + bufs = this._bufArray(); + hex = bufs.map(function(b) { + if (Buffer.isBuffer(b)) { + if (options != null ? options.stylize : void 0) { + return options.stylize(b.toString('hex'), 'string'); + } else { + return b.toString('hex'); + } + } else { + return util.inspect(b, options); + } + }).join(', '); + return this.constructor.name + " [" + hex + "]"; + }; + + _read_gen = function(meth, len) { + return function(val) { + var b; + b = this.read(len); + if (!Buffer.isBuffer(b)) { + return null; + } + return b[meth].call(b, 0, true); + }; + }; + + _write_gen = function(meth, len) { + return function(val) { + var b; + b = new Buffer(len); + b[meth].call(b, val, 0, true); + return this.push(b); + }; + }; + + NoFilter.prototype.writeUInt8 = _write_gen('writeUInt8', 1); + + NoFilter.prototype.writeUInt16LE = _write_gen('writeUInt16LE', 2); + + NoFilter.prototype.writeUInt16BE = _write_gen('writeUInt16BE', 2); + + NoFilter.prototype.writeUInt32LE = _write_gen('writeUInt32LE', 4); + + NoFilter.prototype.writeUInt32BE = _write_gen('writeUInt32BE', 4); + + NoFilter.prototype.writeInt8 = _write_gen('writeInt8', 1); + + NoFilter.prototype.writeInt16LE = _write_gen('writeInt16LE', 2); + + NoFilter.prototype.writeInt16BE = _write_gen('writeInt16BE', 2); + + NoFilter.prototype.writeInt32LE = _write_gen('writeInt32LE', 4); + + NoFilter.prototype.writeInt32BE = _write_gen('writeInt32BE', 4); + + NoFilter.prototype.writeFloatLE = _write_gen('writeFloatLE', 4); + + NoFilter.prototype.writeFloatBE = _write_gen('writeFloatBE', 4); + + NoFilter.prototype.writeDoubleLE = _write_gen('writeDoubleLE', 8); + + NoFilter.prototype.writeDoubleBE = _write_gen('writeDoubleBE', 8); + + NoFilter.prototype.readUInt8 = _read_gen('readUInt8', 1); + + NoFilter.prototype.readUInt16LE = _read_gen('readUInt16LE', 2); + + NoFilter.prototype.readUInt16BE = _read_gen('readUInt16BE', 2); + + NoFilter.prototype.readUInt32LE = _read_gen('readUInt32LE', 4); + + NoFilter.prototype.readUInt32BE = _read_gen('readUInt32BE', 4); + + NoFilter.prototype.readInt8 = _read_gen('readInt8', 1); + + NoFilter.prototype.readInt16LE = _read_gen('readInt16LE', 2); + + NoFilter.prototype.readInt16BE = _read_gen('readInt16BE', 2); + + NoFilter.prototype.readInt32LE = _read_gen('readInt32LE', 4); + + NoFilter.prototype.readInt32BE = _read_gen('readInt32BE', 4); + + NoFilter.prototype.readFloatLE = _read_gen('readFloatLE', 4); + + NoFilter.prototype.readFloatBE = _read_gen('readFloatBE', 4); + + NoFilter.prototype.readDoubleLE = _read_gen('readDoubleLE', 8); + + NoFilter.prototype.readDoubleBE = _read_gen('readDoubleBE', 8); + + get = function(props) { + var getter, name, results; + results = []; + for (name in props) { + getter = props[name]; + results.push(NoFilter.prototype.__defineGetter__(name, getter)); + } + return results; + }; + + get({ + length: function() { + return this._readableState.length; + } + }); + + return NoFilter; + + })(stream.Transform); + +}).call(this); + + + +}).call(this,require("buffer").Buffer) +},{"buffer":6,"stream":72,"util":78}],51:[function(require,module,exports){ +(function (process){ +'use strict'; + +if (!process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = { nextTick: nextTick }; +} else { + module.exports = process +} + +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } +} + + +}).call(this,require('_process')) +},{"_process":52}],52:[function(require,module,exports){ +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],53:[function(require,module,exports){ +(function (global){ +/*! https://mths.be/punycode v1.4.1 by @mathias */ +;(function(root) { + + /** Detect free variables */ + var freeExports = typeof exports == 'object' && exports && + !exports.nodeType && exports; + var freeModule = typeof module == 'object' && module && + !module.nodeType && module; + var freeGlobal = typeof global == 'object' && global; + if ( + freeGlobal.global === freeGlobal || + freeGlobal.window === freeGlobal || + freeGlobal.self === freeGlobal + ) { + root = freeGlobal; + } + + /** + * The `punycode` object. + * @name punycode + * @type Object + */ + var punycode, + + /** Highest positive signed 32-bit float value */ + maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 + + /** Bootstring parameters */ + base = 36, + tMin = 1, + tMax = 26, + skew = 38, + damp = 700, + initialBias = 72, + initialN = 128, // 0x80 + delimiter = '-', // '\x2D' + + /** Regular expressions */ + regexPunycode = /^xn--/, + regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars + regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators + + /** Error messages */ + errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }, + + /** Convenience shortcuts */ + baseMinusTMin = base - tMin, + floor = Math.floor, + stringFromCharCode = String.fromCharCode, + + /** Temporary variable */ + key; + + /*--------------------------------------------------------------------------*/ + + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error(type) { + throw new RangeError(errors[type]); + } + + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var length = array.length; + var result = []; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } + + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } + + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = [], + counter = 0, + length = string.length, + value, + extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } + + /** + * Creates a string based on an array of numeric code points. + * @see `punycode.ucs2.decode` + * @memberOf punycode.ucs2 + * @name encode + * @param {Array} codePoints The array of numeric code points. + * @returns {String} The new Unicode string (UCS-2). + */ + function ucs2encode(array) { + return map(array, function(value) { + var output = ''; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; + } + output += stringFromCharCode(value); + return output; + }).join(''); + } + + /** + * Converts a basic code point into a digit/integer. + * @see `digitToBasic()` + * @private + * @param {Number} codePoint The basic numeric code point value. + * @returns {Number} The numeric value of a basic code point (for use in + * representing integers) in the range `0` to `base - 1`, or `base` if + * the code point does not represent a value. + */ + function basicToDigit(codePoint) { + if (codePoint - 48 < 10) { + return codePoint - 22; + } + if (codePoint - 65 < 26) { + return codePoint - 65; + } + if (codePoint - 97 < 26) { + return codePoint - 97; + } + return base; + } + + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + } + + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + } + + /** + * Converts a Punycode string of ASCII-only symbols to a string of Unicode + * symbols. + * @memberOf punycode + * @param {String} input The Punycode string of ASCII-only symbols. + * @returns {String} The resulting string of Unicode symbols. + */ + function decode(input) { + // Don't use UCS-2 + var output = [], + inputLength = input.length, + out, + i = 0, + n = initialN, + bias = initialBias, + basic, + j, + index, + oldi, + w, + k, + digit, + t, + /** Cached calculation results */ + baseMinusT; + + // Handle the basic code points: let `basic` be the number of input code + // points before the last delimiter, or `0` if there is none, then copy + // the first basic code points to the output. + + basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } + + for (j = 0; j < basic; ++j) { + // if it's not a basic code point + if (input.charCodeAt(j) >= 0x80) { + error('not-basic'); + } + output.push(input.charCodeAt(j)); + } + + // Main decoding loop: start just after the last delimiter if any basic code + // points were copied; start at the beginning otherwise. + + for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { + + // `index` is the index of the next character to be consumed. + // Decode a generalized variable-length integer into `delta`, + // which gets added to `i`. The overflow checking is easier + // if we increase `i` as we go, then subtract off its starting + // value at the end to obtain `delta`. + for (oldi = i, w = 1, k = base; /* no condition */; k += base) { + + if (index >= inputLength) { + error('invalid-input'); + } + + digit = basicToDigit(input.charCodeAt(index++)); + + if (digit >= base || digit > floor((maxInt - i) / w)) { + error('overflow'); + } + + i += digit * w; + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + + if (digit < t) { + break; + } + + baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error('overflow'); + } + + w *= baseMinusT; + + } + + out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); + + // `i` was supposed to wrap around from `out` to `0`, + // incrementing `n` each time, so we'll fix that now: + if (floor(i / out) > maxInt - n) { + error('overflow'); + } + + n += floor(i / out); + i %= out; + + // Insert `n` at position `i` of the output + output.splice(i++, 0, n); + + } + + return ucs2encode(output); + } + + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + function encode(input) { + var n, + delta, + handledCPCount, + basicLength, + bias, + j, + m, + q, + k, + t, + currentValue, + output = [], + /** `inputLength` will hold the number of code points in `input`. */ + inputLength, + /** Cached calculation results */ + handledCPCountPlusOne, + baseMinusT, + qMinusT; + + // Convert the input in UCS-2 to Unicode + input = ucs2decode(input); + + // Cache the length + inputLength = input.length; + + // Initialize the state + n = initialN; + delta = 0; + bias = initialBias; + + // Handle the basic code points + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue < 0x80) { + output.push(stringFromCharCode(currentValue)); + } + } + + handledCPCount = basicLength = output.length; + + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. + + // Finish the basic string - if it is not empty - with a delimiter + if (basicLength) { + output.push(delimiter); + } + + // Main encoding loop: + while (handledCPCount < inputLength) { + + // All non-basic code points < n have been handled already. Find the next + // larger one: + for (m = maxInt, j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } + + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow + handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error('overflow'); + } + + delta += (m - n) * handledCPCountPlusOne; + n = m; + + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + + if (currentValue < n && ++delta > maxInt) { + error('overflow'); + } + + if (currentValue == n) { + // Represent delta as a generalized variable-length integer + for (q = delta, k = base; /* no condition */; k += base) { + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + if (q < t) { + break; + } + qMinusT = q - t; + baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor(qMinusT / baseMinusT); + } + + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } + + ++delta; + ++n; + + } + return output.join(''); + } + + /** + * Converts a Punycode string representing a domain name or an email address + * to Unicode. Only the Punycoded parts of the input will be converted, i.e. + * it doesn't matter if you call it on a string that has already been + * converted to Unicode. + * @memberOf punycode + * @param {String} input The Punycoded domain name or email address to + * convert to Unicode. + * @returns {String} The Unicode representation of the given Punycode + * string. + */ + function toUnicode(input) { + return mapDomain(input, function(string) { + return regexPunycode.test(string) + ? decode(string.slice(4).toLowerCase()) + : string; + }); + } + + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + function toASCII(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) + ? 'xn--' + encode(string) + : string; + }); + } + + /*--------------------------------------------------------------------------*/ + + /** Define the public API */ + punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + 'version': '1.4.1', + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + 'ucs2': { + 'decode': ucs2decode, + 'encode': ucs2encode + }, + 'decode': decode, + 'encode': encode, + 'toASCII': toASCII, + 'toUnicode': toUnicode + }; + + /** Expose `punycode` */ + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + typeof define == 'function' && + typeof define.amd == 'object' && + define.amd + ) { + define('punycode', function() { + return punycode; + }); + } else if (freeExports && freeModule) { + if (module.exports == freeExports) { + // in Node.js, io.js, or RingoJS v0.8.0+ + freeModule.exports = punycode; + } else { + // in Narwhal or RingoJS v0.7.0- + for (key in punycode) { + punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); + } + } + } else { + // in Rhino or a web browser + root.punycode = punycode; + } + +}(this)); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],54:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +'use strict'; + +// If obj.hasOwnProperty has been overridden, then calling +// obj.hasOwnProperty(prop) will break. +// See: https://github.com/joyent/node/issues/1707 +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +module.exports = function(qs, sep, eq, options) { + sep = sep || '&'; + eq = eq || '='; + var obj = {}; + + if (typeof qs !== 'string' || qs.length === 0) { + return obj; + } + + var regexp = /\+/g; + qs = qs.split(sep); + + var maxKeys = 1000; + if (options && typeof options.maxKeys === 'number') { + maxKeys = options.maxKeys; + } + + var len = qs.length; + // maxKeys <= 0 means that we should not limit keys count + if (maxKeys > 0 && len > maxKeys) { + len = maxKeys; + } + + for (var i = 0; i < len; ++i) { + var x = qs[i].replace(regexp, '%20'), + idx = x.indexOf(eq), + kstr, vstr, k, v; + + if (idx >= 0) { + kstr = x.substr(0, idx); + vstr = x.substr(idx + 1); + } else { + kstr = x; + vstr = ''; + } + + k = decodeURIComponent(kstr); + v = decodeURIComponent(vstr); + + if (!hasOwnProperty(obj, k)) { + obj[k] = v; + } else if (isArray(obj[k])) { + obj[k].push(v); + } else { + obj[k] = [obj[k], v]; + } + } + + return obj; +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + +},{}],55:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +'use strict'; + +var stringifyPrimitive = function(v) { + switch (typeof v) { + case 'string': + return v; + + case 'boolean': + return v ? 'true' : 'false'; + + case 'number': + return isFinite(v) ? v : ''; + + default: + return ''; + } +}; + +module.exports = function(obj, sep, eq, name) { + sep = sep || '&'; + eq = eq || '='; + if (obj === null) { + obj = undefined; + } + + if (typeof obj === 'object') { + return map(objectKeys(obj), function(k) { + var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; + if (isArray(obj[k])) { + return map(obj[k], function(v) { + return ks + encodeURIComponent(stringifyPrimitive(v)); + }).join(sep); + } else { + return ks + encodeURIComponent(stringifyPrimitive(obj[k])); + } + }).join(sep); + + } + + if (!name) return ''; + return encodeURIComponent(stringifyPrimitive(name)) + eq + + encodeURIComponent(stringifyPrimitive(obj)); +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + +function map (xs, f) { + if (xs.map) return xs.map(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + res.push(f(xs[i], i)); + } + return res; +} + +var objectKeys = Object.keys || function (obj) { + var res = []; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); + } + return res; +}; + +},{}],56:[function(require,module,exports){ +'use strict'; + +exports.decode = exports.parse = require('./decode'); +exports.encode = exports.stringify = require('./encode'); + +},{"./decode":54,"./encode":55}],57:[function(require,module,exports){ +module.exports = require('./lib/_stream_duplex.js'); + +},{"./lib/_stream_duplex.js":58}],58:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/**/ + +module.exports = Duplex; + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +{ + // avoid scope creep, the keys array can then be collected + var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + pna.nextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +Object.defineProperty(Duplex.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + pna.nextTick(cb, err); +}; +},{"./_stream_readable":60,"./_stream_writable":62,"core-util-is":18,"inherits":46,"process-nextick-args":51}],59:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +'use strict'; + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":61,"core-util-is":18,"inherits":46}],60:[function(require,module,exports){ +(function (process,global){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Readable; + +/**/ +var isArray = require('isarray'); +/**/ + +/**/ +var Duplex; +/**/ + +Readable.ReadableState = ReadableState; + +/**/ +var EE = require('events').EventEmitter; + +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream = require('./internal/streams/stream'); +/**/ + +/**/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +/**/ +var debugUtil = require('util'); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var BufferList = require('./internal/streams/BufferList'); +var destroyImpl = require('./internal/streams/destroy'); +var StringDecoder; + +util.inherits(Readable, Stream); + +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); + + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} + +function ReadableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // has it been destroyed + this.destroyed = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); +} + +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); + +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + } + } + + return needMoreData(state); +} + +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + + return ret; +}; + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + pna.nextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('_read() is not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, unpipeInfo); + }return this; + } + + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this, unpipeInfo); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + pna.nextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + pna.nextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var _this = this; + + var state = this._readableState; + var paused = false; + + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; +}; + +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._readableState.highWaterMark; + } +}); + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } + + return ret; +} + +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} + +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + pna.nextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./_stream_duplex":58,"./internal/streams/BufferList":63,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":52,"core-util-is":18,"events":44,"inherits":46,"isarray":48,"process-nextick-args":51,"safe-buffer":71,"string_decoder/":66,"util":4}],61:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +'use strict'; + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); + } + + ts.writechunk = null; + ts.writecb = null; + + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + + cb(er); + + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); +} + +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +Transform.prototype._destroy = function (err, cb) { + var _this2 = this; + + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this2.emit('close'); + }); +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); + + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + + return stream.push(null); +} +},{"./_stream_duplex":58,"core-util-is":18,"inherits":46}],62:[function(require,module,exports){ +(function (process,global,setImmediate){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; +/**/ + +/**/ +var Duplex; +/**/ + +Writable.WritableState = WritableState; + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +/**/ +var internalUtil = { + deprecate: require('util-deprecate') +}; +/**/ + +/**/ +var Stream = require('./internal/streams/stream'); +/**/ + +/**/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +var destroyImpl = require('./internal/streams/destroy'); + +util.inherits(Writable, Stream); + +function nop() {} + +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // has it been destroyed + this.destroyed = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); + +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} + +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); + } + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); +}; + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + pna.nextTick(cb, er); +} + +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; + + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + pna.nextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + + return ret; +}; + +Writable.prototype.cork = function () { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; +} + +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + pna.nextTick(cb, er); + // this can emit finish, and it will always happen + // after error + pna.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; + + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + pna.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + } + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} + +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } +} + +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; + } +}); + +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); +}; +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) +},{"./_stream_duplex":58,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":52,"core-util-is":18,"inherits":46,"process-nextick-args":51,"safe-buffer":71,"timers":73,"util-deprecate":76}],63:[function(require,module,exports){ +'use strict'; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Buffer = require('safe-buffer').Buffer; +var util = require('util'); + +function copyBuffer(src, target, offset) { + src.copy(target, offset); +} + +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); + + this.head = null; + this.tail = null; + this.length = 0; + } + + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; + + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; + + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; + + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; + + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; + + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; + }; + + return BufferList; +}(); + +if (util && util.inspect && util.inspect.custom) { + module.exports.prototype[util.inspect.custom] = function () { + var obj = util.inspect({ length: this.length }); + return this.constructor.name + ' ' + obj; + }; +} +},{"safe-buffer":71,"util":4}],64:[function(require,module,exports){ +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + pna.nextTick(emitErrorNT, this, err); + } + return this; + } + + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + if (this._readableState) { + this._readableState.destroyed = true; + } + + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } + + this._destroy(err || null, function (err) { + if (!cb && err) { + pna.nextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); + } + }); + + return this; +} + +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } +} + +function emitErrorNT(self, err) { + self.emit('error', err); +} + +module.exports = { + destroy: destroy, + undestroy: undestroy +}; +},{"process-nextick-args":51}],65:[function(require,module,exports){ +module.exports = require('events').EventEmitter; + +},{"events":44}],66:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +'use strict'; + +/**/ + +var Buffer = require('safe-buffer').Buffer; +/**/ + +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } +}; + +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } +}; + +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); +} + +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; + +StringDecoder.prototype.end = utf8End; + +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; + +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; + +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. If an invalid byte is detected, -2 is returned. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; +} + +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; +} + +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } +} + +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} + +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} + +// For UTF-8, a replacement character is added when ending on a partial +// character. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; +} + +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); +} + +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; +} + +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); +} + +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; +} + +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} + +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} +},{"safe-buffer":71}],67:[function(require,module,exports){ +module.exports = require('./readable').PassThrough + +},{"./readable":68}],68:[function(require,module,exports){ +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); + +},{"./lib/_stream_duplex.js":58,"./lib/_stream_passthrough.js":59,"./lib/_stream_readable.js":60,"./lib/_stream_transform.js":61,"./lib/_stream_writable.js":62}],69:[function(require,module,exports){ +module.exports = require('./readable').Transform + +},{"./readable":68}],70:[function(require,module,exports){ +module.exports = require('./lib/_stream_writable.js'); + +},{"./lib/_stream_writable.js":62}],71:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} + +},{"buffer":6}],72:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +module.exports = Stream; + +var EE = require('events').EventEmitter; +var inherits = require('inherits'); + +inherits(Stream, EE); +Stream.Readable = require('readable-stream/readable.js'); +Stream.Writable = require('readable-stream/writable.js'); +Stream.Duplex = require('readable-stream/duplex.js'); +Stream.Transform = require('readable-stream/transform.js'); +Stream.PassThrough = require('readable-stream/passthrough.js'); + +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; + + + +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. + +function Stream() { + EE.call(this); +} + +Stream.prototype.pipe = function(dest, options) { + var source = this; + + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } + + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); + } + + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } + + source.on('error', onerror); + dest.on('error', onerror); + + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); + } + + source.on('end', cleanup); + source.on('close', cleanup); + + dest.on('close', cleanup); + + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; + +},{"events":44,"inherits":46,"readable-stream/duplex.js":57,"readable-stream/passthrough.js":67,"readable-stream/readable.js":68,"readable-stream/transform.js":69,"readable-stream/writable.js":70}],73:[function(require,module,exports){ +(function (setImmediate,clearImmediate){ +var nextTick = require('process/browser.js').nextTick; +var apply = Function.prototype.apply; +var slice = Array.prototype.slice; +var immediateIds = {}; +var nextImmediateId = 0; + +// DOM APIs, for completeness + +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { timeout.close(); }; + +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; + +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; + +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; + +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; + +// That's not how node.js implements it but the exposed api is the same. +exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { + var id = nextImmediateId++; + var args = arguments.length < 2 ? false : slice.call(arguments, 1); + + immediateIds[id] = true; + + nextTick(function onNextTick() { + if (immediateIds[id]) { + // fn.call() is faster so we optimize for the common use-case + // @see http://jsperf.com/call-apply-segu + if (args) { + fn.apply(null, args); + } else { + fn.call(null); + } + // Prevent ids from leaking + exports.clearImmediate(id); + } + }); + + return id; +}; + +exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { + delete immediateIds[id]; +}; +}).call(this,require("timers").setImmediate,require("timers").clearImmediate) +},{"process/browser.js":52,"timers":73}],74:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +'use strict'; + +var punycode = require('punycode'); +var util = require('./util'); + +exports.parse = urlParse; +exports.resolve = urlResolve; +exports.resolveObject = urlResolveObject; +exports.format = urlFormat; + +exports.Url = Url; + +function Url() { + this.protocol = null; + this.slashes = null; + this.auth = null; + this.host = null; + this.port = null; + this.hostname = null; + this.hash = null; + this.search = null; + this.query = null; + this.pathname = null; + this.path = null; + this.href = null; +} + +// Reference: RFC 3986, RFC 1808, RFC 2396 + +// define these here so at least they only have to be +// compiled once on the first module load. +var protocolPattern = /^([a-z0-9.+-]+:)/i, + portPattern = /:[0-9]*$/, + + // Special case for a simple path URL + simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, + + // RFC 2396: characters reserved for delimiting URLs. + // We actually just auto-escape these. + delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], + + // RFC 2396: characters not allowed for various reasons. + unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), + + // Allowed by RFCs, but cause of XSS attacks. Always escape these. + autoEscape = ['\''].concat(unwise), + // Characters that are never ever allowed in a hostname. + // Note that any invalid chars are also handled, but these + // are the ones that are *expected* to be seen, so we fast-path + // them. + nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), + hostEndingChars = ['/', '?', '#'], + hostnameMaxLen = 255, + hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, + hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, + // protocols that can allow "unsafe" and "unwise" chars. + unsafeProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that never have a hostname. + hostlessProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that always contain a // bit. + slashedProtocol = { + 'http': true, + 'https': true, + 'ftp': true, + 'gopher': true, + 'file': true, + 'http:': true, + 'https:': true, + 'ftp:': true, + 'gopher:': true, + 'file:': true + }, + querystring = require('querystring'); + +function urlParse(url, parseQueryString, slashesDenoteHost) { + if (url && util.isObject(url) && url instanceof Url) return url; + + var u = new Url; + u.parse(url, parseQueryString, slashesDenoteHost); + return u; +} + +Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { + if (!util.isString(url)) { + throw new TypeError("Parameter 'url' must be a string, not " + typeof url); + } + + // Copy chrome, IE, opera backslash-handling behavior. + // Back slashes before the query string get converted to forward slashes + // See: https://code.google.com/p/chromium/issues/detail?id=25916 + var queryIndex = url.indexOf('?'), + splitter = + (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', + uSplit = url.split(splitter), + slashRegex = /\\/g; + uSplit[0] = uSplit[0].replace(slashRegex, '/'); + url = uSplit.join(splitter); + + var rest = url; + + // trim before proceeding. + // This is to support parse stuff like " http://foo.com \n" + rest = rest.trim(); + + if (!slashesDenoteHost && url.split('#').length === 1) { + // Try fast path regexp + var simplePath = simplePathPattern.exec(rest); + if (simplePath) { + this.path = rest; + this.href = rest; + this.pathname = simplePath[1]; + if (simplePath[2]) { + this.search = simplePath[2]; + if (parseQueryString) { + this.query = querystring.parse(this.search.substr(1)); + } else { + this.query = this.search.substr(1); + } + } else if (parseQueryString) { + this.search = ''; + this.query = {}; + } + return this; + } + } + + var proto = protocolPattern.exec(rest); + if (proto) { + proto = proto[0]; + var lowerProto = proto.toLowerCase(); + this.protocol = lowerProto; + rest = rest.substr(proto.length); + } + + // figure out if it's got a host + // user@server is *always* interpreted as a hostname, and url + // resolution will treat //foo/bar as host=foo,path=bar because that's + // how the browser resolves relative URLs. + if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { + var slashes = rest.substr(0, 2) === '//'; + if (slashes && !(proto && hostlessProtocol[proto])) { + rest = rest.substr(2); + this.slashes = true; + } + } + + if (!hostlessProtocol[proto] && + (slashes || (proto && !slashedProtocol[proto]))) { + + // there's a hostname. + // the first instance of /, ?, ;, or # ends the host. + // + // If there is an @ in the hostname, then non-host chars *are* allowed + // to the left of the last @ sign, unless some host-ending character + // comes *before* the @-sign. + // URLs are obnoxious. + // + // ex: + // http://a@b@c/ => user:a@b host:c + // http://a@b?@c => user:a host:c path:/?@c + + // v0.12 TODO(isaacs): This is not quite how Chrome does things. + // Review our test case against browsers more comprehensively. + + // find the first instance of any hostEndingChars + var hostEnd = -1; + for (var i = 0; i < hostEndingChars.length; i++) { + var hec = rest.indexOf(hostEndingChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; + } + + // at this point, either we have an explicit point where the + // auth portion cannot go past, or the last @ char is the decider. + var auth, atSign; + if (hostEnd === -1) { + // atSign can be anywhere. + atSign = rest.lastIndexOf('@'); + } else { + // atSign must be in auth portion. + // http://a@b/c@d => host:b auth:a path:/c@d + atSign = rest.lastIndexOf('@', hostEnd); + } + + // Now we have a portion which is definitely the auth. + // Pull that off. + if (atSign !== -1) { + auth = rest.slice(0, atSign); + rest = rest.slice(atSign + 1); + this.auth = decodeURIComponent(auth); + } + + // the host is the remaining to the left of the first non-host char + hostEnd = -1; + for (var i = 0; i < nonHostChars.length; i++) { + var hec = rest.indexOf(nonHostChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; + } + // if we still have not hit it, then the entire thing is a host. + if (hostEnd === -1) + hostEnd = rest.length; + + this.host = rest.slice(0, hostEnd); + rest = rest.slice(hostEnd); + + // pull out port. + this.parseHost(); + + // we've indicated that there is a hostname, + // so even if it's empty, it has to be present. + this.hostname = this.hostname || ''; + + // if hostname begins with [ and ends with ] + // assume that it's an IPv6 address. + var ipv6Hostname = this.hostname[0] === '[' && + this.hostname[this.hostname.length - 1] === ']'; + + // validate a little. + if (!ipv6Hostname) { + var hostparts = this.hostname.split(/\./); + for (var i = 0, l = hostparts.length; i < l; i++) { + var part = hostparts[i]; + if (!part) continue; + if (!part.match(hostnamePartPattern)) { + var newpart = ''; + for (var j = 0, k = part.length; j < k; j++) { + if (part.charCodeAt(j) > 127) { + // we replace non-ASCII char with a temporary placeholder + // we need this to make sure size of hostname is not + // broken by replacing non-ASCII by nothing + newpart += 'x'; + } else { + newpart += part[j]; + } + } + // we test again with ASCII char only + if (!newpart.match(hostnamePartPattern)) { + var validParts = hostparts.slice(0, i); + var notHost = hostparts.slice(i + 1); + var bit = part.match(hostnamePartStart); + if (bit) { + validParts.push(bit[1]); + notHost.unshift(bit[2]); + } + if (notHost.length) { + rest = '/' + notHost.join('.') + rest; + } + this.hostname = validParts.join('.'); + break; + } + } + } + } + + if (this.hostname.length > hostnameMaxLen) { + this.hostname = ''; + } else { + // hostnames are always lower case. + this.hostname = this.hostname.toLowerCase(); + } + + if (!ipv6Hostname) { + // IDNA Support: Returns a punycoded representation of "domain". + // It only converts parts of the domain name that + // have non-ASCII characters, i.e. it doesn't matter if + // you call it with a domain that already is ASCII-only. + this.hostname = punycode.toASCII(this.hostname); + } + + var p = this.port ? ':' + this.port : ''; + var h = this.hostname || ''; + this.host = h + p; + this.href += this.host; + + // strip [ and ] from the hostname + // the host field still retains them, though + if (ipv6Hostname) { + this.hostname = this.hostname.substr(1, this.hostname.length - 2); + if (rest[0] !== '/') { + rest = '/' + rest; + } + } + } + + // now rest is set to the post-host stuff. + // chop off any delim chars. + if (!unsafeProtocol[lowerProto]) { + + // First, make 100% sure that any "autoEscape" chars get + // escaped, even if encodeURIComponent doesn't think they + // need to be. + for (var i = 0, l = autoEscape.length; i < l; i++) { + var ae = autoEscape[i]; + if (rest.indexOf(ae) === -1) + continue; + var esc = encodeURIComponent(ae); + if (esc === ae) { + esc = escape(ae); + } + rest = rest.split(ae).join(esc); + } + } + + + // chop off from the tail first. + var hash = rest.indexOf('#'); + if (hash !== -1) { + // got a fragment string. + this.hash = rest.substr(hash); + rest = rest.slice(0, hash); + } + var qm = rest.indexOf('?'); + if (qm !== -1) { + this.search = rest.substr(qm); + this.query = rest.substr(qm + 1); + if (parseQueryString) { + this.query = querystring.parse(this.query); + } + rest = rest.slice(0, qm); + } else if (parseQueryString) { + // no query string, but parseQueryString still requested + this.search = ''; + this.query = {}; + } + if (rest) this.pathname = rest; + if (slashedProtocol[lowerProto] && + this.hostname && !this.pathname) { + this.pathname = '/'; + } + + //to support http.request + if (this.pathname || this.search) { + var p = this.pathname || ''; + var s = this.search || ''; + this.path = p + s; + } + + // finally, reconstruct the href based on what has been validated. + this.href = this.format(); + return this; +}; + +// format a parsed object into a url string +function urlFormat(obj) { + // ensure it's an object, and not a string url. + // If it's an obj, this is a no-op. + // this way, you can call url_format() on strings + // to clean up potentially wonky urls. + if (util.isString(obj)) obj = urlParse(obj); + if (!(obj instanceof Url)) return Url.prototype.format.call(obj); + return obj.format(); +} + +Url.prototype.format = function() { + var auth = this.auth || ''; + if (auth) { + auth = encodeURIComponent(auth); + auth = auth.replace(/%3A/i, ':'); + auth += '@'; + } + + var protocol = this.protocol || '', + pathname = this.pathname || '', + hash = this.hash || '', + host = false, + query = ''; + + if (this.host) { + host = auth + this.host; + } else if (this.hostname) { + host = auth + (this.hostname.indexOf(':') === -1 ? + this.hostname : + '[' + this.hostname + ']'); + if (this.port) { + host += ':' + this.port; + } + } + + if (this.query && + util.isObject(this.query) && + Object.keys(this.query).length) { + query = querystring.stringify(this.query); + } + + var search = this.search || (query && ('?' + query)) || ''; + + if (protocol && protocol.substr(-1) !== ':') protocol += ':'; + + // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. + // unless they had them to begin with. + if (this.slashes || + (!protocol || slashedProtocol[protocol]) && host !== false) { + host = '//' + (host || ''); + if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; + } else if (!host) { + host = ''; + } + + if (hash && hash.charAt(0) !== '#') hash = '#' + hash; + if (search && search.charAt(0) !== '?') search = '?' + search; + + pathname = pathname.replace(/[?#]/g, function(match) { + return encodeURIComponent(match); + }); + search = search.replace('#', '%23'); + + return protocol + host + pathname + search + hash; +}; + +function urlResolve(source, relative) { + return urlParse(source, false, true).resolve(relative); +} + +Url.prototype.resolve = function(relative) { + return this.resolveObject(urlParse(relative, false, true)).format(); +}; + +function urlResolveObject(source, relative) { + if (!source) return relative; + return urlParse(source, false, true).resolveObject(relative); +} + +Url.prototype.resolveObject = function(relative) { + if (util.isString(relative)) { + var rel = new Url(); + rel.parse(relative, false, true); + relative = rel; + } + + var result = new Url(); + var tkeys = Object.keys(this); + for (var tk = 0; tk < tkeys.length; tk++) { + var tkey = tkeys[tk]; + result[tkey] = this[tkey]; + } + + // hash is always overridden, no matter what. + // even href="" will remove it. + result.hash = relative.hash; + + // if the relative url is empty, then there's nothing left to do here. + if (relative.href === '') { + result.href = result.format(); + return result; + } + + // hrefs like //foo/bar always cut to the protocol. + if (relative.slashes && !relative.protocol) { + // take everything except the protocol from relative + var rkeys = Object.keys(relative); + for (var rk = 0; rk < rkeys.length; rk++) { + var rkey = rkeys[rk]; + if (rkey !== 'protocol') + result[rkey] = relative[rkey]; + } + + //urlParse appends trailing / to urls like http://www.example.com + if (slashedProtocol[result.protocol] && + result.hostname && !result.pathname) { + result.path = result.pathname = '/'; + } + + result.href = result.format(); + return result; + } + + if (relative.protocol && relative.protocol !== result.protocol) { + // if it's a known url protocol, then changing + // the protocol does weird things + // first, if it's not file:, then we MUST have a host, + // and if there was a path + // to begin with, then we MUST have a path. + // if it is file:, then the host is dropped, + // because that's known to be hostless. + // anything else is assumed to be absolute. + if (!slashedProtocol[relative.protocol]) { + var keys = Object.keys(relative); + for (var v = 0; v < keys.length; v++) { + var k = keys[v]; + result[k] = relative[k]; + } + result.href = result.format(); + return result; + } + + result.protocol = relative.protocol; + if (!relative.host && !hostlessProtocol[relative.protocol]) { + var relPath = (relative.pathname || '').split('/'); + while (relPath.length && !(relative.host = relPath.shift())); + if (!relative.host) relative.host = ''; + if (!relative.hostname) relative.hostname = ''; + if (relPath[0] !== '') relPath.unshift(''); + if (relPath.length < 2) relPath.unshift(''); + result.pathname = relPath.join('/'); + } else { + result.pathname = relative.pathname; + } + result.search = relative.search; + result.query = relative.query; + result.host = relative.host || ''; + result.auth = relative.auth; + result.hostname = relative.hostname || relative.host; + result.port = relative.port; + // to support http.request + if (result.pathname || result.search) { + var p = result.pathname || ''; + var s = result.search || ''; + result.path = p + s; + } + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; + } + + var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), + isRelAbs = ( + relative.host || + relative.pathname && relative.pathname.charAt(0) === '/' + ), + mustEndAbs = (isRelAbs || isSourceAbs || + (result.host && relative.pathname)), + removeAllDots = mustEndAbs, + srcPath = result.pathname && result.pathname.split('/') || [], + relPath = relative.pathname && relative.pathname.split('/') || [], + psychotic = result.protocol && !slashedProtocol[result.protocol]; + + // if the url is a non-slashed url, then relative + // links like ../.. should be able + // to crawl up to the hostname, as well. This is strange. + // result.protocol has already been set by now. + // Later on, put the first path part into the host field. + if (psychotic) { + result.hostname = ''; + result.port = null; + if (result.host) { + if (srcPath[0] === '') srcPath[0] = result.host; + else srcPath.unshift(result.host); + } + result.host = ''; + if (relative.protocol) { + relative.hostname = null; + relative.port = null; + if (relative.host) { + if (relPath[0] === '') relPath[0] = relative.host; + else relPath.unshift(relative.host); + } + relative.host = null; + } + mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); + } + + if (isRelAbs) { + // it's absolute. + result.host = (relative.host || relative.host === '') ? + relative.host : result.host; + result.hostname = (relative.hostname || relative.hostname === '') ? + relative.hostname : result.hostname; + result.search = relative.search; + result.query = relative.query; + srcPath = relPath; + // fall through to the dot-handling below. + } else if (relPath.length) { + // it's relative + // throw away the existing file, and take the new path instead. + if (!srcPath) srcPath = []; + srcPath.pop(); + srcPath = srcPath.concat(relPath); + result.search = relative.search; + result.query = relative.query; + } else if (!util.isNullOrUndefined(relative.search)) { + // just pull out the search. + // like href='?foo'. + // Put this after the other two cases because it simplifies the booleans + if (psychotic) { + result.hostname = result.host = srcPath.shift(); + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + var authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } + } + result.search = relative.search; + result.query = relative.query; + //to support http.request + if (!util.isNull(result.pathname) || !util.isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.href = result.format(); + return result; + } + + if (!srcPath.length) { + // no path at all. easy. + // we've already handled the other stuff above. + result.pathname = null; + //to support http.request + if (result.search) { + result.path = '/' + result.search; + } else { + result.path = null; + } + result.href = result.format(); + return result; + } + + // if a url ENDs in . or .., then it must get a trailing slash. + // however, if it ends in anything else non-slashy, + // then it must NOT get a trailing slash. + var last = srcPath.slice(-1)[0]; + var hasTrailingSlash = ( + (result.host || relative.host || srcPath.length > 1) && + (last === '.' || last === '..') || last === ''); + + // strip single dots, resolve double dots to parent dir + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = srcPath.length; i >= 0; i--) { + last = srcPath[i]; + if (last === '.') { + srcPath.splice(i, 1); + } else if (last === '..') { + srcPath.splice(i, 1); + up++; + } else if (up) { + srcPath.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (!mustEndAbs && !removeAllDots) { + for (; up--; up) { + srcPath.unshift('..'); + } + } + + if (mustEndAbs && srcPath[0] !== '' && + (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { + srcPath.unshift(''); + } + + if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { + srcPath.push(''); + } + + var isAbsolute = srcPath[0] === '' || + (srcPath[0] && srcPath[0].charAt(0) === '/'); + + // put the host back + if (psychotic) { + result.hostname = result.host = isAbsolute ? '' : + srcPath.length ? srcPath.shift() : ''; + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + var authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } + } + + mustEndAbs = mustEndAbs || (result.host && srcPath.length); + + if (mustEndAbs && !isAbsolute) { + srcPath.unshift(''); + } + + if (!srcPath.length) { + result.pathname = null; + result.path = null; + } else { + result.pathname = srcPath.join('/'); + } + + //to support request.http + if (!util.isNull(result.pathname) || !util.isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.auth = relative.auth || result.auth; + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; +}; + +Url.prototype.parseHost = function() { + var host = this.host; + var port = portPattern.exec(host); + if (port) { + port = port[0]; + if (port !== ':') { + this.port = port.substr(1); + } + host = host.substr(0, host.length - port.length); + } + if (host) this.hostname = host; +}; + +},{"./util":75,"punycode":53,"querystring":56}],75:[function(require,module,exports){ +'use strict'; + +module.exports = { + isString: function(arg) { + return typeof(arg) === 'string'; + }, + isObject: function(arg) { + return typeof(arg) === 'object' && arg !== null; + }, + isNull: function(arg) { + return arg === null; + }, + isNullOrUndefined: function(arg) { + return arg == null; + } +}; + +},{}],76:[function(require,module,exports){ +(function (global){ + +/** + * Module exports. + */ + +module.exports = deprecate; + +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + +function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +} + +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ + +function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; + } + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],77:[function(require,module,exports){ +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; +} +},{}],78:[function(require,module,exports){ +(function (process,global){ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + if (process.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +}; + + +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; +}; + + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = require('./support/isBuffer'); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = require('inherits'); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./support/isBuffer":77,"_process":52,"inherits":46}],79:[function(require,module,exports){ +var cbor = require('cbor'); +var bs58 = require('bs58'); +var CRC = require('crc'); + +function getDecoded(address) { + try { + var decoded = bs58.decode(address); + return decoded = cbor.decode(decoded); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } +} + +module.exports = { + isValidAddress: function (address) { + var decoded = getDecoded(address); + + if (!decoded || (!Array.isArray(decoded) && decoded.length != 2)) { + return false; + } + + var tagged = decoded[0]; + var validCrc = decoded[1]; + if (!tagged instanceof cbor.Tagged) { + return false; + } + if (typeof (validCrc) != 'number') { + return false; + } + + // not sure what this is + if (tagged.tag != 24) { + return false; + } + + // get crc of the payload + var crc = CRC.crc32(tagged.value); + + return crc == validCrc; + } +}; + +},{"bs58":5,"cbor":7,"crc":43}],80:[function(require,module,exports){ +var base58 = require('./crypto/base58'); +var segwit = require('./crypto/segwit_addr'); +var cryptoUtils = require('./crypto/utils'); + +var DEFAULT_NETWORK_TYPE = 'prod'; + +function getDecoded(address) { + try { + return base58.decode(address); + } catch (e) { + // if decoding fails, assume invalid address + return null; + } +} + +function getChecksum(hashFunction, payload) { + // Each currency may implement different hashing algorithm + switch (hashFunction) { + case 'blake256': + return cryptoUtils.blake256Checksum(payload); + break; + case 'sha256': + default: + return cryptoUtils.sha256Checksum(payload); + } +} + +function getAddressType(address, currency) { + currency = currency || {}; + // should be 25 bytes per btc address spec and 26 decred + var expectedLength = currency.expectedLength || 25; + var hashFunction = currency.hashFunction || 'sha256'; + var decoded = getDecoded(address); + + if (decoded) { + var length = decoded.length; + + if (length !== expectedLength) { + return null; + } + + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), + body = cryptoUtils.toHex(decoded.slice(0, length - 4)), + goodChecksum = getChecksum(hashFunction, body); + + return checksum === goodChecksum ? cryptoUtils.toHex(decoded.slice(0, expectedLength - 24)) : null; + } + + return null; +} + +function isValidP2PKHandP2SHAddress(address, currency, networkType) { + networkType = networkType || DEFAULT_NETWORK_TYPE; + + var correctAddressTypes; + var addressType = getAddressType(address, currency); + + if (addressType) { + if (networkType === 'prod' || networkType === 'testnet') { + correctAddressTypes = currency.addressTypes[networkType] + } else { + correctAddressTypes = currency.addressTypes.prod.concat(currency.addressTypes.testnet); + } + + return correctAddressTypes.indexOf(addressType) >= 0; + } + + return false; +} + +module.exports = { + isValidAddress: function (address, currency, networkType) { + return isValidP2PKHandP2SHAddress(address, currency, networkType) || segwit.isValidAddress(address); + } +}; + +},{"./crypto/base58":81,"./crypto/segwit_addr":86,"./crypto/utils":88}],81:[function(require,module,exports){ +// Base58 encoding/decoding +// Originally written by Mike Hearn for BitcoinJ +// Copyright (c) 2011 Google Inc +// Ported to JavaScript by Stefan Thomas +// Merged Buffer refactorings from base58-native by Stephen Pair +// Copyright (c) 2013 BitPay Inc + +var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; +var ALPHABET_MAP = {}; +for (var i = 0; i < ALPHABET.length; ++i) { + ALPHABET_MAP[ALPHABET.charAt(i)] = i; +} +var BASE = ALPHABET.length; + +module.exports = { + decode: function(string) { + if (string.length === 0) return []; + + var i, j, bytes = [0]; + for (i = 0; i < string.length; ++i) { + var c = string[i]; + if (!(c in ALPHABET_MAP)) throw new Error('Non-base58 character'); + + for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE + bytes[0] += ALPHABET_MAP[c]; + + var carry = 0; + for (j = 0; j < bytes.length; ++j) { + bytes[j] += carry; + carry = bytes[j] >> 8; + bytes[j] &= 0xff + } + + while (carry) { + bytes.push(carry & 0xff); + carry >>= 8; + } + } + // deal with leading zeros + for (i = 0; string[i] === '1' && i < string.length - 1; ++i){ + bytes.push(0); + } + + return bytes.reverse(); + } +}; + +},{}],82:[function(require,module,exports){ +// Copyright (c) 2017 Pieter Wuille +// +// 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. + +var CHARSET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'; +var GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]; + +module.exports = { + decode: decode, + encode: encode, +}; + + +function polymod (values) { + var chk = 1; + for (var p = 0; p < values.length; ++p) { + var top = chk >> 25; + chk = (chk & 0x1ffffff) << 5 ^ values[p]; + for (var i = 0; i < 5; ++i) { + if ((top >> i) & 1) { + chk ^= GENERATOR[i]; + } + } + } + return chk; +} + +function hrpExpand (hrp) { + var ret = []; + var p; + for (p = 0; p < hrp.length; ++p) { + ret.push(hrp.charCodeAt(p) >> 5); + } + ret.push(0); + for (p = 0; p < hrp.length; ++p) { + ret.push(hrp.charCodeAt(p) & 31); + } + return ret; +} + +function verifyChecksum (hrp, data) { + return polymod(hrpExpand(hrp).concat(data)) === 1; +} + +function createChecksum (hrp, data) { + var values = hrpExpand(hrp).concat(data).concat([0, 0, 0, 0, 0, 0]); + var mod = polymod(values) ^ 1; + var ret = []; + for (var p = 0; p < 6; ++p) { + ret.push((mod >> 5 * (5 - p)) & 31); + } + return ret; +} + +function encode (hrp, data) { + var combined = data.concat(createChecksum(hrp, data)); + var ret = hrp + '1'; + for (var p = 0; p < combined.length; ++p) { + ret += CHARSET.charAt(combined[p]); + } + return ret; +} + +function decode (bechString) { + var p; + var has_lower = false; + var has_upper = false; + for (p = 0; p < bechString.length; ++p) { + if (bechString.charCodeAt(p) < 33 || bechString.charCodeAt(p) > 126) { + return null; + } + if (bechString.charCodeAt(p) >= 97 && bechString.charCodeAt(p) <= 122) { + has_lower = true; + } + if (bechString.charCodeAt(p) >= 65 && bechString.charCodeAt(p) <= 90) { + has_upper = true; + } + } + if (has_lower && has_upper) { + return null; + } + bechString = bechString.toLowerCase(); + var pos = bechString.lastIndexOf('1'); + if (pos < 1 || pos + 7 > bechString.length || bechString.length > 90) { + return null; + } + var hrp = bechString.substring(0, pos); + var data = []; + for (p = pos + 1; p < bechString.length; ++p) { + var d = CHARSET.indexOf(bechString.charAt(p)); + if (d === -1) { + return null; + } + data.push(d); + } + if (!verifyChecksum(hrp, data)) { + return null; + } + return {hrp: hrp, data: data.slice(0, data.length - 6)}; +} + +},{}],83:[function(require,module,exports){ +/* + JavaScript BigInteger library version 0.9.1 + http://silentmatt.com/biginteger/ + Copyright (c) 2009 Matthew Crumley + Copyright (c) 2010,2011 by John Tobey + Licensed under the MIT license. + Support for arbitrary internal representation base was added by + Vitaly Magerya. +*/ + +/* + File: biginteger.js + Exports: + +*/ +(function(exports) { + "use strict"; + /* + Class: BigInteger + An arbitrarily-large integer. + objects should be considered immutable. None of the "built-in" + methods modify *this* or their arguments. All properties should be + considered private. + All the methods of instances can be called "statically". The + static versions are convenient if you don't already have a + object. + As an example, these calls are equivalent. + > BigInteger(4).multiply(5); // returns BigInteger(20); + > BigInteger.multiply(4, 5); // returns BigInteger(20); + > var a = 42; + > var a = BigInteger.toJSValue("0b101010"); // Not completely useless... + */ + + var CONSTRUCT = {}; // Unique token to call "private" version of constructor + + /* + Constructor: BigInteger() + Convert a value to a . + Although is the constructor for objects, it is + best not to call it as a constructor. If *n* is a object, it is + simply returned as-is. Otherwise, is equivalent to + without a radix argument. + > var n0 = BigInteger(); // Same as + > var n1 = BigInteger("123"); // Create a new with value 123 + > var n2 = BigInteger(123); // Create a new with value 123 + > var n3 = BigInteger(n2); // Return n2, unchanged + The constructor form only takes an array and a sign. *n* must be an + array of numbers in little-endian order, where each digit is between 0 + and BigInteger.base. The second parameter sets the sign: -1 for + negative, +1 for positive, or 0 for zero. The array is *not copied and + may be modified*. If the array contains only zeros, the sign parameter + is ignored and is forced to zero. + > new BigInteger([5], -1): create a new BigInteger with value -5 + Parameters: + n - Value to convert to a . + Returns: + A value. + See Also: + , + */ + function BigInteger(n, s, token) { + + if (token !== CONSTRUCT) { + if (n instanceof BigInteger) { + return n; + } + else if (typeof n === "undefined") { + return ZERO; + } + return BigInteger.parse(n); + } + + n = n || []; // Provide the nullary constructor for subclasses. + while (n.length && !n[n.length - 1]) { + --n.length; + } + this._d = n; + this._s = n.length ? (s || 1) : 0; + } + + BigInteger._construct = function(n, s) { + return new BigInteger(n, s, CONSTRUCT); + }; + + // Base-10 speedup hacks in parse, toString, exp10 and log functions + // require base to be a power of 10. 10^7 is the largest such power + // that won't cause a precision loss when digits are multiplied. + var BigInteger_base = 10000000; + var BigInteger_base_log10 = 7; + + BigInteger.base = BigInteger_base; + BigInteger.base_log10 = BigInteger_base_log10; + + var ZERO = new BigInteger([], 0, CONSTRUCT); + // Constant: ZERO + // 0. + BigInteger.ZERO = ZERO; + + var ONE = new BigInteger([1], 1, CONSTRUCT); + // Constant: ONE + // 1. + BigInteger.ONE = ONE; + + var M_ONE = new BigInteger(ONE._d, -1, CONSTRUCT); + // Constant: M_ONE + // -1. + BigInteger.M_ONE = M_ONE; + + // Constant: _0 + // Shortcut for . + BigInteger._0 = ZERO; + + // Constant: _1 + // Shortcut for . + BigInteger._1 = ONE; + + /* + Constant: small + Array of from 0 to 36. + These are used internally for parsing, but useful when you need a "small" + . + See Also: + , , <_0>, <_1> + */ + BigInteger.small = [ + ZERO, + ONE, + /* Assuming BigInteger_base > 36 */ + new BigInteger( [2], 1, CONSTRUCT), + new BigInteger( [3], 1, CONSTRUCT), + new BigInteger( [4], 1, CONSTRUCT), + new BigInteger( [5], 1, CONSTRUCT), + new BigInteger( [6], 1, CONSTRUCT), + new BigInteger( [7], 1, CONSTRUCT), + new BigInteger( [8], 1, CONSTRUCT), + new BigInteger( [9], 1, CONSTRUCT), + new BigInteger([10], 1, CONSTRUCT), + new BigInteger([11], 1, CONSTRUCT), + new BigInteger([12], 1, CONSTRUCT), + new BigInteger([13], 1, CONSTRUCT), + new BigInteger([14], 1, CONSTRUCT), + new BigInteger([15], 1, CONSTRUCT), + new BigInteger([16], 1, CONSTRUCT), + new BigInteger([17], 1, CONSTRUCT), + new BigInteger([18], 1, CONSTRUCT), + new BigInteger([19], 1, CONSTRUCT), + new BigInteger([20], 1, CONSTRUCT), + new BigInteger([21], 1, CONSTRUCT), + new BigInteger([22], 1, CONSTRUCT), + new BigInteger([23], 1, CONSTRUCT), + new BigInteger([24], 1, CONSTRUCT), + new BigInteger([25], 1, CONSTRUCT), + new BigInteger([26], 1, CONSTRUCT), + new BigInteger([27], 1, CONSTRUCT), + new BigInteger([28], 1, CONSTRUCT), + new BigInteger([29], 1, CONSTRUCT), + new BigInteger([30], 1, CONSTRUCT), + new BigInteger([31], 1, CONSTRUCT), + new BigInteger([32], 1, CONSTRUCT), + new BigInteger([33], 1, CONSTRUCT), + new BigInteger([34], 1, CONSTRUCT), + new BigInteger([35], 1, CONSTRUCT), + new BigInteger([36], 1, CONSTRUCT) + ]; + + // Used for parsing/radix conversion + BigInteger.digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""); + + /* + Method: toString + Convert a to a string. + When *base* is greater than 10, letters are upper case. + Parameters: + base - Optional base to represent the number in (default is base 10). + Must be between 2 and 36 inclusive, or an Error will be thrown. + Returns: + The string representation of the . + */ + BigInteger.prototype.toString = function(base) { + base = +base || 10; + if (base < 2 || base > 36) { + throw new Error("illegal radix " + base + "."); + } + if (this._s === 0) { + return "0"; + } + if (base === 10) { + var str = this._s < 0 ? "-" : ""; + str += this._d[this._d.length - 1].toString(); + for (var i = this._d.length - 2; i >= 0; i--) { + var group = this._d[i].toString(); + while (group.length < BigInteger_base_log10) group = '0' + group; + str += group; + } + return str; + } + else { + var numerals = BigInteger.digits; + base = BigInteger.small[base]; + var sign = this._s; + + var n = this.abs(); + var digits = []; + var digit; + + while (n._s !== 0) { + var divmod = n.divRem(base); + n = divmod[0]; + digit = divmod[1]; + // TODO: This could be changed to unshift instead of reversing at the end. + // Benchmark both to compare speeds. + digits.push(numerals[digit.valueOf()]); + } + return (sign < 0 ? "-" : "") + digits.reverse().join(""); + } + }; + + // Verify strings for parsing + BigInteger.radixRegex = [ + /^$/, + /^$/, + /^[01]*$/, + /^[012]*$/, + /^[0-3]*$/, + /^[0-4]*$/, + /^[0-5]*$/, + /^[0-6]*$/, + /^[0-7]*$/, + /^[0-8]*$/, + /^[0-9]*$/, + /^[0-9aA]*$/, + /^[0-9abAB]*$/, + /^[0-9abcABC]*$/, + /^[0-9a-dA-D]*$/, + /^[0-9a-eA-E]*$/, + /^[0-9a-fA-F]*$/, + /^[0-9a-gA-G]*$/, + /^[0-9a-hA-H]*$/, + /^[0-9a-iA-I]*$/, + /^[0-9a-jA-J]*$/, + /^[0-9a-kA-K]*$/, + /^[0-9a-lA-L]*$/, + /^[0-9a-mA-M]*$/, + /^[0-9a-nA-N]*$/, + /^[0-9a-oA-O]*$/, + /^[0-9a-pA-P]*$/, + /^[0-9a-qA-Q]*$/, + /^[0-9a-rA-R]*$/, + /^[0-9a-sA-S]*$/, + /^[0-9a-tA-T]*$/, + /^[0-9a-uA-U]*$/, + /^[0-9a-vA-V]*$/, + /^[0-9a-wA-W]*$/, + /^[0-9a-xA-X]*$/, + /^[0-9a-yA-Y]*$/, + /^[0-9a-zA-Z]*$/ + ]; + + /* + Function: parse + Parse a string into a . + *base* is optional but, if provided, must be from 2 to 36 inclusive. If + *base* is not provided, it will be guessed based on the leading characters + of *s* as follows: + - "0x" or "0X": *base* = 16 + - "0c" or "0C": *base* = 8 + - "0b" or "0B": *base* = 2 + - else: *base* = 10 + If no base is provided, or *base* is 10, the number can be in exponential + form. For example, these are all valid: + > BigInteger.parse("1e9"); // Same as "1000000000" + > BigInteger.parse("1.234*10^3"); // Same as 1234 + > BigInteger.parse("56789 * 10 ** -2"); // Same as 567 + If any characters fall outside the range defined by the radix, an exception + will be thrown. + Parameters: + s - The string to parse. + base - Optional radix (default is to guess based on *s*). + Returns: + a instance. + */ + BigInteger.parse = function(s, base) { + // Expands a number in exponential form to decimal form. + // expandExponential("-13.441*10^5") === "1344100"; + // expandExponential("1.12300e-1") === "0.112300"; + // expandExponential(1000000000000000000000000000000) === "1000000000000000000000000000000"; + function expandExponential(str) { + str = str.replace(/\s*[*xX]\s*10\s*(\^|\*\*)\s*/, "e"); + + return str.replace(/^([+\-])?(\d+)\.?(\d*)[eE]([+\-]?\d+)$/, function(x, s, n, f, c) { + c = +c; + var l = c < 0; + var i = n.length + c; + x = (l ? n : f).length; + c = ((c = Math.abs(c)) >= x ? c - x + l : 0); + var z = (new Array(c + 1)).join("0"); + var r = n + f; + return (s || "") + (l ? r = z + r : r += z).substr(0, i += l ? z.length : 0) + (i < r.length ? "." + r.substr(i) : ""); + }); + } + + s = s.toString(); + if (typeof base === "undefined" || +base === 10) { + s = expandExponential(s); + } + + var prefixRE; + if (typeof base === "undefined") { + prefixRE = '0[xcb]'; + } + else if (base == 16) { + prefixRE = '0x'; + } + else if (base == 8) { + prefixRE = '0c'; + } + else if (base == 2) { + prefixRE = '0b'; + } + else { + prefixRE = ''; + } + var parts = new RegExp('^([+\\-]?)(' + prefixRE + ')?([0-9a-z]*)(?:\\.\\d*)?$', 'i').exec(s); + if (parts) { + var sign = parts[1] || "+"; + var baseSection = parts[2] || ""; + var digits = parts[3] || ""; + + if (typeof base === "undefined") { + // Guess base + if (baseSection === "0x" || baseSection === "0X") { // Hex + base = 16; + } + else if (baseSection === "0c" || baseSection === "0C") { // Octal + base = 8; + } + else if (baseSection === "0b" || baseSection === "0B") { // Binary + base = 2; + } + else { + base = 10; + } + } + else if (base < 2 || base > 36) { + throw new Error("Illegal radix " + base + "."); + } + + base = +base; + + // Check for digits outside the range + if (!(BigInteger.radixRegex[base].test(digits))) { + throw new Error("Bad digit for radix " + base); + } + + // Strip leading zeros, and convert to array + digits = digits.replace(/^0+/, "").split(""); + if (digits.length === 0) { + return ZERO; + } + + // Get the sign (we know it's not zero) + sign = (sign === "-") ? -1 : 1; + + // Optimize 10 + if (base == 10) { + var d = []; + while (digits.length >= BigInteger_base_log10) { + d.push(parseInt(digits.splice(digits.length-BigInteger.base_log10, BigInteger.base_log10).join(''), 10)); + } + d.push(parseInt(digits.join(''), 10)); + return new BigInteger(d, sign, CONSTRUCT); + } + + // Do the conversion + var d = ZERO; + base = BigInteger.small[base]; + var small = BigInteger.small; + for (var i = 0; i < digits.length; i++) { + d = d.multiply(base).add(small[parseInt(digits[i], 36)]); + } + return new BigInteger(d._d, sign, CONSTRUCT); + } + else { + throw new Error("Invalid BigInteger format: " + s); + } + }; + + /* + Function: add + Add two . + Parameters: + n - The number to add to *this*. Will be converted to a . + Returns: + The numbers added together. + See Also: + , , , + */ + BigInteger.prototype.add = function(n) { + if (this._s === 0) { + return BigInteger(n); + } + + n = BigInteger(n); + if (n._s === 0) { + return this; + } + if (this._s !== n._s) { + n = n.negate(); + return this.subtract(n); + } + + var a = this._d; + var b = n._d; + var al = a.length; + var bl = b.length; + var sum = new Array(Math.max(al, bl) + 1); + var size = Math.min(al, bl); + var carry = 0; + var digit; + + for (var i = 0; i < size; i++) { + digit = a[i] + b[i] + carry; + sum[i] = digit % BigInteger_base; + carry = (digit / BigInteger_base) | 0; + } + if (bl > al) { + a = b; + al = bl; + } + for (i = size; carry && i < al; i++) { + digit = a[i] + carry; + sum[i] = digit % BigInteger_base; + carry = (digit / BigInteger_base) | 0; + } + if (carry) { + sum[i] = carry; + } + + for ( ; i < al; i++) { + sum[i] = a[i]; + } + + return new BigInteger(sum, this._s, CONSTRUCT); + }; + + /* + Function: negate + Get the additive inverse of a . + Returns: + A with the same magnatude, but with the opposite sign. + See Also: + + */ + BigInteger.prototype.negate = function() { + return new BigInteger(this._d, (-this._s) | 0, CONSTRUCT); + }; + + /* + Function: abs + Get the absolute value of a . + Returns: + A with the same magnatude, but always positive (or zero). + See Also: + + */ + BigInteger.prototype.abs = function() { + return (this._s < 0) ? this.negate() : this; + }; + + /* + Function: subtract + Subtract two . + Parameters: + n - The number to subtract from *this*. Will be converted to a . + Returns: + The *n* subtracted from *this*. + See Also: + , , , + */ + BigInteger.prototype.subtract = function(n) { + if (this._s === 0) { + return BigInteger(n).negate(); + } + + n = BigInteger(n); + if (n._s === 0) { + return this; + } + if (this._s !== n._s) { + n = n.negate(); + return this.add(n); + } + + var m = this; + // negative - negative => -|a| - -|b| => -|a| + |b| => |b| - |a| + if (this._s < 0) { + m = new BigInteger(n._d, 1, CONSTRUCT); + n = new BigInteger(this._d, 1, CONSTRUCT); + } + + // Both are positive => a - b + var sign = m.compareAbs(n); + if (sign === 0) { + return ZERO; + } + else if (sign < 0) { + // swap m and n + var t = n; + n = m; + m = t; + } + + // a > b + var a = m._d; + var b = n._d; + var al = a.length; + var bl = b.length; + var diff = new Array(al); // al >= bl since a > b + var borrow = 0; + var i; + var digit; + + for (i = 0; i < bl; i++) { + digit = a[i] - borrow - b[i]; + if (digit < 0) { + digit += BigInteger_base; + borrow = 1; + } + else { + borrow = 0; + } + diff[i] = digit; + } + for (i = bl; i < al; i++) { + digit = a[i] - borrow; + if (digit < 0) { + digit += BigInteger_base; + } + else { + diff[i++] = digit; + break; + } + diff[i] = digit; + } + for ( ; i < al; i++) { + diff[i] = a[i]; + } + + return new BigInteger(diff, sign, CONSTRUCT); + }; + + (function() { + function addOne(n, sign) { + var a = n._d; + var sum = a.slice(); + var carry = true; + var i = 0; + + while (true) { + var digit = (a[i] || 0) + 1; + sum[i] = digit % BigInteger_base; + if (digit <= BigInteger_base - 1) { + break; + } + ++i; + } + + return new BigInteger(sum, sign, CONSTRUCT); + } + + function subtractOne(n, sign) { + var a = n._d; + var sum = a.slice(); + var borrow = true; + var i = 0; + + while (true) { + var digit = (a[i] || 0) - 1; + if (digit < 0) { + sum[i] = digit + BigInteger_base; + } + else { + sum[i] = digit; + break; + } + ++i; + } + + return new BigInteger(sum, sign, CONSTRUCT); + } + + /* + Function: next + Get the next (add one). + Returns: + *this* + 1. + See Also: + , + */ + BigInteger.prototype.next = function() { + switch (this._s) { + case 0: + return ONE; + case -1: + return subtractOne(this, -1); + // case 1: + default: + return addOne(this, 1); + } + }; + + /* + Function: prev + Get the previous (subtract one). + Returns: + *this* - 1. + See Also: + , + */ + BigInteger.prototype.prev = function() { + switch (this._s) { + case 0: + return M_ONE; + case -1: + return addOne(this, -1); + // case 1: + default: + return subtractOne(this, 1); + } + }; + })(); + + /* + Function: compareAbs + Compare the absolute value of two . + Calling is faster than calling twice, then . + Parameters: + n - The number to compare to *this*. Will be converted to a . + Returns: + -1, 0, or +1 if *|this|* is less than, equal to, or greater than *|n|*. + See Also: + , + */ + BigInteger.prototype.compareAbs = function(n) { + if (this === n) { + return 0; + } + + if (!(n instanceof BigInteger)) { + if (!isFinite(n)) { + return(isNaN(n) ? n : -1); + } + n = BigInteger(n); + } + + if (this._s === 0) { + return (n._s !== 0) ? -1 : 0; + } + if (n._s === 0) { + return 1; + } + + var l = this._d.length; + var nl = n._d.length; + if (l < nl) { + return -1; + } + else if (l > nl) { + return 1; + } + + var a = this._d; + var b = n._d; + for (var i = l-1; i >= 0; i--) { + if (a[i] !== b[i]) { + return a[i] < b[i] ? -1 : 1; + } + } + + return 0; + }; + + /* + Function: compare + Compare two . + Parameters: + n - The number to compare to *this*. Will be converted to a . + Returns: + -1, 0, or +1 if *this* is less than, equal to, or greater than *n*. + See Also: + , , , + */ + BigInteger.prototype.compare = function(n) { + if (this === n) { + return 0; + } + + n = BigInteger(n); + + if (this._s === 0) { + return -n._s; + } + + if (this._s === n._s) { // both positive or both negative + var cmp = this.compareAbs(n); + return cmp * this._s; + } + else { + return this._s; + } + }; + + /* + Function: isUnit + Return true iff *this* is either 1 or -1. + Returns: + true if *this* compares equal to or . + See Also: + , , , , , + , + */ + BigInteger.prototype.isUnit = function() { + return this === ONE || + this === M_ONE || + (this._d.length === 1 && this._d[0] === 1); + }; + + /* + Function: multiply + Multiply two . + Parameters: + n - The number to multiply *this* by. Will be converted to a + . + Returns: + The numbers multiplied together. + See Also: + , , , + */ + BigInteger.prototype.multiply = function(n) { + // TODO: Consider adding Karatsuba multiplication for large numbers + if (this._s === 0) { + return ZERO; + } + + n = BigInteger(n); + if (n._s === 0) { + return ZERO; + } + if (this.isUnit()) { + if (this._s < 0) { + return n.negate(); + } + return n; + } + if (n.isUnit()) { + if (n._s < 0) { + return this.negate(); + } + return this; + } + if (this === n) { + return this.square(); + } + + var r = (this._d.length >= n._d.length); + var a = (r ? this : n)._d; // a will be longer than b + var b = (r ? n : this)._d; + var al = a.length; + var bl = b.length; + + var pl = al + bl; + var partial = new Array(pl); + var i; + for (i = 0; i < pl; i++) { + partial[i] = 0; + } + + for (i = 0; i < bl; i++) { + var carry = 0; + var bi = b[i]; + var jlimit = al + i; + var digit; + for (var j = i; j < jlimit; j++) { + digit = partial[j] + bi * a[j - i] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = (digit % BigInteger_base) | 0; + } + if (carry) { + digit = partial[j] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = digit % BigInteger_base; + } + } + return new BigInteger(partial, this._s * n._s, CONSTRUCT); + }; + + // Multiply a BigInteger by a single-digit native number + // Assumes that this and n are >= 0 + // This is not really intended to be used outside the library itself + BigInteger.prototype.multiplySingleDigit = function(n) { + if (n === 0 || this._s === 0) { + return ZERO; + } + if (n === 1) { + return this; + } + + var digit; + if (this._d.length === 1) { + digit = this._d[0] * n; + if (digit >= BigInteger_base) { + return new BigInteger([(digit % BigInteger_base)|0, + (digit / BigInteger_base)|0], 1, CONSTRUCT); + } + return new BigInteger([digit], 1, CONSTRUCT); + } + + if (n === 2) { + return this.add(this); + } + if (this.isUnit()) { + return new BigInteger([n], 1, CONSTRUCT); + } + + var a = this._d; + var al = a.length; + + var pl = al + 1; + var partial = new Array(pl); + for (var i = 0; i < pl; i++) { + partial[i] = 0; + } + + var carry = 0; + for (var j = 0; j < al; j++) { + digit = n * a[j] + carry; + carry = (digit / BigInteger_base) | 0; + partial[j] = (digit % BigInteger_base) | 0; + } + if (carry) { + partial[j] = carry; + } + + return new BigInteger(partial, 1, CONSTRUCT); + }; + + /* + Function: square + Multiply a by itself. + This is slightly faster than regular multiplication, since it removes the + duplicated multiplcations. + Returns: + > this.multiply(this) + See Also: + + */ + BigInteger.prototype.square = function() { + // Normally, squaring a 10-digit number would take 100 multiplications. + // Of these 10 are unique diagonals, of the remaining 90 (100-10), 45 are repeated. + // This procedure saves (N*(N-1))/2 multiplications, (e.g., 45 of 100 multiplies). + // Based on code by Gary Darby, Intellitech Systems Inc., www.DelphiForFun.org + + if (this._s === 0) { + return ZERO; + } + if (this.isUnit()) { + return ONE; + } + + var digits = this._d; + var length = digits.length; + var imult1 = new Array(length + length + 1); + var product, carry, k; + var i; + + // Calculate diagonal + for (i = 0; i < length; i++) { + k = i * 2; + product = digits[i] * digits[i]; + carry = (product / BigInteger_base) | 0; + imult1[k] = product % BigInteger_base; + imult1[k + 1] = carry; + } + + // Calculate repeating part + for (i = 0; i < length; i++) { + carry = 0; + k = i * 2 + 1; + for (var j = i + 1; j < length; j++, k++) { + product = digits[j] * digits[i] * 2 + imult1[k] + carry; + carry = (product / BigInteger_base) | 0; + imult1[k] = product % BigInteger_base; + } + k = length + i; + var digit = carry + imult1[k]; + carry = (digit / BigInteger_base) | 0; + imult1[k] = digit % BigInteger_base; + imult1[k + 1] += carry; + } + + return new BigInteger(imult1, 1, CONSTRUCT); + }; + + /* + Function: quotient + Divide two and truncate towards zero. + throws an exception if *n* is zero. + Parameters: + n - The number to divide *this* by. Will be converted to a . + Returns: + The *this* / *n*, truncated to an integer. + See Also: + , , , , + */ + BigInteger.prototype.quotient = function(n) { + return this.divRem(n)[0]; + }; + + /* + Function: divide + Deprecated synonym for . + */ + BigInteger.prototype.divide = BigInteger.prototype.quotient; + + /* + Function: remainder + Calculate the remainder of two . + throws an exception if *n* is zero. + Parameters: + n - The remainder after *this* is divided *this* by *n*. Will be + converted to a . + Returns: + *this* % *n*. + See Also: + , + */ + BigInteger.prototype.remainder = function(n) { + return this.divRem(n)[1]; + }; + + /* + Function: divRem + Calculate the integer quotient and remainder of two . + throws an exception if *n* is zero. + Parameters: + n - The number to divide *this* by. Will be converted to a . + Returns: + A two-element array containing the quotient and the remainder. + > a.divRem(b) + is exactly equivalent to + > [a.quotient(b), a.remainder(b)] + except it is faster, because they are calculated at the same time. + See Also: + , + */ + BigInteger.prototype.divRem = function(n) { + n = BigInteger(n); + if (n._s === 0) { + throw new Error("Divide by zero"); + } + if (this._s === 0) { + return [ZERO, ZERO]; + } + if (n._d.length === 1) { + return this.divRemSmall(n._s * n._d[0]); + } + + // Test for easy cases -- |n1| <= |n2| + switch (this.compareAbs(n)) { + case 0: // n1 == n2 + return [this._s === n._s ? ONE : M_ONE, ZERO]; + case -1: // |n1| < |n2| + return [ZERO, this]; + } + + var sign = this._s * n._s; + var a = n.abs(); + var b_digits = this._d; + var b_index = b_digits.length; + var digits = n._d.length; + var quot = []; + var guess; + + var part = new BigInteger([], 0, CONSTRUCT); + + while (b_index) { + part._d.unshift(b_digits[--b_index]); + part = new BigInteger(part._d, 1, CONSTRUCT); + + if (part.compareAbs(n) < 0) { + quot.push(0); + continue; + } + if (part._s === 0) { + guess = 0; + } + else { + var xlen = part._d.length, ylen = a._d.length; + var highx = part._d[xlen-1]*BigInteger_base + part._d[xlen-2]; + var highy = a._d[ylen-1]*BigInteger_base + a._d[ylen-2]; + if (part._d.length > a._d.length) { + // The length of part._d can either match a._d length, + // or exceed it by one. + highx = (highx+1)*BigInteger_base; + } + guess = Math.ceil(highx/highy); + } + do { + var check = a.multiplySingleDigit(guess); + if (check.compareAbs(part) <= 0) { + break; + } + guess--; + } while (guess); + + quot.push(guess); + if (!guess) { + continue; + } + var diff = part.subtract(check); + part._d = diff._d.slice(); + } + + return [new BigInteger(quot.reverse(), sign, CONSTRUCT), + new BigInteger(part._d, this._s, CONSTRUCT)]; + }; + + // Throws an exception if n is outside of (-BigInteger.base, -1] or + // [1, BigInteger.base). It's not necessary to call this, since the + // other division functions will call it if they are able to. + BigInteger.prototype.divRemSmall = function(n) { + var r; + n = +n; + if (n === 0) { + throw new Error("Divide by zero"); + } + + var n_s = n < 0 ? -1 : 1; + var sign = this._s * n_s; + n = Math.abs(n); + + if (n < 1 || n >= BigInteger_base) { + throw new Error("Argument out of range"); + } + + if (this._s === 0) { + return [ZERO, ZERO]; + } + + if (n === 1 || n === -1) { + return [(sign === 1) ? this.abs() : new BigInteger(this._d, sign, CONSTRUCT), ZERO]; + } + + // 2 <= n < BigInteger_base + + // divide a single digit by a single digit + if (this._d.length === 1) { + var q = new BigInteger([(this._d[0] / n) | 0], 1, CONSTRUCT); + r = new BigInteger([(this._d[0] % n) | 0], 1, CONSTRUCT); + if (sign < 0) { + q = q.negate(); + } + if (this._s < 0) { + r = r.negate(); + } + return [q, r]; + } + + var digits = this._d.slice(); + var quot = new Array(digits.length); + var part = 0; + var diff = 0; + var i = 0; + var guess; + + while (digits.length) { + part = part * BigInteger_base + digits[digits.length - 1]; + if (part < n) { + quot[i++] = 0; + digits.pop(); + diff = BigInteger_base * diff + part; + continue; + } + if (part === 0) { + guess = 0; + } + else { + guess = (part / n) | 0; + } + + var check = n * guess; + diff = part - check; + quot[i++] = guess; + if (!guess) { + digits.pop(); + continue; + } + + digits.pop(); + part = diff; + } + + r = new BigInteger([diff], 1, CONSTRUCT); + if (this._s < 0) { + r = r.negate(); + } + return [new BigInteger(quot.reverse(), sign, CONSTRUCT), r]; + }; + + /* + Function: isEven + Return true iff *this* is divisible by two. + Note that is even. + Returns: + true if *this* is even, false otherwise. + See Also: + + */ + BigInteger.prototype.isEven = function() { + var digits = this._d; + return this._s === 0 || digits.length === 0 || (digits[0] % 2) === 0; + }; + + /* + Function: isOdd + Return true iff *this* is not divisible by two. + Returns: + true if *this* is odd, false otherwise. + See Also: + + */ + BigInteger.prototype.isOdd = function() { + return !this.isEven(); + }; + + /* + Function: sign + Get the sign of a . + Returns: + * -1 if *this* < 0 + * 0 if *this* == 0 + * +1 if *this* > 0 + See Also: + , , , , + */ + BigInteger.prototype.sign = function() { + return this._s; + }; + + /* + Function: isPositive + Return true iff *this* > 0. + Returns: + true if *this*.compare() == 1. + See Also: + , , , , , + */ + BigInteger.prototype.isPositive = function() { + return this._s > 0; + }; + + /* + Function: isNegative + Return true iff *this* < 0. + Returns: + true if *this*.compare() == -1. + See Also: + , , , , , + */ + BigInteger.prototype.isNegative = function() { + return this._s < 0; + }; + + /* + Function: isZero + Return true iff *this* == 0. + Returns: + true if *this*.compare() == 0. + See Also: + , , , , + */ + BigInteger.prototype.isZero = function() { + return this._s === 0; + }; + + /* + Function: exp10 + Multiply a by a power of 10. + This is equivalent to, but faster than + > if (n >= 0) { + > return this.multiply(BigInteger("1e" + n)); + > } + > else { // n <= 0 + > return this.quotient(BigInteger("1e" + -n)); + > } + Parameters: + n - The power of 10 to multiply *this* by. *n* is converted to a + javascipt number and must be no greater than + (0x7FFFFFFF), or an exception will be thrown. + Returns: + *this* * (10 ** *n*), truncated to an integer if necessary. + See Also: + , + */ + BigInteger.prototype.exp10 = function(n) { + n = +n; + if (n === 0) { + return this; + } + if (Math.abs(n) > Number(MAX_EXP)) { + throw new Error("exponent too large in BigInteger.exp10"); + } + // Optimization for this == 0. This also keeps us from having to trim zeros in the positive n case + if (this._s === 0) { + return ZERO; + } + if (n > 0) { + var k = new BigInteger(this._d.slice(), this._s, CONSTRUCT); + + for (; n >= BigInteger_base_log10; n -= BigInteger_base_log10) { + k._d.unshift(0); + } + if (n == 0) + return k; + k._s = 1; + k = k.multiplySingleDigit(Math.pow(10, n)); + return (this._s < 0 ? k.negate() : k); + } else if (-n >= this._d.length*BigInteger_base_log10) { + return ZERO; + } else { + var k = new BigInteger(this._d.slice(), this._s, CONSTRUCT); + + for (n = -n; n >= BigInteger_base_log10; n -= BigInteger_base_log10) { + k._d.shift(); + } + return (n == 0) ? k : k.divRemSmall(Math.pow(10, n))[0]; + } + }; + + /* + Function: pow + Raise a to a power. + In this implementation, 0**0 is 1. + Parameters: + n - The exponent to raise *this* by. *n* must be no greater than + (0x7FFFFFFF), or an exception will be thrown. + Returns: + *this* raised to the *nth* power. + See Also: + + */ + BigInteger.prototype.pow = function(n) { + if (this.isUnit()) { + if (this._s > 0) { + return this; + } + else { + return BigInteger(n).isOdd() ? this : this.negate(); + } + } + + n = BigInteger(n); + if (n._s === 0) { + return ONE; + } + else if (n._s < 0) { + if (this._s === 0) { + throw new Error("Divide by zero"); + } + else { + return ZERO; + } + } + if (this._s === 0) { + return ZERO; + } + if (n.isUnit()) { + return this; + } + + if (n.compareAbs(MAX_EXP) > 0) { + throw new Error("exponent too large in BigInteger.pow"); + } + var x = this; + var aux = ONE; + var two = BigInteger.small[2]; + + while (n.isPositive()) { + if (n.isOdd()) { + aux = aux.multiply(x); + if (n.isUnit()) { + return aux; + } + } + x = x.square(); + n = n.quotient(two); + } + + return aux; + }; + + /* + Function: modPow + Raise a to a power (mod m). + Because it is reduced by a modulus, is not limited by + like . + Parameters: + exponent - The exponent to raise *this* by. Must be positive. + modulus - The modulus. + Returns: + *this* ^ *exponent* (mod *modulus*). + See Also: + , + */ + BigInteger.prototype.modPow = function(exponent, modulus) { + var result = ONE; + var base = this; + + while (exponent.isPositive()) { + if (exponent.isOdd()) { + result = result.multiply(base).remainder(modulus); + } + + exponent = exponent.quotient(BigInteger.small[2]); + if (exponent.isPositive()) { + base = base.square().remainder(modulus); + } + } + + return result; + }; + + /* + Function: log + Get the natural logarithm of a as a native JavaScript number. + This is equivalent to + > Math.log(this.toJSValue()) + but handles values outside of the native number range. + Returns: + log( *this* ) + See Also: + + */ + BigInteger.prototype.log = function() { + switch (this._s) { + case 0: return -Infinity; + case -1: return NaN; + default: // Fall through. + } + + var l = this._d.length; + + if (l*BigInteger_base_log10 < 30) { + return Math.log(this.valueOf()); + } + + var N = Math.ceil(30/BigInteger_base_log10); + var firstNdigits = this._d.slice(l - N); + return Math.log((new BigInteger(firstNdigits, 1, CONSTRUCT)).valueOf()) + (l - N) * Math.log(BigInteger_base); + }; + + /* + Function: valueOf + Convert a to a native JavaScript integer. + This is called automatically by JavaScipt to convert a to a + native value. + Returns: + > parseInt(this.toString(), 10) + See Also: + , + */ + BigInteger.prototype.valueOf = function() { + return parseInt(this.toString(), 10); + }; + + /* + Function: toJSValue + Convert a to a native JavaScript integer. + This is the same as valueOf, but more explicitly named. + Returns: + > parseInt(this.toString(), 10) + See Also: + , + */ + BigInteger.prototype.toJSValue = function() { + return parseInt(this.toString(), 10); + }; + + + /* + Function: lowVal + Author: Lucas Jones + */ + BigInteger.prototype.lowVal = function () { + return this._d[0] || 0; + }; + + var MAX_EXP = BigInteger(0x7FFFFFFF); + // Constant: MAX_EXP + // The largest exponent allowed in and (0x7FFFFFFF or 2147483647). + BigInteger.MAX_EXP = MAX_EXP; + + (function() { + function makeUnary(fn) { + return function(a) { + return fn.call(BigInteger(a)); + }; + } + + function makeBinary(fn) { + return function(a, b) { + return fn.call(BigInteger(a), BigInteger(b)); + }; + } + + function makeTrinary(fn) { + return function(a, b, c) { + return fn.call(BigInteger(a), BigInteger(b), BigInteger(c)); + }; + } + + (function() { + var i, fn; + var unary = "toJSValue,isEven,isOdd,sign,isZero,isNegative,abs,isUnit,square,negate,isPositive,toString,next,prev,log".split(","); + var binary = "compare,remainder,divRem,subtract,add,quotient,divide,multiply,pow,compareAbs".split(","); + var trinary = ["modPow"]; + + for (i = 0; i < unary.length; i++) { + fn = unary[i]; + BigInteger[fn] = makeUnary(BigInteger.prototype[fn]); + } + + for (i = 0; i < binary.length; i++) { + fn = binary[i]; + BigInteger[fn] = makeBinary(BigInteger.prototype[fn]); + } + + for (i = 0; i < trinary.length; i++) { + fn = trinary[i]; + BigInteger[fn] = makeTrinary(BigInteger.prototype[fn]); + } + + BigInteger.exp10 = function(x, n) { + return BigInteger(x).exp10(n); + }; + })(); + })(); + + exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt + })(typeof exports !== 'undefined' ? exports : this); +},{}],84:[function(require,module,exports){ +(function (Buffer){ +'use strict'; + +/** + * Credits to https://github.com/cryptocoinjs/blake-hash + */ +Blake256.sigma = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] +] + +Blake256.u256 = [ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 +] + +Blake256.padding = new Buffer([ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +]) + +Blake256.prototype._length_carry = function (arr) { + for (var j = 0; j < arr.length; ++j) { + if (arr[j] < 0x0100000000) break + arr[j] -= 0x0100000000 + arr[j + 1] += 1 + } +} + +Blake256.prototype.update = function (data, encoding) { + data = new Buffer(data, encoding); + var block = this._block + var offset = 0 + + while (this._blockOffset + data.length - offset >= block.length) { + for (var i = this._blockOffset; i < block.length;) block[i++] = data[offset++] + + this._length[0] += block.length * 8 + this._length_carry(this._length) + + this._compress() + this._blockOffset = 0 + } + + while (offset < data.length) block[this._blockOffset++] = data[offset++] + return this; +} + +var zo = new Buffer([0x01]) +var oo = new Buffer([0x81]) + +function rot (x, n) { + return ((x << (32 - n)) | (x >>> n)) >>> 0 +} + +function g (v, m, i, a, b, c, d, e) { + var sigma = Blake256.sigma + var u256 = Blake256.u256 + + v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 16) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 12) + v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0 + v[d] = rot(v[d] ^ v[a], 8) + v[c] = (v[c] + v[d]) >>> 0 + v[b] = rot(v[b] ^ v[c], 7) +} + +function Blake256 () { + this._h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ] + + this._s = [0, 0, 0, 0] + + this._block = new Buffer(64) + this._blockOffset = 0 + this._length = [0, 0] + + this._nullt = false + + this._zo = zo + this._oo = oo +} + +Blake256.prototype._compress = function () { + var u256 = Blake256.u256 + var v = new Array(16) + var m = new Array(16) + var i + + for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4) + for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0 + for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0 + for (i = 12; i < 16; ++i) v[i] = u256[i - 8] + + if (!this._nullt) { + v[12] = (v[12] ^ this._length[0]) >>> 0 + v[13] = (v[13] ^ this._length[0]) >>> 0 + v[14] = (v[14] ^ this._length[1]) >>> 0 + v[15] = (v[15] ^ this._length[1]) >>> 0 + } + + for (i = 0; i < 14; ++i) { + /* column step */ + g(v, m, i, 0, 4, 8, 12, 0) + g(v, m, i, 1, 5, 9, 13, 2) + g(v, m, i, 2, 6, 10, 14, 4) + g(v, m, i, 3, 7, 11, 15, 6) + /* diagonal step */ + g(v, m, i, 0, 5, 10, 15, 8) + g(v, m, i, 1, 6, 11, 12, 10) + g(v, m, i, 2, 7, 8, 13, 12) + g(v, m, i, 3, 4, 9, 14, 14) + } + + for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0 + for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0 +} + +Blake256.prototype._padding = function () { + var lo = this._length[0] + this._blockOffset * 8 + var hi = this._length[1] + if (lo >= 0x0100000000) { + lo -= 0x0100000000 + hi += 1 + } + + var msglen = new Buffer(8) + msglen.writeUInt32BE(hi, 0) + msglen.writeUInt32BE(lo, 4) + + if (this._blockOffset === 55) { + this._length[0] -= 8 + this.update(this._oo) + } else { + if (this._blockOffset < 55) { + if (this._blockOffset === 0) this._nullt = true + this._length[0] -= (55 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 55 - this._blockOffset)) + } else { + this._length[0] -= (64 - this._blockOffset) * 8 + this.update(Blake256.padding.slice(0, 64 - this._blockOffset)) + this._length[0] -= 55 * 8 + this.update(Blake256.padding.slice(1, 1 + 55)) + this._nullt = true + } + + this.update(this._zo) + this._length[0] -= 8 + } + + this._length[0] -= 64 + this.update(msglen) +} + +Blake256.prototype.digest = function (encoding) { + this._padding() + + var buffer = new Buffer(32) + for (var i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4) + return buffer.toString(encoding); +} + +module.exports = Blake256; +}).call(this,require("buffer").Buffer) +},{"buffer":6}],85:[function(require,module,exports){ +var JSBigInt = require('./biginteger')['JSBigInt']; + +/** +Copyright (c) 2017, moneroexamples + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Parts of the project are originally copyright (c) 2014-2017, MyMonero.com +*/ + +var cnBase58 = (function () { + var b58 = {}; + + var alphabet_str = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + var alphabet = []; + for (var i = 0; i < alphabet_str.length; i++) { + alphabet.push(alphabet_str.charCodeAt(i)); + } + var encoded_block_sizes = [0, 2, 3, 5, 6, 7, 9, 10, 11]; + + var alphabet_size = alphabet.length; + var full_block_size = 8; + var full_encoded_block_size = 11; + + var UINT64_MAX = new JSBigInt(2).pow(64); + + function hextobin(hex) { + if (hex.length % 2 !== 0) throw "Hex string has invalid length!"; + var res = new Uint8Array(hex.length / 2); + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); + } + return res; + } + + function bintohex(bin) { + var out = []; + for (var i = 0; i < bin.length; ++i) { + out.push(("0" + bin[i].toString(16)).slice(-2)); + } + return out.join(""); + } + + function strtobin(str) { + var res = new Uint8Array(str.length); + for (var i = 0; i < str.length; i++) { + res[i] = str.charCodeAt(i); + } + return res; + } + + function bintostr(bin) { + var out = []; + for (var i = 0; i < bin.length; i++) { + out.push(String.fromCharCode(bin[i])); + } + return out.join(""); + } + + function uint8_be_to_64(data) { + if (data.length < 1 || data.length > 8) { + throw "Invalid input length"; + } + var res = JSBigInt.ZERO; + var twopow8 = new JSBigInt(2).pow(8); + var i = 0; + switch (9 - data.length) { + case 1: + res = res.add(data[i++]); + case 2: + res = res.multiply(twopow8).add(data[i++]); + case 3: + res = res.multiply(twopow8).add(data[i++]); + case 4: + res = res.multiply(twopow8).add(data[i++]); + case 5: + res = res.multiply(twopow8).add(data[i++]); + case 6: + res = res.multiply(twopow8).add(data[i++]); + case 7: + res = res.multiply(twopow8).add(data[i++]); + case 8: + res = res.multiply(twopow8).add(data[i++]); + break; + default: + throw "Impossible condition"; + } + return res; + } + + function uint64_to_8be(num, size) { + var res = new Uint8Array(size); + if (size < 1 || size > 8) { + throw "Invalid input length"; + } + var twopow8 = new JSBigInt(2).pow(8); + for (var i = size - 1; i >= 0; i--) { + res[i] = num.remainder(twopow8).toJSValue(); + num = num.divide(twopow8); + } + return res; + } + + b58.encode_block = function (data, buf, index) { + if (data.length < 1 || data.length > full_encoded_block_size) { + throw "Invalid block length: " + data.length; + } + var num = uint8_be_to_64(data); + var i = encoded_block_sizes[data.length] - 1; + // while num > 0 + while (num.compare(0) === 1) { + var div = num.divRem(alphabet_size); + // remainder = num % alphabet_size + var remainder = div[1]; + // num = num / alphabet_size + num = div[0]; + buf[index + i] = alphabet[remainder.toJSValue()]; + i--; + } + return buf; + }; + + b58.encode = function (hex) { + var data = hextobin(hex); + if (data.length === 0) { + return ""; + } + var full_block_count = Math.floor(data.length / full_block_size); + var last_block_size = data.length % full_block_size; + var res_size = full_block_count * full_encoded_block_size + encoded_block_sizes[last_block_size]; + + var res = new Uint8Array(res_size); + var i; + for (i = 0; i < res_size; ++i) { + res[i] = alphabet[0]; + } + for (i = 0; i < full_block_count; i++) { + res = b58.encode_block(data.subarray(i * full_block_size, i * full_block_size + full_block_size), res, i * full_encoded_block_size); + } + if (last_block_size > 0) { + res = b58.encode_block(data.subarray(full_block_count * full_block_size, full_block_count * full_block_size + last_block_size), res, full_block_count * full_encoded_block_size) + } + return bintostr(res); + }; + + b58.decode_block = function (data, buf, index) { + if (data.length < 1 || data.length > full_encoded_block_size) { + throw "Invalid block length: " + data.length; + } + + var res_size = encoded_block_sizes.indexOf(data.length); + if (res_size <= 0) { + throw "Invalid block size"; + } + var res_num = new JSBigInt(0); + var order = new JSBigInt(1); + for (var i = data.length - 1; i >= 0; i--) { + var digit = alphabet.indexOf(data[i]); + if (digit < 0) { + throw "Invalid symbol"; + } + var product = order.multiply(digit).add(res_num); + // if product > UINT64_MAX + if (product.compare(UINT64_MAX) === 1) { + throw "Overflow"; + } + res_num = product; + order = order.multiply(alphabet_size); + } + if (res_size < full_block_size && (new JSBigInt(2).pow(8 * res_size).compare(res_num) <= 0)) { + throw "Overflow 2"; + } + buf.set(uint64_to_8be(res_num, res_size), index); + return buf; + }; + + b58.decode = function (enc) { + enc = strtobin(enc); + if (enc.length === 0) { + return ""; + } + var full_block_count = Math.floor(enc.length / full_encoded_block_size); + var last_block_size = enc.length % full_encoded_block_size; + var last_block_decoded_size = encoded_block_sizes.indexOf(last_block_size); + if (last_block_decoded_size < 0) { + throw "Invalid encoded length"; + } + var data_size = full_block_count * full_block_size + last_block_decoded_size; + var data = new Uint8Array(data_size); + for (var i = 0; i < full_block_count; i++) { + data = b58.decode_block(enc.subarray(i * full_encoded_block_size, i * full_encoded_block_size + full_encoded_block_size), data, i * full_block_size); + } + if (last_block_size > 0) { + data = b58.decode_block(enc.subarray(full_block_count * full_encoded_block_size, full_block_count * full_encoded_block_size + last_block_size), data, full_block_count * full_block_size); + } + return bintohex(data); + }; + + return b58; +})(); +module.exports = cnBase58; +},{"./biginteger":83}],86:[function(require,module,exports){ +// Copyright (c) 2017 Pieter Wuille +// +// 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. + +var bech32 = require('./bech32'); + +function convertbits (data, frombits, tobits, pad) { + var acc = 0; + var bits = 0; + var ret = []; + var maxv = (1 << tobits) - 1; + for (var p = 0; p < data.length; ++p) { + var value = data[p]; + if (value < 0 || (value >> frombits) !== 0) { + return null; + } + acc = (acc << frombits) | value; + bits += frombits; + while (bits >= tobits) { + bits -= tobits; + ret.push((acc >> bits) & maxv); + } + } + if (pad) { + if (bits > 0) { + ret.push((acc << (tobits - bits)) & maxv); + } + } else if (bits >= frombits || ((acc << (tobits - bits)) & maxv)) { + return null; + } + return ret; +} + +function decode (hrp, addr) { + var dec = bech32.decode(addr); + if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) { + return null; + } + var res = convertbits(dec.data.slice(1), 5, 8, false); + if (res === null || res.length < 2 || res.length > 40) { + return null; + } + if (dec.data[0] === 0 && res.length !== 20 && res.length !== 32) { + return null; + } + return {version: dec.data[0], program: res}; +} + +function encode (hrp, version, program) { + var ret = bech32.encode(hrp, [version].concat(convertbits(program, 8, 5, true))); + if (decode(hrp, ret) === null) { + return null; + } + return ret; +} + +function isValidAddress(address) { + var hrp = 'bc'; + var ret = decode(hrp, address); + + if (ret === null) { + hrp = 'tb'; + ret = decode(hrp, address); + } + + if (ret === null) { + return false; + } + + var recreate = encode(hrp, ret.version, ret.program); + return recreate === address.toLowerCase(); +} + +module.exports = { + encode: encode, + decode: decode, + isValidAddress: isValidAddress, +}; + +},{"./bech32":82}],87:[function(require,module,exports){ +(function (process,global){ +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.7.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2017 + * @license MIT + */ +/*jslint bitwise: true */ +'use strict'; + +var ERROR = 'input is invalid type'; +var WINDOW = typeof window === 'object'; +var root = WINDOW ? window : {}; +if (root.JS_SHA3_NO_WINDOW) { + WINDOW = false; +} +var WEB_WORKER = !WINDOW && typeof self === 'object'; +var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; +if (NODE_JS) { + root = global; +} else if (WEB_WORKER) { + root = self; +} +var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; +var HEX_CHARS = '0123456789abcdef'.split(''); +var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; +var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; +var KECCAK_PADDING = [1, 256, 65536, 16777216]; +var PADDING = [6, 1536, 393216, 100663296]; +var SHIFT = [0, 8, 16, 24]; +var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; +var BITS = [224, 256, 384, 512]; +var SHAKE_BITS = [128, 256]; +var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; +var CSHAKE_BYTEPAD = { + '128': 168, + '256': 136 +}; + +if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { + Array.isArray = function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; +} + +if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { + ArrayBuffer.isView = function (obj) { + return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; + }; +} + +var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; +}; + +var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; +}; + +var createCshakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits, n, s) { + return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); + }; +}; + +var createKmacOutputMethod = function (bits, padding, outputType) { + return function (key, message, outputBits, s) { + return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); + }; +}; + +var createOutputMethods = function (method, createMethod, bits, padding) { + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createMethod(bits, padding, type); + } + return method; +}; + +var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + return createOutputMethods(method, createOutputMethod, bits, padding); +}; + +var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + return createOutputMethods(method, createShakeOutputMethod, bits, padding); +}; + +var createCshakeMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createCshakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits, n, s) { + if (!n && !s) { + return methods['shake' + bits].create(outputBits); + } else { + return new Keccak(bits, padding, outputBits).bytepad([n, s], w); + } + }; + method.update = function (message, outputBits, n, s) { + return method.create(outputBits, n, s).update(message); + }; + return createOutputMethods(method, createCshakeOutputMethod, bits, padding); +}; + +var createKmacMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createKmacOutputMethod(bits, padding, 'hex'); + method.create = function (key, outputBits, s) { + return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); + }; + method.update = function (key, message, outputBits, s) { + return method.create(key, outputBits, s).update(message); + }; + return createOutputMethods(method, createKmacOutputMethod, bits, padding); +}; + +var algorithms = [ + { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, + { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, + { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, + { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, + { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } +]; + +var methods = {}, methodNames = []; + +for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name + '_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + if (algorithm.name !== 'sha3') { + var newMethodName = algorithm.name + bits[j]; + methodNames.push(newMethodName); + methods[newMethodName] = methods[methodName]; + } + } +} + +function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.finalized = false; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } +} + +Keccak.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString, type = typeof message; + if (type !== 'string') { + if (type === 'object') { + if (message === null) { + throw ERROR; + } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (!Array.isArray(message)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var blocks = this.blocks, byteCount = this.byteCount, length = message.length, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; +}; + +Keccak.prototype.encode = function (x, right) { + var o = x & 255, n = 1; + var bytes = [o]; + x = x >> 8; + o = x & 255; + while (o > 0) { + bytes.unshift(o); + x = x >> 8; + o = x & 255; + ++n; + } + if (right) { + bytes.push(n); + } else { + bytes.unshift(n); + } + this.update(bytes); + return bytes.length; +}; + +Keccak.prototype.encodeString = function (str) { + var notString, type = typeof str; + if (type !== 'string') { + if (type === 'object') { + if (str === null) { + throw ERROR; + } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { + str = new Uint8Array(str); + } else if (!Array.isArray(str)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { + throw ERROR; + } + } + } else { + throw ERROR; + } + notString = true; + } + var bytes = 0, length = str.length; + if (notString) { + bytes = length; + } else { + for (var i = 0; i < str.length; ++i) { + var code = str.charCodeAt(i); + if (code < 0x80) { + bytes += 1; + } else if (code < 0x800) { + bytes += 2; + } else if (code < 0xd800 || code >= 0xe000) { + bytes += 3; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); + bytes += 4; + } + } + } + bytes += this.encode(bytes * 8); + this.update(str); + return bytes; +}; + +Keccak.prototype.bytepad = function (strs, w) { + var bytes = this.encode(w); + for (var i = 0; i < strs.length; ++i) { + bytes += this.encodeString(strs[i]); + } + var paddingBytes = w - bytes % w; + var zeros = []; + zeros.length = paddingBytes; + this.update(zeros); + return this; +}; + +Keccak.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); +}; + +Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; +}; + +Keccak.prototype.arrayBuffer = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; +}; + +Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + +Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; +}; + +function Kmac(bits, padding, outputBits) { + Keccak.call(this, bits, padding, outputBits); +} + +Kmac.prototype = new Keccak(); + +Kmac.prototype.finalize = function () { + this.encode(this.outputBits, true); + return Keccak.prototype.finalize.call(this); +}; + +var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } +}; + +module.exports = methods; + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":52}],88:[function(require,module,exports){ +var jsSHA = require('jssha/src/sha256'); +var Blake256 = require('./blake256'); +var keccak256 = require('./sha3')['keccak256']; + +function numberToHex (number) { + var hex = Math.round(number).toString(16); + if(hex.length === 1) { + hex = '0' + hex; + } + return hex; +} + +module.exports = { + toHex: function (arrayOfBytes) { + var hex = ''; + for(var i = 0; i < arrayOfBytes.length; i++) { + hex += numberToHex(arrayOfBytes[i]); + } + return hex; + }, + sha256: function (hexString) { + var sha = new jsSHA('SHA-256', 'HEX'); + sha.update(hexString); + return sha.getHash('HEX'); + }, + sha256Checksum: function (payload) { + return this.sha256(this.sha256(payload)).substr(0, 8); + }, + blake256: function (hexString) { + return new Blake256().update(hexString, 'hex').digest('hex'); + }, + blake256Checksum: function (payload) { + return this.blake256(this.blake256(payload)).substr(0, 8); + }, + keccak256: function (hexString) { + return keccak256(hexString); + }, + keccak256Checksum: function (payload) { + return keccak256(payload).toString().substr(0, 8); + } +}; + +},{"./blake256":84,"./sha3":87,"jssha/src/sha256":49}],89:[function(require,module,exports){ +var XRPValidator = require('./ripple_validator'); +var ETHValidator = require('./ethereum_validator'); +var BTCValidator = require('./bitcoin_validator'); +var ADAValidator = require('./ada_validator'); +var XMRValidator = require('./monero_validator'); + +// defines P2PKH and P2SH address types for standard (prod) and testnet networks +var CURRENCIES = [{ + name: 'bitcoin', + symbol: 'btc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'bitcoincash', + symbol: 'bch', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'litecoin', + symbol: 'ltc', + addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']}, + validator: BTCValidator +},{ + name: 'peercoin', + symbol: 'ppc', + addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'dogecoin', + symbol: 'doge', + addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']}, + validator: BTCValidator +},{ + name: 'beavercoin', + symbol: 'bvc', + addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator, +},{ + name: 'freicoin', + symbol: 'frc', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'protoshares', + symbol: 'pts', + addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'megacoin', + symbol: 'mec', + addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'primecoin', + symbol: 'xpm', + addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'auroracoin', + symbol: 'aur', + addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'namecoin', + symbol: 'nmc', + addressTypes: {prod: ['34'], testnet: []}, + validator: BTCValidator +},{ + name: 'biocoin', + symbol: 'bio', + addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'garlicoin', + symbol: 'grlc', + addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'vertcoin', + symbol: 'vtc', + addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'bitcoingold', + symbol: 'btg', + addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'komodo', + symbol: 'kmd', + addressTypes: {prod: ['3c', '55'], testnet: ['0','5']}, + validator: BTCValidator +},{ + name: 'bitcoinz', + symbol: 'btcz', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator +},{ + name: 'bitcoinprivate', + symbol: 'btcp', + expectedLength: 26, + addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']}, + validator: BTCValidator +},{ + name: 'hush', + symbol: 'hush', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator +},{ + name: 'snowgem', + symbol: 'sng', + expectedLength: 26, + addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']}, + validator: BTCValidator +},{ + name: 'zcash', + symbol: 'zec', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator +},{ + name: 'zclassic', + symbol: 'zcl', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator +},{ + name: 'zencash', + symbol: 'zen', + expectedLength: 26, + addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']}, + validator: BTCValidator +},{ + name: 'votecoin', + symbol: 'vot', + expectedLength: 26, + addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + validator: BTCValidator +},{ + name: 'decred', + symbol: 'dcr', + addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, + hashFunction: 'blake256', + expectedLength: 26, + validator: BTCValidator +},{ + name: 'gamecredits', + symbol: 'game', + addressTypes: {prod: ['26', '05'], testnet: []}, + validator: BTCValidator +},{ + name: 'pivx', + symbol: 'pivx', + addressTypes: {prod: ['1e', '0d'], testnet: []}, + validator: BTCValidator +},{ + name: 'SolarCoin', + symbol: 'slr', + addressTypes: {prod: ['12', '05'], testnet: []}, + validator: BTCValidator +},{ + name: 'MonaCoin', + symbol: 'mona', + addressTypes: {prod: ['32', '37'], testnet: []}, + validator: BTCValidator +},{ + name: 'digibyte', + symbol: 'dgb', + addressTypes: {prod: ['1e'], testnet: []}, + validator: BTCValidator +},{ + name: 'Tether', + symbol: 'usdt', + addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'ripple', + symbol: 'xrp', + validator: XRPValidator, +},{ + name: 'dash', + symbol: 'dash', + addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']}, + validator: BTCValidator +},{ + name: 'neo', + symbol: 'neo', + addressTypes: {prod: ['17'], testnet: []}, + validator: BTCValidator +},{ + name: 'neogas', + symbol: 'gas', + addressTypes: {prod: ['17'], testnet: []}, + validator: BTCValidator +},{ + name: 'qtum', + symbol: 'qtum', + addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, + validator: BTCValidator +},{ + name: 'ethereum', + symbol: 'eth', + validator: ETHValidator, +},{ + name: 'etherzero', + symbol: 'etz', + validator: ETHValidator, +},{ + name: 'ethereumclassic', + symbol: 'etc', + validator: ETHValidator, +},{ + name: 'callisto', + symbol: 'clo', + validator: ETHValidator, +},{ + name: 'bankex', + symbol: 'bkx', + validator: ETHValidator +},{ + name: 'cardano', + symbol: 'ada', + validator: ADAValidator +},{ + name: 'monero', + symbol: 'xmr', + addressTypes: {prod: ['18'], testnet: ['53']}, + iAddressTypes: {prod: ['19'], testnet: ['54']}, + validator: XMRValidator +},{ + name: 'Aragon', + symbol: 'ant', + validator: ETHValidator +},{ + name: 'Basic Attention Token', + symbol: 'bat', + validator: ETHValidator +},{ + name: 'Bancor', + symbol: 'bnt', + validator: ETHValidator +},{ + name: 'cvc', + symbol: 'Civic', + validator: ETHValidator +},{ + name: 'dnt', + symbol: 'District0x', + validator: ETHValidator +},{ + name: 'Gnosis', + symbol: 'gno', + validator: ETHValidator +},{ + name: 'Golem', + symbol: 'gnt', + validator: ETHValidator +},{ + name: 'Matchpool', + symbol: 'gup', + validator: ETHValidator +},{ + name: 'Melon', + symbol: 'mln', + validator: ETHValidator +},{ + name: 'Numeraire', + symbol: 'nmr', + validator: ETHValidator +},{ + name: 'OmiseGO', + symbol: 'omg', + validator: ETHValidator +},{ + name: 'TenX', + symbol: 'pay', + validator: ETHValidator +},{ + name: 'Ripio Credit Network', + symbol: 'rcn', + validator: ETHValidator +},{ + name: 'Augur', + symbol: 'rep', + validator: ETHValidator +},{ + name: 'Status', + symbol: 'snt', + validator: ETHValidator +},{ + name: 'Swarm City', + symbol: 'swt', + validator: ETHValidator +},{ + name: 'TrueUSD', + symbol: 'tusd', + validator: ETHValidator +},{ + name: 'Wings', + symbol: 'wings', + validator: ETHValidator +},{ + name: '0x', + symbol: 'zrx', + validator: ETHValidator +},{ + name: 'Expanse', + symbol: 'exp', + validator: ETHValidator +}]; + + +module.exports = { + getByNameOrSymbol: function (currencyNameOrSymbol) { + var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); + for (var i = 0; i < CURRENCIES.length; i++) { + var currency = CURRENCIES[i]; + if(currency.name.toLowerCase() === nameOrSymbol || currency.symbol.toLowerCase() === nameOrSymbol) { + return currency; + } + } + return null; + } +}; + + + +},{"./ada_validator":79,"./bitcoin_validator":80,"./ethereum_validator":90,"./monero_validator":91,"./ripple_validator":92}],90:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); + +module.exports = { + isValidAddress: function (address) { + if (!/^0x[0-9a-fA-F]{40}$/.test(address)) { + // Check if it has the basic requirements of an address + return false; + } + + if (/^0x[0-9a-f]{40}$/.test(address) || /^0x?[0-9A-F]{40}$/.test(address)) { + // If it's all small caps or all all caps, return true + return true; + } + + // Otherwise check each case + return this.verifyChecksum(address); + }, + verifyChecksum: function (address) { + // Check each case + address = address.replace('0x',''); + + var addressHash = cryptoUtils.keccak256(address.toLowerCase()); + + for (var i = 0; i < 40; i++ ) { + // The nth letter should be uppercase if the nth digit of casemap is 1 + if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || + (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { + return false; + } + } + + return true; + } +}; + +},{"./crypto/utils":88}],91:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var cnBase58 = require('./crypto/cnBase58'); + +var DEFAULT_NETWORK_TYPE = 'prod'; +var addressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$'); +var integratedAddressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$'); + +function validateNetwork(decoded, currency, networkType, addressType){ + var network = currency.addressTypes; + if(addressType == 'integrated'){ + network = currency.iAddressTypes; + } + + switch(networkType){ + case 'prod': + return parseInt(decoded.substr(0,2), 16) == network.prod[0]; + case 'testnet': + return parseInt(decoded.substr(0,2), 16) == network.testnet[0]; + case 'both': + return parseInt(decoded.substr(0,2), 16) == network.prod[0] || parseInt(decoded.substr(0,2), 16) == network.testnet[0]; + default: + return false; + } +} + +function hextobin(hex) { + if (hex.length % 2 !== 0) return null; + var res = new Uint8Array(hex.length / 2); + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); + } + return res; +} + +module.exports = { + isValidAddress: function (address, currency, networkType) { + networkType = networkType || DEFAULT_NETWORK_TYPE; + var addressType = 'standard'; + if(!addressRegTest.test(address)){ + if(integratedAddressRegTest.test(address)){ + addressType = 'integrated'; + } + else{ + return false; + } + } + + var decodedAddrStr = cnBase58.decode(address); + if(!decodedAddrStr) + return false; + + if(!validateNetwork(decodedAddrStr, currency, networkType, addressType)) + return false; + + var addrChecksum = decodedAddrStr.slice(-8); + var hashChecksum = cryptoUtils.keccak256Checksum(hextobin(decodedAddrStr.slice(0, -8))); + + return addrChecksum === hashChecksum; + } +}; + +},{"./crypto/cnBase58":85,"./crypto/utils":88}],92:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var baseX = require('base-x'); + +var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; + +var codec = baseX(ALLOWED_CHARS); +var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); + +module.exports = { + /** + * ripple address validation + */ + isValidAddress: function (address) { + if (regexp.test(address)) { + return this.verifyChecksum(address); + } + + return false; + }, + + verifyChecksum: function (address) { + var bytes = codec.decode(address); + var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); + var checksum = cryptoUtils.toHex(bytes.slice(-4)); + + return computedChecksum === checksum + } +}; + +},{"./crypto/utils":88,"base-x":1}],93:[function(require,module,exports){ +var currencies = require('./currencies'); + +var DEFAULT_CURRENCY_NAME = 'bitcoin'; + +module.exports = { + validate: function (address, currencyNameOrSymbol, networkType) { + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); + + if (currency && currency.validator) { + return currency.validator.isValidAddress(address, currency, networkType); + } + + throw new Error('Missing validator for currency: ' + currencyNameOrSymbol); + }, +}; + +},{"./currencies":89}]},{},[93])(93) +}); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js new file mode 100644 index 00000000..6e90c7db --- /dev/null +++ b/dist/wallet-address-validator.min.js @@ -0,0 +1 @@ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function o(s,a,u){function f(e,t){if(!a[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[e]={exports:{}};s[e][0].call(i.exports,function(t){return f(s[e][1][t]||t)},i,i.exports,o,s,a,u)}return a[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===c&&s>16&255,o[s++]=e>>8&255,o[s++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[s++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[s++]=e>>8&255,o[s++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,s=r-n;o>2]+a[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(a[e>>10]+a[e>>4&63]+a[e<<2&63]+"="));return i.join("")};for(var a=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+a[i>>12&63]+a[i>>6&63]+a[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function s(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,s,a,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,L(function(t,e){for(var r,n,i,o=[],s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-s),o,s,a);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function S(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(t,e,r,n,i){return e=+e,r>>>=0,i||S(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,i){return e=+e,r>>>=0,i||S(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||T(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||T(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);T(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);T(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;0<=--o&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return U(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return U(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:30}],5:[function(t,e,r){"use strict";e.exports=t("./es6/crc1").default},{"./es6/crc1":16}],6:[function(t,e,r){"use strict";e.exports=t("./es6/crc16").default},{"./es6/crc16":17}],7:[function(t,e,r){"use strict";e.exports=t("./es6/crc16ccitt").default},{"./es6/crc16ccitt":18}],8:[function(t,e,r){"use strict";e.exports=t("./es6/crc16kermit").default},{"./es6/crc16kermit":19}],9:[function(t,e,r){"use strict";e.exports=t("./es6/crc16modbus").default},{"./es6/crc16modbus":20}],10:[function(t,e,r){"use strict";e.exports=t("./es6/crc16xmodem").default},{"./es6/crc16xmodem":21}],11:[function(t,e,r){"use strict";e.exports=t("./es6/crc24").default},{"./es6/crc24":22}],12:[function(t,e,r){"use strict";e.exports=t("./es6/crc32").default},{"./es6/crc32":23}],13:[function(t,e,r){"use strict";e.exports=t("./es6/crc8").default},{"./es6/crc8":24}],14:[function(t,e,r){"use strict";e.exports=t("./es6/crc81wire").default},{"./es6/crc81wire":25}],15:[function(t,e,r){"use strict";e.exports=t("./es6/crcjam").default},{"./es6/crcjam":26}],16:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("crc1",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=~~e,n=0,i=0;i>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],18:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":27,"./define_crc":28,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],27:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],29:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":5,"./crc16":6,"./crc16_ccitt":7,"./crc16_kermit":8,"./crc16_modbus":9,"./crc16_xmodem":10,"./crc24":11,"./crc32":12,"./crc8":13,"./crc8_1wire":14,"./crcjam":15}],30:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=a;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(e+=1<=s+h?l/u:l*Math.pow(2,1-h))*u&&(s++,u/=2),c<=s+h?(a=0,s=c):1<=s+h?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));8<=i;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,s)},l=function(t,e,r,n){var i,o;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,v)).binLen,r=e.value,e=t>>>5,n=0;n>>5),v=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(g.slice(),v,y,d(a)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,s="",a=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)s+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return s}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,s,a,u,f,c,h=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=u;)e.push(0);e[u]|=i[s]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+a)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,s,a,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i console.log(c.symbol)); - - From be035bcdc0278b6ead3304827e5debe61ecc5967 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 26 Oct 2018 01:02:51 +0200 Subject: [PATCH 057/108] fixed ada browser compatibility --- dist/wallet-address-validator.js | 15714 ++++--------------------- dist/wallet-address-validator.min.js | 2 +- package.json | 12 +- src/ada_validator.js | 23 +- yarn.lock | 1180 +- 5 files changed, 2604 insertions(+), 14327 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index f11c293f..98f7b6e4 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -92,7 +92,7 @@ module.exports = function base (ALPHABET) { } } -},{"safe-buffer":71}],2:[function(require,module,exports){ +},{"safe-buffer":34}],2:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -246,13846 +246,3130 @@ function fromByteArray (uint8) { } },{}],3:[function(require,module,exports){ -;(function (globalObject) { - 'use strict'; +var basex = require('base-x') +var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' -/* - * bignumber.js v7.2.1 - * A JavaScript library for arbitrary-precision arithmetic. - * https://github.com/MikeMcl/bignumber.js - * Copyright (c) 2018 Michael Mclaughlin - * MIT Licensed. - * - * BigNumber.prototype methods | BigNumber methods - * | - * absoluteValue abs | clone - * comparedTo | config set - * decimalPlaces dp | DECIMAL_PLACES - * dividedBy div | ROUNDING_MODE - * dividedToIntegerBy idiv | EXPONENTIAL_AT - * exponentiatedBy pow | RANGE - * integerValue | CRYPTO - * isEqualTo eq | MODULO_MODE - * isFinite | POW_PRECISION - * isGreaterThan gt | FORMAT - * isGreaterThanOrEqualTo gte | ALPHABET - * isInteger | isBigNumber - * isLessThan lt | maximum max - * isLessThanOrEqualTo lte | minimum min - * isNaN | random - * isNegative | - * isPositive | - * isZero | - * minus | - * modulo mod | - * multipliedBy times | - * negated | - * plus | - * precision sd | - * shiftedBy | - * squareRoot sqrt | - * toExponential | - * toFixed | - * toFormat | - * toFraction | - * toJSON | - * toNumber | - * toPrecision | - * toString | - * valueOf | +module.exports = basex(ALPHABET) + +},{"base-x":1}],4:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. * + * @author Feross Aboukhadijeh + * @license MIT */ +/* eslint-disable no-proto */ +'use strict' - var BigNumber, - isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, - - mathceil = Math.ceil, - mathfloor = Math.floor, - - bignumberError = '[BigNumber Error] ', - tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ', - - BASE = 1e14, - LOG_BASE = 14, - MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1 - // MAX_INT32 = 0x7fffffff, // 2^31 - 1 - POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], - SQRT_BASE = 1e7, - - // EDITABLE - // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and - // the arguments to toExponential, toFixed, toFormat, and toPrecision. - MAX = 1E9; // 0 to MAX_INT32 +var base64 = require('base64-js') +var ieee754 = require('ieee754') +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 - /* - * Create and return a BigNumber constructor. - */ - function clone(configObject) { - var div, convertBase, parseNumeric, - P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null }, - ONE = new BigNumber(1), +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - //----------------------------- EDITABLE CONFIG DEFAULTS ------------------------------- +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } + return arr.foo() === 42 + } catch (e) { + return false + } +} - // The default values below must be integers within the inclusive ranges stated. - // The values can also be changed at run-time using BigNumber.set. +Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.buffer + } +}) - // The maximum number of decimal places for operations involving division. - DECIMAL_PLACES = 20, // 0 to MAX +Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.byteOffset + } +}) - // The rounding mode used when rounding to the above decimal places, and when using - // toExponential, toFixed, toFormat and toPrecision, and round (default value). - // UP 0 Away from zero. - // DOWN 1 Towards zero. - // CEIL 2 Towards +Infinity. - // FLOOR 3 Towards -Infinity. - // HALF_UP 4 Towards nearest neighbour. If equidistant, up. - // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. - // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. - // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. - // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. - ROUNDING_MODE = 4, // 0 to 8 +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf +} - // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS] +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ - // The exponent value at and beneath which toString returns exponential notation. - // Number type: -7 - TO_EXP_NEG = -7, // 0 to -MAX +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError( + 'The "string" argument must be of type string. Received type number' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} - // The exponent value at and above which toString returns exponential notation. - // Number type: 21 - TO_EXP_POS = 21, // 0 to MAX +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species != null && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) +} - // RANGE : [MIN_EXP, MAX_EXP] +Buffer.poolSize = 8192 // not used by this implementation - // The minimum exponent value, beneath which underflow to zero occurs. - // Number type: -324 (5e-324) - MIN_EXP = -1e7, // -1 to -MAX +function from (value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } - // The maximum exponent value, above which overflow to Infinity occurs. - // Number type: 308 (1.7976931348623157e+308) - // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow. - MAX_EXP = 1e7, // 1 to MAX + if (ArrayBuffer.isView(value)) { + return fromArrayLike(value) + } - // Whether to use cryptographically-secure random number generation, if available. - CRYPTO = false, // true or false + if (value == null) { + throw TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) + } - // The modulo mode used when calculating the modulus: a mod n. - // The quotient (q = a / n) is calculated according to the corresponding rounding mode. - // The remainder (r) is calculated as: r = a - n * q. - // - // UP 0 The remainder is positive if the dividend is negative, else is negative. - // DOWN 1 The remainder has the same sign as the dividend. - // This modulo mode is commonly known as 'truncated division' and is - // equivalent to (a % n) in JavaScript. - // FLOOR 3 The remainder has the same sign as the divisor (Python %). - // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function. - // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). - // The remainder is always positive. - // - // The truncated division, floored division, Euclidian division and IEEE 754 remainder - // modes are commonly used for the modulus operation. - // Although the other rounding modes can also be used, they may not give useful results. - MODULO_MODE = 1, // 0 to 9 + if (isInstance(value, ArrayBuffer) || + (value && isInstance(value.buffer, ArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } - // 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 - - // The format specification used by the BigNumber.prototype.toFormat method. - FORMAT = { - decimalSeparator: '.', - groupSeparator: ',', - groupSize: 3, - secondaryGroupSize: 0, - fractionGroupSeparator: '\xA0', // non-breaking space - fractionGroupSize: 0 - }, - - // The alphabet used for base conversion. - // It must be at least 2 characters long, with no '.' or repeated character. - // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' - ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'; + if (typeof value === 'number') { + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) + } + var valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) + } - //------------------------------------------------------------------------------------------ - - - // CONSTRUCTOR + var b = fromObject(value) + if (b) return b + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && + typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from( + value[Symbol.toPrimitive]('string'), encodingOrOffset, length + ) + } - /* - * The BigNumber constructor and exported function. - * Create and return a new instance of a BigNumber object. - * - * n {number|string|BigNumber} A numeric value. - * [b] {number} The base of n. Integer, 2 to ALPHABET.length inclusive. - */ - function BigNumber(n, b) { - var alphabet, c, caseChanged, e, i, isNum, len, str, - x = this; + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) +} - // Enable constructor usage without new. - if (!(x instanceof BigNumber)) { +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} - // Don't throw on constructor call without new (#81). - // '[BigNumber Error] Constructor call without new: {n}' - //throw Error(bignumberError + ' Constructor call without new: ' + n); - return new BigNumber(n, b); - } +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array - if (b == null) { +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } +} - // Duplicate. - if (n instanceof BigNumber) { - x.s = n.s; - x.e = n.e; - x.c = (n = n.c) ? n.slice() : n; - return; - } +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} - isNum = typeof n == 'number'; +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} - if (isNum && n * 0 == 0) { +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} - // Use `1 / n` to handle minus zero also. - x.s = 1 / n < 0 ? (n = -n, -1) : 1; +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} - // Faster path for integers. - if (n === ~~n) { - for (e = 0, i = n; i >= 10; i /= 10, e++); - x.e = e; - x.c = [n]; - return; - } +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } - str = n + ''; - } else { - if (!isNumeric.test(str = n + '')) return parseNumeric(x, str, isNum); - x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1; - } + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } - // Decimal point? - if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) - // Exponential form? - if ((i = str.search(/e/i)) > 0) { + var actual = buf.write(string, encoding) - // Determine exponent. - if (e < 0) e = i; - e += +str.slice(i + 1); - str = str.substring(0, i); - } else if (e < 0) { + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } - // Integer. - e = str.length; - } + return buf +} - } else { +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} - // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' - intCheck(b, 2, ALPHABET.length, 'Base'); - str = n + ''; +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } - // Allow exponential notation to be used with base 10 argument, while - // also rounding to DECIMAL_PLACES as with other bases. - if (b == 10) { - x = new BigNumber(n instanceof BigNumber ? n : str); - return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE); - } + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } - isNum = typeof n == 'number'; + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } - if (isNum) { - - // Avoid potential interpretation of Infinity and NaN as base 44+ values. - if (n * 0 != 0) return parseNumeric(x, str, isNum, b); - - x.s = 1 / n < 0 ? (str = str.slice(1), -1) : 1; - - // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' - if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) { - throw Error - (tooManyDigits + n); - } - - // Prevent later check for length on converted number. - isNum = false; - } else { - x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1; - } - - alphabet = ALPHABET.slice(0, b); - e = i = 0; - - // Check that str is a valid base b number. - // Don't use RegExp so alphabet can contain special characters. - for (len = str.length; i < len; i++) { - if (alphabet.indexOf(c = str.charAt(i)) < 0) { - if (c == '.') { - - // If '.' is not the first character and it has not be found before. - if (i > e) { - e = len; - continue; - } - } else if (!caseChanged) { - - // Allow e.g. hexadecimal 'FF' as well as 'ff'. - if (str == str.toUpperCase() && (str = str.toLowerCase()) || - str == str.toLowerCase() && (str = str.toUpperCase())) { - caseChanged = true; - i = -1; - e = 0; - continue; - } - } - - return parseNumeric(x, n + '', isNum, b); - } - } - - str = convertBase(str, b, 10, x.s); - - // Decimal point? - if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); - else e = str.length; - } - - // Determine leading zeros. - for (i = 0; str.charCodeAt(i) === 48; i++); - - // Determine trailing zeros. - for (len = str.length; str.charCodeAt(--len) === 48;); - - str = str.slice(i, ++len); - - if (str) { - len -= i; - - // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' - if (isNum && BigNumber.DEBUG && - len > 15 && (n > MAX_SAFE_INTEGER || n !== mathfloor(n))) { - throw Error - (tooManyDigits + (x.s * n)); - } - - e = e - i - 1; - - // Overflow? - if (e > MAX_EXP) { - - // Infinity. - x.c = x.e = null; - - // Underflow? - } else if (e < MIN_EXP) { - - // Zero. - x.c = [x.e = 0]; - } else { - x.e = e; - x.c = []; - - // Transform base - - // e is the base 10 exponent. - // i is where to slice str to get the first element of the coefficient array. - i = (e + 1) % LOG_BASE; - if (e < 0) i += LOG_BASE; - - if (i < len) { - if (i) x.c.push(+str.slice(0, i)); - - for (len -= LOG_BASE; i < len;) { - x.c.push(+str.slice(i, i += LOG_BASE)); - } - - str = str.slice(i); - i = LOG_BASE - str.length; - } else { - i -= len; - } - - for (; i--; str += '0'); - x.c.push(+str); - } - } else { - - // Zero. - x.c = [x.e = 0]; - } - } - - - // CONSTRUCTOR PROPERTIES - - - BigNumber.clone = clone; - - BigNumber.ROUND_UP = 0; - BigNumber.ROUND_DOWN = 1; - BigNumber.ROUND_CEIL = 2; - BigNumber.ROUND_FLOOR = 3; - BigNumber.ROUND_HALF_UP = 4; - BigNumber.ROUND_HALF_DOWN = 5; - BigNumber.ROUND_HALF_EVEN = 6; - BigNumber.ROUND_HALF_CEIL = 7; - BigNumber.ROUND_HALF_FLOOR = 8; - BigNumber.EUCLID = 9; - - - /* - * Configure infrequently-changing library-wide settings. - * - * Accept an object with the following optional properties (if the value of a property is - * a number, it must be an integer within the inclusive range stated): - * - * DECIMAL_PLACES {number} 0 to MAX - * ROUNDING_MODE {number} 0 to 8 - * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX] - * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX] - * CRYPTO {boolean} true or false - * 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 '.'. - * FORMAT {object} An object with some of the following properties: - * decimalSeparator {string} - * groupSeparator {string} - * groupSize {number} - * secondaryGroupSize {number} - * fractionGroupSeparator {string} - * fractionGroupSize {number} - * - * (The values assigned to the above FORMAT object properties are not checked for validity.) - * - * E.g. - * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 }) - * - * Ignore properties/parameters set to null or undefined, except for ALPHABET. - * - * Return an object with the properties current values. - */ - BigNumber.config = BigNumber.set = function (obj) { - var p, v; - - if (obj != null) { - - if (typeof obj == 'object') { - - // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive. - // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) { - v = obj[p]; - intCheck(v, 0, MAX, p); - DECIMAL_PLACES = v; - } - - // ROUNDING_MODE {number} Integer, 0 to 8 inclusive. - // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) { - v = obj[p]; - intCheck(v, 0, 8, p); - ROUNDING_MODE = v; - } - - // EXPONENTIAL_AT {number|number[]} - // Integer, -MAX to MAX inclusive or - // [integer -MAX to 0 inclusive, 0 to MAX inclusive]. - // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) { - v = obj[p]; - if (isArray(v)) { - intCheck(v[0], -MAX, 0, p); - intCheck(v[1], 0, MAX, p); - TO_EXP_NEG = v[0]; - TO_EXP_POS = v[1]; - } else { - intCheck(v, -MAX, MAX, p); - TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v); - } - } - - // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or - // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive]. - // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}' - if (obj.hasOwnProperty(p = 'RANGE')) { - v = obj[p]; - if (isArray(v)) { - intCheck(v[0], -MAX, -1, p); - intCheck(v[1], 1, MAX, p); - MIN_EXP = v[0]; - MAX_EXP = v[1]; - } else { - intCheck(v, -MAX, MAX, p); - if (v) { - MIN_EXP = -(MAX_EXP = v < 0 ? -v : v); - } else { - throw Error - (bignumberError + p + ' cannot be zero: ' + v); - } - } - } - - // CRYPTO {boolean} true or false. - // '[BigNumber Error] CRYPTO not true or false: {v}' - // '[BigNumber Error] crypto unavailable' - if (obj.hasOwnProperty(p = 'CRYPTO')) { - v = obj[p]; - if (v === !!v) { - if (v) { - if (typeof crypto != 'undefined' && crypto && - (crypto.getRandomValues || crypto.randomBytes)) { - CRYPTO = v; - } else { - CRYPTO = !v; - throw Error - (bignumberError + 'crypto unavailable'); - } - } else { - CRYPTO = v; - } - } else { - throw Error - (bignumberError + p + ' not true or false: ' + v); - } - } - - // MODULO_MODE {number} Integer, 0 to 9 inclusive. - // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'MODULO_MODE')) { - v = obj[p]; - intCheck(v, 0, 9, p); - MODULO_MODE = v; - } - - // POW_PRECISION {number} Integer, 0 to MAX inclusive. - // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}' - if (obj.hasOwnProperty(p = 'POW_PRECISION')) { - v = obj[p]; - intCheck(v, 0, MAX, p); - POW_PRECISION = v; - } - - // FORMAT {object} - // '[BigNumber Error] FORMAT not an object: {v}' - if (obj.hasOwnProperty(p = 'FORMAT')) { - v = obj[p]; - if (typeof v == 'object') FORMAT = v; - else throw Error - (bignumberError + p + ' not an object: ' + v); - } - - // ALPHABET {string} - // '[BigNumber Error] ALPHABET invalid: {v}' - if (obj.hasOwnProperty(p = 'ALPHABET')) { - v = obj[p]; - - // Disallow if only one character, or contains '.' or a repeated character. - if (typeof v == 'string' && !/^.$|\.|(.).*\1/.test(v)) { - ALPHABET = v; - } else { - throw Error - (bignumberError + p + ' invalid: ' + v); - } - } - - } else { - - // '[BigNumber Error] Object expected: {v}' - throw Error - (bignumberError + 'Object expected: ' + obj); - } - } - - return { - DECIMAL_PLACES: DECIMAL_PLACES, - ROUNDING_MODE: ROUNDING_MODE, - EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS], - RANGE: [MIN_EXP, MAX_EXP], - CRYPTO: CRYPTO, - MODULO_MODE: MODULO_MODE, - POW_PRECISION: POW_PRECISION, - FORMAT: FORMAT, - ALPHABET: ALPHABET - }; - }; - - - /* - * Return true if v is a BigNumber instance, otherwise return false. - * - * v {any} - */ - BigNumber.isBigNumber = function (v) { - return v instanceof BigNumber || v && v._isBigNumber === true || false; - }; - - - /* - * Return a new BigNumber whose value is the maximum of the arguments. - * - * arguments {number|string|BigNumber} - */ - BigNumber.maximum = BigNumber.max = function () { - return maxOrMin(arguments, P.lt); - }; - - - /* - * Return a new BigNumber whose value is the minimum of the arguments. - * - * arguments {number|string|BigNumber} - */ - BigNumber.minimum = BigNumber.min = function () { - return maxOrMin(arguments, P.gt); - }; - - - /* - * Return a new BigNumber with a random value equal to or greater than 0 and less than 1, - * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing - * zeros are produced). - * - * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}' - * '[BigNumber Error] crypto unavailable' - */ - BigNumber.random = (function () { - var pow2_53 = 0x20000000000000; - - // Return a 53 bit integer n, where 0 <= n < 9007199254740992. - // Check if Math.random() produces more than 32 bits of randomness. - // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits. - // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1. - var random53bitInt = (Math.random() * pow2_53) & 0x1fffff - ? function () { return mathfloor(Math.random() * pow2_53); } - : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) + - (Math.random() * 0x800000 | 0); }; - - return function (dp) { - var a, b, e, k, v, - i = 0, - c = [], - rand = new BigNumber(ONE); - - if (dp == null) dp = DECIMAL_PLACES; - else intCheck(dp, 0, MAX); - - k = mathceil(dp / LOG_BASE); - - if (CRYPTO) { - - // Browsers supporting crypto.getRandomValues. - if (crypto.getRandomValues) { - - a = crypto.getRandomValues(new Uint32Array(k *= 2)); - - for (; i < k;) { - - // 53 bits: - // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2) - // 11111 11111111 11111111 11111111 11100000 00000000 00000000 - // ((Math.pow(2, 32) - 1) >>> 11).toString(2) - // 11111 11111111 11111111 - // 0x20000 is 2^21. - v = a[i] * 0x20000 + (a[i + 1] >>> 11); - - // Rejection sampling: - // 0 <= v < 9007199254740992 - // Probability that v >= 9e15, is - // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251 - if (v >= 9e15) { - b = crypto.getRandomValues(new Uint32Array(2)); - a[i] = b[0]; - a[i + 1] = b[1]; - } else { - - // 0 <= v <= 8999999999999999 - // 0 <= (v % 1e14) <= 99999999999999 - c.push(v % 1e14); - i += 2; - } - } - i = k / 2; - - // Node.js supporting crypto.randomBytes. - } else if (crypto.randomBytes) { - - // buffer - a = crypto.randomBytes(k *= 7); - - for (; i < k;) { - - // 0x1000000000000 is 2^48, 0x10000000000 is 2^40 - // 0x100000000 is 2^32, 0x1000000 is 2^24 - // 11111 11111111 11111111 11111111 11111111 11111111 11111111 - // 0 <= v < 9007199254740992 - v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) + - (a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) + - (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6]; - - if (v >= 9e15) { - crypto.randomBytes(7).copy(a, i); - } else { - - // 0 <= (v % 1e14) <= 99999999999999 - c.push(v % 1e14); - i += 7; - } - } - i = k / 7; - } else { - CRYPTO = false; - throw Error - (bignumberError + 'crypto unavailable'); - } - } - - // Use Math.random. - if (!CRYPTO) { - - for (; i < k;) { - v = random53bitInt(); - if (v < 9e15) c[i++] = v % 1e14; - } - } - - k = c[--i]; - dp %= LOG_BASE; - - // Convert trailing digits to zeros according to dp. - if (k && dp) { - v = POWS_TEN[LOG_BASE - dp]; - c[i] = mathfloor(k / v) * v; - } - - // Remove trailing elements which are zero. - for (; c[i] === 0; c.pop(), i--); - - // Zero? - if (i < 0) { - c = [e = 0]; - } else { - - // Remove leading elements which are zero and adjust exponent accordingly. - for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE); - - // Count the digits of the first element of c to determine leading zeros, and... - for (i = 1, v = c[0]; v >= 10; v /= 10, i++); - - // adjust the exponent accordingly. - if (i < LOG_BASE) e -= LOG_BASE - i; - } - - rand.e = e; - rand.c = c; - return rand; - }; - })(); - - - // PRIVATE FUNCTIONS - - - // Called by BigNumber and BigNumber.prototype.toString. - convertBase = (function () { - var decimal = '0123456789'; - - /* - * Convert string of baseIn to an array of numbers of baseOut. - * Eg. toBaseOut('255', 10, 16) returns [15, 15]. - * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5]. - */ - function toBaseOut(str, baseIn, baseOut, alphabet) { - var j, - arr = [0], - arrL, - i = 0, - len = str.length; - - for (; i < len;) { - for (arrL = arr.length; arrL--; arr[arrL] *= baseIn); - - arr[0] += alphabet.indexOf(str.charAt(i++)); - - for (j = 0; j < arr.length; j++) { - - if (arr[j] > baseOut - 1) { - if (arr[j + 1] == null) arr[j + 1] = 0; - arr[j + 1] += arr[j] / baseOut | 0; - arr[j] %= baseOut; - } - } - } - - return arr.reverse(); - } - - // Convert a numeric string of baseIn to a numeric string of baseOut. - // If the caller is toString, we are converting from base 10 to baseOut. - // If the caller is BigNumber, we are converting from baseIn to base 10. - return function (str, baseIn, baseOut, sign, callerIsToString) { - var alphabet, d, e, k, r, x, xc, y, - i = str.indexOf('.'), - dp = DECIMAL_PLACES, - rm = ROUNDING_MODE; - - // Non-integer. - if (i >= 0) { - k = POW_PRECISION; - - // Unlimited precision. - POW_PRECISION = 0; - str = str.replace('.', ''); - y = new BigNumber(baseIn); - x = y.pow(str.length - i); - POW_PRECISION = k; - - // Convert str as if an integer, then restore the fraction part by dividing the - // result by its base raised to a power. - - y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'), - 10, baseOut, decimal); - y.e = y.c.length; - } - - // Convert the number as integer. - - xc = toBaseOut(str, baseIn, baseOut, callerIsToString - ? (alphabet = ALPHABET, decimal) - : (alphabet = decimal, ALPHABET)); - - // xc now represents str as an integer and converted to baseOut. e is the exponent. - e = k = xc.length; - - // Remove trailing zeros. - for (; xc[--k] == 0; xc.pop()); - - // Zero? - if (!xc[0]) return alphabet.charAt(0); - - // Does str represent an integer? If so, no need for the division. - if (i < 0) { - --e; - } else { - x.c = xc; - x.e = e; - - // The sign is needed for correct rounding. - x.s = sign; - x = div(x, y, dp, rm, baseOut); - xc = x.c; - r = x.r; - e = x.e; - } - - // xc now represents str converted to baseOut. - - // THe index of the rounding digit. - d = e + dp + 1; - - // The rounding digit: the digit to the right of the digit that may be rounded up. - i = xc[d]; - - // Look at the rounding digits and mode to determine whether to round up. - - k = baseOut / 2; - r = r || d < 0 || xc[d + 1] != null; - - r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) - : i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 || - rm == (x.s < 0 ? 8 : 7)); - - // If the index of the rounding digit is not greater than zero, or xc represents - // zero, then the result of the base conversion is zero or, if rounding up, a value - // such as 0.00001. - if (d < 1 || !xc[0]) { - - // 1^-dp or 0 - str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) - : alphabet.charAt(0); - } else { - - // Truncate xc to the required number of decimal places. - xc.length = d; - - // Round up? - if (r) { - - // Rounding up may mean the previous digit has to be rounded up and so on. - for (--baseOut; ++xc[--d] > baseOut;) { - xc[d] = 0; - - if (!d) { - ++e; - xc = [1].concat(xc); - } - } - } - - // Determine trailing zeros. - for (k = xc.length; !xc[--k];); - - // E.g. [4, 11, 15] becomes 4bf. - for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++])); - - // Add leading zeros, decimal point and trailing zeros as required. - str = toFixedPoint(str, e, alphabet.charAt(0)); - } - - // The caller will add the sign. - return str; - }; - })(); - - - // Perform division in the specified base. Called by div and convertBase. - div = (function () { - - // Assume non-zero x and k. - function multiply(x, k, base) { - var m, temp, xlo, xhi, - carry = 0, - i = x.length, - klo = k % SQRT_BASE, - khi = k / SQRT_BASE | 0; - - for (x = x.slice(); i--;) { - xlo = x[i] % SQRT_BASE; - xhi = x[i] / SQRT_BASE | 0; - m = khi * xlo + xhi * klo; - temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry; - carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi; - x[i] = temp % base; - } - - if (carry) x = [carry].concat(x); - - return x; - } - - function compare(a, b, aL, bL) { - var i, cmp; - - if (aL != bL) { - cmp = aL > bL ? 1 : -1; - } else { - - for (i = cmp = 0; i < aL; i++) { - - if (a[i] != b[i]) { - cmp = a[i] > b[i] ? 1 : -1; - break; - } - } - } - - return cmp; - } - - function subtract(a, b, aL, base) { - var i = 0; - - // Subtract b from a. - for (; aL--;) { - a[aL] -= i; - i = a[aL] < b[aL] ? 1 : 0; - a[aL] = i * base + a[aL] - b[aL]; - } - - // Remove leading zeros. - for (; !a[0] && a.length > 1; a.splice(0, 1)); - } - - // x: dividend, y: divisor. - return function (x, y, dp, rm, base) { - var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, - yL, yz, - s = x.s == y.s ? 1 : -1, - xc = x.c, - yc = y.c; - - // Either NaN, Infinity or 0? - if (!xc || !xc[0] || !yc || !yc[0]) { - - return new BigNumber( - - // Return NaN if either NaN, or both Infinity or 0. - !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : - - // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0. - xc && xc[0] == 0 || !yc ? s * 0 : s / 0 - ); - } - - q = new BigNumber(s); - qc = q.c = []; - e = x.e - y.e; - s = dp + e + 1; - - if (!base) { - base = BASE; - e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE); - s = s / LOG_BASE | 0; - } - - // Result exponent may be one less then the current value of e. - // The coefficients of the BigNumbers from convertBase may have trailing zeros. - for (i = 0; yc[i] == (xc[i] || 0); i++); - - if (yc[i] > (xc[i] || 0)) e--; - - if (s < 0) { - qc.push(1); - more = true; - } else { - xL = xc.length; - yL = yc.length; - i = 0; - s += 2; - - // Normalise xc and yc so highest order digit of yc is >= base / 2. - - n = mathfloor(base / (yc[0] + 1)); - - // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1. - // if (n > 1 || n++ == 1 && yc[0] < base / 2) { - if (n > 1) { - yc = multiply(yc, n, base); - xc = multiply(xc, n, base); - yL = yc.length; - xL = xc.length; - } - - xi = yL; - rem = xc.slice(0, yL); - remL = rem.length; - - // Add zeros to make remainder as long as divisor. - for (; remL < yL; rem[remL++] = 0); - yz = yc.slice(); - yz = [0].concat(yz); - yc0 = yc[0]; - if (yc[1] >= base / 2) yc0++; - // Not necessary, but to prevent trial digit n > base, when using base 3. - // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15; - - do { - n = 0; - - // Compare divisor and remainder. - cmp = compare(yc, rem, yL, remL); - - // If divisor < remainder. - if (cmp < 0) { - - // Calculate trial digit, n. - - rem0 = rem[0]; - if (yL != remL) rem0 = rem0 * base + (rem[1] || 0); - - // n is how many times the divisor goes into the current remainder. - n = mathfloor(rem0 / yc0); - - // Algorithm: - // product = divisor multiplied by trial digit (n). - // Compare product and remainder. - // If product is greater than remainder: - // Subtract divisor from product, decrement trial digit. - // Subtract product from remainder. - // If product was less than remainder at the last compare: - // Compare new remainder and divisor. - // If remainder is greater than divisor: - // Subtract divisor from remainder, increment trial digit. - - if (n > 1) { - - // n may be > base only when base is 3. - if (n >= base) n = base - 1; - - // product = divisor * trial digit. - prod = multiply(yc, n, base); - prodL = prod.length; - remL = rem.length; - - // Compare product and remainder. - // If product > remainder then trial digit n too high. - // n is 1 too high about 5% of the time, and is not known to have - // ever been more than 1 too high. - while (compare(prod, rem, prodL, remL) == 1) { - n--; - - // Subtract divisor from product. - subtract(prod, yL < prodL ? yz : yc, prodL, base); - prodL = prod.length; - cmp = 1; - } - } else { - - // n is 0 or 1, cmp is -1. - // If n is 0, there is no need to compare yc and rem again below, - // so change cmp to 1 to avoid it. - // If n is 1, leave cmp as -1, so yc and rem are compared again. - if (n == 0) { - - // divisor < remainder, so n must be at least 1. - cmp = n = 1; - } - - // product = divisor - prod = yc.slice(); - prodL = prod.length; - } - - if (prodL < remL) prod = [0].concat(prod); - - // Subtract product from remainder. - subtract(rem, prod, remL, base); - remL = rem.length; - - // If product was < remainder. - if (cmp == -1) { - - // Compare divisor and new remainder. - // If divisor < new remainder, subtract divisor from remainder. - // Trial digit n too low. - // n is 1 too low about 5% of the time, and very rarely 2 too low. - while (compare(yc, rem, yL, remL) < 1) { - n++; - - // Subtract divisor from remainder. - subtract(rem, yL < remL ? yz : yc, remL, base); - remL = rem.length; - } - } - } else if (cmp === 0) { - n++; - rem = [0]; - } // else cmp === 1 and n will be 0 - - // Add the next digit, n, to the result array. - qc[i++] = n; - - // Update the remainder. - if (rem[0]) { - rem[remL++] = xc[xi] || 0; - } else { - rem = [xc[xi]]; - remL = 1; - } - } while ((xi++ < xL || rem[0] != null) && s--); - - more = rem[0] != null; - - // Leading zero? - if (!qc[0]) qc.splice(0, 1); - } - - if (base == BASE) { - - // To calculate q.e, first get the number of digits of qc[0]. - for (i = 1, s = qc[0]; s >= 10; s /= 10, i++); - - round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more); - - // Caller is convertBase. - } else { - q.e = e; - q.r = +more; - } - - return q; - }; - })(); - - - /* - * Return a string representing the value of BigNumber n in fixed-point or exponential - * notation rounded to the specified decimal places or significant digits. - * - * n: a BigNumber. - * i: the index of the last digit required (i.e. the digit that may be rounded up). - * rm: the rounding mode. - * id: 1 (toExponential) or 2 (toPrecision). - */ - function format(n, i, rm, id) { - var c0, e, ne, len, str; - - if (rm == null) rm = ROUNDING_MODE; - else intCheck(rm, 0, 8); - - if (!n.c) return n.toString(); - - c0 = n.c[0]; - ne = n.e; - - if (i == null) { - str = coeffToString(n.c); - str = id == 1 || id == 2 && ne <= TO_EXP_NEG - ? toExponential(str, ne) - : toFixedPoint(str, ne, '0'); - } else { - n = round(new BigNumber(n), i, rm); - - // n.e may have changed if the value was rounded up. - e = n.e; - - str = coeffToString(n.c); - len = str.length; - - // toPrecision returns exponential notation if the number of significant digits - // specified is less than the number of digits necessary to represent the integer - // part of the value in fixed-point notation. - - // Exponential notation. - if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) { - - // Append zeros? - for (; len < i; str += '0', len++); - str = toExponential(str, e); - - // Fixed-point notation. - } else { - i -= ne; - str = toFixedPoint(str, e, '0'); - - // Append zeros? - if (e + 1 > len) { - if (--i > 0) for (str += '.'; i--; str += '0'); - } else { - i += e - len; - if (i > 0) { - if (e + 1 == len) str += '.'; - for (; i--; str += '0'); - } - } - } - } - - return n.s < 0 && c0 ? '-' + str : str; - } - - - // Handle BigNumber.max and BigNumber.min. - function maxOrMin(args, method) { - var m, n, - i = 0; - - if (isArray(args[0])) args = args[0]; - m = new BigNumber(args[0]); - - for (; ++i < args.length;) { - n = new BigNumber(args[i]); - - // If any number is NaN, return NaN. - if (!n.s) { - m = n; - break; - } else if (method.call(m, n)) { - m = n; - } - } - - return m; - } - - - /* - * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP. - * Called by minus, plus and times. - */ - function normalise(n, c, e) { - var i = 1, - j = c.length; - - // Remove trailing zeros. - for (; !c[--j]; c.pop()); - - // Calculate the base 10 exponent. First get the number of digits of c[0]. - for (j = c[0]; j >= 10; j /= 10, i++); - - // Overflow? - if ((e = i + e * LOG_BASE - 1) > MAX_EXP) { - - // Infinity. - n.c = n.e = null; - - // Underflow? - } else if (e < MIN_EXP) { - - // Zero. - n.c = [n.e = 0]; - } else { - n.e = e; - n.c = c; - } - - return n; - } - - - // Handle values that fail the validity test in BigNumber. - parseNumeric = (function () { - var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, - dotAfter = /^([^.]+)\.$/, - dotBefore = /^\.([^.]+)$/, - isInfinityOrNaN = /^-?(Infinity|NaN)$/, - whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g; - - return function (x, str, isNum, b) { - var base, - s = isNum ? str : str.replace(whitespaceOrPlus, ''); - - // No exception on ±Infinity or NaN. - if (isInfinityOrNaN.test(s)) { - x.s = isNaN(s) ? null : s < 0 ? -1 : 1; - x.c = x.e = null; - } else { - if (!isNum) { - - // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i - s = s.replace(basePrefix, function (m, p1, p2) { - base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8; - return !b || b == base ? p1 : m; - }); - - if (b) { - base = b; - - // E.g. '1.' to '1', '.1' to '0.1' - s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1'); - } - - if (str != s) return new BigNumber(s, base); - } - - // '[BigNumber Error] Not a number: {n}' - // '[BigNumber Error] Not a base {b} number: {n}' - if (BigNumber.DEBUG) { - throw Error - (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str); - } - - // NaN - x.c = x.e = x.s = null; - } - } - })(); - - - /* - * Round x to sd significant digits using rounding mode rm. Check for over/under-flow. - * If r is truthy, it is known that there are more digits after the rounding digit. - */ - function round(x, sd, rm, r) { - var d, i, j, k, n, ni, rd, - xc = x.c, - pows10 = POWS_TEN; - - // if x is not Infinity or NaN... - if (xc) { - - // rd is the rounding digit, i.e. the digit after the digit that may be rounded up. - // n is a base 1e14 number, the value of the element of array x.c containing rd. - // ni is the index of n within x.c. - // d is the number of digits of n. - // i is the index of rd within n including leading zeros. - // j is the actual index of rd within n (if < 0, rd is a leading zero). - out: { - - // Get the number of digits of the first element of xc. - for (d = 1, k = xc[0]; k >= 10; k /= 10, d++); - i = sd - d; - - // If the rounding digit is in the first element of xc... - if (i < 0) { - i += LOG_BASE; - j = sd; - n = xc[ni = 0]; - - // Get the rounding digit at index j of n. - rd = n / pows10[d - j - 1] % 10 | 0; - } else { - ni = mathceil((i + 1) / LOG_BASE); - - if (ni >= xc.length) { - - if (r) { - - // Needed by sqrt. - for (; xc.length <= ni; xc.push(0)); - n = rd = 0; - d = 1; - i %= LOG_BASE; - j = i - LOG_BASE + 1; - } else { - break out; - } - } else { - n = k = xc[ni]; - - // Get the number of digits of n. - for (d = 1; k >= 10; k /= 10, d++); - - // Get the index of rd within n. - i %= LOG_BASE; - - // Get the index of rd within n, adjusted for leading zeros. - // The number of leading zeros of n is given by LOG_BASE - d. - j = i - LOG_BASE + d; - - // Get the rounding digit at index j of n. - rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0; - } - } - - r = r || sd < 0 || - - // Are there any non-zero digits after the rounding digit? - // The expression n % pows10[d - j - 1] returns all digits of n to the right - // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714. - xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]); - - r = rm < 4 - ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) - : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && - - // Check whether the digit to the left of the rounding digit is odd. - ((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 || - rm == (x.s < 0 ? 8 : 7)); - - if (sd < 1 || !xc[0]) { - xc.length = 0; - - if (r) { - - // Convert sd to decimal places. - sd -= x.e + 1; - - // 1, 0.1, 0.01, 0.001, 0.0001 etc. - xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE]; - x.e = -sd || 0; - } else { - - // Zero. - xc[0] = x.e = 0; - } - - return x; - } - - // Remove excess digits. - if (i == 0) { - xc.length = ni; - k = 1; - ni--; - } else { - xc.length = ni + 1; - k = pows10[LOG_BASE - i]; - - // E.g. 56700 becomes 56000 if 7 is the rounding digit. - // j > 0 means i > number of leading zeros of n. - xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0; - } - - // Round up? - if (r) { - - for (; ;) { - - // If the digit to be rounded up is in the first element of xc... - if (ni == 0) { - - // i will be the length of xc[0] before k is added. - for (i = 1, j = xc[0]; j >= 10; j /= 10, i++); - j = xc[0] += k; - for (k = 1; j >= 10; j /= 10, k++); - - // if i != k the length has increased. - if (i != k) { - x.e++; - if (xc[0] == BASE) xc[0] = 1; - } - - break; - } else { - xc[ni] += k; - if (xc[ni] != BASE) break; - xc[ni--] = 0; - k = 1; - } - } - } - - // Remove trailing zeros. - for (i = xc.length; xc[--i] === 0; xc.pop()); - } - - // Overflow? Infinity. - if (x.e > MAX_EXP) { - x.c = x.e = null; - - // Underflow? Zero. - } else if (x.e < MIN_EXP) { - x.c = [x.e = 0]; - } - } - - return x; - } - - - // PROTOTYPE/INSTANCE METHODS - - - /* - * Return a new BigNumber whose value is the absolute value of this BigNumber. - */ - P.absoluteValue = P.abs = function () { - var x = new BigNumber(this); - if (x.s < 0) x.s = 1; - return x; - }; - - - /* - * Return - * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b), - * -1 if the value of this BigNumber is less than the value of BigNumber(y, b), - * 0 if they have the same value, - * or null if the value of either is NaN. - */ - P.comparedTo = function (y, b) { - return compare(this, new BigNumber(y, b)); - }; - - - /* - * If dp is undefined or null or true or false, return the number of decimal places of the - * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. - * - * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this - * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or - * ROUNDING_MODE if rm is omitted. - * - * [dp] {number} Decimal places: integer, 0 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' - */ - P.decimalPlaces = P.dp = function (dp, rm) { - var c, n, v, - x = this; - - if (dp != null) { - intCheck(dp, 0, MAX); - if (rm == null) rm = ROUNDING_MODE; - else intCheck(rm, 0, 8); - - return round(new BigNumber(x), dp + x.e + 1, rm); - } - - if (!(c = x.c)) return null; - n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE; - - // Subtract the number of trailing zeros of the last number. - if (v = c[v]) for (; v % 10 == 0; v /= 10, n--); - if (n < 0) n = 0; - - return n; - }; - - - /* - * n / 0 = I - * n / N = N - * n / I = 0 - * 0 / n = 0 - * 0 / 0 = N - * 0 / N = N - * 0 / I = 0 - * N / n = N - * N / 0 = N - * N / N = N - * N / I = N - * I / n = I - * I / 0 = I - * I / N = N - * I / I = N - * - * Return a new BigNumber whose value is the value of this BigNumber divided by the value of - * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE. - */ - P.dividedBy = P.div = function (y, b) { - return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE); - }; - - - /* - * Return a new BigNumber whose value is the integer part of dividing the value of this - * BigNumber by the value of BigNumber(y, b). - */ - P.dividedToIntegerBy = P.idiv = function (y, b) { - return div(this, new BigNumber(y, b), 0, 1); - }; - - - /* - * Return a BigNumber whose value is the value of this BigNumber exponentiated by n. - * - * If m is present, return the result modulo m. - * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE. - * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE. - * - * The modular power operation works efficiently when x, n, and m are integers, otherwise it - * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0. - * - * n {number|string|BigNumber} The exponent. An integer. - * [m] {number|string|BigNumber} The modulus. - * - * '[BigNumber Error] Exponent not an integer: {n}' - */ - P.exponentiatedBy = P.pow = function (n, m) { - var half, isModExp, k, more, nIsBig, nIsNeg, nIsOdd, y, - x = this; - - n = new BigNumber(n); - - // Allow NaN and ±Infinity, but not other non-integers. - if (n.c && !n.isInteger()) { - throw Error - (bignumberError + 'Exponent not an integer: ' + n); - } - - if (m != null) m = new BigNumber(m); - - // Exponent of MAX_SAFE_INTEGER is 15. - nIsBig = n.e > 14; - - // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0. - if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) { - - // The sign of the result of pow when x is negative depends on the evenness of n. - // If +n overflows to ±Infinity, the evenness of n would be not be known. - y = new BigNumber(Math.pow(+x.valueOf(), nIsBig ? 2 - isOdd(n) : +n)); - return m ? y.mod(m) : y; - } - - nIsNeg = n.s < 0; - - if (m) { - - // x % m returns NaN if abs(m) is zero, or m is NaN. - if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN); - - isModExp = !nIsNeg && x.isInteger() && m.isInteger(); - - if (isModExp) x = x.mod(m); - - // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15. - // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15. - } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 - // [1, 240000000] - ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 - // [80000000000000] [99999750000000] - : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) { - - // If x is negative and n is odd, k = -0, else k = 0. - k = x.s < 0 && isOdd(n) ? -0 : 0; - - // If x >= 1, k = ±Infinity. - if (x.e > -1) k = 1 / k; - - // If n is negative return ±0, else return ±Infinity. - return new BigNumber(nIsNeg ? 1 / k : k); - - } else if (POW_PRECISION) { - - // Truncating each coefficient array to a length of k after each multiplication - // equates to truncating significant digits to POW_PRECISION + [28, 41], - // i.e. there will be a minimum of 28 guard digits retained. - k = mathceil(POW_PRECISION / LOG_BASE + 2); - } - - if (nIsBig) { - half = new BigNumber(0.5); - nIsOdd = isOdd(n); - } else { - nIsOdd = n % 2; - } - - if (nIsNeg) n.s = 1; - - y = new BigNumber(ONE); - - // Performs 54 loop iterations for n of 9007199254740991. - for (; ;) { - - if (nIsOdd) { - y = y.times(x); - if (!y.c) break; - - if (k) { - if (y.c.length > k) y.c.length = k; - } else if (isModExp) { - y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m)); - } - } - - if (nIsBig) { - n = n.times(half); - round(n, n.e + 1, 1); - if (!n.c[0]) break; - nIsBig = n.e > 14; - nIsOdd = isOdd(n); - } else { - n = mathfloor(n / 2); - if (!n) break; - nIsOdd = n % 2; - } - - x = x.times(x); - - if (k) { - if (x.c && x.c.length > k) x.c.length = k; - } else if (isModExp) { - x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m)); - } - } - - if (isModExp) return y; - if (nIsNeg) y = ONE.div(y); - - return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y; - }; - - - /* - * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer - * using rounding mode rm, or ROUNDING_MODE if rm is omitted. - * - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}' - */ - P.integerValue = function (rm) { - var n = new BigNumber(this); - if (rm == null) rm = ROUNDING_MODE; - else intCheck(rm, 0, 8); - return round(n, n.e + 1, rm); - }; - - - /* - * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b), - * otherwise return false. - */ - P.isEqualTo = P.eq = function (y, b) { - return compare(this, new BigNumber(y, b)) === 0; - }; - - - /* - * Return true if the value of this BigNumber is a finite number, otherwise return false. - */ - P.isFinite = function () { - return !!this.c; - }; - - - /* - * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b), - * otherwise return false. - */ - P.isGreaterThan = P.gt = function (y, b) { - return compare(this, new BigNumber(y, b)) > 0; - }; - - - /* - * Return true if the value of this BigNumber is greater than or equal to the value of - * BigNumber(y, b), otherwise return false. - */ - P.isGreaterThanOrEqualTo = P.gte = function (y, b) { - return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0; - - }; - - - /* - * Return true if the value of this BigNumber is an integer, otherwise return false. - */ - P.isInteger = function () { - return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2; - }; - - - /* - * Return true if the value of this BigNumber is less than the value of BigNumber(y, b), - * otherwise return false. - */ - P.isLessThan = P.lt = function (y, b) { - return compare(this, new BigNumber(y, b)) < 0; - }; - - - /* - * Return true if the value of this BigNumber is less than or equal to the value of - * BigNumber(y, b), otherwise return false. - */ - P.isLessThanOrEqualTo = P.lte = function (y, b) { - return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0; - }; - - - /* - * Return true if the value of this BigNumber is NaN, otherwise return false. - */ - P.isNaN = function () { - return !this.s; - }; - - - /* - * Return true if the value of this BigNumber is negative, otherwise return false. - */ - P.isNegative = function () { - return this.s < 0; - }; - - - /* - * Return true if the value of this BigNumber is positive, otherwise return false. - */ - P.isPositive = function () { - return this.s > 0; - }; - - - /* - * Return true if the value of this BigNumber is 0 or -0, otherwise return false. - */ - P.isZero = function () { - return !!this.c && this.c[0] == 0; - }; - - - /* - * n - 0 = n - * n - N = N - * n - I = -I - * 0 - n = -n - * 0 - 0 = 0 - * 0 - N = N - * 0 - I = -I - * N - n = N - * N - 0 = N - * N - N = N - * N - I = N - * I - n = I - * I - 0 = I - * I - N = N - * I - I = N - * - * Return a new BigNumber whose value is the value of this BigNumber minus the value of - * BigNumber(y, b). - */ - P.minus = function (y, b) { - var i, j, t, xLTy, - x = this, - a = x.s; - - y = new BigNumber(y, b); - b = y.s; - - // Either NaN? - if (!a || !b) return new BigNumber(NaN); - - // Signs differ? - if (a != b) { - y.s = -b; - return x.plus(y); - } - - var xe = x.e / LOG_BASE, - ye = y.e / LOG_BASE, - xc = x.c, - yc = y.c; - - if (!xe || !ye) { - - // Either Infinity? - if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN); - - // Either zero? - if (!xc[0] || !yc[0]) { - - // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. - return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x : - - // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity - ROUNDING_MODE == 3 ? -0 : 0); - } - } - - xe = bitFloor(xe); - ye = bitFloor(ye); - xc = xc.slice(); - - // Determine which is the bigger number. - if (a = xe - ye) { - - if (xLTy = a < 0) { - a = -a; - t = xc; - } else { - ye = xe; - t = yc; - } - - t.reverse(); - - // Prepend zeros to equalise exponents. - for (b = a; b--; t.push(0)); - t.reverse(); - } else { - - // Exponents equal. Check digit by digit. - j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b; - - for (a = b = 0; b < j; b++) { - - if (xc[b] != yc[b]) { - xLTy = xc[b] < yc[b]; - break; - } - } - } - - // x < y? Point xc to the array of the bigger number. - if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s; - - b = (j = yc.length) - (i = xc.length); - - // Append zeros to xc if shorter. - // No need to add zeros to yc if shorter as subtract only needs to start at yc.length. - if (b > 0) for (; b--; xc[i++] = 0); - b = BASE - 1; - - // Subtract yc from xc. - for (; j > a;) { - - if (xc[--j] < yc[j]) { - for (i = j; i && !xc[--i]; xc[i] = b); - --xc[i]; - xc[j] += BASE; - } - - xc[j] -= yc[j]; - } - - // Remove leading zeros and adjust exponent accordingly. - for (; xc[0] == 0; xc.splice(0, 1), --ye); - - // Zero? - if (!xc[0]) { - - // Following IEEE 754 (2008) 6.3, - // n - n = +0 but n - n = -0 when rounding towards -Infinity. - y.s = ROUNDING_MODE == 3 ? -1 : 1; - y.c = [y.e = 0]; - return y; - } - - // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity - // for finite x and y. - return normalise(y, xc, ye); - }; - - - /* - * n % 0 = N - * n % N = N - * n % I = n - * 0 % n = 0 - * -0 % n = -0 - * 0 % 0 = N - * 0 % N = N - * 0 % I = 0 - * N % n = N - * N % 0 = N - * N % N = N - * N % I = N - * I % n = N - * I % 0 = N - * I % N = N - * I % I = N - * - * Return a new BigNumber whose value is the value of this BigNumber modulo the value of - * BigNumber(y, b). The result depends on the value of MODULO_MODE. - */ - P.modulo = P.mod = function (y, b) { - var q, s, - x = this; - - y = new BigNumber(y, b); - - // Return NaN if x is Infinity or NaN, or y is NaN or zero. - if (!x.c || !y.s || y.c && !y.c[0]) { - return new BigNumber(NaN); - - // Return x if y is Infinity or x is zero. - } else if (!y.c || x.c && !x.c[0]) { - return new BigNumber(x); - } - - if (MODULO_MODE == 9) { - - // Euclidian division: q = sign(y) * floor(x / abs(y)) - // r = x - qy where 0 <= r < abs(y) - s = y.s; - y.s = 1; - q = div(x, y, 0, 3); - y.s = s; - q.s *= s; - } else { - q = div(x, y, 0, MODULO_MODE); - } - - y = x.minus(q.times(y)); - - // To match JavaScript %, ensure sign of zero is sign of dividend. - if (!y.c[0] && MODULO_MODE == 1) y.s = x.s; - - return y; - }; - - - /* - * n * 0 = 0 - * n * N = N - * n * I = I - * 0 * n = 0 - * 0 * 0 = 0 - * 0 * N = N - * 0 * I = N - * N * n = N - * N * 0 = N - * N * N = N - * N * I = N - * I * n = I - * I * 0 = N - * I * N = N - * I * I = I - * - * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value - * of BigNumber(y, b). - */ - P.multipliedBy = P.times = function (y, b) { - var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, - base, sqrtBase, - x = this, - xc = x.c, - yc = (y = new BigNumber(y, b)).c; - - // Either NaN, ±Infinity or ±0? - if (!xc || !yc || !xc[0] || !yc[0]) { - - // Return NaN if either is NaN, or one is 0 and the other is Infinity. - if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) { - y.c = y.e = y.s = null; - } else { - y.s *= x.s; - - // Return ±Infinity if either is ±Infinity. - if (!xc || !yc) { - y.c = y.e = null; - - // Return ±0 if either is ±0. - } else { - y.c = [0]; - y.e = 0; - } - } - - return y; - } - - e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE); - y.s *= x.s; - xcL = xc.length; - ycL = yc.length; - - // Ensure xc points to longer array and xcL to its length. - if (xcL < ycL) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i; - - // Initialise the result array with zeros. - for (i = xcL + ycL, zc = []; i--; zc.push(0)); - - base = BASE; - sqrtBase = SQRT_BASE; - - for (i = ycL; --i >= 0;) { - c = 0; - ylo = yc[i] % sqrtBase; - yhi = yc[i] / sqrtBase | 0; - - for (k = xcL, j = i + k; j > i;) { - xlo = xc[--k] % sqrtBase; - xhi = xc[k] / sqrtBase | 0; - m = yhi * xlo + xhi * ylo; - xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c; - c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi; - zc[j--] = xlo % base; - } - - zc[j] = c; - } - - if (c) { - ++e; - } else { - zc.splice(0, 1); - } - - return normalise(y, zc, e); - }; - - - /* - * Return a new BigNumber whose value is the value of this BigNumber negated, - * i.e. multiplied by -1. - */ - P.negated = function () { - var x = new BigNumber(this); - x.s = -x.s || null; - return x; - }; - - - /* - * n + 0 = n - * n + N = N - * n + I = I - * 0 + n = n - * 0 + 0 = 0 - * 0 + N = N - * 0 + I = I - * N + n = N - * N + 0 = N - * N + N = N - * N + I = N - * I + n = I - * I + 0 = I - * I + N = N - * I + I = I - * - * Return a new BigNumber whose value is the value of this BigNumber plus the value of - * BigNumber(y, b). - */ - P.plus = function (y, b) { - var t, - x = this, - a = x.s; - - y = new BigNumber(y, b); - b = y.s; - - // Either NaN? - if (!a || !b) return new BigNumber(NaN); - - // Signs differ? - if (a != b) { - y.s = -b; - return x.minus(y); - } - - var xe = x.e / LOG_BASE, - ye = y.e / LOG_BASE, - xc = x.c, - yc = y.c; - - if (!xe || !ye) { - - // Return ±Infinity if either ±Infinity. - if (!xc || !yc) return new BigNumber(a / 0); - - // Either zero? - // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. - if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0); - } - - xe = bitFloor(xe); - ye = bitFloor(ye); - xc = xc.slice(); - - // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts. - if (a = xe - ye) { - if (a > 0) { - ye = xe; - t = yc; - } else { - a = -a; - t = xc; - } - - t.reverse(); - for (; a--; t.push(0)); - t.reverse(); - } - - a = xc.length; - b = yc.length; - - // Point xc to the longer array, and b to the shorter length. - if (a - b < 0) t = yc, yc = xc, xc = t, b = a; - - // Only start adding at yc.length - 1 as the further digits of xc can be ignored. - for (a = 0; b;) { - a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0; - xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE; - } - - if (a) { - xc = [a].concat(xc); - ++ye; - } - - // No need to check for zero, as +x + +y != 0 && -x + -y != 0 - // ye = MAX_EXP + 1 possible - return normalise(y, xc, ye); - }; - - - /* - * If sd is undefined or null or true or false, return the number of significant digits of - * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. - * If sd is true include integer-part trailing zeros in the count. - * - * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this - * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or - * ROUNDING_MODE if rm is omitted. - * - * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive. - * boolean: whether to count integer-part trailing zeros: true or false. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' - */ - P.precision = P.sd = function (sd, rm) { - var c, n, v, - x = this; - - if (sd != null && sd !== !!sd) { - intCheck(sd, 1, MAX); - if (rm == null) rm = ROUNDING_MODE; - else intCheck(rm, 0, 8); - - return round(new BigNumber(x), sd, rm); - } - - if (!(c = x.c)) return null; - v = c.length - 1; - n = v * LOG_BASE + 1; - - if (v = c[v]) { - - // Subtract the number of trailing zeros of the last element. - for (; v % 10 == 0; v /= 10, n--); - - // Add the number of digits of the first element. - for (v = c[0]; v >= 10; v /= 10, n++); - } - - if (sd && x.e + 1 > n) n = x.e + 1; - - return n; - }; - - - /* - * Return a new BigNumber whose value is the value of this BigNumber shifted by k places - * (powers of 10). Shift to the right if n > 0, and to the left if n < 0. - * - * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}' - */ - P.shiftedBy = function (k) { - intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER); - return this.times('1e' + k); - }; - - - /* - * sqrt(-n) = N - * sqrt(N) = N - * sqrt(-I) = N - * sqrt(I) = I - * sqrt(0) = 0 - * sqrt(-0) = -0 - * - * Return a new BigNumber whose value is the square root of the value of this BigNumber, - * rounded according to DECIMAL_PLACES and ROUNDING_MODE. - */ - P.squareRoot = P.sqrt = function () { - var m, n, r, rep, t, - x = this, - c = x.c, - s = x.s, - e = x.e, - dp = DECIMAL_PLACES + 4, - half = new BigNumber('0.5'); - - // Negative/NaN/Infinity/zero? - if (s !== 1 || !c || !c[0]) { - return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0); - } - - // Initial estimate. - s = Math.sqrt(+x); - - // Math.sqrt underflow/overflow? - // Pass x to Math.sqrt as integer, then adjust the exponent of the result. - if (s == 0 || s == 1 / 0) { - n = coeffToString(c); - if ((n.length + e) % 2 == 0) n += '0'; - s = Math.sqrt(n); - e = bitFloor((e + 1) / 2) - (e < 0 || e % 2); - - if (s == 1 / 0) { - n = '1e' + e; - } else { - n = s.toExponential(); - n = n.slice(0, n.indexOf('e') + 1) + e; - } - - r = new BigNumber(n); - } else { - r = new BigNumber(s + ''); - } - - // Check for zero. - // r could be zero if MIN_EXP is changed after the this value was created. - // This would cause a division by zero (x/t) and hence Infinity below, which would cause - // coeffToString to throw. - if (r.c[0]) { - e = r.e; - s = e + dp; - if (s < 3) s = 0; - - // Newton-Raphson iteration. - for (; ;) { - t = r; - r = half.times(t.plus(div(x, t, dp, 1))); - - if (coeffToString(t.c ).slice(0, s) === (n = - coeffToString(r.c)).slice(0, s)) { - - // The exponent of r may here be one less than the final result exponent, - // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits - // are indexed correctly. - if (r.e < e) --s; - n = n.slice(s - 3, s + 1); - - // The 4th rounding digit may be in error by -1 so if the 4 rounding digits - // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the - // iteration. - if (n == '9999' || !rep && n == '4999') { - - // On the first iteration only, check to see if rounding up gives the - // exact result as the nines may infinitely repeat. - if (!rep) { - round(t, t.e + DECIMAL_PLACES + 2, 0); - - if (t.times(t).eq(x)) { - r = t; - break; - } - } - - dp += 4; - s += 4; - rep = 1; - } else { - - // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact - // result. If not, then there are further digits and m will be truthy. - if (!+n || !+n.slice(1) && n.charAt(0) == '5') { - - // Truncate to the first rounding digit. - round(r, r.e + DECIMAL_PLACES + 2, 1); - m = !r.times(r).eq(x); - } - - break; - } - } - } - } - - return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m); - }; - - - /* - * Return a string representing the value of this BigNumber in exponential notation and - * rounded using ROUNDING_MODE to dp fixed decimal places. - * - * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' - */ - P.toExponential = function (dp, rm) { - if (dp != null) { - intCheck(dp, 0, MAX); - dp++; - } - return format(this, dp, rm, 1); - }; - - - /* - * Return a string representing the value of this BigNumber in fixed-point notation rounding - * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted. - * - * Note: as with JavaScript's number type, (-0).toFixed(0) is '0', - * but e.g. (-0.00001).toFixed(0) is '-0'. - * - * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' - */ - P.toFixed = function (dp, rm) { - if (dp != null) { - intCheck(dp, 0, MAX); - dp = dp + this.e + 1; - } - return format(this, dp, rm); - }; - - - /* - * Return a string representing the value of this BigNumber in fixed-point notation rounded - * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties - * of the FORMAT object (see BigNumber.set). - * - * FORMAT = { - * decimalSeparator : '.', - * groupSeparator : ',', - * groupSize : 3, - * secondaryGroupSize : 0, - * fractionGroupSeparator : '\xA0', // non-breaking space - * fractionGroupSize : 0 - * }; - * - * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' - */ - P.toFormat = function (dp, rm) { - var str = this.toFixed(dp, rm); - - if (this.c) { - var i, - arr = str.split('.'), - g1 = +FORMAT.groupSize, - g2 = +FORMAT.secondaryGroupSize, - groupSeparator = FORMAT.groupSeparator, - intPart = arr[0], - fractionPart = arr[1], - isNeg = this.s < 0, - intDigits = isNeg ? intPart.slice(1) : intPart, - len = intDigits.length; - - if (g2) i = g1, g1 = g2, g2 = i, len -= i; - - if (g1 > 0 && len > 0) { - i = len % g1 || g1; - intPart = intDigits.substr(0, i); - - for (; i < len; i += g1) { - intPart += groupSeparator + intDigits.substr(i, g1); - } - - if (g2 > 0) intPart += groupSeparator + intDigits.slice(i); - if (isNeg) intPart = '-' + intPart; - } - - str = fractionPart - ? intPart + FORMAT.decimalSeparator + ((g2 = +FORMAT.fractionGroupSize) - ? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'), - '$&' + FORMAT.fractionGroupSeparator) - : fractionPart) - : intPart; - } - - return str; - }; - - - /* - * Return a string array representing the value of this BigNumber as a simple fraction with - * an integer numerator and an integer denominator. The denominator will be a positive - * non-zero value less than or equal to the specified maximum denominator. If a maximum - * denominator is not specified, the denominator will be the lowest value necessary to - * represent the number exactly. - * - * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator. - * - * '[BigNumber Error] Argument {not an integer|out of range} : {md}' - */ - P.toFraction = function (md) { - var arr, d, d0, d1, d2, e, exp, n, n0, n1, q, s, - x = this, - xc = x.c; - - if (md != null) { - n = new BigNumber(md); - - // Throw if md is less than one or is not an integer, unless it is Infinity. - if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) { - throw Error - (bignumberError + 'Argument ' + - (n.isInteger() ? 'out of range: ' : 'not an integer: ') + md); - } - } - - if (!xc) return x.toString(); - - d = new BigNumber(ONE); - n1 = d0 = new BigNumber(ONE); - d1 = n0 = new BigNumber(ONE); - s = coeffToString(xc); - - // Determine initial denominator. - // d is a power of 10 and the minimum max denominator that specifies the value exactly. - e = d.e = s.length - x.e - 1; - d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp]; - md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n; - - exp = MAX_EXP; - MAX_EXP = 1 / 0; - n = new BigNumber(s); - - // n0 = d1 = 0 - n0.c[0] = 0; - - for (; ;) { - q = div(n, d, 0, 1); - d2 = d0.plus(q.times(d1)); - if (d2.comparedTo(md) == 1) break; - d0 = d1; - d1 = d2; - n1 = n0.plus(q.times(d2 = n1)); - n0 = d2; - d = n.minus(q.times(d2 = d)); - n = d2; - } - - d2 = div(md.minus(d0), d1, 0, 1); - n0 = n0.plus(d2.times(n1)); - d0 = d0.plus(d2.times(d1)); - n0.s = n1.s = x.s; - e *= 2; - - // Determine which fraction is closer to x, n0/d0 or n1/d1 - arr = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo( - div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 - ? [n1.toString(), d1.toString()] - : [n0.toString(), d0.toString()]; - - MAX_EXP = exp; - return arr; - }; - - - /* - * Return the value of this BigNumber converted to a number primitive. - */ - P.toNumber = function () { - return +this; - }; - - - /* - * Return a string representing the value of this BigNumber rounded to sd significant digits - * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits - * necessary to represent the integer part of the value in fixed-point notation, then use - * exponential notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' - */ - P.toPrecision = function (sd, rm) { - if (sd != null) intCheck(sd, 1, MAX); - return format(this, sd, rm, 2); - }; - - - /* - * Return a string representing the value of this BigNumber in base b, or base 10 if b is - * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and - * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent - * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than - * TO_EXP_NEG, return exponential notation. - * - * [b] {number} Integer, 2 to ALPHABET.length inclusive. - * - * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' - */ - P.toString = function (b) { - var str, - n = this, - s = n.s, - e = n.e; - - // Infinity or NaN? - if (e === null) { - - if (s) { - str = 'Infinity'; - if (s < 0) str = '-' + str; - } else { - str = 'NaN'; - } - } else { - str = coeffToString(n.c); - - if (b == null) { - str = e <= TO_EXP_NEG || e >= TO_EXP_POS - ? toExponential(str, e) - : toFixedPoint(str, e, '0'); - } else { - intCheck(b, 2, ALPHABET.length, 'Base'); - str = convertBase(toFixedPoint(str, e, '0'), 10, b, s, true); - } - - if (s < 0 && n.c[0]) str = '-' + str; - } - - return str; - }; - - - /* - * Return as toString, but do not accept a base argument, and include the minus sign for - * negative zero. - */ - P.valueOf = P.toJSON = function () { - var str, - n = this, - e = n.e; - - if (e === null) return n.toString(); - - str = coeffToString(n.c); - - str = e <= TO_EXP_NEG || e >= TO_EXP_POS - ? toExponential(str, e) - : toFixedPoint(str, e, '0'); - - return n.s < 0 ? '-' + str : str; - }; - - - P._isBigNumber = true; - - if (configObject != null) BigNumber.set(configObject); - - return BigNumber; - } - - - // PRIVATE HELPER FUNCTIONS - - - function bitFloor(n) { - var i = n | 0; - return n > 0 || n === i ? i : i - 1; - } - - - // Return a coefficient array as a string of base 10 digits. - function coeffToString(a) { - var s, z, - i = 1, - j = a.length, - r = a[0] + ''; - - for (; i < j;) { - s = a[i++] + ''; - z = LOG_BASE - s.length; - for (; z--; s = '0' + s); - r += s; - } - - // Determine trailing zeros. - for (j = r.length; r.charCodeAt(--j) === 48;); - return r.slice(0, j + 1 || 1); - } - - - // Compare the value of BigNumbers x and y. - function compare(x, y) { - var a, b, - xc = x.c, - yc = y.c, - i = x.s, - j = y.s, - k = x.e, - l = y.e; - - // Either NaN? - if (!i || !j) return null; - - a = xc && !xc[0]; - b = yc && !yc[0]; - - // Either zero? - if (a || b) return a ? b ? 0 : -j : i; - - // Signs differ? - if (i != j) return i; - - a = i < 0; - b = k == l; - - // Either Infinity? - if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1; - - // Compare exponents. - if (!b) return k > l ^ a ? 1 : -1; - - j = (k = xc.length) < (l = yc.length) ? k : l; - - // Compare digit by digit. - for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1; - - // Compare lengths. - return k == l ? 0 : k > l ^ a ? 1 : -1; - } - - - /* - * Check that n is a primitive number, an integer, and in range, otherwise throw. - */ - function intCheck(n, min, max, name) { - if (n < min || n > max || n !== (n < 0 ? mathceil(n) : mathfloor(n))) { - throw Error - (bignumberError + (name || 'Argument') + (typeof n == 'number' - ? n < min || n > max ? ' out of range: ' : ' not an integer: ' - : ' not a primitive number: ') + n); - } - } - - - function isArray(obj) { - return Object.prototype.toString.call(obj) == '[object Array]'; - } - - - // Assumes finite n. - function isOdd(n) { - var k = n.c.length - 1; - return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0; - } - - - function toExponential(str, e) { - return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) + - (e < 0 ? 'e' : 'e+') + e; - } - - - function toFixedPoint(str, e, z) { - var len, zs; - - // Negative exponent? - if (e < 0) { - - // Prepend zeros. - for (zs = z + '.'; ++e; zs += z); - str = zs + str; - - // Positive exponent - } else { - len = str.length; - - // Append zeros. - if (++e > len) { - for (zs = z, e -= len; --e; zs += z); - str += zs; - } else if (e < len) { - str = str.slice(0, e) + '.' + str.slice(e); - } - } - - return str; - } - - - // EXPORT - - - BigNumber = clone(); - BigNumber['default'] = BigNumber.BigNumber = BigNumber; - - // AMD. - if (typeof define == 'function' && define.amd) { - define(function () { return BigNumber; }); - - // Node.js and other environments that support module.exports. - } else if (typeof module != 'undefined' && module.exports) { - module.exports = BigNumber; - - // Browser. - } else { - if (!globalObject) { - globalObject = typeof self != 'undefined' && self ? self : window; - } - - globalObject.BigNumber = BigNumber; - } -})(this); - -},{}],4:[function(require,module,exports){ - -},{}],5:[function(require,module,exports){ -var basex = require('base-x') -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' - -module.exports = basex(ALPHABET) - -},{"base-x":1}],6:[function(require,module,exports){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' - -var base64 = require('base64-js') -var ieee754 = require('ieee754') - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -var K_MAX_LENGTH = 0x7fffffff -exports.kMaxLength = K_MAX_LENGTH - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ -Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - -if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) -} - -function typedArraySupport () { - // Can typed array instances can be augmented? - try { - var arr = new Uint8Array(1) - arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } - return arr.foo() === 42 - } catch (e) { - return false - } -} - -Object.defineProperty(Buffer.prototype, 'parent', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.buffer - } -}) - -Object.defineProperty(Buffer.prototype, 'offset', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.byteOffset - } -}) - -function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('The value "' + length + '" is invalid for option "size"') - } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype - return buf -} - -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new TypeError( - 'The "string" argument must be of type string. Received type number' - ) - } - return allocUnsafe(arg) - } - return from(arg, encodingOrOffset, length) -} - -// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species != null && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) -} - -Buffer.poolSize = 8192 // not used by this implementation - -function from (value, encodingOrOffset, length) { - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } - - if (ArrayBuffer.isView(value)) { - return fromArrayLike(value) - } - - if (value == null) { - throw TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) - } - - if (isInstance(value, ArrayBuffer) || - (value && isInstance(value.buffer, ArrayBuffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - - if (typeof value === 'number') { - throw new TypeError( - 'The "value" argument must not be of type number. Received type number' - ) - } - - var valueOf = value.valueOf && value.valueOf() - if (valueOf != null && valueOf !== value) { - return Buffer.from(valueOf, encodingOrOffset, length) - } - - var b = fromObject(value) - if (b) return b - - if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && - typeof value[Symbol.toPrimitive] === 'function') { - return Buffer.from( - value[Symbol.toPrimitive]('string'), encodingOrOffset, length - ) - } - - throw new TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) -} - -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) -} - -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array - -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('The value "' + size + '" is invalid for option "size"') - } -} - -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) -} - -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) -} - -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) -} - -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) -} - -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) - - var actual = buf.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } - - return buf -} - -function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf -} - -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } - - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } - - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf -} - -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } - - obj.copy(buf, 0, 0, len) - return buf - } - - if (obj.length !== undefined) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } - - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } -} - -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} - -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true && - b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false -} - -Buffer.compare = function compare (a, b) { - if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) - if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError( - 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' - ) - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (isInstance(buf, Uint8Array)) { - buf = Buffer.from(buf) - } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer -} - -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { - return string.byteLength - } - if (typeof string !== 'string') { - throw new TypeError( - 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + - 'Received type ' + typeof string - ) - } - - var len = string.length - var mustMatch = (arguments.length > 2 && arguments[2] === true) - if (!mustMatch && len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) { - return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 - } - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true - -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i -} - -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} - -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} - -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.toLocaleString = Buffer.prototype.toString - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() - if (this.length > max) str += ' ... ' - return '' -} - -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (isInstance(target, Uint8Array)) { - target = Buffer.from(target, target.offset, target.byteLength) - } - if (!Buffer.isBuffer(target)) { - throw new TypeError( - 'The "target" argument must be one of type Buffer or Uint8Array. ' + - 'Received type ' + (typeof target) - ) - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 -} - -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} - -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - var strLen = string.length - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) - } - - return len -} - -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code - } - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : Buffer.from(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this -} - -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass -// the `instanceof` check but they should be treated as of that type. -// See: https://github.com/feross/buffer/issues/166 -function isInstance (obj, type) { - return obj instanceof type || - (obj != null && obj.constructor != null && obj.constructor.name != null && - obj.constructor.name === type.name) -} -function numberIsNaN (obj) { - // For IE11 support - return obj !== obj // eslint-disable-line no-self-compare -} - -},{"base64-js":2,"ieee754":45}],7:[function(require,module,exports){ -'use strict' - -exports.Commented = require('./commented') -exports.Diagnose = require('./diagnose') -exports.Decoder = require('./decoder') -exports.Encoder = require('./encoder') -exports.Simple = require('./simple') -exports.Tagged = require('./tagged') -exports.Map = require('./map') - -exports.comment = exports.Commented.comment -exports.decodeAll = exports.Decoder.decodeAll -exports.decodeFirst = exports.Decoder.decodeFirst -exports.decodeAllSync = exports.Decoder.decodeAllSync -exports.decodeFirstSync = exports.Decoder.decodeFirstSync -exports.diagnose = exports.Diagnose.diagnose -exports.encode = exports.Encoder.encode -exports.encodeCanonical = exports.Encoder.encodeCanonical -exports.encodeOne = exports.Encoder.encodeOne -exports.decode = exports.Decoder.decodeFirstSync - -exports.leveldb = { - decode: exports.Decoder.decodeAllSync, - encode: exports.Encoder.encode, - buffer: true, - name: 'cbor' -} - -},{"./commented":8,"./decoder":10,"./diagnose":11,"./encoder":12,"./map":13,"./simple":14,"./tagged":15}],8:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const stream = require('stream') -const util = require('util') -const utils = require('./utils') -const Simple = require('./simple') -const Decoder = require('./decoder') -const constants = require('./constants') -const bignumber = require('bignumber.js') -const NoFilter = require('nofilter') - -const MT = constants.MT -const NUMBYTES = constants.NUMBYTES -const SYMS = constants.SYMS - -function plural(c) { - if (c > 1) { - return 's' - } else { - return '' - } -} - -/** - * Generate the expanded format of RFC 7049, section 2.2.1 - * - * @extends {stream.Transform} - */ -class Commented extends stream.Transform { - /** - * Create a CBOR commenter. - * - * @param {any} [options={}] - Stream options - * @param {bool} [options.max_depth=10] - how many times to indent the dashes - */ - constructor(options) { - options = options || {} - options.readableObjectMode = false - options.writableObjectMode = false - const max_depth = (options.max_depth != null) ? options.max_depth : 10 - delete options.max_depth - super(options) - - this.depth = 1 - this.max_depth = max_depth - this.all = new NoFilter - this.parser = new Decoder(options) - this.parser.on('value', this._on_value.bind(this)) - this.parser.on('start', this._on_start.bind(this)) - this.parser.on('start-string', this._on_start_string.bind(this)) - this.parser.on('stop', this._on_stop.bind(this)) - this.parser.on('more-bytes', this._on_more.bind(this)) - this.parser.on('error', this._on_error.bind(this)) - this.parser.on('data', this._on_data.bind(this)) - this.parser.bs.on('read', this._on_read.bind(this)) - } - - /** - * @private - */ - _transform(fresh, encoding, cb) { - this.parser.write(fresh, encoding, cb) - } - - /** - * @private - */ - _flush(cb) { - // TODO: find the test that covers this, and look at the return value - return this.parser._flush(cb) - } - - /** - * @callback commentCallback - * @param {Error} error - if one was generated - * @param {string} commented - the comment string - */ - - /** - * Comment on an input Buffer or string, creating a string passed to the - * callback. If callback not specified, a promise is returned. - * - * @static - * @param {(string|Buffer|NoFilter)} input - * @param {(string|Object|function)} options - * @param {number} [options.max_depth=10] how many times to indent the dashes - * @param {commentCallback=} cb - * @returns {Promise} if cb not specified - */ - static comment(input, options, cb) { - if (input == null) { - throw new Error('input required') - } - let encoding = (typeof input === 'string') ? 'hex' : void 0 - let max_depth = 10 - switch (typeof options) { - case 'function': - cb = options - break - case 'string': - encoding = options - break - case 'number': - max_depth = options - break - case 'object': - const ref1 = options.encoding - const ref2 = options.max_depth - encoding = (ref1 != null) ? ref1 : encoding - max_depth = (ref2 != null) ? ref2 : max_depth - break - case 'undefined': - break - default: - throw new Error('Unknown option type') - } - const bs = new NoFilter - const d = new Commented({ - max_depth: max_depth - }) - let p = null - if (typeof cb === 'function') { - d.on('end', () => { - cb(null, bs.toString('utf8')) - }) - d.on('error', cb) - } else { - p = new Promise((resolve, reject) => { - d.on('end', () => { - resolve(bs.toString('utf8')) - }) - return d.on('error', reject) - }) - } - d.pipe(bs) - d.end(input, encoding) - return p - } - - /** - * @private - */ - _on_error(er) { - return this.push('ERROR: ') && - this.push(er.toString()) && - this.push('\n') - } - - /** - * @private - */ - _on_read(buf) { - this.all.write(buf) - const hex = buf.toString('hex') - this.push(new Array(this.depth + 1).join(' ')) - this.push(hex) - let ind = (this.max_depth - this.depth) * 2 - ind -= hex.length - if (ind < 1) { - ind = 1 - } - this.push(new Array(ind + 1).join(' ')) - return this.push('-- ') - } - - /** - * @private - */ - _on_more(mt, len, parent_mt, pos) { - this.depth++ - let desc = '' - switch (mt) { - case MT.POS_INT: - desc = 'Positive number,' - break - case MT.NEG_INT: - desc = 'Negative number,' - break - case MT.ARRAY: - desc = 'Array, length' - break - case MT.MAP: - desc = 'Map, count' - break - case MT.BYTE_STRING: - desc = 'Bytes, length' - break - case MT.UTF8_STRING: - desc = 'String, length' - break - case MT.SIMPLE_FLOAT: - if (len === 1) { - desc = 'Simple value,' - } else { - desc = 'Float,' - } - break - } - return this.push(desc + ' next ' + len + ' byte' + (plural(len)) + '\n') - } - - /** - * @private - */ - _on_start_string(mt, tag, parent_mt, pos) { - this.depth++ - let desc = '' - switch (mt) { - case MT.BYTE_STRING: - desc = 'Bytes, length: ' + tag - break - case MT.UTF8_STRING: - desc = 'String, length: ' + (tag.toString()) - break - } - return this.push(desc + '\n') - } - - /** - * @private - */ - _on_start(mt, tag, parent_mt, pos) { - this.depth++ - if (tag !== SYMS.BREAK) { - this.push((() => { - switch (parent_mt) { - case MT.ARRAY: - return '[' + pos + '], ' - case MT.MAP: - if (pos % 2) { - return '{Val:' + (Math.floor(pos / 2)) + '}, ' - } else { - return '{Key:' + (Math.floor(pos / 2)) + '}, ' - } - } - })()) - } - this.push((() => { - switch (mt) { - case MT.TAG: - return 'Tag #' + tag - case MT.ARRAY: - if (tag === SYMS.STREAM) { - return 'Array (streaming)' - } else { - return 'Array, ' + tag + ' item' + (plural(tag)) - } - case MT.MAP: - if (tag === SYMS.STREAM) { - return 'Map (streaming)' - } else { - return 'Map, ' + tag + ' pair' + (plural(tag)) - } - case MT.BYTE_STRING: - return 'Bytes (streaming)' - case MT.UTF8_STRING: - return 'String (streaming)' - } - })()) - return this.push('\n') - } - - /** - * @private - */ - _on_stop(mt) { - return this.depth-- - } - - /** - * @private - */ - _on_value(val, parent_mt, pos, ai) { - if (val !== SYMS.BREAK) { - this.push((() => { - switch (parent_mt) { - case MT.ARRAY: - return '[' + pos + '], ' - case MT.MAP: - if (pos % 2) { - return '{Val:' + (Math.floor(pos / 2)) + '}, ' - } else { - return '{Key:' + (Math.floor(pos / 2)) + '}, ' - } - } - })()) - } - - if (val === SYMS.BREAK) { - this.push('BREAK\n') - } else if (val === SYMS.NULL) { - this.push('null\n') - } else if (val === SYMS.UNDEFINED) { - this.push('undefined\n') - } else if (typeof val === 'string') { - this.depth-- - if (val.length > 0 ) { - this.push(JSON.stringify(val)) - this.push('\n') - } - } else if (Buffer.isBuffer(val)) { - this.depth-- - if (val.length > 0) { - this.push(val.toString('hex')) - this.push('\n') - } - } else if (val instanceof bignumber) { - this.push(val.toString()) - this.push('\n') - } else { - this.push(util.inspect(val)) - this.push('\n') - } - - switch (ai) { - case NUMBYTES.ONE: - case NUMBYTES.TWO: - case NUMBYTES.FOUR: - case NUMBYTES.EIGHT: - this.depth-- - } - } - - /** - * @private - */ - _on_data() { - this.push('0x') - this.push(this.all.read().toString('hex')) - return this.push('\n') - } -} - -module.exports = Commented - -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":47,"./constants":9,"./decoder":10,"./simple":14,"./utils":16,"bignumber.js":3,"nofilter":50,"stream":72,"util":78}],9:[function(require,module,exports){ -'use strict' - -exports.MT = { - POS_INT: 0, - NEG_INT: 1, - BYTE_STRING: 2, - UTF8_STRING: 3, - ARRAY: 4, - MAP: 5, - TAG: 6, - SIMPLE_FLOAT: 7 -} - -exports.TAG = { - DATE_STRING: 0, - DATE_EPOCH: 1, - POS_BIGINT: 2, - NEG_BIGINT: 3, - DECIMAL_FRAC: 4, - BIGFLOAT: 5, - BASE64URL_EXPECTED: 21, - BASE64_EXPECTED: 22, - BASE16_EXPECTED: 23, - CBOR: 24, - URI: 32, - BASE64URL: 33, - BASE64: 34, - REGEXP: 35, - MIME: 36 -} - -exports.NUMBYTES = { - ZERO: 0, - ONE: 24, - TWO: 25, - FOUR: 26, - EIGHT: 27, - INDEFINITE: 31 -} - -exports.SIMPLE = { - FALSE: 20, - TRUE: 21, - NULL: 22, - UNDEFINED: 23 -} - -exports.SYMS = { - NULL: Symbol('null'), - UNDEFINED: Symbol('undef'), - PARENT: Symbol('parent'), - BREAK: Symbol('break'), - STREAM: Symbol('stream') -} - -exports.SHIFT32 = Math.pow(2, 32) - -},{}],10:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const BinaryParseStream = require('../vendor/binary-parse-stream') -const Tagged = require('./tagged') -const Simple = require('./simple') -const utils = require('./utils') -const bignumber = require('bignumber.js') -const NoFilter = require('nofilter') -const constants = require('./constants') -// Do not fix this if you want to support node v4 -const MT = constants.MT -const NUMBYTES = constants.NUMBYTES -const SIMPLE = constants.SIMPLE -const SYMS = constants.SYMS - -const NEG_ONE = new bignumber(-1) -const NEG_MAX = NEG_ONE.minus( - new bignumber(Number.MAX_SAFE_INTEGER.toString(16), 16)) -const COUNT = Symbol('count') -const PENDING_KEY = Symbol('pending_key') -const MAJOR = Symbol('major type') -const ERROR = Symbol('error') -const NOT_FOUND = Symbol('not found') - -function parentArray(parent, typ, count) { - const a = [] - a[COUNT] = count - a[SYMS.PARENT] = parent - a[MAJOR] = typ - return a -} - -function parentBufferStream(parent, typ) { - const b = new NoFilter - b[SYMS.PARENT] = parent - b[MAJOR] = typ - return b -} - -/** - * Decode a stream of CBOR bytes by transforming them into equivalent - * JavaScript data. Because of the limitations of Node object streams, - * special symbols are emitted instead of NULL or UNDEFINED. Fix those - * up by calling {@link Decoder.nullcheck}. - * - * @extends {BinaryParseStream} - */ -class Decoder extends BinaryParseStream { - - /** - * Create a parsing stream. - * - * @param {object} [options={}] - * @param {number} [options.max_depth=-1] - the maximum depth to parse. - * Use -1 for "until you run out of memory". Set this to a finite - * positive number for un-trusted inputs. Most standard inputs won't nest - * more than 100 or so levels; I've tested into the millions before - * running out of memory. - * @param {object=} options.tags - mapping from tag number to function(v), - * where v is the decoded value that comes after the tag, and where the - * function returns the correctly-created value for that tag. - */ - constructor(options) { - options = options || {} - const tags = options.tags - delete options.tags - const max_depth = (options.max_depth != null) ? options.max_depth : -1 - delete options.max_depth - super(options) - - this.running = true - this.max_depth = max_depth - this.tags = tags - } - - /** - * Check the given value for a symbol encoding a NULL or UNDEFINED value in - * the CBOR stream. - * - * @static - * @param {any} val - the value to check - * @returns {any} the corrected value - * - * @example - * myDecoder.on('data', function(val) { - * val = Decoder.nullcheck(val); - * ... - * }); - */ - static nullcheck(val) { - switch (val) { - case SYMS.NULL: - return null - case SYMS.UNDEFINED: - return undefined - case NOT_FOUND: - throw new Error('Value not found') - default: - return val - } - } - - /** - * Decode the first CBOR item in the input, synchronously. This will throw an - * exception if the input is not valid CBOR. - * - * @static - * @param {(string|Buffer)} input - * @param {object} [options={encoding: 'hex'}] - * @param {string} [options.encoding: 'hex'] - The encoding of the input. - * Ignored if input is a Buffer. - * @returns {any} - the decoded value - */ - static decodeFirstSync(input, options) { - options = options || { encoding: 'hex' } - let opts = {} - let encod - switch (typeof options) { - case 'string': - encod = options - break - case 'object': - opts = utils.extend({}, options) - encod = opts.encoding - delete opts.encoding - break - } - const c = new Decoder(opts) - const s = new NoFilter( - input, - encod != null ? encod : utils.guessEncoding(input)) - const parser = c._parse() - let state = parser.next() - while (!state.done) { - const b = s.read(state.value) - if ((b == null) || (b.length !== state.value)) { - throw new Error('Insufficient data') - } - state = parser.next(b) - } - return Decoder.nullcheck(state.value) - } - - /** - * Decode all of the CBOR items in the input into an array. This will throw - * an exception if the input is not valid CBOR; a zero-length input will - * return an empty array. - * - * @static - * @param {(string|Buffer)} input - * @param {(string|Object)} [options={encoding: 'hex'}] - * @param {string} [options.encoding: 'hex'] - The encoding of the input. - * Ignored if input is a Buffer. - * @returns {Array} - Array of all found items - */ - static decodeAllSync(input, options) { - options = options || { encoding: 'hex' } - let opts = {} - let encod - switch (typeof options) { - case 'string': - encod = options - break - case 'object': - opts = utils.extend({}, options) - encod = opts.encoding - delete opts.encoding - } - const c = new Decoder(opts) - const s = new NoFilter( - input, - encod != null ? encod : utils.guessEncoding(input)) - const res = [] - while (s.length > 0) { - const parser = c._parse() - let state = parser.next() - while (!state.done) { - const b = s.read(state.value) - if ((b == null) || (b.length !== state.value)) { - throw new Error('Insufficient data') - } - state = parser.next(b) - } - res.push(Decoder.nullcheck(state.value)) - } - return res - } - - /** - * @callback decodeCallback - * @param {Error} error - if one was generated - * @param {any} value - the decoded value - */ - - /** - * Decode the first CBOR item in the input. This will error if there are more - * bytes left over at the end, and optionally if there were no valid CBOR - * bytes in the input. Emits the {Decoder.NOT_FOUND} Symbol in the callback - * if no data was found and the `required` option is false. - * - * @static - * @param {(string|Buffer)} input - the input to parse - * @param {(function|string|Object)} options - * @param {string} [options.encoding: 'hex'] - The encoding of the input. - * Ignored if input is a Buffer. - * @param {decodeCallback} cb - * @returns {Promise} if no cb specified - */ - static decodeFirst(input, options, cb) { - let opts = {} - let required = false - let encod = 'hex' - switch (typeof options) { - case 'function': - cb = options - encod = utils.guessEncoding(input) - break - case 'string': - encod = options - break - case 'object': - opts = utils.extend({}, options) - encod = (opts.encoding != null) ? - opts.encoding : utils.guessEncoding(input) - delete opts.encoding - required = (opts.required != null) ? opts.required : false - delete opts.required - } - const c = new Decoder(opts) - let p - let v = NOT_FOUND - c.on('data', (val) => { - v = Decoder.nullcheck(val) - c.close() - }) - if (typeof cb === 'function') { - c.once('error', (er) => { - const u = v - v = ERROR - c.close() - return cb(er, u) - }) - c.once('end', () => { - switch (v) { - case NOT_FOUND: - if (required) { - return cb(new Error('No CBOR found')) - } else { - return cb(null, v) - } - case ERROR: - return void 0 - default: - return cb(null, v) - } - }) - } else { - p = new Promise((resolve, reject) => { - c.once('error', (er) => { - v = ERROR - c.close() - return reject(er) - }) - return c.once('end', () => { - switch (v) { - case NOT_FOUND: - if (required) { - return reject(new Error('No CBOR found')) - } else { - return resolve(v) - } - case ERROR: - return void 0 - default: - return resolve(v) - } - }) - }) - } - c.end(input, encod) - return p - } - - /** - * @callback decodeAllCallback - * @param {Error} error - if one was generated - * @param {Array} value - all of the decoded values, wrapped in an Array - */ - - /** - * Decode all of the CBOR items in the input. This will error if there are - * more bytes left over at the end. - * - * @static - * @param {(string|Buffer)} input - the input to parse - * @param {(string|Object)} options - Decoding options. - * If string, the input encoding. - * @param {decodeAllCallback} cb - * @returns {Promise} if no callback - */ - static decodeAll(input, options, cb) { - let opts = {} - let encod = 'hex' - switch (typeof options) { - case 'function': - cb = options - encod = utils.guessEncoding(input) - break - case 'string': - encod = options - break - case 'object': - opts = utils.extend({}, options) - encod = (opts.encoding != null) ? - opts.encoding : utils.guessEncoding(input) - delete opts.encoding - } - const c = new Decoder(opts) - let p - const vals = [] - c.on('data', (val) => { - return vals.push(Decoder.nullcheck(val)) - }) - if (typeof cb === 'function') { - c.on('error', cb) - c.on('end', () => cb(null, vals)) - } else { - p = new Promise((resolve, reject) => { - c.on('error', reject) - c.on('end', () => resolve(vals)) - }) - } - c.end(input, encod) - return p - } - - /** - * Stop processing - */ - close() { - this.running = false - this.__fresh = true - } - - *_parse() { - let parent = null - let depth = 0 - let val = null - while (true) { - if ((this.max_depth >= 0) && (depth > this.max_depth)) { - throw new Error('Maximum depth ' + this.max_depth + ' exceeded') - } - const octet = (yield 1)[0] - if (!this.running) { - throw new Error('Unexpected data: 0x' + (octet.toString(16))) - } - const mt = octet >> 5 - const ai = octet & 0x1f - const parent_major = (parent != null) ? parent[MAJOR] : undefined - const parent_length = (parent != null) ? parent.length : undefined - switch (ai) { - case NUMBYTES.ONE: - this.emit('more-bytes', mt, 1, parent_major, parent_length) - val = (yield 1)[0] - break - case NUMBYTES.TWO: - case NUMBYTES.FOUR: - case NUMBYTES.EIGHT: - const numbytes = 1 << (ai - 24) - this.emit('more-bytes', mt, numbytes, parent_major, parent_length) - const buf = yield numbytes - val = (mt === MT.SIMPLE_FLOAT) ? buf : utils.parseCBORint(ai, buf) - break - case 28: - case 29: - case 30: - this.running = false - throw new Error('Additional info not implemented: ' + ai) - case NUMBYTES.INDEFINITE: - val = -1 - break - default: - val = ai - } - switch (mt) { - case MT.POS_INT: - // val already decoded - break - case MT.NEG_INT: - if (val === Number.MAX_SAFE_INTEGER) { - val = NEG_MAX - } else if (val instanceof bignumber) { - val = NEG_ONE.minus(val) - } else { - val = -1 - val - } - break - case MT.BYTE_STRING: - case MT.UTF8_STRING: - switch (val) { - case 0: - this.emit('start-string', mt, val, parent_major, parent_length) - val = (mt === MT.BYTE_STRING) ? Buffer.allocUnsafe(0) : '' - break - case -1: - this.emit('start', mt, SYMS.STREAM, parent_major, parent_length) - parent = parentBufferStream(parent, mt) - depth++ - continue - default: - this.emit('start-string', mt, val, parent_major, parent_length) - val = yield val - if (mt === MT.UTF8_STRING) { - val = val.toString('utf-8') - } - } - break - case MT.ARRAY: - case MT.MAP: - switch (val) { - case 0: - val = (mt === MT.MAP) ? {} : [] - break - case -1: - this.emit('start', mt, SYMS.STREAM, parent_major, parent_length) - parent = parentArray(parent, mt, -1) - depth++ - continue - default: - this.emit('start', mt, val, parent_major, parent_length) - parent = parentArray(parent, mt, val * (mt - 3)) - depth++ - continue - } - break - case MT.TAG: - this.emit('start', mt, val, parent_major, parent_length) - parent = parentArray(parent, mt, 1) - parent.push(val) - depth++ - continue - case MT.SIMPLE_FLOAT: - if (typeof val === 'number') { - val = Simple.decode(val, parent != null) - } else { - val = utils.parseCBORfloat(val) - } - } - this.emit('value', val, parent_major, parent_length, ai) - let again = false - while (parent != null) { - switch (false) { - case val !== SYMS.BREAK: - parent[COUNT] = 1 - break - case !Array.isArray(parent): - parent.push(val) - break - case !(parent instanceof NoFilter): - const pm = parent[MAJOR] - if ((pm != null) && (pm !== mt)) { - this.running = false - throw new Error('Invalid major type in indefinite encoding') - } - parent.write(val) - } - if ((--parent[COUNT]) !== 0) { - again = true - break - } - --depth - delete parent[COUNT] - this.emit('stop', parent[MAJOR]) - - if (Array.isArray(parent)) { - switch (parent[MAJOR]) { - case MT.ARRAY: - val = parent - break - case MT.MAP: - let allstrings = true - if ((parent.length % 2) !== 0) { - throw new Error('Invalid map length: ' + parent.length) - } - for (let i = 0, len = parent.length; i < len; i += 2) { - if (typeof parent[i] !== 'string') { - allstrings = false - break - } - } - if (allstrings) { - val = {} - for (let i = 0, len = parent.length; i < len; i += 2) { - val[parent[i]] = parent[i + 1] - } - } else { - val = new Map - for (let i = 0, len = parent.length; i < len; i += 2) { - val.set(parent[i], parent[i + 1]) - } - } - break - case MT.TAG: - const t = new Tagged(parent[0], parent[1]) - val = t.convert(this.tags) - break - } - } else if (parent instanceof NoFilter) { - switch (parent[MAJOR]) { - case MT.BYTE_STRING: - val = parent.slice() - break - case MT.UTF8_STRING: - val = parent.toString('utf-8') - break - } - } - - const old = parent - parent = parent[SYMS.PARENT] - delete old[SYMS.PARENT] - delete old[MAJOR] - } - if (!again) { - return val - } - } - } -} - -Decoder.NOT_FOUND = NOT_FOUND -module.exports = Decoder - -}).call(this,require("buffer").Buffer) -},{"../vendor/binary-parse-stream":17,"./constants":9,"./simple":14,"./tagged":15,"./utils":16,"bignumber.js":3,"buffer":6,"nofilter":50}],11:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const stream = require('stream') -const util = require('util') -const Decoder = require('./decoder') -const Simple = require('./simple') -const utils = require('./utils') -const constants = require('./constants') -const bignumber = require('bignumber.js') -const NoFilter = require('nofilter') - -const MT = constants.MT -const SYMS = constants.SYMS - -/** - * Output the diagnostic format from a stream of CBOR bytes. - * - * @extends {stream.Transform} - */ -class Diagnose extends stream.Transform { - - /** - * Creates an instance of Diagnose. - * - * @param {Object} [options={}] - options for creation - * @param {string} [options.separator='\n'] - output between detected objects - * @param {bool} [options.stream_errors=false] - put error info into the - * output stream - * @param {number} [options.max_depth=-1] - -1 for "until you run out of - * memory". Set this to a finite positive number for un-trusted inputs. - * Most standard inputs won't nest more than 100 or so levels; I've tested - * into the millions before running out of memory. - */ - constructor(options) { - options = options || {} - const separator = (options.separator != null) ? options.separator : '\n' - delete options.separator - const stream_errors = (options.stream_errors != null) ? - options.stream_errors : false - delete options.stream_errors - options.readableObjectMode = false - options.writableObjectMode = false - super(options) - - this.float_bytes = -1 - this.separator = separator - this.stream_errors = stream_errors - this.parser = new Decoder(options) - this.parser.on('more-bytes', this._on_more.bind(this)) - this.parser.on('value', this._on_value.bind(this)) - this.parser.on('start', this._on_start.bind(this)) - this.parser.on('stop', this._on_stop.bind(this)) - this.parser.on('data', this._on_data.bind(this)) - this.parser.on('error', this._on_error.bind(this)) - } - - _transform(fresh, encoding, cb) { - return this.parser.write(fresh, encoding, cb) - } - - _flush(cb) { - return this.parser._flush((er) => { - if (this.stream_errors) { - this._on_error(er) - return cb() - } else { - return cb(er) - } - }) - } - - /** - * Convenience function to return a string in diagnostic format. - * - * @param {(Buffer|string)} input - the CBOR bytes to format - * @param {string} [encoding='hex'] - the encoding of input, ignored if - * input is Buffer - * @param {commentCallback} cb - callback - * @returns {Promise} if callback not specified - */ - static diagnose(input, encoding, cb) { - if (input == null) { - throw new Error('input required') - } - let opts = {} - let encod = 'hex' - switch (typeof encoding) { - case 'function': - cb = encoding - encod = utils.guessEncoding(input) - break - case 'object': - opts = utils.extend({}, encoding) - encod = (opts.encoding != null) ? - opts.encoding : utils.guessEncoding(input) - delete opts.encoding - break - default: - encod = (encoding != null) ? encoding : 'hex' - } - const bs = new NoFilter - const d = new Diagnose(opts) - let p = null - if (typeof cb === 'function') { - d.on('end', () => cb(null, bs.toString('utf8'))) - d.on('error', cb) - } else { - p = new Promise((resolve, reject) => { - d.on('end', () => resolve(bs.toString('utf8'))) - return d.on('error', reject) - }) - } - d.pipe(bs) - d.end(input, encod) - return p - } - - _on_error(er) { - if (this.stream_errors) { - return this.push(er.toString()) - } else { - return this.emit('error', er) - } - } - - _on_more(mt, len, parent_mt, pos) { - if (mt === MT.SIMPLE_FLOAT) { - return this.float_bytes = (function() { - switch (len) { - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - } - })() - } - } - - _fore(parent_mt, pos) { - switch (parent_mt) { - case MT.BYTE_STRING: - case MT.UTF8_STRING: - case MT.ARRAY: - if (pos > 0) { - return this.push(', ') - } - break - case MT.MAP: - if (pos > 0) { - if (pos % 2) { - return this.push(': ') - } else { - return this.push(', ') - } - } - } - } - - _on_value(val, parent_mt, pos) { - if (val === SYMS.BREAK) { - return - } - this._fore(parent_mt, pos) - return this.push((function() { - switch (false) { - case val !== SYMS.NULL: - return 'null' - case val !== SYMS.UNDEFINED: - return 'undefined' - case typeof val !== 'string': - return JSON.stringify(val) - case !(this.float_bytes > 0): - const fb = this.float_bytes - this.float_bytes = -1 - return (util.inspect(val)) + '_' + fb - case !Buffer.isBuffer(val): - return 'h\'' + (val.toString('hex')) + '\'' - case !(val instanceof bignumber): - return val.toString() - default: - return util.inspect(val) - } - }).call(this)) - } - - _on_start(mt, tag, parent_mt, pos) { - this._fore(parent_mt, pos) - this.push((function() { - switch (mt) { - case MT.TAG: - return tag + '(' - case MT.ARRAY: - return '[' - case MT.MAP: - return '{' - case MT.BYTE_STRING: - case MT.UTF8_STRING: - return '(' - default: - // istanbul ignore next - throw new Error('Unknown diagnostic type: ' + mt) - } - })()) - if (tag === SYMS.STREAM) { - return this.push('_ ') - } - } - - _on_stop(mt) { - return this.push((function() { - switch (mt) { - case MT.TAG: - return ')' - case MT.ARRAY: - return ']' - case MT.MAP: - return '}' - case MT.BYTE_STRING: - case MT.UTF8_STRING: - return ')' - default: - // istanbul ignore next - throw new Error('Unknown diagnostic type: ' + mt) - } - })()) - } - - _on_data() { - return this.push(this.separator) - } -} - -module.exports = Diagnose - -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":47,"./constants":9,"./decoder":10,"./simple":14,"./utils":16,"bignumber.js":3,"nofilter":50,"stream":72,"util":78}],12:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const stream = require('stream') -const url = require('url') -const bignumber = require('bignumber.js') -const NoFilter = require('nofilter') -const Tagged = require('./tagged') -const Simple = require('./simple') -const utils = require('./utils') - -const constants = require('./constants') -const MT = constants.MT -const NUMBYTES = constants.NUMBYTES -const SHIFT32 = constants.SHIFT32 -const SYMS = constants.SYMS -const TAG = constants.TAG -const HALF = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.TWO -const FLOAT = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.FOUR -const DOUBLE = (constants.MT.SIMPLE_FLOAT << 5) | constants.NUMBYTES.EIGHT -const TRUE = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.TRUE -const FALSE = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.FALSE -const UNDEFINED = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.UNDEFINED -const NULL = (constants.MT.SIMPLE_FLOAT << 5) | constants.SIMPLE.NULL - -const MAXINT_BN = new bignumber('0x20000000000000') -const BUF_NAN = Buffer.from('f97e00', 'hex') -const BUF_INF_NEG = Buffer.from('f9fc00', 'hex') -const BUF_INF_POS = Buffer.from('f97c00', 'hex') -const BUF_NEG_ZERO = Buffer.from('f98000', 'hex') -const LOOP_DETECT = Symbol('CBOR_LOOP_DETECT') - -/** - * Transform JavaScript values into CBOR bytes. The `Writable` side of - * the stream is in object mode. - * - * @extends {stream.Transform} - */ -class Encoder extends stream.Transform { - - /** - * Creates an instance of Encoder. - * - * @param {Object} [options={}] - options for the encoder - * @param {any[]} [options.genTypes=[]] - array of pairs of `type`, - * `function(Encoder)` for semantic types to be encoded. Not needed - * for Array, Date, Buffer, Map, RegExp, Set, Url, or bignumber. - * @param {boolean} [options.canonical=false] - should the output be - * canonicalized - * @param {boolean|Symbol} [options.detectLoops=false] - should object loops - * be detected? This will currently modify the encoded object graph - * by adding a Symbol property to each object. If this bothers you, - * call `removeLoopDetectors` on the encoded object when done. Do not - * encode the same object twice on the same encoder, without calling - * `removeLoopDetectors` in between. - * @param {("number"|"float"|"int"|"string")} [options.dateType="number"] - - * how should dates be encoded? "number" means float or int, if no - * fractional seconds. - */ - constructor(options) { - options = options || {} - options.readableObjectMode = false - options.writableObjectMode = true - super(options) - - this.canonical = options.canonical - this.dateType = (options.dateType != null) ? - options.dateType.toLowerCase() : 'number' - - // new Symbol for each instance. Note: means we can't re-use the same - // encoder and encoded object - if (typeof(options.detectLoops) === 'symbol') { - this.detectLoops = options.detectLoops - } else { - this.detectLoops = !!options.detectLoops ? Symbol('CBOR_DETECT') : null - } - - this.semanticTypes = [ - Array, this._pushArray, - Date, this._pushDate, - Buffer, this._pushBuffer, - Map, this._pushMap, - NoFilter, this._pushNoFilter, - RegExp, this._pushRegexp, - Set, this._pushSet, - url.Url, this._pushUrl, - bignumber, this._pushBigNumber - ] - - const addTypes = options.genTypes || [] - for (let i = 0, len = addTypes.length; i < len; i += 2) { - this.addSemanticType(addTypes[i], addTypes[i + 1]) - } - } - - _transform(fresh, encoding, cb) { - const ret = this.pushAny(fresh) - // Old transformers might not return bool. undefined !== false - return cb((ret === false) ? new Error('Push Error') : undefined) - } - - _flush(cb) { - return cb() - } - - /** - * @callback encodeFunction - * @param {Encoder} encoder - the encoder to serialize into. Call "write" - * on the encoder as needed. - * @return {bool} - true on success, else false - */ - - /** - * Add an encoding function to the list of supported semantic types. This is - * useful for objects for which you can't add an encodeCBOR method - * - * @param {any} type - * @param {any} fun - * @returns {encodeFunction} - */ - addSemanticType(type, fun) { - for (let i = 0, len = this.semanticTypes.length; i < len; i += 2) { - const typ = this.semanticTypes[i] - if (typ === type) { - const old = this.semanticTypes[i + 1] - this.semanticTypes[i + 1] = fun - return old - } - } - this.semanticTypes.push(type, fun) - return null - } - - _pushUInt8(val) { - const b = Buffer.allocUnsafe(1) - b.writeUInt8(val) - return this.push(b) - } - - _pushUInt16BE(val) { - const b = Buffer.allocUnsafe(2) - b.writeUInt16BE(val) - return this.push(b) - } - - _pushUInt32BE(val) { - const b = Buffer.allocUnsafe(4) - b.writeUInt32BE(val) - return this.push(b) - } - - _pushDoubleBE(val) { - const b = Buffer.allocUnsafe(8) - b.writeDoubleBE(val) - return this.push(b) - } - - _pushNaN() { - return this.push(BUF_NAN) - } - - _pushInfinity(obj) { - const half = (obj < 0) ? BUF_INF_NEG : BUF_INF_POS - return this.push(half) - } - - _pushFloat(obj) { - if (this.canonical) { - // TODO: is this enough slower to hide behind canonical? - // It's certainly enough of a hack (see utils.parseHalf) - - // From section 3.9: - // If a protocol allows for IEEE floats, then additional canonicalization - // rules might need to be added. One example rule might be to have all - // floats start as a 64-bit float, then do a test conversion to a 32-bit - // float; if the result is the same numeric value, use the shorter value - // and repeat the process with a test conversion to a 16-bit float. (This - // rule selects 16-bit float for positive and negative Infinity as well.) - - // which seems pretty much backwards to me. - const b2 = Buffer.allocUnsafe(2) - if (utils.writeHalf(b2, obj)) { - if (utils.parseHalf(b2) === obj) { - return this._pushUInt8(HALF) && this.push(b2) - } - } - const b4 = Buffer.allocUnsafe(4) - b4.writeFloatBE(obj) - if (b4.readFloatBE(0) === obj) { - return this._pushUInt8(FLOAT) && this.push(b4) - } - } - - return this._pushUInt8(DOUBLE) && this._pushDoubleBE(obj) - } - - _pushInt(obj, mt, orig) { - const m = mt << 5 - switch (false) { - case !(obj < 24): - return this._pushUInt8(m | obj) - case !(obj <= 0xff): - return this._pushUInt8(m | NUMBYTES.ONE) && this._pushUInt8(obj) - case !(obj <= 0xffff): - return this._pushUInt8(m | NUMBYTES.TWO) && this._pushUInt16BE(obj) - case !(obj <= 0xffffffff): - return this._pushUInt8(m | NUMBYTES.FOUR) && this._pushUInt32BE(obj) - case !(obj <= Number.MAX_SAFE_INTEGER): - return this._pushUInt8(m | NUMBYTES.EIGHT) && - this._pushUInt32BE(Math.floor(obj / SHIFT32)) && - this._pushUInt32BE(obj % SHIFT32) - default: - if (mt === MT.NEG_INT) { - return this._pushFloat(orig) - } else { - return this._pushFloat(obj) - } - } - } - - _pushIntNum(obj) { - if (Object.is(obj, -0)) { - return this.push(BUF_NEG_ZERO) - } - - if (obj < 0) { - return this._pushInt(-obj - 1, MT.NEG_INT, obj) - } else { - return this._pushInt(obj, MT.POS_INT) - } - } - - _pushNumber(obj) { - switch (false) { - case !isNaN(obj): - return this._pushNaN(obj) - case isFinite(obj): - return this._pushInfinity(obj) - case Math.round(obj) !== obj: - return this._pushIntNum(obj) - default: - return this._pushFloat(obj) - } - } - - _pushString(obj) { - const len = Buffer.byteLength(obj, 'utf8') - return this._pushInt(len, MT.UTF8_STRING) && this.push(obj, 'utf8') - } - - _pushBoolean(obj) { - return this._pushUInt8(obj ? TRUE : FALSE) - } - - _pushUndefined(obj) { - return this._pushUInt8(UNDEFINED) - } - - _pushNull(obj) { - return this._pushUInt8(NULL) - } - - _pushArray(gen, obj) { - const len = obj.length - if (!gen._pushInt(len, MT.ARRAY)) { - return false - } - for (let j = 0; j < len; j++) { - if (!gen.pushAny(obj[j])) { - return false - } - } - return true - } - - _pushTag(tag) { - return this._pushInt(tag, MT.TAG) - } - - _pushDate(gen, obj) { - switch (gen.dateType) { - case 'string': - return gen._pushTag(TAG.DATE_STRING) && - gen._pushString(obj.toISOString()) - case 'int': - case 'integer': - return gen._pushTag(TAG.DATE_EPOCH) && - gen._pushIntNum(Math.round(obj / 1000)) - case 'float': - // force float - return gen._pushTag(TAG.DATE_EPOCH) && - gen._pushFloat(obj / 1000) - case 'number': - default: - // if we happen to have an integral number of seconds, - // use integer. Otherwise, use float. - return gen._pushTag(TAG.DATE_EPOCH) && - gen.pushAny(obj / 1000) - } - } - - _pushBuffer(gen, obj) { - return gen._pushInt(obj.length, MT.BYTE_STRING) && gen.push(obj) - } - - _pushNoFilter(gen, obj) { - return gen._pushBuffer(gen, obj.slice()) - } - - _pushRegexp(gen, obj) { - return gen._pushTag(TAG.REGEXP) && gen.pushAny(obj.source) - } - - _pushSet(gen, obj) { - if (!gen._pushInt(obj.size, MT.ARRAY)) { - return false - } - for (const x of obj) { - if (!gen.pushAny(x)) { - return false - } - } - return true - } - - _pushUrl(gen, obj) { - return gen._pushTag(TAG.URI) && gen.pushAny(obj.format()) - } - - _pushBigint(obj) { - let tag = TAG.POS_BIGINT - if (obj.isNegative()) { - obj = obj.negated().minus(1) - tag = TAG.NEG_BIGINT - } - let str = obj.toString(16) - if (str.length % 2) { - str = '0' + str - } - const buf = Buffer.from(str, 'hex') - return this._pushTag(tag) && this._pushBuffer(this, buf) - } - - _pushBigNumber(gen, obj) { - if (obj.isNaN()) { - return gen._pushNaN() - } - if (!obj.isFinite()) { - return gen._pushInfinity(obj.isNegative() ? -Infinity : Infinity) - } - if (obj.isInteger()) { - return gen._pushBigint(obj) - } - if (!(gen._pushTag(TAG.DECIMAL_FRAC) && - gen._pushInt(2, MT.ARRAY))) { - return false - } - - const dec = obj.decimalPlaces() - const slide = obj.times(new bignumber(10).pow(dec)) - if (!gen._pushIntNum(-dec)) { - return false - } - if (slide.abs().isLessThan(MAXINT_BN)) { - return gen._pushIntNum(slide.toNumber()) - } else { - return gen._pushBigint(slide) - } - } - - _pushMap(gen, obj) { - if (!gen._pushInt(obj.size, MT.MAP)) { - return false - } - // memoizing the cbor only helps in certain cases, and hurts in most - // others. Just avoid it. - if (gen.canonical) { - // keep the key/value pairs together, so we don't have to do odd - // gets with object keys later - const entries = [] - // iterator. If we drop support for node4, use ... - for (const e of obj.entries()) { - entries.push(e) - } - entries.sort((a, b) => { - // a, b are both entries of [key, value] - const a_cbor = Encoder.encode(a[0]) - const b_cbor = Encoder.encode(b[0]) - return a_cbor.compare(b_cbor) - }) - for (const kv of entries) { - if (!(gen.pushAny(kv[0]) && gen.pushAny(kv[1]))) { - return false - } - } - } else { - for (const kv of obj) { - if (!(gen.pushAny(kv[0]) && gen.pushAny(kv[1]))) { - return false - } - } - } - return true - } - - removeLoopDetectors(obj) { - if (!this.detectLoops || (typeof(obj) !== 'object') || !obj) { - return false - } - const dl = obj[LOOP_DETECT] - if (!dl || (dl !== this.detectLoops)) { - // ironically, use loop marking to detect loops on removal as well - return false - } - delete obj[LOOP_DETECT] - if (Array.isArray(obj)) { - for (const i of obj) { - this.removeLoopDetectors(i) - } - } else { - for (const k in obj) { - this.removeLoopDetectors(obj[k]) - } - } - return true - } - - _pushObject(obj) { - if (!obj) { - return this._pushNull(obj) - } - if (this.detectLoops) { - if (obj[LOOP_DETECT] === this.detectLoops) { - throw new Error('Loop detected while CBOR encoding') - } else { - obj[LOOP_DETECT] = this.detectLoops - } - } - const f = obj.encodeCBOR - if (typeof f === 'function') { - return f.call(obj, this) - } - for (let i = 0, len1 = this.semanticTypes.length; i < len1; i += 2) { - const typ = this.semanticTypes[i] - if (obj instanceof typ) { - return this.semanticTypes[i + 1].call(obj, this, obj) - } - } - const keys = Object.keys(obj) - const cbor_keys = {} - if (this.canonical) { - // note: this can't be a normal sort, because 'b' needs to sort before - // 'aa' - keys.sort((a, b) => { - // Always strings, so don't bother to pass options. - // hold on to the cbor versions, since there's no need - // to encode more than once - const a_cbor = cbor_keys[a] || (cbor_keys[a] = Encoder.encode(a)) - const b_cbor = cbor_keys[b] || (cbor_keys[b] = Encoder.encode(b)) - - return a_cbor.compare(b_cbor) - }) - } - if (!this._pushInt(keys.length, MT.MAP)) { - return false - } - let ck - for (let j = 0, len2 = keys.length; j < len2; j++) { - const k = keys[j] - if (this.canonical && ((ck = cbor_keys[k]))) { - if (!this.push(ck)) { // already a Buffer - return false - } - } else { - if (!this._pushString(k)) { - return false - } - } - if (!this.pushAny(obj[k])) { - return false - } - } - - return true - } - - /** - * Push any supported type onto the encoded stream - * - * @param {any} obj - * @returns {boolean} true on success - */ - pushAny(obj) { - switch (typeof obj) { - case 'number': - return this._pushNumber(obj) - case 'string': - return this._pushString(obj) - case 'boolean': - return this._pushBoolean(obj) - case 'undefined': - return this._pushUndefined(obj) - case 'object': - return this._pushObject(obj) - case 'symbol': - switch (obj) { - case SYMS.NULL: - return this._pushNull(null) - case SYMS.UNDEFINED: - return this._pushUndefined(void 0) - // TODO: Add pluggable support for other symbols - default: - throw new Error('Unknown symbol: ' + obj.toString()) - } - default: - throw new Error( - 'Unknown type: ' + typeof obj + ', ' + - (!!obj ? obj.toString() : '')) - } - } - - /* backwards-compat wrapper */ - _pushAny(obj) { - // TODO: write deprecation warning - return this.pushAny(obj) - } - - _encodeAll(objs) { - const bs = new NoFilter() - this.pipe(bs) - for (const o of objs) { - if (typeof o === 'undefined') { - this._pushUndefined() - } else if (o === null) { - this._pushNull(null) - } else { - this.write(o) - } - } - this.end() - return bs.read() - } - - /** - * Encode one or more JavaScript objects, and return a Buffer containing the - * CBOR bytes. - * - * @param {...any} objs - the objects to encode - * @returns {Buffer} - the encoded objects - */ - static encode() { - const objs = Array.prototype.slice.apply(arguments) - return new Encoder()._encodeAll(objs) - } - - /** - * Encode one or more JavaScript objects canonically (slower!), and return - * a Buffer containing the CBOR bytes. - * - * @param {...any} objs - the objects to encode - * @returns {Buffer} - the encoded objects - */ - static encodeCanonical() { - const objs = Array.prototype.slice.apply(arguments) - return new Encoder({canonical: true})._encodeAll(objs) - } - - /** - * Encode one JavaScript object using the given options. - * - * @static - * @param {any} obj - the object to encode - * @param {Object?} options - passed to the Encoder constructor - * @returns {Buffer} - the encoded objects - */ - static encodeOne(obj, options) { - return new Encoder(options)._encodeAll([obj]) - } -} - -module.exports = Encoder - -}).call(this,require("buffer").Buffer) -},{"./constants":9,"./simple":14,"./tagged":15,"./utils":16,"bignumber.js":3,"buffer":6,"nofilter":50,"stream":72,"url":74}],13:[function(require,module,exports){ -(function (Buffer){ -'use strict' - -const encoder = require('./encoder') -const decoder = require('./decoder') -const constants = require('./constants') -const MT = constants.MT - -/** - * Wrapper around a JavaScript Map object that allows the keys to be - * any complex type. The base Map object allows this, but will only - * compare the keys by identity, not by value. CborMap translates keys - * to CBOR first (and base64's them to ensure by-value comparison). - * - * This is not a subclass of Object, because it would be tough to get - * the semantics to be an exact match. - * - * @class CborMap - * @extends {Map} - */ -class CborMap extends Map { - /** - * Creates an instance of CborMap. - * @param {Iterable>} args An Array or other iterable object - * whose elements are key-value pairs (arrays with two elements, e.g. - * [[ 1, 'one' ],[ 2, 'two' ]]). Each key-value pair is added - * to the new CborMap; null values are treated as undefined. - */ - constructor(iterable) { - super(iterable) - } - - /** - * @private - */ - static _encode(key) { - return encoder.encodeCanonical(key).toString('base64') - } - - /** - * @private - */ - static _decode(key) { - return decoder.decodeFirstSync(key, 'base64') - } - - /** - * Retrieve a specified element. - * - * @param {any} key The key identifying the element to retrieve. - * Can be any type, which will be serialized into CBOR and compared by - * value. - * @returns {any} The element if it exists, or undefined. - */ - get(key) { - return super.get(CborMap._encode(key)) - } - - /** - * Adds or updates an element with a specified key and value. - * - * @param {any} key The key identifying the element to store. - * Can be any type, which will be serialized into CBOR and compared by - * value. - * @param {any} val The element to store - */ - set(key, val) { - return super.set(CborMap._encode(key), val) - } - - /** - * Removes the specified element. - * - * @param {any} key The key identifying the element to delete. - * Can be any type, which will be serialized into CBOR and compared by - * value. - * @returns {boolean} - */ - delete(key) { - return super.delete(CborMap._encode(key)) - } - - /** - * Does an element with the specified key exist? - * - * @param {any} key The key identifying the element to check. - * Can be any type, which will be serialized into CBOR and compared by - * value. - * @returns {boolean} - */ - has(key) { - return super.has(CborMap._encode(key)) - } - - /** - * Returns a new Iterator object that contains the keys for each element - * in the Map object in insertion order. The keys are decoded into their - * original format. - * - * @returns {Iterator} - */ - *keys() { - for (const k of super.keys()) { - yield CborMap._decode(k) - } - } - - /** - * Returns a new Iterator object that contains the [key, value] pairs for - * each element in the Map object in insertion order. - * - * @returns {Iterator.>} - */ - *entries() { - for (const kv of super.entries()) { - yield [CborMap._decode(kv[0]), kv[1]] - } - } - - /** - * Returns a new Iterator object that contains the [key, value] pairs for - * each element in the Map object in insertion order. - * - * @returns {Iterator.>} - */ - [Symbol.iterator]() { - return this.entries() - } - - /** - * Executes a provided function once per each key/value pair in the Map - * object, in insertion order. - * - * @param {function(any, any, CborMap)} fun Function to execute for each - * element, which takes a value, a key, and the Map being traversed. - * @param {any} thisArg Value to use as this when executing callback - */ - forEach(fun, thisArg) { - if (typeof(fun) !== 'function') { - throw new TypeError('Must be function') - } - for (const kv of super.entries()) { - fun.call(this, kv[1], CborMap._decode(kv[0]), this) - } - } - - /** - * Push the simple value onto the CBOR stream - * - * @param {cbor.Encoder} gen The generator to push onto - * @returns {boolean} true on success - */ - encodeCBOR(gen) { - if (!gen._pushInt(this.size, MT.MAP)) { - return false - } - if (gen.canonical) { - const entries = Array.from(super.entries()) - .map((kv) => [Buffer.from(kv[0], 'base64'), kv[1]]) - entries.sort((a, b) => a[0].compare(b[0])) - for (const kv of entries) { - if (!(gen.push(kv[0]) && gen.pushAny(kv[1]))) { - return false - } - } - } else { - for (const kv of super.entries()) { - if (!(gen.push(Buffer.from(kv[0], 'base64')) && gen.pushAny(kv[1]))) { - return false - } - } - } - return true - } -} - -module.exports = CborMap -}).call(this,require("buffer").Buffer) -},{"./constants":9,"./decoder":10,"./encoder":12,"buffer":6}],14:[function(require,module,exports){ -'use strict' - -const util = require('util') -const constants = require('./constants') -const MT = constants.MT -const SIMPLE = constants.SIMPLE -const SYMS = constants.SYMS - -/** - * A CBOR Simple Value that does not map onto a known constant. - */ -class Simple { - /** - * Creates an instance of Simple. - * - * @param {integer} value - the simple value's integer value - */ - constructor(value) { - if (typeof value !== 'number') { - throw new Error('Invalid Simple type: ' + (typeof value)) - } - if ((value < 0) || (value > 255) || ((value|0) !== value)) { - throw new Error('value must be a small positive integer: ' + value) - } - this.value = value - } - - /** - * Debug string for simple value - * - * @returns {string} simple(value) - */ - toString() { - return 'simple(' + this.value + ')' - } - - /** - * Debug string for simple value - * - * @returns {string} simple(value) - */ - [util.inspect.custom](depth, opts) { - return 'simple(' + this.value + ')' - } - - /** - * Debug string for simple value (backward-compatibility version) - * - * @returns {string} simple(value) - */ - inspect(depth, opts) { - return 'simple(' + this.value + ')' - } - - /** - * Push the simple value onto the CBOR stream - * - * @param {cbor.Encoder} gen The generator to push onto - */ - encodeCBOR(gen) { - return gen._pushInt(this.value, MT.SIMPLE_FLOAT) - } - - /** - * Is the given object a Simple? - * - * @param {any} obj - object to test - * @returns {bool} - is it Simple? - */ - static isSimple(obj) { - return obj instanceof Simple - } - - /** - * Decode from the CBOR additional information into a JavaScript value. - * If the CBOR item has no parent, return a "safe" symbol instead of - * `null` or `undefined`, so that the value can be passed through a - * stream in object mode. - * - * @param {number} val - the CBOR additional info to convert - * @param {bool} has_parent - Does the CBOR item have a parent? - * @returns {(null|undefined|bool|Symbol)} - the decoded value - */ - static decode(val, has_parent) { - if (has_parent == null) { - has_parent = true - } - switch (val) { - case SIMPLE.FALSE: - return false - case SIMPLE.TRUE: - return true - case SIMPLE.NULL: - if (has_parent) { - return null - } else { - return SYMS.NULL - } - case SIMPLE.UNDEFINED: - if (has_parent) { - return void 0 - } else { - return SYMS.UNDEFINED - } - case -1: - if (!has_parent) { - throw new Error('Invalid BREAK') - } - return SYMS.BREAK - default: - return new Simple(val) - } - } -} - -module.exports = Simple - -},{"./constants":9,"util":78}],15:[function(require,module,exports){ -'use strict' - -const bignumber = require('bignumber.js') -const utils = require('./utils') -const url = require('url') - -const MINUS_ONE = new bignumber(-1) -const TEN = new bignumber(10) -const TWO = new bignumber(2) - -/** - * A CBOR tagged item, where the tag does not have semantics specified at the - * moment, or those semantics threw an error during parsing. Typically this will - * be an extension point you're not yet expecting. - */ -class Tagged { - - /** - * Creates an instance of Tagged. - * - * @param {number} tag - the number of the tag - * @param {any} value - the value inside the tag - * @param {Error} err - the error that was thrown parsing the tag, or null - */ - constructor(tag, value, err) { - this.tag = tag - this.value = value - this.err = err - if (typeof this.tag !== 'number') { - throw new Error('Invalid tag type (' + (typeof this.tag) + ')') - } - if ((this.tag < 0) || ((this.tag | 0) !== this.tag)) { - throw new Error('Tag must be a positive integer: ' + this.tag) - } - } - - /** - * Convert to a String - * - * @returns {string} string of the form '1(2)' - */ - toString() { - return `${this.tag}(${JSON.stringify(this.value)})` - } - - /** - * Push the simple value onto the CBOR stream - * - * @param {cbor.Encoder} gen The generator to push onto - */ - encodeCBOR(gen) { - gen._pushTag(this.tag) - return gen.pushAny(this.value) - } - - /** - * If we have a converter for this type, do the conversion. Some converters - * are built-in. Additional ones can be passed in. If you want to remove - * a built-in converter, pass a converter in whose value is 'null' instead - * of a function. - * - * @param {Object} converters - keys in the object are a tag number, the value - * is a function that takes the decoded CBOR and returns a JavaScript value - * of the appropriate type. Throw an exception in the function on errors. - * @returns {any} - the converted item - */ - convert(converters) { - let f = converters != null ? converters[this.tag] : void 0 - if (typeof f !== 'function') { - f = Tagged['_tag_' + this.tag] - if (typeof f !== 'function') { - return this - } - } - try { - return f.call(Tagged, this.value) - } catch (error) { - this.err = error - return this - } - } - - static _tag_0(v) { - return new Date(v) - } - - static _tag_1(v) { - return new Date(v * 1000) - } - - static _tag_2(v) { - return utils.bufferToBignumber(v) - } - - static _tag_3(v) { - return MINUS_ONE.minus(utils.bufferToBignumber(v)) - } - - static _tag_4(v) { - return TEN.pow(v[0]).times(v[1]) - } - - static _tag_5(v) { - return TWO.pow(v[0]).times(v[1]) - } - - static _tag_32(v) { - return url.parse(v) - } - - static _tag_35(v) { - return new RegExp(v) - } -} - -module.exports = Tagged - -},{"./utils":16,"bignumber.js":3,"url":74}],16:[function(require,module,exports){ -(function (process,Buffer){ -'use strict' - -const fs = require('fs') -const stream = require('stream') -const bignumber = require('bignumber.js') - -const constants = require('./constants') -const NUMBYTES = constants.NUMBYTES -const SHIFT32 = constants.SHIFT32 -const MAX_SAFE_HIGH = 0x1fffff - -exports.parseCBORint = function(ai, buf) { - switch (ai) { - case NUMBYTES.ONE: - return buf.readUInt8(0) - case NUMBYTES.TWO: - return buf.readUInt16BE(0) - case NUMBYTES.FOUR: - return buf.readUInt32BE(0) - case NUMBYTES.EIGHT: - const f = buf.readUInt32BE(0) - const g = buf.readUInt32BE(4) - if (f > MAX_SAFE_HIGH) { - return new bignumber(f).times(SHIFT32).plus(g) - } else { - return (f * SHIFT32) + g - } - default: - throw new Error('Invalid additional info for int: ' + ai) - } -} - -exports.writeHalf = function writeHalf(buf, half) { - // assume 0, -0, NaN, Infinity, and -Infinity have already been caught - - // HACK: everyone settle in. This isn't going to be pretty. - // Translate cn-cbor's C code (from Carsten Borman): - - // uint32_t be32; - // uint16_t be16, u16; - // union { - // float f; - // uint32_t u; - // } u32; - // u32.f = float_val; - - const u32 = Buffer.allocUnsafe(4) - u32.writeFloatBE(half) - const u = u32.readUInt32BE(0) - - // if ((u32.u & 0x1FFF) == 0) { /* worth trying half */ - - // hildjj: If the lower 13 bits are 0, - // we won't lose anything in the conversion - if ((u & 0x1FFF) !== 0) { - return false - } - - // int s16 = (u32.u >> 16) & 0x8000; - // int exp = (u32.u >> 23) & 0xff; - // int mant = u32.u & 0x7fffff; - - let s16 = (u >> 16) & 0x8000 // top bit is sign - const exp = (u >> 23) & 0xff // then 5 bits of exponent - const mant = u & 0x7fffff - - // if (exp == 0 && mant == 0) - // ; /* 0.0, -0.0 */ - - // hildjj: zeros already handled. Assert if you don't believe me. - - // else if (exp >= 113 && exp <= 142) /* normalized */ - // s16 += ((exp - 112) << 10) + (mant >> 13); - - if ((exp >= 113) && (exp <= 142)) { - s16 += ((exp - 112) << 10) + (mant >> 13) - } else if ((exp >= 103) && (exp < 113)) { - // else if (exp >= 103 && exp < 113) { /* denorm, exp16 = 0 */ - // if (mant & ((1 << (126 - exp)) - 1)) - // goto float32; /* loss of precision */ - // s16 += ((mant + 0x800000) >> (126 - exp)); - - if (mant & ((1 << (126 - exp)) - 1)) { - return false - } - s16 += ((mant + 0x800000) >> (126 - exp)) - } else { - // } else if (exp == 255 && mant == 0) { /* Inf */ - // s16 += 0x7c00; - - // hildjj: Infinity already handled - - // } else - // goto float32; /* loss of range */ - - return false - } - - // ensure_writable(3); - // u16 = s16; - // be16 = hton16p((const uint8_t*)&u16); - buf.writeUInt16BE(s16) - return true -} - -exports.parseHalf = function parseHalf(buf) { - const sign = buf[0] & 0x80 ? -1 : 1 - const exp = (buf[0] & 0x7C) >> 2 - const mant = ((buf[0] & 0x03) << 8) | buf[1] - if (!exp) { - return sign * 5.9604644775390625e-8 * mant - } else if (exp === 0x1f) { - return sign * (mant ? 0 / 0 : 2e308) - } else { - return sign * Math.pow(2, exp - 25) * (1024 + mant) - } -} - -exports.parseCBORfloat = function parseCBORfloat(buf) { - switch (buf.length) { - case 2: - return exports.parseHalf(buf) - case 4: - return buf.readFloatBE(0) - case 8: - return buf.readDoubleBE(0) - default: - throw new Error('Invalid float size: ' + buf.length) - } -} - -exports.hex = function hex(s) { - return Buffer.from(s.replace(/^0x/, ''), 'hex') -} - -exports.bin = function bin(s) { - s = s.replace(/\s/g, '') - let start = 0 - let end = (s.length % 8) || 8 - const chunks = [] - while (end <= s.length) { - chunks.push(parseInt(s.slice(start, end), 2)) - start = end - end += 8 - } - return Buffer.from(chunks) -} - -exports.extend = function extend() { - let old = arguments[0] - const adds = (2 <= arguments.length) ? - Array.prototype.slice.call(arguments, 1) : [] - const len = adds.length - if (old == null) { - old = {} - } - for (let j = 0; j < len; j++) { - const a = adds[j] - for (const k in a) { - const v = a[k] - old[k] = v - } - } - return old -} - -exports.arrayEqual = function arrayEqual(a, b) { - if ((a == null) && (b == null)) { - return true - } - if ((a == null) || (b == null)) { - return false - } - return (a.length === b.length) && a.every((elem, i) => elem === b[i]) -} - -exports.bufferEqual = function bufferEqual(a, b) { - if ((a == null) && (b == null)) { - return true - } - if ((a == null) || (b == null)) { - return false - } - if (!(Buffer.isBuffer(a) && Buffer.isBuffer(b) && (a.length === b.length))) { - return false - } - const len = a.length - let ret = true - let i - let j - for (i = j = 0; j < len; i = ++j) { - const byte = a[i] - ret &= b[i] === byte - } - return !!ret -} - -exports.bufferToBignumber = function bufferToBignumber(buf) { - return new bignumber(buf.toString('hex'), 16) -} - -exports.DeHexStream = class DeHexStream extends stream.Readable { - constructor(hex) { - super() - hex = hex.replace(/^0x/, '') - if (hex) { - this.push(Buffer.from(hex, 'hex')) - } - this.push(null) - } -} - -exports.HexStream = class HexStream extends stream.Transform { - constructor(options) { - super(options) - } - - _transform(fresh, encoding, cb) { - this.push(fresh.toString('hex')) - return cb() - } -} - -function printError(er) { - if (er != null) { - return console.log(er) - } -} - -exports.streamFiles = function streamFiles(files, streamFunc, cb) { - if (cb == null) { - cb = printError - } - const f = files.shift() - if (!f) { - return cb() - } - const sf = streamFunc() - sf.on('end', () => exports.streamFiles(files, streamFunc, cb)) - sf.on('error', cb) - const s = (f === '-') ? - process.stdin : (f instanceof stream.Stream) ? f : fs.createReadStream(f) - s.on('error', cb) - return s.pipe(sf) -} - -exports.guessEncoding = function guessEncoding(input) { - switch (false) { - case typeof input !== 'string': - return 'hex' - case !Buffer.isBuffer(input): - return undefined - default: - throw new Error('Unknown input type') - } -} - -}).call(this,require('_process'),require("buffer").Buffer) -},{"./constants":9,"_process":52,"bignumber.js":3,"buffer":6,"fs":4,"stream":72}],17:[function(require,module,exports){ -// Tweaked version of nathan7's binary-parse-stream -// (see https://github.com/nathan7/binary-parse-stream) -// Uses NoFilter instead of the readable in the original. Removes -// the ability to read -1, which was odd and un-needed. -// License for binary-parse-stream: MIT - -'use strict'; -exports = module.exports = BinaryParseStream -var Stream = require('stream') - , TransformStream = Stream.Transform - , inherits = require('util').inherits - , NoFilter = require('nofilter') - -exports.One = -1 - -inherits(BinaryParseStream, TransformStream) -function BinaryParseStream(options) { - TransformStream.call(this, options) - this._writableState.objectMode = false - this._readableState.objectMode = true - - this.bs = new NoFilter() - this.__restart() -} - -BinaryParseStream.prototype._transform = function(fresh, encoding, cb) { var self = this - this.bs.write(fresh) - - while (this.bs.length >= this.__needed) { - var ret - , chunk = this.__needed === null - ? undefined - : this.bs.read(this.__needed) - - try { ret = this.__parser.next(chunk) } - catch (e) { - return cb(e) } - - if (this.__needed) - this.__fresh = false - - if (!ret.done) - this.__needed = ret.value | 0 - else { - this.push(ret.value) - this.__restart() - } - } - - return cb() -} - -BinaryParseStream.prototype.__restart = function() { - this.__needed = null - this.__parser = this._parse() - this.__fresh = true -} - -BinaryParseStream.prototype._flush = function(cb) { - cb(this.__fresh - ? null - : new Error('unexpected end of input')) -} - -},{"nofilter":50,"stream":72,"util":78}],18:[function(require,module,exports){ -(function (Buffer){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// NOTE: These type checking functions intentionally don't use `instanceof` -// because it is fragile and can be easily faked with `Object.create()`. - -function isArray(arg) { - if (Array.isArray) { - return Array.isArray(arg); - } - return objectToString(arg) === '[object Array]'; -} -exports.isArray = isArray; - -function isBoolean(arg) { - return typeof arg === 'boolean'; -} -exports.isBoolean = isBoolean; - -function isNull(arg) { - return arg === null; -} -exports.isNull = isNull; - -function isNullOrUndefined(arg) { - return arg == null; -} -exports.isNullOrUndefined = isNullOrUndefined; - -function isNumber(arg) { - return typeof arg === 'number'; -} -exports.isNumber = isNumber; - -function isString(arg) { - return typeof arg === 'string'; -} -exports.isString = isString; - -function isSymbol(arg) { - return typeof arg === 'symbol'; -} -exports.isSymbol = isSymbol; - -function isUndefined(arg) { - return arg === void 0; -} -exports.isUndefined = isUndefined; - -function isRegExp(re) { - return objectToString(re) === '[object RegExp]'; -} -exports.isRegExp = isRegExp; - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} -exports.isObject = isObject; - -function isDate(d) { - return objectToString(d) === '[object Date]'; -} -exports.isDate = isDate; - -function isError(e) { - return (objectToString(e) === '[object Error]' || e instanceof Error); -} -exports.isError = isError; - -function isFunction(arg) { - return typeof arg === 'function'; -} -exports.isFunction = isFunction; - -function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; -} -exports.isPrimitive = isPrimitive; - -exports.isBuffer = Buffer.isBuffer; - -function objectToString(o) { - return Object.prototype.toString.call(o); -} - -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":47}],19:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc1').default; - -},{"./es6/crc1":30}],20:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16').default; - -},{"./es6/crc16":31}],21:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16ccitt').default; - -},{"./es6/crc16ccitt":32}],22:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16kermit').default; - -},{"./es6/crc16kermit":33}],23:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16modbus').default; - -},{"./es6/crc16modbus":34}],24:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc16xmodem').default; - -},{"./es6/crc16xmodem":35}],25:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc24').default; - -},{"./es6/crc24":36}],26:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc32').default; - -},{"./es6/crc32":37}],27:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc8').default; - -},{"./es6/crc8":38}],28:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crc81wire').default; - -},{"./es6/crc81wire":39}],29:[function(require,module,exports){ -'use strict'; - -module.exports = require('./es6/crcjam').default; - -},{"./es6/crcjam":40}],30:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var crc1 = (0, _define_crc2.default)('crc1', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = ~~previous; - var accum = 0; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - accum += byte; - } - - crc += accum % 256; - return crc % 256; -}); - -exports.default = crc1; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],31:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c` -// prettier-ignore -var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc16 = (0, _define_crc2.default)('crc-16', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = ~~previous; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; - } - - return crc; -}); - -exports.default = crc16; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],32:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=ccitt --generate=c` -// prettier-ignore -var TABLE = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc16ccitt = (0, _define_crc2.default)('ccitt', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc >> 8 ^ byte) & 0xff] ^ crc << 8) & 0xffff; - } - - return crc; -}); - -exports.default = crc16ccitt; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],33:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c` -// prettier-ignore -var TABLE = [0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc16kermit = (0, _define_crc2.default)('kermit', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0x0000; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; - } - - return crc; -}); - -exports.default = crc16kermit; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],34:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16-modbus --generate=c` -// prettier-ignore -var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc16modbus = (0, _define_crc2.default)('crc-16-modbus', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; - } - - return crc; -}); - -exports.default = crc16modbus; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],35:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var crc16xmodem = (0, _define_crc2.default)('xmodem', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0x0; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - var code = crc >>> 8 & 0xff; - - code ^= byte & 0xff; - code ^= code >>> 4; - crc = crc << 8 & 0xffff; - crc ^= code; - code = code << 5 & 0xffff; - crc ^= code; - code = code << 7 & 0xffff; - crc ^= code; - } - - return crc; -}); - -exports.default = crc16xmodem; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],36:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-drive --model=crc-24 --generate=c` -// prettier-ignore -var TABLE = [0x000000, 0x864cfb, 0x8ad50d, 0x0c99f6, 0x93e6e1, 0x15aa1a, 0x1933ec, 0x9f7f17, 0xa18139, 0x27cdc2, 0x2b5434, 0xad18cf, 0x3267d8, 0xb42b23, 0xb8b2d5, 0x3efe2e, 0xc54e89, 0x430272, 0x4f9b84, 0xc9d77f, 0x56a868, 0xd0e493, 0xdc7d65, 0x5a319e, 0x64cfb0, 0xe2834b, 0xee1abd, 0x685646, 0xf72951, 0x7165aa, 0x7dfc5c, 0xfbb0a7, 0x0cd1e9, 0x8a9d12, 0x8604e4, 0x00481f, 0x9f3708, 0x197bf3, 0x15e205, 0x93aefe, 0xad50d0, 0x2b1c2b, 0x2785dd, 0xa1c926, 0x3eb631, 0xb8faca, 0xb4633c, 0x322fc7, 0xc99f60, 0x4fd39b, 0x434a6d, 0xc50696, 0x5a7981, 0xdc357a, 0xd0ac8c, 0x56e077, 0x681e59, 0xee52a2, 0xe2cb54, 0x6487af, 0xfbf8b8, 0x7db443, 0x712db5, 0xf7614e, 0x19a3d2, 0x9fef29, 0x9376df, 0x153a24, 0x8a4533, 0x0c09c8, 0x00903e, 0x86dcc5, 0xb822eb, 0x3e6e10, 0x32f7e6, 0xb4bb1d, 0x2bc40a, 0xad88f1, 0xa11107, 0x275dfc, 0xdced5b, 0x5aa1a0, 0x563856, 0xd074ad, 0x4f0bba, 0xc94741, 0xc5deb7, 0x43924c, 0x7d6c62, 0xfb2099, 0xf7b96f, 0x71f594, 0xee8a83, 0x68c678, 0x645f8e, 0xe21375, 0x15723b, 0x933ec0, 0x9fa736, 0x19ebcd, 0x8694da, 0x00d821, 0x0c41d7, 0x8a0d2c, 0xb4f302, 0x32bff9, 0x3e260f, 0xb86af4, 0x2715e3, 0xa15918, 0xadc0ee, 0x2b8c15, 0xd03cb2, 0x567049, 0x5ae9bf, 0xdca544, 0x43da53, 0xc596a8, 0xc90f5e, 0x4f43a5, 0x71bd8b, 0xf7f170, 0xfb6886, 0x7d247d, 0xe25b6a, 0x641791, 0x688e67, 0xeec29c, 0x3347a4, 0xb50b5f, 0xb992a9, 0x3fde52, 0xa0a145, 0x26edbe, 0x2a7448, 0xac38b3, 0x92c69d, 0x148a66, 0x181390, 0x9e5f6b, 0x01207c, 0x876c87, 0x8bf571, 0x0db98a, 0xf6092d, 0x7045d6, 0x7cdc20, 0xfa90db, 0x65efcc, 0xe3a337, 0xef3ac1, 0x69763a, 0x578814, 0xd1c4ef, 0xdd5d19, 0x5b11e2, 0xc46ef5, 0x42220e, 0x4ebbf8, 0xc8f703, 0x3f964d, 0xb9dab6, 0xb54340, 0x330fbb, 0xac70ac, 0x2a3c57, 0x26a5a1, 0xa0e95a, 0x9e1774, 0x185b8f, 0x14c279, 0x928e82, 0x0df195, 0x8bbd6e, 0x872498, 0x016863, 0xfad8c4, 0x7c943f, 0x700dc9, 0xf64132, 0x693e25, 0xef72de, 0xe3eb28, 0x65a7d3, 0x5b59fd, 0xdd1506, 0xd18cf0, 0x57c00b, 0xc8bf1c, 0x4ef3e7, 0x426a11, 0xc426ea, 0x2ae476, 0xaca88d, 0xa0317b, 0x267d80, 0xb90297, 0x3f4e6c, 0x33d79a, 0xb59b61, 0x8b654f, 0x0d29b4, 0x01b042, 0x87fcb9, 0x1883ae, 0x9ecf55, 0x9256a3, 0x141a58, 0xefaaff, 0x69e604, 0x657ff2, 0xe33309, 0x7c4c1e, 0xfa00e5, 0xf69913, 0x70d5e8, 0x4e2bc6, 0xc8673d, 0xc4fecb, 0x42b230, 0xddcd27, 0x5b81dc, 0x57182a, 0xd154d1, 0x26359f, 0xa07964, 0xace092, 0x2aac69, 0xb5d37e, 0x339f85, 0x3f0673, 0xb94a88, 0x87b4a6, 0x01f85d, 0x0d61ab, 0x8b2d50, 0x145247, 0x921ebc, 0x9e874a, 0x18cbb1, 0xe37b16, 0x6537ed, 0x69ae1b, 0xefe2e0, 0x709df7, 0xf6d10c, 0xfa48fa, 0x7c0401, 0x42fa2f, 0xc4b6d4, 0xc82f22, 0x4e63d9, 0xd11cce, 0x575035, 0x5bc9c3, 0xdd8538]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc24 = (0, _define_crc2.default)('crc-24', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0xb704ce; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc >> 16 ^ byte) & 0xff] ^ crc << 8) & 0xffffff; - } - - return crc; -}); - -exports.default = crc24; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],37:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c` -// prettier-ignore -var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc32 = (0, _define_crc2.default)('crc-32', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = previous === 0 ? 0 : ~~previous ^ -1; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; - } - - return crc ^ -1; -}); - -exports.default = crc32; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],38:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=crc-8 --generate=c` -// prettier-ignore -var TABLE = [0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc8 = (0, _define_crc2.default)('crc-8', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = ~~previous; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = TABLE[(crc ^ byte) & 0xff] & 0xff; - } - - return crc; -}); - -exports.default = crc8; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],39:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c` -// prettier-ignore -var TABLE = [0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62, 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff, 0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07, 0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a, 0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24, 0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9, 0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd, 0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50, 0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee, 0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73, 0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5, 0x8b, 0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16, 0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8, 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc81wire = (0, _define_crc2.default)('dallas-1-wire', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = ~~previous; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = TABLE[(crc ^ byte) & 0xff] & 0xff; - } - - return crc; -}); - -exports.default = crc81wire; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],40:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var _create_buffer = require('./create_buffer'); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = require('./define_crc'); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=jam --generate=c` -// prettier-ignore -var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crcjam = (0, _define_crc2.default)('jam', function (buf) { - var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; - - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = previous === 0 ? 0 : ~~previous; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; - } - - return crc; -}); - -exports.default = crcjam; - -},{"./create_buffer":41,"./define_crc":42,"buffer":6}],41:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = require('buffer'); - -var createBuffer = _buffer.Buffer.from && _buffer.Buffer.alloc && _buffer.Buffer.allocUnsafe && _buffer.Buffer.allocUnsafeSlow ? _buffer.Buffer.from : // support for Node < 5.10 -function (val) { - return new _buffer.Buffer(val); -}; - -exports.default = createBuffer; - -},{"buffer":6}],42:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (model, calc) { - var fn = function fn(buf, previous) { - return calc(buf, previous) >>> 0; - }; - fn.signed = calc; - fn.unsigned = fn; - fn.model = model; - - return fn; -}; - -},{}],43:[function(require,module,exports){ -'use strict'; - -module.exports = { - crc1: require('./crc1'), - crc8: require('./crc8'), - crc81wire: require('./crc8_1wire'), - crc16: require('./crc16'), - crc16ccitt: require('./crc16_ccitt'), - crc16modbus: require('./crc16_modbus'), - crc16xmodem: require('./crc16_xmodem'), - crc16kermit: require('./crc16_kermit'), - crc24: require('./crc24'), - crc32: require('./crc32'), - crcjam: require('./crcjam') -}; - -},{"./crc1":19,"./crc16":20,"./crc16_ccitt":21,"./crc16_kermit":22,"./crc16_modbus":23,"./crc16_xmodem":24,"./crc24":25,"./crc32":26,"./crc8":27,"./crc8_1wire":28,"./crcjam":29}],44:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; - -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; - -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; - -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; -} - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} - -function isUndefined(arg) { - return arg === void 0; -} - -},{}],45:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} - -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} - -},{}],46:[function(require,module,exports){ -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} - -},{}],47:[function(require,module,exports){ -/*! - * Determine if an object is a Buffer - * - * @author Feross Aboukhadijeh - * @license MIT - */ - -// The _isBuffer check is for Safari 5-7 support, because it's missing -// Object.prototype.constructor. Remove this eventually -module.exports = function (obj) { - return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) -} - -function isBuffer (obj) { - return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) -} - -// For Node v0.10 support. Remove this eventually. -function isSlowBuffer (obj) { - return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) -} - -},{}],48:[function(require,module,exports){ -var toString = {}.toString; - -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; -}; - -},{}],49:[function(require,module,exports){ -/* - A JavaScript implementation of the SHA family of hashes, as - defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding - HMAC implementation as defined in FIPS PUB 198a - - Copyright Brian Turek 2008-2017 - Distributed under the BSD License - See http://caligatio.github.com/jsSHA/ for more information - - Several functions taken from Paul Johnston -*/ -'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; -b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> -5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); -}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> -6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); -if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, -"");if(-1!==k&&k 0) && (om !== _this._readableState.objectMode)) { - throw new Error('Do not switch objectMode in the middle of the stream'); - } - _this._readableState.objectMode = om; - return _this._writableState.objectMode = om; - }; - })(this)); - } - if (inp != null) { - this.end(inp, inpE); - } - } - - NoFilter.isNoFilter = function(obj) { - return obj instanceof this; - }; - - NoFilter.compare = function(nf1, nf2) { - if (!(nf1 instanceof this)) { - throw new TypeError('Arguments must be NoFilters'); - } - if (nf1 === nf2) { - return 0; - } else { - return nf1.compare(nf2); - } - }; - - NoFilter.concat = function(list, length) { - var bufs; - if (!Array.isArray(list)) { - throw new TypeError('list argument must be an Array of NoFilters'); - } - if ((list.length === 0) || (length === 0)) { - return new Buffer(0); - } - if (length == null) { - length = list.reduce(function(tot, nf) { - if (!(nf instanceof NoFilter)) { - throw new TypeError('list argument must be an Array of NoFilters'); - } - return tot + nf.length; - }, 0); - } - bufs = list.map(function(nf) { - if (!(nf instanceof NoFilter)) { - throw new TypeError('list argument must be an Array of NoFilters'); - } - if (nf._readableState.objectMode) { - throw new Error('NoFilter may not be in object mode for concat'); - } - return nf.slice(); - }); - return Buffer.concat(bufs, length); - }; - - NoFilter.prototype._transform = function(chunk, encoding, callback) { - if (!this._readableState.objectMode && !Buffer.isBuffer(chunk)) { - chunk = new Buffer(chunk, encoding); - } - this.push(chunk); - return callback(); - }; - - NoFilter.prototype._bufArray = function() { - var b, bufs; - bufs = this._readableState.buffer; - if (!Array.isArray(bufs)) { - b = bufs.head; - bufs = []; - while (b != null) { - bufs.push(b.data); - b = b.next; - } - } - return bufs; - }; - - NoFilter.prototype.read = function(size) { - var buf; - buf = NoFilter.__super__.read.call(this, size); - if (buf != null) { - this.emit('read', buf); - } - return buf; - }; - - NoFilter.prototype.promise = function(cb) { - var done; - done = false; - return new Promise((function(_this) { - return function(resolve, reject) { - _this.on('finish', function() { - var data; - data = _this.read(); - if ((cb != null) && !done) { - done = true; - cb(null, data); - } - return resolve(data); - }); - return _this.on('error', function(er) { - if ((cb != null) && !done) { - done = true; - cb(er); - } - return reject(er); - }); - }; - })(this)); - }; - - NoFilter.prototype.compare = function(other) { - if (!(other instanceof NoFilter)) { - throw new TypeError('Arguments must be NoFilters'); - } - if (this._readableState.objectMode || other._readableState.objectMode) { - throw new Error('Must not be in object mode to compare'); - } - if (this === other) { - return 0; - } else { - return this.slice().compare(other.slice()); - } - }; - - NoFilter.prototype.equals = function(other) { - return this.compare(other) === 0; - }; - - NoFilter.prototype.slice = function(start, end) { - var b, bufs; - if (this._readableState.objectMode) { - return this._bufArray().slice(start, end); - } else { - bufs = this._bufArray(); - switch (bufs.length) { - case 0: - return new Buffer(0); - case 1: - return bufs[0].slice(start, end); - default: - b = Buffer.concat(bufs); - return b.slice(start, end); - } - } - }; - - NoFilter.prototype.get = function(index) { - return this.slice()[index]; - }; - - NoFilter.prototype.toJSON = function() { - var b; - b = this.slice(); - if (Buffer.isBuffer(b)) { - return b.toJSON(); - } else { - return b; - } - }; - - NoFilter.prototype.toString = function(encoding, start, end) { - return this.slice().toString(encoding, start, end); - }; - - NoFilter.prototype.inspect = function(depth, options) { - var bufs, hex; - bufs = this._bufArray(); - hex = bufs.map(function(b) { - if (Buffer.isBuffer(b)) { - if (options != null ? options.stylize : void 0) { - return options.stylize(b.toString('hex'), 'string'); - } else { - return b.toString('hex'); - } - } else { - return util.inspect(b, options); - } - }).join(', '); - return this.constructor.name + " [" + hex + "]"; - }; - - _read_gen = function(meth, len) { - return function(val) { - var b; - b = this.read(len); - if (!Buffer.isBuffer(b)) { - return null; - } - return b[meth].call(b, 0, true); - }; - }; - - _write_gen = function(meth, len) { - return function(val) { - var b; - b = new Buffer(len); - b[meth].call(b, val, 0, true); - return this.push(b); - }; - }; - - NoFilter.prototype.writeUInt8 = _write_gen('writeUInt8', 1); - - NoFilter.prototype.writeUInt16LE = _write_gen('writeUInt16LE', 2); - - NoFilter.prototype.writeUInt16BE = _write_gen('writeUInt16BE', 2); - - NoFilter.prototype.writeUInt32LE = _write_gen('writeUInt32LE', 4); - - NoFilter.prototype.writeUInt32BE = _write_gen('writeUInt32BE', 4); - - NoFilter.prototype.writeInt8 = _write_gen('writeInt8', 1); - - NoFilter.prototype.writeInt16LE = _write_gen('writeInt16LE', 2); - - NoFilter.prototype.writeInt16BE = _write_gen('writeInt16BE', 2); - - NoFilter.prototype.writeInt32LE = _write_gen('writeInt32LE', 4); - - NoFilter.prototype.writeInt32BE = _write_gen('writeInt32BE', 4); - - NoFilter.prototype.writeFloatLE = _write_gen('writeFloatLE', 4); - - NoFilter.prototype.writeFloatBE = _write_gen('writeFloatBE', 4); - - NoFilter.prototype.writeDoubleLE = _write_gen('writeDoubleLE', 8); - - NoFilter.prototype.writeDoubleBE = _write_gen('writeDoubleBE', 8); - - NoFilter.prototype.readUInt8 = _read_gen('readUInt8', 1); - - NoFilter.prototype.readUInt16LE = _read_gen('readUInt16LE', 2); - - NoFilter.prototype.readUInt16BE = _read_gen('readUInt16BE', 2); - - NoFilter.prototype.readUInt32LE = _read_gen('readUInt32LE', 4); - - NoFilter.prototype.readUInt32BE = _read_gen('readUInt32BE', 4); - - NoFilter.prototype.readInt8 = _read_gen('readInt8', 1); - - NoFilter.prototype.readInt16LE = _read_gen('readInt16LE', 2); - - NoFilter.prototype.readInt16BE = _read_gen('readInt16BE', 2); - - NoFilter.prototype.readInt32LE = _read_gen('readInt32LE', 4); - - NoFilter.prototype.readInt32BE = _read_gen('readInt32BE', 4); - - NoFilter.prototype.readFloatLE = _read_gen('readFloatLE', 4); - - NoFilter.prototype.readFloatBE = _read_gen('readFloatBE', 4); - - NoFilter.prototype.readDoubleLE = _read_gen('readDoubleLE', 8); - - NoFilter.prototype.readDoubleBE = _read_gen('readDoubleBE', 8); - - get = function(props) { - var getter, name, results; - results = []; - for (name in props) { - getter = props[name]; - results.push(NoFilter.prototype.__defineGetter__(name, getter)); - } - return results; - }; - - get({ - length: function() { - return this._readableState.length; - } - }); - - return NoFilter; - - })(stream.Transform); - -}).call(this); - - - -}).call(this,require("buffer").Buffer) -},{"buffer":6,"stream":72,"util":78}],51:[function(require,module,exports){ -(function (process){ -'use strict'; - -if (!process.version || - process.version.indexOf('v0.') === 0 || - process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { - module.exports = { nextTick: nextTick }; -} else { - module.exports = process -} - -function nextTick(fn, arg1, arg2, arg3) { - if (typeof fn !== 'function') { - throw new TypeError('"callback" argument must be a function'); - } - var len = arguments.length; - var args, i; - switch (len) { - case 0: - case 1: - return process.nextTick(fn); - case 2: - return process.nextTick(function afterTickOne() { - fn.call(null, arg1); - }); - case 3: - return process.nextTick(function afterTickTwo() { - fn.call(null, arg1, arg2); - }); - case 4: - return process.nextTick(function afterTickThree() { - fn.call(null, arg1, arg2, arg3); - }); - default: - args = new Array(len - 1); - i = 0; - while (i < args.length) { - args[i++] = arguments[i]; - } - return process.nextTick(function afterTick() { - fn.apply(null, args); - }); - } -} - - -}).call(this,require('_process')) -},{"_process":52}],52:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],53:[function(require,module,exports){ -(function (global){ -/*! https://mths.be/punycode v1.4.1 by @mathias */ -;(function(root) { - - /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports && - !exports.nodeType && exports; - var freeModule = typeof module == 'object' && module && - !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; - if ( - freeGlobal.global === freeGlobal || - freeGlobal.window === freeGlobal || - freeGlobal.self === freeGlobal - ) { - root = freeGlobal; - } - - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, - - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' - - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators - - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, - - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, - - /** Temporary variable */ - key; - - /*--------------------------------------------------------------------------*/ - - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw new RangeError(errors[type]); - } - - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - var result = []; - while (length--) { - result[length] = fn(array[length]); - } - return result; - } - - /** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; - } - - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } - - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } - - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } - - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } - - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } - - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - /** Cached calculation results */ - baseMinusT; - - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. - - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } - - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } - - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. - - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { - - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { - - if (index >= inputLength) { - error('invalid-input'); - } - - digit = basicToDigit(input.charCodeAt(index++)); - - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } - - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - - if (digit < t) { - break; - } - - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } - - w *= baseMinusT; - - } - - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); - - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } - - n += floor(i / out); - i %= out; - - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); - - } - - return ucs2encode(output); - } - - /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; - - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); - - // Cache the length - inputLength = input.length; - - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; - - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } - - handledCPCount = basicLength = output.length; - - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. - - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } - - // Main encoding loop: - while (handledCPCount < inputLength) { - - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } - - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } - - delta += (m - n) * handledCPCountPlusOne; - n = m; - - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } - - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } - - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } - - ++delta; - ++n; - - } - return output.join(''); - } - - /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(input) { - return mapDomain(input, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } - - /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ - function toASCII(input) { - return mapDomain(input, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } - - /*--------------------------------------------------------------------------*/ - - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.4.1', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode - }; - - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define('punycode', function() { - return punycode; - }); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { - // in Node.js, io.js, or RingoJS v0.8.0+ - freeModule.exports = punycode; - } else { - // in Narwhal or RingoJS v0.7.0- - for (key in punycode) { - punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); - } - } - } else { - // in Rhino or a web browser - root.punycode = punycode; - } - -}(this)); - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],54:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -'use strict'; - -// If obj.hasOwnProperty has been overridden, then calling -// obj.hasOwnProperty(prop) will break. -// See: https://github.com/joyent/node/issues/1707 -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf } -module.exports = function(qs, sep, eq, options) { - sep = sep || '&'; - eq = eq || '='; - var obj = {}; - - if (typeof qs !== 'string' || qs.length === 0) { - return obj; - } - - var regexp = /\+/g; - qs = qs.split(sep); - - var maxKeys = 1000; - if (options && typeof options.maxKeys === 'number') { - maxKeys = options.maxKeys; - } - - var len = qs.length; - // maxKeys <= 0 means that we should not limit keys count - if (maxKeys > 0 && len > maxKeys) { - len = maxKeys; - } - - for (var i = 0; i < len; ++i) { - var x = qs[i].replace(regexp, '%20'), - idx = x.indexOf(eq), - kstr, vstr, k, v; - - if (idx >= 0) { - kstr = x.substr(0, idx); - vstr = x.substr(idx + 1); - } else { - kstr = x; - vstr = ''; - } - - k = decodeURIComponent(kstr); - v = decodeURIComponent(vstr); - - if (!hasOwnProperty(obj, k)) { - obj[k] = v; - } else if (isArray(obj[k])) { - obj[k].push(v); - } else { - obj[k] = [obj[k], v]; - } - } - - return obj; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -},{}],55:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -'use strict'; - -var stringifyPrimitive = function(v) { - switch (typeof v) { - case 'string': - return v; - - case 'boolean': - return v ? 'true' : 'false'; - - case 'number': - return isFinite(v) ? v : ''; +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) - default: - return ''; - } -}; + if (buf.length === 0) { + return buf + } -module.exports = function(obj, sep, eq, name) { - sep = sep || '&'; - eq = eq || '='; - if (obj === null) { - obj = undefined; + obj.copy(buf, 0, 0, len) + return buf } - if (typeof obj === 'object') { - return map(objectKeys(obj), function(k) { - var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; - if (isArray(obj[k])) { - return map(obj[k], function(v) { - return ks + encodeURIComponent(stringifyPrimitive(v)); - }).join(sep); - } else { - return ks + encodeURIComponent(stringifyPrimitive(obj[k])); - } - }).join(sep); - + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) } - if (!name) return ''; - return encodeURIComponent(stringifyPrimitive(name)) + eq + - encodeURIComponent(stringifyPrimitive(obj)); -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -function map (xs, f) { - if (xs.map) return xs.map(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - res.push(f(xs[i], i)); + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) } - return res; } -var objectKeys = Object.keys || function (obj) { - var res = []; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') } - return res; -}; - -},{}],56:[function(require,module,exports){ -'use strict'; - -exports.decode = exports.parse = require('./decode'); -exports.encode = exports.stringify = require('./encode'); - -},{"./decode":54,"./encode":55}],57:[function(require,module,exports){ -module.exports = require('./lib/_stream_duplex.js'); - -},{"./lib/_stream_duplex.js":58}],58:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// a duplex stream is just a stream that is both readable and writable. -// Since JS doesn't have multiple prototypal inheritance, this class -// prototypally inherits from Readable, and then parasitically from -// Writable. - -'use strict'; - -/**/ - -var pna = require('process-nextick-args'); -/**/ - -/**/ -var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) { - keys.push(key); - }return keys; -}; -/**/ - -module.exports = Duplex; - -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -var Readable = require('./_stream_readable'); -var Writable = require('./_stream_writable'); - -util.inherits(Duplex, Readable); + return length | 0 +} -{ - // avoid scope creep, the keys array can then be collected - var keys = objectKeys(Writable.prototype); - for (var v = 0; v < keys.length; v++) { - var method = keys[v]; - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 } + return Buffer.alloc(+length) } -function Duplex(options) { - if (!(this instanceof Duplex)) return new Duplex(options); +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true && + b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false +} - Readable.call(this, options); - Writable.call(this, options); +Buffer.compare = function compare (a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) + } - if (options && options.readable === false) this.readable = false; + if (a === b) return 0 - if (options && options.writable === false) this.writable = false; + var x = a.length + var y = b.length - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } - this.once('end', onend); + if (x < y) return -1 + if (y < x) return 1 + return 0 } -Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function () { - return this._writableState.highWaterMark; +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false } -}); +} -// the no-half-open enforcer -function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) return; +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } - // no more data can be written. - // But allow more writes to happen in this tick. - pna.nextTick(onEndNT, this); -} + if (list.length === 0) { + return Buffer.alloc(0) + } -function onEndNT(self) { - self.end(); -} + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } -Object.defineProperty(Duplex.prototype, 'destroyed', { - get: function () { - if (this._readableState === undefined || this._writableState === undefined) { - return false; + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (isInstance(buf, Uint8Array)) { + buf = Buffer.from(buf) } - return this._readableState.destroyed && this._writableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (this._readableState === undefined || this._writableState === undefined) { - return; + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') } - - // backward compatibility, the user is explicitly - // managing destroyed - this._readableState.destroyed = value; - this._writableState.destroyed = value; + buf.copy(buffer, pos) + pos += buf.length } -}); - -Duplex.prototype._destroy = function (err, cb) { - this.push(null); - this.end(); - - pna.nextTick(cb, err); -}; -},{"./_stream_readable":60,"./_stream_writable":62,"core-util-is":18,"inherits":46,"process-nextick-args":51}],59:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// a passthrough stream. -// basically just the most minimal sort of Transform stream. -// Every written chunk gets output as-is. + return buffer +} -'use strict'; +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) + } -module.exports = PassThrough; + var len = string.length + var mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 -var Transform = require('./_stream_transform'); + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ +function slowToString (encoding, start, end) { + var loweredCase = false -util.inherits(PassThrough, Transform); + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. -function PassThrough(options) { - if (!(this instanceof PassThrough)) return new PassThrough(options); + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } - Transform.call(this, options); -} + if (end === undefined || end > this.length) { + end = this.length + } -PassThrough.prototype._transform = function (chunk, encoding, cb) { - cb(null, chunk); -}; -},{"./_stream_transform":61,"core-util-is":18,"inherits":46}],60:[function(require,module,exports){ -(function (process,global){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. + if (end <= 0) { + return '' + } -'use strict'; + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 -/**/ + if (end <= start) { + return '' + } -var pna = require('process-nextick-args'); -/**/ + if (!encoding) encoding = 'utf8' -module.exports = Readable; + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) -/**/ -var isArray = require('isarray'); -/**/ + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) -/**/ -var Duplex; -/**/ + case 'ascii': + return asciiSlice(this, start, end) -Readable.ReadableState = ReadableState; + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) -/**/ -var EE = require('events').EventEmitter; + case 'base64': + return base64Slice(this, start, end) -var EElistenerCount = function (emitter, type) { - return emitter.listeners(type).length; -}; -/**/ + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) -/**/ -var Stream = require('./internal/streams/stream'); -/**/ + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} -/**/ +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true -var Buffer = require('safe-buffer').Buffer; -var OurUint8Array = global.Uint8Array || function () {}; -function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i } -function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this } -/**/ +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} -/**/ -var debugUtil = require('util'); -var debug = void 0; -if (debugUtil && debugUtil.debuglog) { - debug = debugUtil.debuglog('stream'); -} else { - debug = function () {}; +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) } -/**/ -var BufferList = require('./internal/streams/BufferList'); -var destroyImpl = require('./internal/streams/destroy'); -var StringDecoder; +Buffer.prototype.toLocaleString = Buffer.prototype.toString -util.inherits(Readable, Stream); +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} -var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' + return '' +} -function prependListener(emitter, event, fn) { - // Sadly this is not cacheable as some libraries bundle their own - // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength) + } + if (!Buffer.isBuffer(target)) { + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) + } - // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; -} + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } -function ReadableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); - - options = options || {}; - - // Duplex streams are both readable and writable, but share - // the same options object. - // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream. - // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; - - // object stream flag. Used to make read(n) ignore n and to - // make all the buffer merging and length checks go away - this.objectMode = !!options.objectMode; - - if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; - - // the point at which it stops calling _read() to fill the buffer - // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var readableHwm = options.readableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; - - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); - - // A linked list is used to store data chunks instead of an array because the - // linked list can remove elements from the beginning faster than - // array.shift() - this.buffer = new BufferList(); - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - this.endEmitted = false; - this.reading = false; - - // a flag to be able to tell if the event 'readable'/'data' is emitted - // immediately, or on a later tick. We set this to true at first, because - // any actions that shouldn't happen until "later" should generally also - // not happen before the first read call. - this.sync = true; - - // whenever we return null, then we set a flag to say - // that we're awaiting a 'readable' event emission. - this.needReadable = false; - this.emittedReadable = false; - this.readableListening = false; - this.resumeScheduled = false; - - // has it been destroyed - this.destroyed = false; - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; - - // if true, a maybeReadMore has been scheduled - this.readingMore = false; - - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') } -} -function Readable(options) { - Duplex = Duplex || require('./_stream_duplex'); + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } - if (!(this instanceof Readable)) return new Readable(options); + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 - this._readableState = new ReadableState(options, this); + if (this === target) return 0 - // legacy - this.readable = true; + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) - if (options) { - if (typeof options.read === 'function') this._read = options.read; + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) - if (typeof options.destroy === 'function') this._destroy = options.destroy; + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } } - Stream.call(this); + if (x < y) return -1 + if (y < x) return 1 + return 0 } -Object.defineProperty(Readable.prototype, 'destroyed', { - get: function () { - if (this._readableState === undefined) { - return false; - } - return this._readableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (!this._readableState) { - return; - } +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } - // backward compatibility, the user is explicitly - // managing destroyed - this._readableState.destroyed = value; + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 } -}); -Readable.prototype.destroy = destroyImpl.destroy; -Readable.prototype._undestroy = destroyImpl.undestroy; -Readable.prototype._destroy = function (err, cb) { - this.push(null); - cb(err); -}; + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } -// Manually shove something into the read() buffer. -// This returns true if the highWaterMark has not been hit yet, -// similar to how Writable.write() returns true if you should -// write() some more. -Readable.prototype.push = function (chunk, encoding) { - var state = this._readableState; - var skipChunkCheck; - - if (!state.objectMode) { - if (typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = Buffer.from(chunk, encoding); - encoding = ''; + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) } - skipChunkCheck = true; } - } else { - skipChunkCheck = true; + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) } - return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); -}; + throw new TypeError('val must be string, number or Buffer') +} -// Unshift should *always* be something directly out of read() -Readable.prototype.unshift = function (chunk) { - return readableAddChunk(this, chunk, null, true, false); -}; +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length -function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { - var state = stream._readableState; - if (chunk === null) { - state.reading = false; - onEofChunk(stream, state); - } else { - var er; - if (!skipChunkCheck) er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { - chunk = _uint8ArrayToBuffer(chunk); + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } - if (addToFront) { - if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); - } else if (state.ended) { - stream.emit('error', new Error('stream.push() after EOF')); + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize } else { - state.reading = false; - if (state.decoder && !encoding) { - chunk = state.decoder.write(chunk); - if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); - } else { - addChunk(stream, state, chunk, false); + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break } } - } else if (!addToFront) { - state.reading = false; + if (found) return i } } - return needMoreData(state); + return -1 } -function addChunk(stream, state, chunk, addToFront) { - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); - } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} - if (state.needReadable) emitReadable(stream); - } - maybeReadMore(stream, state); +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) } -function chunkInvalid(state, chunk) { - var er; - if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed } - return er; + return i } -// if it's past the high water mark, we can push in some more. -// Also, if we have no data yet, we can stand some -// more bytes. This is to work around cases where hwm=0, -// such as the repl. Also, if the push() triggered a -// readable event, and the user called read(largeNumber) such that -// needReadable was set, then we ought to push more, so that another -// 'readable' event will be triggered. -function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) } -Readable.prototype.isPaused = function () { - return this._readableState.flowing === false; -}; +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} -// backwards compatibility. -Readable.prototype.setEncoding = function (enc) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; -}; +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} -// Don't raise the hwm > 8MB -var MAX_HWM = 0x800000; -function computeNewHighWaterMark(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - // Get the next highest power of 2 to prevent increasing hwm excessively in - // tiny amounts - n--; - n |= n >>> 1; - n |= n >>> 2; - n |= n >>> 4; - n |= n >>> 8; - n |= n >>> 16; - n++; - } - return n; +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) } -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function howMuchToRead(n, state) { - if (n <= 0 || state.length === 0 && state.ended) return 0; - if (state.objectMode) return 1; - if (n !== n) { - // Only flow one buffer at a time - if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; - } - // If we're asking for more than the current hwm, then raise the hwm. - if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) return n; - // Don't have enough - if (!state.ended) { - state.needReadable = true; - return 0; - } - return state.length; +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) } -// you can override either this method, or the async _read(n) below. -Readable.prototype.read = function (n) { - debug('read', n); - n = parseInt(n, 10); - var state = this._readableState; - var nOrig = n; - - if (n !== 0) state.emittedReadable = false; - - // if we're doing read(0) to trigger a readable event, but we - // already have a bunch of data in the buffer, then just trigger - // the 'readable' event and move on. - if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { - debug('read: emitReadable', state.length, state.ended); - if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); - return null; +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) } - n = howMuchToRead(n, state); - - // if we've ended, and we're now clear, then finish it up. - if (n === 0 && state.ended) { - if (state.length === 0) endReadable(this); - return null; - } + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining - // All the actual chunk generation logic needs to be - // *below* the call to _read. The reason is that in certain - // synthetic stream cases, such as passthrough streams, _read - // may be a completely synchronous operation which may change - // the state of the read buffer, providing enough data when - // before there was *not* enough. - // - // So, the steps are: - // 1. Figure out what the state of things will be after we do - // a read from the buffer. - // - // 2. If that resulting state will trigger a _read, then call _read. - // Note that this may be asynchronous, or synchronous. Yes, it is - // deeply ugly to write APIs this way, but that still doesn't mean - // that the Readable class should behave improperly, as streams are - // designed to be sync/async agnostic. - // Take note if the _read call is sync or async (ie, if the read call - // has returned yet), so that we know whether or not it's safe to emit - // 'readable' etc. - // - // 3. Actually pull the requested chunks out of the buffer and return. - - // if we need a readable event, then we need to do some reading. - var doRead = state.needReadable; - debug('need readable', doRead); - - // if we currently have less than the highWaterMark, then also read some - if (state.length === 0 || state.length - n < state.highWaterMark) { - doRead = true; - debug('length less than watermark', doRead); + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') } - // however, if we've ended, then there's no point, and if we're already - // reading, then it's unnecessary. - if (state.ended || state.reading) { - doRead = false; - debug('reading or ended', doRead); - } else if (doRead) { - debug('do read'); - state.reading = true; - state.sync = true; - // if the length is currently zero, then we *need* a readable event. - if (state.length === 0) state.needReadable = true; - // call internal read method - this._read(state.highWaterMark); - state.sync = false; - // If _read pushed data synchronously, then `reading` will be false, - // and we need to re-evaluate how much data we can return to the user. - if (!state.reading) n = howMuchToRead(nOrig, state); - } + if (!encoding) encoding = 'utf8' - var ret; - if (n > 0) ret = fromList(n, state);else ret = null; + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) - if (ret === null) { - state.needReadable = true; - n = 0; - } else { - state.length -= n; - } + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) - if (state.length === 0) { - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true; + case 'ascii': + return asciiWrite(this, string, offset, length) - // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended) endReadable(this); - } + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) - if (ret !== null) this.emit('data', ret); + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) - return ret; -}; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) -function onEofChunk(stream, state) { - if (state.ended) return; - if (state.decoder) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) { - state.buffer.push(chunk); - state.length += state.objectMode ? 1 : chunk.length; + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true } } - state.ended = true; - - // emit 'readable' now to make sure it gets picked up. - emitReadable(stream); -} - -// Don't emit readable right away in sync mode, because this can trigger -// another read() call => stack overflow. This way, it might trigger -// a nextTick recursion warning, but that's not so bad. -function emitReadable(stream) { - var state = stream._readableState; - state.needReadable = false; - if (!state.emittedReadable) { - debug('emitReadable', state.flowing); - state.emittedReadable = true; - if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); - } -} - -function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); } -// at this point, the user has presumably seen the 'readable' event, -// and called read() to consume some data. that may have triggered -// in turn another _read(n) call, in which case reading = true if -// it's in progress. -// However, if we're not ended, or reading, and the length < hwm, -// then go ahead and try to read some more preemptively. -function maybeReadMore(stream, state) { - if (!state.readingMore) { - state.readingMore = true; - pna.nextTick(maybeReadMore_, stream, state); +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) } } -function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { - debug('maybeReadMore read 0'); - stream.read(0); - if (len === state.length) - // didn't get any data, stop spinning. - break;else len = state.length; +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) } - state.readingMore = false; } -// abstract method. to be overridden in specific implementation classes. -// call cb(er, data) where data is <= n in length. -// for virtual (non-string, non-buffer) streams, "length" is somewhat -// arbitrary, and perhaps not very meaningful. -Readable.prototype._read = function (n) { - this.emit('error', new Error('_read() is not implemented')); -}; - -Readable.prototype.pipe = function (dest, pipeOpts) { - var src = this; - var state = this._readableState; - - switch (state.pipesCount) { - case 0: - state.pipes = dest; - break; - case 1: - state.pipes = [state.pipes, dest]; - break; - default: - state.pipes.push(dest); - break; - } - state.pipesCount += 1; - debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 - var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint - dest.on('unpipe', onunpipe); - function onunpipe(readable, unpipeInfo) { - debug('onunpipe'); - if (readable === src) { - if (unpipeInfo && unpipeInfo.hasUnpiped === false) { - unpipeInfo.hasUnpiped = true; - cleanup(); + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } } } - } - - function onend() { - debug('onend'); - dest.end(); - } - - // when the dest drains, it reduces the awaitDrain counter - // on the source. This would be more elegant with a .once() - // handler in flow(), but adding and removing repeatedly is - // too slow. - var ondrain = pipeOnDrain(src); - dest.on('drain', ondrain); - - var cleanedUp = false; - function cleanup() { - debug('cleanup'); - // cleanup event handlers once the pipe is broken - dest.removeListener('close', onclose); - dest.removeListener('finish', onfinish); - dest.removeListener('drain', ondrain); - dest.removeListener('error', onerror); - dest.removeListener('unpipe', onunpipe); - src.removeListener('end', onend); - src.removeListener('end', unpipe); - src.removeListener('data', ondata); - - cleanedUp = true; - - // if the reader is waiting for a drain event from this - // specific writer, then it would cause it to never start - // flowing again. - // So, if this is awaiting a drain, then we just call it now. - // If we don't know, then assume that we are waiting for one. - if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); - } - // If the user pushes more data while we're writing to dest then we'll end up - // in ondata again. However, we only want to increase awaitDrain once because - // dest will only emit one 'drain' event for the multiple writes. - // => Introduce a guard on increasing awaitDrain. - var increasedAwaitDrain = false; - src.on('data', ondata); - function ondata(chunk) { - debug('ondata'); - increasedAwaitDrain = false; - var ret = dest.write(chunk); - if (false === ret && !increasedAwaitDrain) { - // If the user unpiped during `dest.write()`, it is possible - // to get stuck in a permanently paused state if that write - // also returned false. - // => Check whether `dest` is still a piping destination. - if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', src._readableState.awaitDrain); - src._readableState.awaitDrain++; - increasedAwaitDrain = true; - } - src.pause(); + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF } - } - // if the dest has an error, then stop piping into it. - // however, don't suppress the throwing behavior for this. - function onerror(er) { - debug('onerror', er); - unpipe(); - dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + res.push(codePoint) + i += bytesPerSequence } - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror); + return decodeCodePointsArray(res) +} - // Both close and finish should trigger unpipe, but only once. - function onclose() { - dest.removeListener('finish', onfinish); - unpipe(); - } - dest.once('close', onclose); - function onfinish() { - debug('onfinish'); - dest.removeListener('close', onclose); - unpipe(); +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() } - dest.once('finish', onfinish); - function unpipe() { - debug('unpipe'); - src.unpipe(dest); + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) } + return res +} - // tell the dest that it's being piped to - dest.emit('pipe', src); +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) - // start the flow if it hasn't been started already. - if (!state.flowing) { - debug('pipe resume'); - src.resume(); + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) } + return ret +} - return dest; -}; +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) -function pipeOnDrain(src) { - return function () { - var state = src._readableState; - debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) state.awaitDrain--; - if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { - state.flowing = true; - flow(src); - } - }; + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret } -Readable.prototype.unpipe = function (dest) { - var state = this._readableState; - var unpipeInfo = { hasUnpiped: false }; - - // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) return this; +function hexSlice (buf, start, end) { + var len = buf.length - // just one destination. most common case. - if (state.pipesCount === 1) { - // passed in one, but it's not the right one. - if (dest && dest !== state.pipes) return this; + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len - if (!dest) dest = state.pipes; + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} - // got a match. - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - if (dest) dest.emit('unpipe', this, unpipeInfo); - return this; +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) } + return res +} - // slow case. multiple pipe destinations. +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end - if (!dest) { - // remove all. - var dests = state.pipes; - var len = state.pipesCount; - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } - for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this, unpipeInfo); - }return this; + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len } - // try to find the right one. - var index = indexOf(state.pipes, dest); - if (index === -1) return this; + if (end < start) end = start - state.pipes.splice(index, 1); - state.pipesCount -= 1; - if (state.pipesCount === 1) state.pipes = state.pipes[0]; + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf +} - dest.emit('unpipe', this, unpipeInfo); +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} - return this; -}; +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) -// set up data events if they are asked for -// Ensure readable listeners eventually get something -Readable.prototype.on = function (ev, fn) { - var res = Stream.prototype.on.call(this, ev, fn); - - if (ev === 'data') { - // Start flowing on next tick if stream isn't explicitly paused - if (this._readableState.flowing !== false) this.resume(); - } else if (ev === 'readable') { - var state = this._readableState; - if (!state.endEmitted && !state.readableListening) { - state.readableListening = state.needReadable = true; - state.emittedReadable = false; - if (!state.reading) { - pna.nextTick(nReadingNextTick, this); - } else if (state.length) { - emitReadable(this); - } - } + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul } - return res; -}; -Readable.prototype.addListener = Readable.prototype.on; - -function nReadingNextTick(self) { - debug('readable nexttick read 0'); - self.read(0); + return val } -// pause() and resume() are remnants of the legacy readable stream API -// If the user uses them, then switch into old mode. -Readable.prototype.resume = function () { - var state = this._readableState; - if (!state.flowing) { - debug('resume'); - state.flowing = true; - resume(this, state); - } - return this; -}; - -function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - pna.nextTick(resume_, stream, state); +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) } -} -function resume_(stream, state) { - if (!state.reading) { - debug('resume read 0'); - stream.read(0); + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul } - state.resumeScheduled = false; - state.awaitDrain = 0; - stream.emit('resume'); - flow(stream); - if (state.flowing && !state.reading) stream.read(0); + return val } -Readable.prototype.pause = function () { - debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { - debug('pause'); - this._readableState.flowing = false; - this.emit('pause'); - } - return this; -}; +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} -function flow(stream) { - var state = stream._readableState; - debug('flow', state.flowing); - while (state.flowing && stream.read() !== null) {} +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) } -// wrap an old-style stream as the async data source. -// This is *not* part of the readable stream interface. -// It is an ugly unfortunate mess of history. -Readable.prototype.wrap = function (stream) { - var _this = this; +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} - var state = this._readableState; - var paused = false; +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) - stream.on('end', function () { - debug('wrapped end'); - if (state.decoder && !state.ended) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) _this.push(chunk); - } + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} - _this.push(null); - }); +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) - stream.on('data', function (chunk) { - debug('wrapped data'); - if (state.decoder) chunk = state.decoder.write(chunk); + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} - // don't skip over falsy values in objectMode - if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) - var ret = _this.push(chunk); - if (!ret) { - paused = true; - stream.pause(); - } - }); - - // proxy all the other methods. - // important when wrapping filters and duplexes. - for (var i in stream) { - if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function (method) { - return function () { - return stream[method].apply(stream, arguments); - }; - }(i); - } + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul } + mul *= 0x80 - // proxy certain important events. - for (var n = 0; n < kProxyEvents.length; n++) { - stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); - } + if (val >= mul) val -= Math.pow(2, 8 * byteLength) - // when we try to consume some more bytes, simply unpause the - // underlying stream. - this._read = function (n) { - debug('wrapped _read', n); - if (paused) { - paused = false; - stream.resume(); - } - }; + return val +} - return this; -}; +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) -Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function () { - return this._readableState.highWaterMark; + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul } -}); + mul *= 0x80 -// exposed for testing purposes only. -Readable._fromList = fromList; - -// Pluck off n bytes from an array of buffers. -// Length is the combined lengths of all the buffers in the list. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromList(n, state) { - // nothing buffered - if (state.length === 0) return null; - - var ret; - if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { - // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); - state.buffer.clear(); - } else { - // read part of list - ret = fromListPartial(n, state.buffer, state.decoder); - } + if (val >= mul) val -= Math.pow(2, 8 * byteLength) - return ret; + return val } -// Extracts only enough buffered data to satisfy the amount requested. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - // slice is the same for buffers and strings - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - // first chunk is a perfect match - ret = list.shift(); - } else { - // result spans more than one buffer - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); - } - return ret; +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) } -// Copies a specified amount of characters from the list of buffered data -// chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val } -// Copies a specified amount of bytes from the list of buffered data chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBuffer(n, list) { - var ret = Buffer.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val } -function endReadable(stream) { - var state = stream._readableState; - - // If we get here before consuming all the bytes, then that is a - // bug in node. Should never happen. - if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) - if (!state.endEmitted) { - state.ended = true; - pna.nextTick(endReadableNT, state, stream); - } + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) } -function endReadableNT(state, stream) { - // Check that we didn't get one last unshift. - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit('end'); - } -} +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) -function indexOf(xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) return i; - } - return -1; + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":58,"./internal/streams/BufferList":63,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":52,"core-util-is":18,"events":44,"inherits":46,"isarray":48,"process-nextick-args":51,"safe-buffer":71,"string_decoder/":66,"util":4}],61:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// a transform stream is a readable/writable stream where you do -// something with the data. Sometimes it's called a "filter", -// but that's not a great name for it, since that implies a thing where -// some bits pass through, and others are simply ignored. (That would -// be a valid example of a transform, of course.) -// -// While the output is causally related to the input, it's not a -// necessarily symmetric or synchronous transformation. For example, -// a zlib stream might take multiple plain-text writes(), and then -// emit a single compressed chunk some time in the future. -// -// Here's how this works: -// -// The Transform stream has all the aspects of the readable and writable -// stream classes. When you write(chunk), that calls _write(chunk,cb) -// internally, and returns false if there's a lot of pending writes -// buffered up. When you call read(), that calls _read(n) until -// there's enough pending readable data buffered up. -// -// In a transform stream, the written data is placed in a buffer. When -// _read(n) is called, it transforms the queued up data, calling the -// buffered _write cb's as it consumes chunks. If consuming a single -// written chunk would result in multiple output chunks, then the first -// outputted bit calls the readcb, and subsequent chunks just go into -// the read buffer, and will cause it to emit 'readable' if necessary. -// -// This way, back-pressure is actually determined by the reading side, -// since _read has to be called to start processing a new chunk. However, -// a pathological inflate type of transform can cause excessive buffering -// here. For example, imagine a stream where every byte of input is -// interpreted as an integer from 0-255, and then results in that many -// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in -// 1kb of data being output. In this case, you could write a very small -// amount of input, and end up with a very large amount of output. In -// such a pathological inflating mechanism, there'd be no way to tell -// the system to stop doing the transform. A single 4MB write could -// cause the system to run out of memory. -// -// However, even in such a pathological case, only a single written chunk -// would be consumed, and then the rest would wait (un-transformed) until -// the results of the previous transformed chunk were consumed. - -'use strict'; - -module.exports = Transform; -var Duplex = require('./_stream_duplex'); +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} -util.inherits(Transform, Duplex); +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} -function afterTransform(er, data) { - var ts = this._transformState; - ts.transforming = false; +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} - var cb = ts.writecb; +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} - if (!cb) { - return this.emit('error', new Error('write callback called multiple times')); +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) } - ts.writechunk = null; - ts.writecb = null; + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } - if (data != null) // single equals check for both `null` and `undefined` - this.push(data); + return offset + byteLength +} - cb(er); +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } - var rs = this._readableState; - rs.reading = false; - if (rs.needReadable || rs.length < rs.highWaterMark) { - this._read(rs.highWaterMark); + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF } + + return offset + byteLength } -function Transform(options) { - if (!(this instanceof Transform)) return new Transform(options); +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} - Duplex.call(this, options); +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} - this._transformState = { - afterTransform: afterTransform.bind(this), - needTransform: false, - transforming: false, - writecb: null, - writechunk: null, - writeencoding: null - }; +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} - // we have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - this._readableState.sync = false; +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} - if (options) { - if (typeof options.transform === 'function') this._transform = options.transform; +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) - if (typeof options.flush === 'function') this._flush = options.flush; + checkInt(this, value, offset, byteLength, limit - 1, -limit) } - // When the writable side finishes, then flush out anything remaining. - this.on('prefinish', prefinish); -} - -function prefinish() { - var _this = this; - - if (typeof this._flush === 'function') { - this._flush(function (er, data) { - done(_this, er, data); - }); - } else { - done(this, null, null); + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } -} -Transform.prototype.push = function (chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); -}; + return offset + byteLength +} -// This is the part where you do stuff! -// override this function in implementation classes. -// 'chunk' is an input chunk. -// -// Call `push(newChunk)` to pass along transformed output -// to the readable side. You may call 'push' zero or more times. -// -// Call `cb(err)` when you are done with this chunk. If you pass -// an error, then that'll put the hurt on the whole operation. If you -// never call cb(), then you'll never get another chunk. -Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('_transform() is not implemented'); -}; +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) -Transform.prototype._write = function (chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + checkInt(this, value, offset, byteLength, limit - 1, -limit) } -}; -// Doesn't matter what the args are here. -// _transform does all the work. -// That we got here means that the readable side wants more data. -Transform.prototype._read = function (n) { - var ts = this._transformState; - - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { - ts.transforming = true; - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } -}; - -Transform.prototype._destroy = function (err, cb) { - var _this2 = this; - - Duplex.prototype._destroy.call(this, err, function (err2) { - cb(err2); - _this2.emit('close'); - }); -}; - -function done(stream, er, data) { - if (er) return stream.emit('error', er); - - if (data != null) // single equals check for both `null` and `undefined` - stream.push(data); - - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); - if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); - - return stream.push(null); + return offset + byteLength } -},{"./_stream_duplex":58,"core-util-is":18,"inherits":46}],62:[function(require,module,exports){ -(function (process,global,setImmediate){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// A bit simpler than readable streams. -// Implement an async ._write(chunk, encoding, cb), and it'll handle all -// the drain event emission and buffering. - -'use strict'; - -/**/ -var pna = require('process-nextick-args'); -/**/ - -module.exports = Writable; - -/* */ -function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - this.next = null; +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 } -// It seems a linked list but it is not -// there will be only 2 of these for each stream -function CorkedRequest(state) { - var _this = this; - - this.next = null; - this.entry = null; - this.finish = function () { - onCorkedFinish(_this, state); - }; +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 } -/* */ - -/**/ -var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; -/**/ - -/**/ -var Duplex; -/**/ -Writable.WritableState = WritableState; - -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -/**/ -var internalUtil = { - deprecate: require('util-deprecate') -}; -/**/ - -/**/ -var Stream = require('./internal/streams/stream'); -/**/ - -/**/ - -var Buffer = require('safe-buffer').Buffer; -var OurUint8Array = global.Uint8Array || function () {}; -function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); -} -function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 } -/**/ - -var destroyImpl = require('./internal/streams/destroy'); - -util.inherits(Writable, Stream); - -function nop() {} - -function WritableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); - - options = options || {}; - - // Duplex streams are both readable and writable, but share - // the same options object. - // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream. - // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; - - // object stream flag to indicate whether or not this stream - // contains buffers or objects. - this.objectMode = !!options.objectMode; - - if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; - - // the point at which write() starts returning false - // Note: 0 is a valid value, means that we always return false if - // the entire buffer is not flushed immediately on write() - var hwm = options.highWaterMark; - var writableHwm = options.writableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; - - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); - - // if _final has been called - this.finalCalled = false; - - // drain event flag. - this.needDrain = false; - // at the start of calling end() - this.ending = false; - // when end() has been called, and returned - this.ended = false; - // when 'finish' is emitted - this.finished = false; - - // has it been destroyed - this.destroyed = false; - - // should we decode strings into buffers before passing to _write? - // this is here so that some node-core streams can optimize string - // handling at a lower level. - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - - // not an actual buffer we keep track of, but a measurement - // of how much we're waiting to get pushed to some underlying - // socket or file. - this.length = 0; - - // a flag to see when we're in the middle of a write. - this.writing = false; - - // when true all writes will be buffered until .uncork() call - this.corked = 0; +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - this.sync = true; +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} - // a flag to know if we're processing previously buffered items, which - // may call the _write() callback in the same tick, so that we don't - // end up in an overlapped onwrite situation. - this.bufferProcessing = false; +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} - // the callback that's passed to _write(chunk,cb) - this.onwrite = function (er) { - onwrite(stream, er); - }; +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} - // the callback that the user supplies to write(chunk,encoding,cb) - this.writecb = null; +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} - // the amount that is being written when _write is called. - this.writelen = 0; +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} - this.bufferedRequest = null; - this.lastBufferedRequest = null; +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} - // number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} - // emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams - this.prefinished = false; +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start - // count buffered requests - this.bufferedRequestCount = 0; + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 - // allocate the first CorkedRequest, there is always - // one allocated and free to use, and we maintain at most two - this.corkedRequestsFree = new CorkedRequest(this); -} + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') -WritableState.prototype.getBuffer = function getBuffer() { - var current = this.bufferedRequest; - var out = []; - while (current) { - out.push(current); - current = current.next; + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start } - return out; -}; -(function () { - try { - Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function () { - return this.getBuffer(); - }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') - }); - } catch (_) {} -})(); + var len = end - start -// Test _writableState for inheritance to account for Duplex streams, -// whose prototype chain only points to Readable. -var realHasInstance; -if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { - realHasInstance = Function.prototype[Symbol.hasInstance]; - Object.defineProperty(Writable, Symbol.hasInstance, { - value: function (object) { - if (realHasInstance.call(this, object)) return true; - if (this !== Writable) return false; - - return object && object._writableState instanceof WritableState; + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] } - }); -} else { - realHasInstance = function (object) { - return object instanceof this; - }; -} - -function Writable(options) { - Duplex = Duplex || require('./_stream_duplex'); + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } - // Writable ctor is applied to Duplexes, too. - // `realHasInstance` is necessary because using plain `instanceof` - // would return false, as no `_writableState` property is attached. + return len +} - // Trying to use the custom `instanceof` for Writable here will also break the - // Node.js LazyTransform implementation, which has a non-trivial getter for - // `_writableState` that would lead to infinite recursion. - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new Writable(options); +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 } - this._writableState = new WritableState(options, this); - - // legacy. - this.writable = true; + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } - if (options) { - if (typeof options.write === 'function') this._write = options.write; + if (end <= start) { + return this + } - if (typeof options.writev === 'function') this._writev = options.writev; + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 - if (typeof options.destroy === 'function') this._destroy = options.destroy; + if (!val) val = 0 - if (typeof options.final === 'function') this._final = options.final; + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : Buffer.from(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } } - Stream.call(this); + return this } -// Otherwise people can pipe Writable streams, which is just wrong. -Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe, not readable')); -}; +// HELPER FUNCTIONS +// ================ -function writeAfterEnd(stream, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - pna.nextTick(cb, er); -} +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g -// Checks that a user-supplied chunk is valid, especially for the particular -// mode the stream is in. Currently this means that `null` is never accepted -// and undefined/non-string values are only allowed in object mode. -function validChunk(stream, state, chunk, cb) { - var valid = true; - var er = false; - - if (chunk === null) { - er = new TypeError('May not write null values to stream'); - } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - if (er) { - stream.emit('error', er); - pna.nextTick(cb, er); - valid = false; +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' } - return valid; + return str } -Writable.prototype.write = function (chunk, encoding, cb) { - var state = this._writableState; - var ret = false; - var isBuf = !state.objectMode && _isUint8Array(chunk); - - if (isBuf && !Buffer.isBuffer(chunk)) { - chunk = _uint8ArrayToBuffer(chunk); - } - - if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} - if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] - if (typeof cb !== 'function') cb = nop; + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) - if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); - } + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } - return ret; -}; + // valid lead + leadSurrogate = codePoint -Writable.prototype.cork = function () { - var state = this._writableState; + continue + } - state.corked++; -}; + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } -Writable.prototype.uncork = function () { - var state = this._writableState; + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } - if (state.corked) { - state.corked--; + leadSurrogate = null - if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } } -}; -Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { - // node::ParseEncoding() requires lower case. - if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); - this._writableState.defaultEncoding = encoding; - return this; -}; + return bytes +} -function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = Buffer.from(chunk, encoding); +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) } - return chunk; + return byteArray } -Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function () { - return this._writableState.highWaterMark; - } -}); +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break -// if we're already writing something, then just put this -// in the queue, and wait our turn. Otherwise, call _write -// If we return false, then we need a drain event, so set that flag. -function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { - if (!isBuf) { - var newChunk = decodeChunk(state, chunk, encoding); - if (chunk !== newChunk) { - isBuf = true; - encoding = 'buffer'; - chunk = newChunk; - } - } - var len = state.objectMode ? 1 : chunk.length; - - state.length += len; - - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. - if (!ret) state.needDrain = true; - - if (state.writing || state.corked) { - var last = state.lastBufferedRequest; - state.lastBufferedRequest = { - chunk: chunk, - encoding: encoding, - isBuf: isBuf, - callback: cb, - next: null - }; - if (last) { - last.next = state.lastBufferedRequest; - } else { - state.bufferedRequest = state.lastBufferedRequest; - } - state.bufferedRequestCount += 1; - } else { - doWrite(stream, state, false, len, chunk, encoding, cb); + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) } - return ret; + return byteArray } -function doWrite(stream, state, writev, len, chunk, encoding, cb) { - state.writelen = len; - state.writecb = cb; - state.writing = true; - state.sync = true; - if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); - state.sync = false; +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) } -function onwriteError(stream, state, sync, er, cb) { - --state.pendingcb; - - if (sync) { - // defer the callback if we are being called synchronously - // to avoid piling up things on the stack - pna.nextTick(cb, er); - // this can emit finish, and it will always happen - // after error - pna.nextTick(finishMaybe, stream, state); - stream._writableState.errorEmitted = true; - stream.emit('error', er); - } else { - // the caller expect this to happen before if - // it is async - cb(er); - stream._writableState.errorEmitted = true; - stream.emit('error', er); - // this can emit finish, but finish must - // always follow error - finishMaybe(stream, state); +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] } + return i } -function onwriteStateUpdate(state) { - state.writing = false; - state.writecb = null; - state.length -= state.writelen; - state.writelen = 0; +// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass +// the `instanceof` check but they should be treated as of that type. +// See: https://github.com/feross/buffer/issues/166 +function isInstance (obj, type) { + return obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && + obj.constructor.name === type.name) +} +function numberIsNaN (obj) { + // For IE11 support + return obj !== obj // eslint-disable-line no-self-compare } -function onwrite(stream, er) { - var state = stream._writableState; - var sync = state.sync; - var cb = state.writecb; - - onwriteStateUpdate(state); +},{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 Patrick Gansterer + * + * 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. + */ - if (er) onwriteError(stream, state, sync, er, cb);else { - // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state); +(function(global, undefined) { "use strict"; +var POW_2_24 = Math.pow(2, -24), + POW_2_32 = Math.pow(2, 32), + POW_2_53 = Math.pow(2, 53); + +function encode(value) { + var data = new ArrayBuffer(256); + var dataView = new DataView(data); + var lastLength; + var offset = 0; + + function ensureSpace(length) { + var newByteLength = data.byteLength; + var requiredLength = offset + length; + while (newByteLength < requiredLength) + newByteLength *= 2; + if (newByteLength !== data.byteLength) { + var oldDataView = dataView; + data = new ArrayBuffer(newByteLength); + dataView = new DataView(data); + var uint32count = (offset + 3) >> 2; + for (var i = 0; i < uint32count; ++i) + dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); + } + + lastLength = length; + return dataView; + } + function write() { + offset += lastLength; + } + function writeFloat64(value) { + write(ensureSpace(8).setFloat64(offset, value)); + } + function writeUint8(value) { + write(ensureSpace(1).setUint8(offset, value)); + } + function writeUint8Array(value) { + var dataView = ensureSpace(value.length); + for (var i = 0; i < value.length; ++i) + dataView.setUint8(offset + i, value[i]); + write(); + } + function writeUint16(value) { + write(ensureSpace(2).setUint16(offset, value)); + } + function writeUint32(value) { + write(ensureSpace(4).setUint32(offset, value)); + } + function writeUint64(value) { + var low = value % POW_2_32; + var high = (value - low) / POW_2_32; + var dataView = ensureSpace(8); + dataView.setUint32(offset, high); + dataView.setUint32(offset + 4, low); + write(); + } + function writeTypeAndLength(type, length) { + if (length < 24) { + writeUint8(type << 5 | length); + } else if (length < 0x100) { + writeUint8(type << 5 | 24); + writeUint8(length); + } else if (length < 0x10000) { + writeUint8(type << 5 | 25); + writeUint16(length); + } else if (length < 0x100000000) { + writeUint8(type << 5 | 26); + writeUint32(length); + } else { + writeUint8(type << 5 | 27); + writeUint64(length); + } + } + + function encodeItem(value) { + var i; + + if (value === false) + return writeUint8(0xf4); + if (value === true) + return writeUint8(0xf5); + if (value === null) + return writeUint8(0xf6); + if (value === undefined) + return writeUint8(0xf7); + + switch (typeof value) { + case "number": + if (Math.floor(value) === value) { + if (0 <= value && value <= POW_2_53) + return writeTypeAndLength(0, value); + if (-POW_2_53 <= value && value < 0) + return writeTypeAndLength(1, -(value + 1)); + } + writeUint8(0xfb); + return writeFloat64(value); + + case "string": + var utf8data = []; + for (i = 0; i < value.length; ++i) { + var charCode = value.charCodeAt(i); + if (charCode < 0x80) { + utf8data.push(charCode); + } else if (charCode < 0x800) { + utf8data.push(0xc0 | charCode >> 6); + utf8data.push(0x80 | charCode & 0x3f); + } else if (charCode < 0xd800) { + utf8data.push(0xe0 | charCode >> 12); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } else { + charCode = (charCode & 0x3ff) << 10; + charCode |= value.charCodeAt(++i) & 0x3ff; + charCode += 0x10000; + + utf8data.push(0xf0 | charCode >> 18); + utf8data.push(0x80 | (charCode >> 12) & 0x3f); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } + } - if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { - clearBuffer(stream, state); - } + writeTypeAndLength(3, utf8data.length); + return writeUint8Array(utf8data); - if (sync) { - /**/ - asyncWrite(afterWrite, stream, state, finished, cb); - /**/ - } else { - afterWrite(stream, state, finished, cb); + default: + var length; + if (Array.isArray(value)) { + length = value.length; + writeTypeAndLength(4, length); + for (i = 0; i < length; ++i) + encodeItem(value[i]); + } else if (value instanceof Uint8Array) { + writeTypeAndLength(2, value.length); + writeUint8Array(value); + } else { + var keys = Object.keys(value); + length = keys.length; + writeTypeAndLength(5, length); + for (i = 0; i < length; ++i) { + var key = keys[i]; + encodeItem(key); + encodeItem(value[key]); + } + } } } -} + + encodeItem(value); -function afterWrite(stream, state, finished, cb) { - if (!finished) onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); + if ("slice" in data) + return data.slice(0, offset); + + var ret = new ArrayBuffer(offset); + var retView = new DataView(ret); + for (var i = 0; i < offset; ++i) + retView.setUint8(i, dataView.getUint8(i)); + return ret; } -// Must force callback to be called on nextTick, so that we don't -// emit 'drain' before the write() consumer gets the 'false' return -// value, and has a chance to attach a 'drain' listener. -function onwriteDrain(stream, state) { - if (state.length === 0 && state.needDrain) { - state.needDrain = false; - stream.emit('drain'); - } -} +function decode(data, tagger, simpleValue) { + var dataView = new DataView(data); + var offset = 0; + + if (typeof tagger !== "function") + tagger = function(value) { return value; }; + if (typeof simpleValue !== "function") + simpleValue = function() { return undefined; }; -// if there's something in the buffer waiting, then process it -function clearBuffer(stream, state) { - state.bufferProcessing = true; - var entry = state.bufferedRequest; - - if (stream._writev && entry && entry.next) { - // Fast case, write everything using _writev() - var l = state.bufferedRequestCount; - var buffer = new Array(l); - var holder = state.corkedRequestsFree; - holder.entry = entry; - - var count = 0; - var allBuffers = true; - while (entry) { - buffer[count] = entry; - if (!entry.isBuf) allBuffers = false; - entry = entry.next; - count += 1; - } - buffer.allBuffers = allBuffers; + function read(value, length) { + offset += length; + return value; + } + function readArrayBuffer(length) { + return read(new Uint8Array(data, offset, length), length); + } + function readFloat16() { + var tempArrayBuffer = new ArrayBuffer(4); + var tempDataView = new DataView(tempArrayBuffer); + var value = readUint16(); - doWrite(stream, state, true, state.length, buffer, '', holder.finish); + var sign = value & 0x8000; + var exponent = value & 0x7c00; + var fraction = value & 0x03ff; + + if (exponent === 0x7c00) + exponent = 0xff << 10; + else if (exponent !== 0) + exponent += (127 - 15) << 10; + else if (fraction !== 0) + return fraction * POW_2_24; + + tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); + return tempDataView.getFloat32(0); + } + function readFloat32() { + return read(dataView.getFloat32(offset), 4); + } + function readFloat64() { + return read(dataView.getFloat64(offset), 8); + } + function readUint8() { + return read(dataView.getUint8(offset), 1); + } + function readUint16() { + return read(dataView.getUint16(offset), 2); + } + function readUint32() { + return read(dataView.getUint32(offset), 4); + } + function readUint64() { + return readUint32() * POW_2_32 + readUint32(); + } + function readBreak() { + if (dataView.getUint8(offset) !== 0xff) + return false; + offset += 1; + return true; + } + function readLength(additionalInformation) { + if (additionalInformation < 24) + return additionalInformation; + if (additionalInformation === 24) + return readUint8(); + if (additionalInformation === 25) + return readUint16(); + if (additionalInformation === 26) + return readUint32(); + if (additionalInformation === 27) + return readUint64(); + if (additionalInformation === 31) + return -1; + throw "Invalid length encoding"; + } + function readIndefiniteStringLength(majorType) { + var initialByte = readUint8(); + if (initialByte === 0xff) + return -1; + var length = readLength(initialByte & 0x1f); + if (length < 0 || (initialByte >> 5) !== majorType) + throw "Invalid indefinite length element"; + return length; + } + + function appendUtf16data(utf16data, length) { + for (var i = 0; i < length; ++i) { + var value = readUint8(); + if (value & 0x80) { + if (value < 0xe0) { + value = (value & 0x1f) << 6 + | (readUint8() & 0x3f); + length -= 1; + } else if (value < 0xf0) { + value = (value & 0x0f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 2; + } else { + value = (value & 0x0f) << 18 + | (readUint8() & 0x3f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 3; + } + } - // doWrite is almost always async, defer these to save a bit of time - // as the hot path ends with doWrite - state.pendingcb++; - state.lastBufferedRequest = null; - if (holder.next) { - state.corkedRequestsFree = holder.next; - holder.next = null; - } else { - state.corkedRequestsFree = new CorkedRequest(state); - } - state.bufferedRequestCount = 0; - } else { - // Slow case, write chunks one-by-one - while (entry) { - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; - - doWrite(stream, state, false, len, chunk, encoding, cb); - entry = entry.next; - state.bufferedRequestCount--; - // if we didn't call the onwrite immediately, then - // it means that we need to wait until it does. - // also, that means that the chunk and cb are currently - // being processed, so move the buffer counter past them. - if (state.writing) { - break; + if (value < 0x10000) { + utf16data.push(value); + } else { + value -= 0x10000; + utf16data.push(0xd800 | (value >> 10)); + utf16data.push(0xdc00 | (value & 0x3ff)); } } - - if (entry === null) state.lastBufferedRequest = null; } - state.bufferedRequest = entry; - state.bufferProcessing = false; -} - -Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('_write() is not implemented')); -}; + function decodeItem() { + var initialByte = readUint8(); + var majorType = initialByte >> 5; + var additionalInformation = initialByte & 0x1f; + var i; + var length; -Writable.prototype._writev = null; + if (majorType === 7) { + switch (additionalInformation) { + case 25: + return readFloat16(); + case 26: + return readFloat32(); + case 27: + return readFloat64(); + } + } -Writable.prototype.end = function (chunk, encoding, cb) { - var state = this._writableState; + length = readLength(additionalInformation); + if (length < 0 && (majorType < 2 || 6 < majorType)) + throw "Invalid length"; - if (typeof chunk === 'function') { - cb = chunk; - chunk = null; - encoding = null; - } else if (typeof encoding === 'function') { - cb = encoding; - encoding = null; + switch (majorType) { + case 0: + return length; + case 1: + return -1 - length; + case 2: + if (length < 0) { + var elements = []; + var fullArrayLength = 0; + while ((length = readIndefiniteStringLength(majorType)) >= 0) { + fullArrayLength += length; + elements.push(readArrayBuffer(length)); + } + var fullArray = new Uint8Array(fullArrayLength); + var fullArrayOffset = 0; + for (i = 0; i < elements.length; ++i) { + fullArray.set(elements[i], fullArrayOffset); + fullArrayOffset += elements[i].length; + } + return fullArray; + } + return readArrayBuffer(length); + case 3: + var utf16data = []; + if (length < 0) { + while ((length = readIndefiniteStringLength(majorType)) >= 0) + appendUtf16data(utf16data, length); + } else + appendUtf16data(utf16data, length); + return String.fromCharCode.apply(null, utf16data); + case 4: + var retArray; + if (length < 0) { + retArray = []; + while (!readBreak()) + retArray.push(decodeItem()); + } else { + retArray = new Array(length); + for (i = 0; i < length; ++i) + retArray[i] = decodeItem(); + } + return retArray; + case 5: + var retObject = {}; + for (i = 0; i < length || length < 0 && !readBreak(); ++i) { + var key = decodeItem(); + retObject[key] = decodeItem(); + } + return retObject; + case 6: + return tagger(decodeItem(), length); + case 7: + switch (length) { + case 20: + return false; + case 21: + return true; + case 22: + return null; + case 23: + return undefined; + default: + return simpleValue(length); + } + } } - if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + var ret = decodeItem(); + if (offset !== data.byteLength) + throw "Remaining bytes"; + return ret; +} - // .end() fully uncorks - if (state.corked) { - state.corked = 1; - this.uncork(); - } +var obj = { encode: encode, decode: decode }; - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) endWritable(this, state, cb); -}; +if (typeof define === "function" && define.amd) + define("cbor/cbor", obj); +else if (typeof module !== 'undefined' && module.exports) + module.exports = obj; +else if (!global.CBOR) + global.CBOR = obj; -function needFinish(state) { - return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; -} -function callFinal(stream, state) { - stream._final(function (err) { - state.pendingcb--; - if (err) { - stream.emit('error', err); - } - state.prefinished = true; - stream.emit('prefinish'); - finishMaybe(stream, state); - }); -} -function prefinish(stream, state) { - if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function') { - state.pendingcb++; - state.finalCalled = true; - pna.nextTick(callFinal, stream, state); - } else { - state.prefinished = true; - stream.emit('prefinish'); - } - } -} +})(this); -function finishMaybe(stream, state) { - var need = needFinish(state); - if (need) { - prefinish(stream, state); - if (state.pendingcb === 0) { - state.finished = true; - stream.emit('finish'); - } - } - return need; -} +},{}],6:[function(require,module,exports){ +'use strict'; -function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - if (cb) { - if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); - } - state.ended = true; - stream.writable = false; -} +module.exports = require('./es6/crc1').default; -function onCorkedFinish(corkReq, state, err) { - var entry = corkReq.entry; - corkReq.entry = null; - while (entry) { - var cb = entry.callback; - state.pendingcb--; - cb(err); - entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = corkReq; - } else { - state.corkedRequestsFree = corkReq; - } -} +},{"./es6/crc1":17}],7:[function(require,module,exports){ +'use strict'; -Object.defineProperty(Writable.prototype, 'destroyed', { - get: function () { - if (this._writableState === undefined) { - return false; - } - return this._writableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (!this._writableState) { - return; - } +module.exports = require('./es6/crc16').default; + +},{"./es6/crc16":18}],8:[function(require,module,exports){ +'use strict'; - // backward compatibility, the user is explicitly - // managing destroyed - this._writableState.destroyed = value; - } -}); +module.exports = require('./es6/crc16ccitt').default; -Writable.prototype.destroy = destroyImpl.destroy; -Writable.prototype._undestroy = destroyImpl.undestroy; -Writable.prototype._destroy = function (err, cb) { - this.end(); - cb(err); -}; -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) -},{"./_stream_duplex":58,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":52,"core-util-is":18,"inherits":46,"process-nextick-args":51,"safe-buffer":71,"timers":73,"util-deprecate":76}],63:[function(require,module,exports){ +},{"./es6/crc16ccitt":19}],9:[function(require,module,exports){ 'use strict'; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +module.exports = require('./es6/crc16kermit').default; -var Buffer = require('safe-buffer').Buffer; -var util = require('util'); +},{"./es6/crc16kermit":20}],10:[function(require,module,exports){ +'use strict'; -function copyBuffer(src, target, offset) { - src.copy(target, offset); -} +module.exports = require('./es6/crc16modbus').default; -module.exports = function () { - function BufferList() { - _classCallCheck(this, BufferList); +},{"./es6/crc16modbus":21}],11:[function(require,module,exports){ +'use strict'; - this.head = null; - this.tail = null; - this.length = 0; - } +module.exports = require('./es6/crc16xmodem').default; - BufferList.prototype.push = function push(v) { - var entry = { data: v, next: null }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; - }; +},{"./es6/crc16xmodem":22}],12:[function(require,module,exports){ +'use strict'; - BufferList.prototype.unshift = function unshift(v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; - }; +module.exports = require('./es6/crc24').default; - BufferList.prototype.shift = function shift() { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; - }; +},{"./es6/crc24":23}],13:[function(require,module,exports){ +'use strict'; - BufferList.prototype.clear = function clear() { - this.head = this.tail = null; - this.length = 0; - }; +module.exports = require('./es6/crc32').default; - BufferList.prototype.join = function join(s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) { - ret += s + p.data; - }return ret; - }; +},{"./es6/crc32":24}],14:[function(require,module,exports){ +'use strict'; - BufferList.prototype.concat = function concat(n) { - if (this.length === 0) return Buffer.alloc(0); - if (this.length === 1) return this.head.data; - var ret = Buffer.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - copyBuffer(p.data, ret, i); - i += p.data.length; - p = p.next; - } - return ret; - }; +module.exports = require('./es6/crc8').default; - return BufferList; -}(); +},{"./es6/crc8":25}],15:[function(require,module,exports){ +'use strict'; -if (util && util.inspect && util.inspect.custom) { - module.exports.prototype[util.inspect.custom] = function () { - var obj = util.inspect({ length: this.length }); - return this.constructor.name + ' ' + obj; - }; -} -},{"safe-buffer":71,"util":4}],64:[function(require,module,exports){ +module.exports = require('./es6/crc81wire').default; + +},{"./es6/crc81wire":26}],16:[function(require,module,exports){ 'use strict'; -/**/ +module.exports = require('./es6/crcjam').default; -var pna = require('process-nextick-args'); -/**/ +},{"./es6/crcjam":27}],17:[function(require,module,exports){ +'use strict'; -// undocumented cb() API, needed for core, not for public API -function destroy(err, cb) { - var _this = this; +Object.defineProperty(exports, "__esModule", { + value: true +}); - var readableDestroyed = this._readableState && this._readableState.destroyed; - var writableDestroyed = this._writableState && this._writableState.destroyed; +var _buffer = require('buffer'); - if (readableDestroyed || writableDestroyed) { - if (cb) { - cb(err); - } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { - pna.nextTick(emitErrorNT, this, err); - } - return this; - } +var _create_buffer = require('./create_buffer'); - // we set destroyed to true before firing error callbacks in order - // to make it re-entrance safe in case destroy() is called within callbacks +var _create_buffer2 = _interopRequireDefault(_create_buffer); - if (this._readableState) { - this._readableState.destroyed = true; - } +var _define_crc = require('./define_crc'); - // if this is a duplex stream mark the writable part as destroyed as well - if (this._writableState) { - this._writableState.destroyed = true; - } +var _define_crc2 = _interopRequireDefault(_define_crc); - this._destroy(err || null, function (err) { - if (!cb && err) { - pna.nextTick(emitErrorNT, _this, err); - if (_this._writableState) { - _this._writableState.errorEmitted = true; - } - } else if (cb) { - cb(err); - } - }); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - return this; -} +var crc1 = (0, _define_crc2.default)('crc1', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); -function undestroy() { - if (this._readableState) { - this._readableState.destroyed = false; - this._readableState.reading = false; - this._readableState.ended = false; - this._readableState.endEmitted = false; - } + var crc = ~~previous; + var accum = 0; - if (this._writableState) { - this._writableState.destroyed = false; - this._writableState.ended = false; - this._writableState.ending = false; - this._writableState.finished = false; - this._writableState.errorEmitted = false; + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + accum += byte; } -} - -function emitErrorNT(self, err) { - self.emit('error', err); -} -module.exports = { - destroy: destroy, - undestroy: undestroy -}; -},{"process-nextick-args":51}],65:[function(require,module,exports){ -module.exports = require('events').EventEmitter; + crc += accum % 256; + return crc % 256; +}); -},{"events":44}],66:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. +exports.default = crc1; +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],18:[function(require,module,exports){ 'use strict'; -/**/ +Object.defineProperty(exports, "__esModule", { + value: true +}); -var Buffer = require('safe-buffer').Buffer; -/**/ +var _buffer = require('buffer'); -var isEncoding = Buffer.isEncoding || function (encoding) { - encoding = '' + encoding; - switch (encoding && encoding.toLowerCase()) { - case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': - return true; - default: - return false; - } -}; +var _create_buffer = require('./create_buffer'); -function _normalizeEncoding(enc) { - if (!enc) return 'utf8'; - var retried; - while (true) { - switch (enc) { - case 'utf8': - case 'utf-8': - return 'utf8'; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return 'utf16le'; - case 'latin1': - case 'binary': - return 'latin1'; - case 'base64': - case 'ascii': - case 'hex': - return enc; - default: - if (retried) return; // undefined - enc = ('' + enc).toLowerCase(); - retried = true; - } - } -}; +var _create_buffer2 = _interopRequireDefault(_create_buffer); -// Do not cache `Buffer.isEncoding` when checking encoding names as some -// modules monkey-patch it to support additional encodings -function normalizeEncoding(enc) { - var nenc = _normalizeEncoding(enc); - if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); - return nenc || enc; -} +var _define_crc = require('./define_crc'); -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. -exports.StringDecoder = StringDecoder; -function StringDecoder(encoding) { - this.encoding = normalizeEncoding(encoding); - var nb; - switch (this.encoding) { - case 'utf16le': - this.text = utf16Text; - this.end = utf16End; - nb = 4; - break; - case 'utf8': - this.fillLast = utf8FillLast; - nb = 4; - break; - case 'base64': - this.text = base64Text; - this.end = base64End; - nb = 3; - break; - default: - this.write = simpleWrite; - this.end = simpleEnd; - return; - } - this.lastNeed = 0; - this.lastTotal = 0; - this.lastChar = Buffer.allocUnsafe(nb); -} +var _define_crc2 = _interopRequireDefault(_define_crc); -StringDecoder.prototype.write = function (buf) { - if (buf.length === 0) return ''; - var r; - var i; - if (this.lastNeed) { - r = this.fillLast(buf); - if (r === undefined) return ''; - i = this.lastNeed; - this.lastNeed = 0; - } else { - i = 0; - } - if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); - return r || ''; -}; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -StringDecoder.prototype.end = utf8End; +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; -// Returns only complete characters in a Buffer -StringDecoder.prototype.text = utf8Text; +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); -// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer -StringDecoder.prototype.fillLast = function (buf) { - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); - this.lastNeed -= buf.length; -}; +var crc16 = (0, _define_crc2.default)('crc-16', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); -// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a -// continuation byte. If an invalid byte is detected, -2 is returned. -function utf8CheckByte(byte) { - if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; - return byte >> 6 === 0x02 ? -1 : -2; -} + var crc = ~~previous; -// Checks at most 3 bytes at the end of a Buffer in order to detect an -// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) -// needed to complete the UTF-8 character (if applicable) are returned. -function utf8CheckIncomplete(self, buf, i) { - var j = buf.length - 1; - if (j < i) return 0; - var nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 1; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 2; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) { - if (nb === 2) nb = 0;else self.lastNeed = nb - 3; - } - return nb; + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; } - return 0; -} -// Validates as many continuation bytes for a multi-byte UTF-8 character as -// needed or are available. If we see a non-continuation byte where we expect -// one, we "replace" the validated continuation bytes we've seen so far with -// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding -// behavior. The continuation byte check is included three times in the case -// where all of the continuation bytes for a character exist in the same buffer. -// It is also done this way as a slight performance increase instead of using a -// loop. -function utf8CheckExtraBytes(self, buf, p) { - if ((buf[0] & 0xC0) !== 0x80) { - self.lastNeed = 0; - return '\ufffd'; - } - if (self.lastNeed > 1 && buf.length > 1) { - if ((buf[1] & 0xC0) !== 0x80) { - self.lastNeed = 1; - return '\ufffd'; - } - if (self.lastNeed > 2 && buf.length > 2) { - if ((buf[2] & 0xC0) !== 0x80) { - self.lastNeed = 2; - return '\ufffd'; - } - } - } -} + return crc; +}); -// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. -function utf8FillLast(buf) { - var p = this.lastTotal - this.lastNeed; - var r = utf8CheckExtraBytes(this, buf, p); - if (r !== undefined) return r; - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, p, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, p, 0, buf.length); - this.lastNeed -= buf.length; -} +exports.default = crc16; -// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a -// partial character, the character's bytes are buffered until the required -// number of bytes are available. -function utf8Text(buf, i) { - var total = utf8CheckIncomplete(this, buf, i); - if (!this.lastNeed) return buf.toString('utf8', i); - this.lastTotal = total; - var end = buf.length - (total - this.lastNeed); - buf.copy(this.lastChar, 0, end); - return buf.toString('utf8', i, end); -} +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],19:[function(require,module,exports){ +'use strict'; -// For UTF-8, a replacement character is added when ending on a partial -// character. -function utf8End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + '\ufffd'; - return r; -} +Object.defineProperty(exports, "__esModule", { + value: true +}); -// UTF-16LE typically needs two bytes per character, but even if we have an even -// number of bytes available, we need to check if we end on a leading/high -// surrogate. In that case, we need to wait for the next two bytes in order to -// decode the last character properly. -function utf16Text(buf, i) { - if ((buf.length - i) % 2 === 0) { - var r = buf.toString('utf16le', i); - if (r) { - var c = r.charCodeAt(r.length - 1); - if (c >= 0xD800 && c <= 0xDBFF) { - this.lastNeed = 2; - this.lastTotal = 4; - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - return r.slice(0, -1); - } - } - return r; - } - this.lastNeed = 1; - this.lastTotal = 2; - this.lastChar[0] = buf[buf.length - 1]; - return buf.toString('utf16le', i, buf.length - 1); -} +var _buffer = require('buffer'); -// For UTF-16LE we do not explicitly append special replacement characters if we -// end on a partial character, we simply let v8 handle that. -function utf16End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) { - var end = this.lastTotal - this.lastNeed; - return r + this.lastChar.toString('utf16le', 0, end); - } - return r; -} +var _create_buffer = require('./create_buffer'); -function base64Text(buf, i) { - var n = (buf.length - i) % 3; - if (n === 0) return buf.toString('base64', i); - this.lastNeed = 3 - n; - this.lastTotal = 3; - if (n === 1) { - this.lastChar[0] = buf[buf.length - 1]; - } else { - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - } - return buf.toString('base64', i, buf.length - n); -} +var _create_buffer2 = _interopRequireDefault(_create_buffer); -function base64End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); - return r; -} +var _define_crc = require('./define_crc'); -// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) -function simpleWrite(buf) { - return buf.toString(this.encoding); -} +var _define_crc2 = _interopRequireDefault(_define_crc); -function simpleEnd(buf) { - return buf && buf.length ? this.write(buf) : ''; -} -},{"safe-buffer":71}],67:[function(require,module,exports){ -module.exports = require('./readable').PassThrough +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -},{"./readable":68}],68:[function(require,module,exports){ -exports = module.exports = require('./lib/_stream_readable.js'); -exports.Stream = exports; -exports.Readable = exports; -exports.Writable = require('./lib/_stream_writable.js'); -exports.Duplex = require('./lib/_stream_duplex.js'); -exports.Transform = require('./lib/_stream_transform.js'); -exports.PassThrough = require('./lib/_stream_passthrough.js'); +// Generated by `./pycrc.py --algorithm=table-driven --model=ccitt --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0]; -},{"./lib/_stream_duplex.js":58,"./lib/_stream_passthrough.js":59,"./lib/_stream_readable.js":60,"./lib/_stream_transform.js":61,"./lib/_stream_writable.js":62}],69:[function(require,module,exports){ -module.exports = require('./readable').Transform +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); -},{"./readable":68}],70:[function(require,module,exports){ -module.exports = require('./lib/_stream_writable.js'); +var crc16ccitt = (0, _define_crc2.default)('ccitt', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); -},{"./lib/_stream_writable.js":62}],71:[function(require,module,exports){ -/* eslint-disable node/no-deprecated-api */ -var buffer = require('buffer') -var Buffer = buffer.Buffer + var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; -// alternative to using Object.keys for old browsers -function copyProps (src, dst) { - for (var key in src) { - dst[key] = src[key] + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc >> 8 ^ byte) & 0xff] ^ crc << 8) & 0xffff; } -} -if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer -} else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer -} -function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) -} + return crc; +}); -// Copy static methods from Buffer -copyProps(Buffer, SafeBuffer) +exports.default = crc16ccitt; -SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) -} +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],20:[function(require,module,exports){ +'use strict'; -SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) - } - return buf -} +Object.defineProperty(exports, "__esModule", { + value: true +}); -SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) -} +var _buffer = require('buffer'); -SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return buffer.SlowBuffer(size) -} +var _create_buffer = require('./create_buffer'); -},{"buffer":6}],72:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. +var _create_buffer2 = _interopRequireDefault(_create_buffer); + +var _define_crc = require('./define_crc'); + +var _define_crc2 = _interopRequireDefault(_define_crc); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -module.exports = Stream; +// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78]; -var EE = require('events').EventEmitter; -var inherits = require('inherits'); +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); -inherits(Stream, EE); -Stream.Readable = require('readable-stream/readable.js'); -Stream.Writable = require('readable-stream/writable.js'); -Stream.Duplex = require('readable-stream/duplex.js'); -Stream.Transform = require('readable-stream/transform.js'); -Stream.PassThrough = require('readable-stream/passthrough.js'); +var crc16kermit = (0, _define_crc2.default)('kermit', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); -// Backwards-compat with node 0.4.x -Stream.Stream = Stream; + var crc = typeof previous !== 'undefined' ? ~~previous : 0x0000; + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; + } + return crc; +}); -// old-style streams. Note that the pipe method (the only relevant -// part of this class) is overridden in the Readable class. +exports.default = crc16kermit; -function Stream() { - EE.call(this); -} +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],21:[function(require,module,exports){ +'use strict'; -Stream.prototype.pipe = function(dest, options) { - var source = this; +Object.defineProperty(exports, "__esModule", { + value: true +}); - function ondata(chunk) { - if (dest.writable) { - if (false === dest.write(chunk) && source.pause) { - source.pause(); - } - } - } +var _buffer = require('buffer'); - source.on('data', ondata); +var _create_buffer = require('./create_buffer'); - function ondrain() { - if (source.readable && source.resume) { - source.resume(); - } - } +var _create_buffer2 = _interopRequireDefault(_create_buffer); - dest.on('drain', ondrain); +var _define_crc = require('./define_crc'); - // If the 'end' option is not supplied, dest.end() will be called when - // source gets the 'end' or 'close' events. Only dest.end() once. - if (!dest._isStdio && (!options || options.end !== false)) { - source.on('end', onend); - source.on('close', onclose); - } +var _define_crc2 = _interopRequireDefault(_define_crc); - var didOnEnd = false; - function onend() { - if (didOnEnd) return; - didOnEnd = true; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - dest.end(); - } +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16-modbus --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040]; +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - function onclose() { - if (didOnEnd) return; - didOnEnd = true; +var crc16modbus = (0, _define_crc2.default)('crc-16-modbus', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - if (typeof dest.destroy === 'function') dest.destroy(); - } + var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff; - // don't leave dangling pipes when there are errors. - function onerror(er) { - cleanup(); - if (EE.listenerCount(this, 'error') === 0) { - throw er; // Unhandled stream error in pipe. - } + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; } - source.on('error', onerror); - dest.on('error', onerror); - - // remove all the event listeners that were added. - function cleanup() { - source.removeListener('data', ondata); - dest.removeListener('drain', ondrain); - - source.removeListener('end', onend); - source.removeListener('close', onclose); + return crc; +}); - source.removeListener('error', onerror); - dest.removeListener('error', onerror); +exports.default = crc16modbus; - source.removeListener('end', cleanup); - source.removeListener('close', cleanup); +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],22:[function(require,module,exports){ +'use strict'; - dest.removeListener('close', cleanup); - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - source.on('end', cleanup); - source.on('close', cleanup); +var _buffer = require('buffer'); - dest.on('close', cleanup); +var _create_buffer = require('./create_buffer'); - dest.emit('pipe', source); +var _create_buffer2 = _interopRequireDefault(_create_buffer); - // Allow for unix-like usage: A.pipe(B).pipe(C) - return dest; -}; +var _define_crc = require('./define_crc'); -},{"events":44,"inherits":46,"readable-stream/duplex.js":57,"readable-stream/passthrough.js":67,"readable-stream/readable.js":68,"readable-stream/transform.js":69,"readable-stream/writable.js":70}],73:[function(require,module,exports){ -(function (setImmediate,clearImmediate){ -var nextTick = require('process/browser.js').nextTick; -var apply = Function.prototype.apply; -var slice = Array.prototype.slice; -var immediateIds = {}; -var nextImmediateId = 0; +var _define_crc2 = _interopRequireDefault(_define_crc); -// DOM APIs, for completeness +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -exports.setTimeout = function() { - return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); -}; -exports.setInterval = function() { - return new Timeout(apply.call(setInterval, window, arguments), clearInterval); -}; -exports.clearTimeout = -exports.clearInterval = function(timeout) { timeout.close(); }; +var crc16xmodem = (0, _define_crc2.default)('xmodem', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); -function Timeout(id, clearFn) { - this._id = id; - this._clearFn = clearFn; -} -Timeout.prototype.unref = Timeout.prototype.ref = function() {}; -Timeout.prototype.close = function() { - this._clearFn.call(window, this._id); -}; + var crc = typeof previous !== 'undefined' ? ~~previous : 0x0; -// Does not start the time, just sets up the members needed. -exports.enroll = function(item, msecs) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = msecs; -}; + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + var code = crc >>> 8 & 0xff; -exports.unenroll = function(item) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = -1; -}; + code ^= byte & 0xff; + code ^= code >>> 4; + crc = crc << 8 & 0xffff; + crc ^= code; + code = code << 5 & 0xffff; + crc ^= code; + code = code << 7 & 0xffff; + crc ^= code; + } -exports._unrefActive = exports.active = function(item) { - clearTimeout(item._idleTimeoutId); + return crc; +}); - var msecs = item._idleTimeout; - if (msecs >= 0) { - item._idleTimeoutId = setTimeout(function onTimeout() { - if (item._onTimeout) - item._onTimeout(); - }, msecs); - } -}; +exports.default = crc16xmodem; -// That's not how node.js implements it but the exposed api is the same. -exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { - var id = nextImmediateId++; - var args = arguments.length < 2 ? false : slice.call(arguments, 1); +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],23:[function(require,module,exports){ +'use strict'; - immediateIds[id] = true; +Object.defineProperty(exports, "__esModule", { + value: true +}); - nextTick(function onNextTick() { - if (immediateIds[id]) { - // fn.call() is faster so we optimize for the common use-case - // @see http://jsperf.com/call-apply-segu - if (args) { - fn.apply(null, args); - } else { - fn.call(null); - } - // Prevent ids from leaking - exports.clearImmediate(id); - } - }); +var _buffer = require('buffer'); - return id; -}; +var _create_buffer = require('./create_buffer'); -exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { - delete immediateIds[id]; -}; -}).call(this,require("timers").setImmediate,require("timers").clearImmediate) -},{"process/browser.js":52,"timers":73}],74:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. +var _create_buffer2 = _interopRequireDefault(_create_buffer); -'use strict'; +var _define_crc = require('./define_crc'); -var punycode = require('punycode'); -var util = require('./util'); - -exports.parse = urlParse; -exports.resolve = urlResolve; -exports.resolveObject = urlResolveObject; -exports.format = urlFormat; - -exports.Url = Url; - -function Url() { - this.protocol = null; - this.slashes = null; - this.auth = null; - this.host = null; - this.port = null; - this.hostname = null; - this.hash = null; - this.search = null; - this.query = null; - this.pathname = null; - this.path = null; - this.href = null; -} +var _define_crc2 = _interopRequireDefault(_define_crc); -// Reference: RFC 3986, RFC 1808, RFC 2396 - -// define these here so at least they only have to be -// compiled once on the first module load. -var protocolPattern = /^([a-z0-9.+-]+:)/i, - portPattern = /:[0-9]*$/, - - // Special case for a simple path URL - simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, - - // RFC 2396: characters reserved for delimiting URLs. - // We actually just auto-escape these. - delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], - - // RFC 2396: characters not allowed for various reasons. - unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), - - // Allowed by RFCs, but cause of XSS attacks. Always escape these. - autoEscape = ['\''].concat(unwise), - // Characters that are never ever allowed in a hostname. - // Note that any invalid chars are also handled, but these - // are the ones that are *expected* to be seen, so we fast-path - // them. - nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), - hostEndingChars = ['/', '?', '#'], - hostnameMaxLen = 255, - hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, - hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, - // protocols that can allow "unsafe" and "unwise" chars. - unsafeProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that never have a hostname. - hostlessProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that always contain a // bit. - slashedProtocol = { - 'http': true, - 'https': true, - 'ftp': true, - 'gopher': true, - 'file': true, - 'http:': true, - 'https:': true, - 'ftp:': true, - 'gopher:': true, - 'file:': true - }, - querystring = require('querystring'); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function urlParse(url, parseQueryString, slashesDenoteHost) { - if (url && util.isObject(url) && url instanceof Url) return url; +// Generated by `./pycrc.py --algorithm=table-drive --model=crc-24 --generate=c` +// prettier-ignore +var TABLE = [0x000000, 0x864cfb, 0x8ad50d, 0x0c99f6, 0x93e6e1, 0x15aa1a, 0x1933ec, 0x9f7f17, 0xa18139, 0x27cdc2, 0x2b5434, 0xad18cf, 0x3267d8, 0xb42b23, 0xb8b2d5, 0x3efe2e, 0xc54e89, 0x430272, 0x4f9b84, 0xc9d77f, 0x56a868, 0xd0e493, 0xdc7d65, 0x5a319e, 0x64cfb0, 0xe2834b, 0xee1abd, 0x685646, 0xf72951, 0x7165aa, 0x7dfc5c, 0xfbb0a7, 0x0cd1e9, 0x8a9d12, 0x8604e4, 0x00481f, 0x9f3708, 0x197bf3, 0x15e205, 0x93aefe, 0xad50d0, 0x2b1c2b, 0x2785dd, 0xa1c926, 0x3eb631, 0xb8faca, 0xb4633c, 0x322fc7, 0xc99f60, 0x4fd39b, 0x434a6d, 0xc50696, 0x5a7981, 0xdc357a, 0xd0ac8c, 0x56e077, 0x681e59, 0xee52a2, 0xe2cb54, 0x6487af, 0xfbf8b8, 0x7db443, 0x712db5, 0xf7614e, 0x19a3d2, 0x9fef29, 0x9376df, 0x153a24, 0x8a4533, 0x0c09c8, 0x00903e, 0x86dcc5, 0xb822eb, 0x3e6e10, 0x32f7e6, 0xb4bb1d, 0x2bc40a, 0xad88f1, 0xa11107, 0x275dfc, 0xdced5b, 0x5aa1a0, 0x563856, 0xd074ad, 0x4f0bba, 0xc94741, 0xc5deb7, 0x43924c, 0x7d6c62, 0xfb2099, 0xf7b96f, 0x71f594, 0xee8a83, 0x68c678, 0x645f8e, 0xe21375, 0x15723b, 0x933ec0, 0x9fa736, 0x19ebcd, 0x8694da, 0x00d821, 0x0c41d7, 0x8a0d2c, 0xb4f302, 0x32bff9, 0x3e260f, 0xb86af4, 0x2715e3, 0xa15918, 0xadc0ee, 0x2b8c15, 0xd03cb2, 0x567049, 0x5ae9bf, 0xdca544, 0x43da53, 0xc596a8, 0xc90f5e, 0x4f43a5, 0x71bd8b, 0xf7f170, 0xfb6886, 0x7d247d, 0xe25b6a, 0x641791, 0x688e67, 0xeec29c, 0x3347a4, 0xb50b5f, 0xb992a9, 0x3fde52, 0xa0a145, 0x26edbe, 0x2a7448, 0xac38b3, 0x92c69d, 0x148a66, 0x181390, 0x9e5f6b, 0x01207c, 0x876c87, 0x8bf571, 0x0db98a, 0xf6092d, 0x7045d6, 0x7cdc20, 0xfa90db, 0x65efcc, 0xe3a337, 0xef3ac1, 0x69763a, 0x578814, 0xd1c4ef, 0xdd5d19, 0x5b11e2, 0xc46ef5, 0x42220e, 0x4ebbf8, 0xc8f703, 0x3f964d, 0xb9dab6, 0xb54340, 0x330fbb, 0xac70ac, 0x2a3c57, 0x26a5a1, 0xa0e95a, 0x9e1774, 0x185b8f, 0x14c279, 0x928e82, 0x0df195, 0x8bbd6e, 0x872498, 0x016863, 0xfad8c4, 0x7c943f, 0x700dc9, 0xf64132, 0x693e25, 0xef72de, 0xe3eb28, 0x65a7d3, 0x5b59fd, 0xdd1506, 0xd18cf0, 0x57c00b, 0xc8bf1c, 0x4ef3e7, 0x426a11, 0xc426ea, 0x2ae476, 0xaca88d, 0xa0317b, 0x267d80, 0xb90297, 0x3f4e6c, 0x33d79a, 0xb59b61, 0x8b654f, 0x0d29b4, 0x01b042, 0x87fcb9, 0x1883ae, 0x9ecf55, 0x9256a3, 0x141a58, 0xefaaff, 0x69e604, 0x657ff2, 0xe33309, 0x7c4c1e, 0xfa00e5, 0xf69913, 0x70d5e8, 0x4e2bc6, 0xc8673d, 0xc4fecb, 0x42b230, 0xddcd27, 0x5b81dc, 0x57182a, 0xd154d1, 0x26359f, 0xa07964, 0xace092, 0x2aac69, 0xb5d37e, 0x339f85, 0x3f0673, 0xb94a88, 0x87b4a6, 0x01f85d, 0x0d61ab, 0x8b2d50, 0x145247, 0x921ebc, 0x9e874a, 0x18cbb1, 0xe37b16, 0x6537ed, 0x69ae1b, 0xefe2e0, 0x709df7, 0xf6d10c, 0xfa48fa, 0x7c0401, 0x42fa2f, 0xc4b6d4, 0xc82f22, 0x4e63d9, 0xd11cce, 0x575035, 0x5bc9c3, 0xdd8538]; - var u = new Url; - u.parse(url, parseQueryString, slashesDenoteHost); - return u; -} +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); -Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { - if (!util.isString(url)) { - throw new TypeError("Parameter 'url' must be a string, not " + typeof url); - } +var crc24 = (0, _define_crc2.default)('crc-24', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - // Copy chrome, IE, opera backslash-handling behavior. - // Back slashes before the query string get converted to forward slashes - // See: https://code.google.com/p/chromium/issues/detail?id=25916 - var queryIndex = url.indexOf('?'), - splitter = - (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', - uSplit = url.split(splitter), - slashRegex = /\\/g; - uSplit[0] = uSplit[0].replace(slashRegex, '/'); - url = uSplit.join(splitter); - - var rest = url; - - // trim before proceeding. - // This is to support parse stuff like " http://foo.com \n" - rest = rest.trim(); - - if (!slashesDenoteHost && url.split('#').length === 1) { - // Try fast path regexp - var simplePath = simplePathPattern.exec(rest); - if (simplePath) { - this.path = rest; - this.href = rest; - this.pathname = simplePath[1]; - if (simplePath[2]) { - this.search = simplePath[2]; - if (parseQueryString) { - this.query = querystring.parse(this.search.substr(1)); - } else { - this.query = this.search.substr(1); - } - } else if (parseQueryString) { - this.search = ''; - this.query = {}; - } - return this; - } - } + var crc = typeof previous !== 'undefined' ? ~~previous : 0xb704ce; - var proto = protocolPattern.exec(rest); - if (proto) { - proto = proto[0]; - var lowerProto = proto.toLowerCase(); - this.protocol = lowerProto; - rest = rest.substr(proto.length); + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc >> 16 ^ byte) & 0xff] ^ crc << 8) & 0xffffff; } - // figure out if it's got a host - // user@server is *always* interpreted as a hostname, and url - // resolution will treat //foo/bar as host=foo,path=bar because that's - // how the browser resolves relative URLs. - if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { - var slashes = rest.substr(0, 2) === '//'; - if (slashes && !(proto && hostlessProtocol[proto])) { - rest = rest.substr(2); - this.slashes = true; - } - } + return crc; +}); - if (!hostlessProtocol[proto] && - (slashes || (proto && !slashedProtocol[proto]))) { - - // there's a hostname. - // the first instance of /, ?, ;, or # ends the host. - // - // If there is an @ in the hostname, then non-host chars *are* allowed - // to the left of the last @ sign, unless some host-ending character - // comes *before* the @-sign. - // URLs are obnoxious. - // - // ex: - // http://a@b@c/ => user:a@b host:c - // http://a@b?@c => user:a host:c path:/?@c - - // v0.12 TODO(isaacs): This is not quite how Chrome does things. - // Review our test case against browsers more comprehensively. - - // find the first instance of any hostEndingChars - var hostEnd = -1; - for (var i = 0; i < hostEndingChars.length; i++) { - var hec = rest.indexOf(hostEndingChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } +exports.default = crc24; - // at this point, either we have an explicit point where the - // auth portion cannot go past, or the last @ char is the decider. - var auth, atSign; - if (hostEnd === -1) { - // atSign can be anywhere. - atSign = rest.lastIndexOf('@'); - } else { - // atSign must be in auth portion. - // http://a@b/c@d => host:b auth:a path:/c@d - atSign = rest.lastIndexOf('@', hostEnd); - } +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],24:[function(require,module,exports){ +'use strict'; - // Now we have a portion which is definitely the auth. - // Pull that off. - if (atSign !== -1) { - auth = rest.slice(0, atSign); - rest = rest.slice(atSign + 1); - this.auth = decodeURIComponent(auth); - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - // the host is the remaining to the left of the first non-host char - hostEnd = -1; - for (var i = 0; i < nonHostChars.length; i++) { - var hec = rest.indexOf(nonHostChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } - // if we still have not hit it, then the entire thing is a host. - if (hostEnd === -1) - hostEnd = rest.length; - - this.host = rest.slice(0, hostEnd); - rest = rest.slice(hostEnd); - - // pull out port. - this.parseHost(); - - // we've indicated that there is a hostname, - // so even if it's empty, it has to be present. - this.hostname = this.hostname || ''; - - // if hostname begins with [ and ends with ] - // assume that it's an IPv6 address. - var ipv6Hostname = this.hostname[0] === '[' && - this.hostname[this.hostname.length - 1] === ']'; - - // validate a little. - if (!ipv6Hostname) { - var hostparts = this.hostname.split(/\./); - for (var i = 0, l = hostparts.length; i < l; i++) { - var part = hostparts[i]; - if (!part) continue; - if (!part.match(hostnamePartPattern)) { - var newpart = ''; - for (var j = 0, k = part.length; j < k; j++) { - if (part.charCodeAt(j) > 127) { - // we replace non-ASCII char with a temporary placeholder - // we need this to make sure size of hostname is not - // broken by replacing non-ASCII by nothing - newpart += 'x'; - } else { - newpart += part[j]; - } - } - // we test again with ASCII char only - if (!newpart.match(hostnamePartPattern)) { - var validParts = hostparts.slice(0, i); - var notHost = hostparts.slice(i + 1); - var bit = part.match(hostnamePartStart); - if (bit) { - validParts.push(bit[1]); - notHost.unshift(bit[2]); - } - if (notHost.length) { - rest = '/' + notHost.join('.') + rest; - } - this.hostname = validParts.join('.'); - break; - } - } - } - } +var _buffer = require('buffer'); - if (this.hostname.length > hostnameMaxLen) { - this.hostname = ''; - } else { - // hostnames are always lower case. - this.hostname = this.hostname.toLowerCase(); - } +var _create_buffer = require('./create_buffer'); - if (!ipv6Hostname) { - // IDNA Support: Returns a punycoded representation of "domain". - // It only converts parts of the domain name that - // have non-ASCII characters, i.e. it doesn't matter if - // you call it with a domain that already is ASCII-only. - this.hostname = punycode.toASCII(this.hostname); - } +var _create_buffer2 = _interopRequireDefault(_create_buffer); - var p = this.port ? ':' + this.port : ''; - var h = this.hostname || ''; - this.host = h + p; - this.href += this.host; - - // strip [ and ] from the hostname - // the host field still retains them, though - if (ipv6Hostname) { - this.hostname = this.hostname.substr(1, this.hostname.length - 2); - if (rest[0] !== '/') { - rest = '/' + rest; - } - } - } +var _define_crc = require('./define_crc'); - // now rest is set to the post-host stuff. - // chop off any delim chars. - if (!unsafeProtocol[lowerProto]) { - - // First, make 100% sure that any "autoEscape" chars get - // escaped, even if encodeURIComponent doesn't think they - // need to be. - for (var i = 0, l = autoEscape.length; i < l; i++) { - var ae = autoEscape[i]; - if (rest.indexOf(ae) === -1) - continue; - var esc = encodeURIComponent(ae); - if (esc === ae) { - esc = escape(ae); - } - rest = rest.split(ae).join(esc); - } - } +var _define_crc2 = _interopRequireDefault(_define_crc); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - // chop off from the tail first. - var hash = rest.indexOf('#'); - if (hash !== -1) { - // got a fragment string. - this.hash = rest.substr(hash); - rest = rest.slice(0, hash); - } - var qm = rest.indexOf('?'); - if (qm !== -1) { - this.search = rest.substr(qm); - this.query = rest.substr(qm + 1); - if (parseQueryString) { - this.query = querystring.parse(this.query); - } - rest = rest.slice(0, qm); - } else if (parseQueryString) { - // no query string, but parseQueryString still requested - this.search = ''; - this.query = {}; - } - if (rest) this.pathname = rest; - if (slashedProtocol[lowerProto] && - this.hostname && !this.pathname) { - this.pathname = '/'; - } +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c` +// prettier-ignore +var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; - //to support http.request - if (this.pathname || this.search) { - var p = this.pathname || ''; - var s = this.search || ''; - this.path = p + s; - } +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - // finally, reconstruct the href based on what has been validated. - this.href = this.format(); - return this; -}; +var crc32 = (0, _define_crc2.default)('crc-32', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); -// format a parsed object into a url string -function urlFormat(obj) { - // ensure it's an object, and not a string url. - // If it's an obj, this is a no-op. - // this way, you can call url_format() on strings - // to clean up potentially wonky urls. - if (util.isString(obj)) obj = urlParse(obj); - if (!(obj instanceof Url)) return Url.prototype.format.call(obj); - return obj.format(); -} + var crc = previous === 0 ? 0 : ~~previous ^ -1; -Url.prototype.format = function() { - var auth = this.auth || ''; - if (auth) { - auth = encodeURIComponent(auth); - auth = auth.replace(/%3A/i, ':'); - auth += '@'; + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; } - var protocol = this.protocol || '', - pathname = this.pathname || '', - hash = this.hash || '', - host = false, - query = ''; - - if (this.host) { - host = auth + this.host; - } else if (this.hostname) { - host = auth + (this.hostname.indexOf(':') === -1 ? - this.hostname : - '[' + this.hostname + ']'); - if (this.port) { - host += ':' + this.port; - } - } + return crc ^ -1; +}); - if (this.query && - util.isObject(this.query) && - Object.keys(this.query).length) { - query = querystring.stringify(this.query); - } +exports.default = crc32; - var search = this.search || (query && ('?' + query)) || ''; +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],25:[function(require,module,exports){ +'use strict'; - if (protocol && protocol.substr(-1) !== ':') protocol += ':'; +Object.defineProperty(exports, "__esModule", { + value: true +}); - // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. - // unless they had them to begin with. - if (this.slashes || - (!protocol || slashedProtocol[protocol]) && host !== false) { - host = '//' + (host || ''); - if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; - } else if (!host) { - host = ''; - } +var _buffer = require('buffer'); - if (hash && hash.charAt(0) !== '#') hash = '#' + hash; - if (search && search.charAt(0) !== '?') search = '?' + search; +var _create_buffer = require('./create_buffer'); - pathname = pathname.replace(/[?#]/g, function(match) { - return encodeURIComponent(match); - }); - search = search.replace('#', '%23'); +var _create_buffer2 = _interopRequireDefault(_create_buffer); - return protocol + host + pathname + search + hash; -}; +var _define_crc = require('./define_crc'); -function urlResolve(source, relative) { - return urlParse(source, false, true).resolve(relative); -} +var _define_crc2 = _interopRequireDefault(_define_crc); -Url.prototype.resolve = function(relative) { - return this.resolveObject(urlParse(relative, false, true)).format(); -}; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function urlResolveObject(source, relative) { - if (!source) return relative; - return urlParse(source, false, true).resolveObject(relative); -} +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-8 --generate=c` +// prettier-ignore +var TABLE = [0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3]; -Url.prototype.resolveObject = function(relative) { - if (util.isString(relative)) { - var rel = new Url(); - rel.parse(relative, false, true); - relative = rel; - } +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - var result = new Url(); - var tkeys = Object.keys(this); - for (var tk = 0; tk < tkeys.length; tk++) { - var tkey = tkeys[tk]; - result[tkey] = this[tkey]; - } +var crc8 = (0, _define_crc2.default)('crc-8', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - // hash is always overridden, no matter what. - // even href="" will remove it. - result.hash = relative.hash; + var crc = ~~previous; - // if the relative url is empty, then there's nothing left to do here. - if (relative.href === '') { - result.href = result.format(); - return result; + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] & 0xff; } - // hrefs like //foo/bar always cut to the protocol. - if (relative.slashes && !relative.protocol) { - // take everything except the protocol from relative - var rkeys = Object.keys(relative); - for (var rk = 0; rk < rkeys.length; rk++) { - var rkey = rkeys[rk]; - if (rkey !== 'protocol') - result[rkey] = relative[rkey]; - } - - //urlParse appends trailing / to urls like http://www.example.com - if (slashedProtocol[result.protocol] && - result.hostname && !result.pathname) { - result.path = result.pathname = '/'; - } + return crc; +}); - result.href = result.format(); - return result; - } +exports.default = crc8; - if (relative.protocol && relative.protocol !== result.protocol) { - // if it's a known url protocol, then changing - // the protocol does weird things - // first, if it's not file:, then we MUST have a host, - // and if there was a path - // to begin with, then we MUST have a path. - // if it is file:, then the host is dropped, - // because that's known to be hostless. - // anything else is assumed to be absolute. - if (!slashedProtocol[relative.protocol]) { - var keys = Object.keys(relative); - for (var v = 0; v < keys.length; v++) { - var k = keys[v]; - result[k] = relative[k]; - } - result.href = result.format(); - return result; - } +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],26:[function(require,module,exports){ +'use strict'; - result.protocol = relative.protocol; - if (!relative.host && !hostlessProtocol[relative.protocol]) { - var relPath = (relative.pathname || '').split('/'); - while (relPath.length && !(relative.host = relPath.shift())); - if (!relative.host) relative.host = ''; - if (!relative.hostname) relative.hostname = ''; - if (relPath[0] !== '') relPath.unshift(''); - if (relPath.length < 2) relPath.unshift(''); - result.pathname = relPath.join('/'); - } else { - result.pathname = relative.pathname; - } - result.search = relative.search; - result.query = relative.query; - result.host = relative.host || ''; - result.auth = relative.auth; - result.hostname = relative.hostname || relative.host; - result.port = relative.port; - // to support http.request - if (result.pathname || result.search) { - var p = result.pathname || ''; - var s = result.search || ''; - result.path = p + s; - } - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), - isRelAbs = ( - relative.host || - relative.pathname && relative.pathname.charAt(0) === '/' - ), - mustEndAbs = (isRelAbs || isSourceAbs || - (result.host && relative.pathname)), - removeAllDots = mustEndAbs, - srcPath = result.pathname && result.pathname.split('/') || [], - relPath = relative.pathname && relative.pathname.split('/') || [], - psychotic = result.protocol && !slashedProtocol[result.protocol]; - - // if the url is a non-slashed url, then relative - // links like ../.. should be able - // to crawl up to the hostname, as well. This is strange. - // result.protocol has already been set by now. - // Later on, put the first path part into the host field. - if (psychotic) { - result.hostname = ''; - result.port = null; - if (result.host) { - if (srcPath[0] === '') srcPath[0] = result.host; - else srcPath.unshift(result.host); - } - result.host = ''; - if (relative.protocol) { - relative.hostname = null; - relative.port = null; - if (relative.host) { - if (relPath[0] === '') relPath[0] = relative.host; - else relPath.unshift(relative.host); - } - relative.host = null; - } - mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); - } +var _buffer = require('buffer'); - if (isRelAbs) { - // it's absolute. - result.host = (relative.host || relative.host === '') ? - relative.host : result.host; - result.hostname = (relative.hostname || relative.hostname === '') ? - relative.hostname : result.hostname; - result.search = relative.search; - result.query = relative.query; - srcPath = relPath; - // fall through to the dot-handling below. - } else if (relPath.length) { - // it's relative - // throw away the existing file, and take the new path instead. - if (!srcPath) srcPath = []; - srcPath.pop(); - srcPath = srcPath.concat(relPath); - result.search = relative.search; - result.query = relative.query; - } else if (!util.isNullOrUndefined(relative.search)) { - // just pull out the search. - // like href='?foo'. - // Put this after the other two cases because it simplifies the booleans - if (psychotic) { - result.hostname = result.host = srcPath.shift(); - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } - } - result.search = relative.search; - result.query = relative.query; - //to support http.request - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.href = result.format(); - return result; - } +var _create_buffer = require('./create_buffer'); - if (!srcPath.length) { - // no path at all. easy. - // we've already handled the other stuff above. - result.pathname = null; - //to support http.request - if (result.search) { - result.path = '/' + result.search; - } else { - result.path = null; - } - result.href = result.format(); - return result; - } +var _create_buffer2 = _interopRequireDefault(_create_buffer); - // if a url ENDs in . or .., then it must get a trailing slash. - // however, if it ends in anything else non-slashy, - // then it must NOT get a trailing slash. - var last = srcPath.slice(-1)[0]; - var hasTrailingSlash = ( - (result.host || relative.host || srcPath.length > 1) && - (last === '.' || last === '..') || last === ''); - - // strip single dots, resolve double dots to parent dir - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = srcPath.length; i >= 0; i--) { - last = srcPath[i]; - if (last === '.') { - srcPath.splice(i, 1); - } else if (last === '..') { - srcPath.splice(i, 1); - up++; - } else if (up) { - srcPath.splice(i, 1); - up--; - } - } +var _define_crc = require('./define_crc'); - // if the path is allowed to go above the root, restore leading ..s - if (!mustEndAbs && !removeAllDots) { - for (; up--; up) { - srcPath.unshift('..'); - } - } +var _define_crc2 = _interopRequireDefault(_define_crc); - if (mustEndAbs && srcPath[0] !== '' && - (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { - srcPath.unshift(''); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { - srcPath.push(''); - } +// Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c` +// prettier-ignore +var TABLE = [0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62, 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff, 0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07, 0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a, 0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24, 0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9, 0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd, 0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50, 0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee, 0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73, 0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5, 0x8b, 0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16, 0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8, 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35]; - var isAbsolute = srcPath[0] === '' || - (srcPath[0] && srcPath[0].charAt(0) === '/'); - - // put the host back - if (psychotic) { - result.hostname = result.host = isAbsolute ? '' : - srcPath.length ? srcPath.shift() : ''; - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } - } +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - mustEndAbs = mustEndAbs || (result.host && srcPath.length); +var crc81wire = (0, _define_crc2.default)('dallas-1-wire', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - if (mustEndAbs && !isAbsolute) { - srcPath.unshift(''); - } + var crc = ~~previous; - if (!srcPath.length) { - result.pathname = null; - result.path = null; - } else { - result.pathname = srcPath.join('/'); + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] & 0xff; } - //to support request.http - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.auth = relative.auth || result.auth; - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; -}; + return crc; +}); -Url.prototype.parseHost = function() { - var host = this.host; - var port = portPattern.exec(host); - if (port) { - port = port[0]; - if (port !== ':') { - this.port = port.substr(1); - } - host = host.substr(0, host.length - port.length); - } - if (host) this.hostname = host; -}; +exports.default = crc81wire; -},{"./util":75,"punycode":53,"querystring":56}],75:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],27:[function(require,module,exports){ 'use strict'; -module.exports = { - isString: function(arg) { - return typeof(arg) === 'string'; - }, - isObject: function(arg) { - return typeof(arg) === 'object' && arg !== null; - }, - isNull: function(arg) { - return arg === null; - }, - isNullOrUndefined: function(arg) { - return arg == null; - } -}; +Object.defineProperty(exports, "__esModule", { + value: true +}); -},{}],76:[function(require,module,exports){ -(function (global){ +var _buffer = require('buffer'); -/** - * Module exports. - */ +var _create_buffer = require('./create_buffer'); -module.exports = deprecate; +var _create_buffer2 = _interopRequireDefault(_create_buffer); -/** - * Mark that a method should not be used. - * Returns a modified function which warns once by default. - * - * If `localStorage.noDeprecation = true` is set, then it is a no-op. - * - * If `localStorage.throwDeprecation = true` is set, then deprecated functions - * will throw an Error when invoked. - * - * If `localStorage.traceDeprecation = true` is set, then deprecated functions - * will invoke `console.trace()` instead of `console.error()`. - * - * @param {Function} fn - the function to deprecate - * @param {String} msg - the string to print to the console when `fn` is invoked - * @returns {Function} a new "deprecated" version of `fn` - * @api public - */ +var _define_crc = require('./define_crc'); -function deprecate (fn, msg) { - if (config('noDeprecation')) { - return fn; - } +var _define_crc2 = _interopRequireDefault(_define_crc); - var warned = false; - function deprecated() { - if (!warned) { - if (config('throwDeprecation')) { - throw new Error(msg); - } else if (config('traceDeprecation')) { - console.trace(msg); - } else { - console.warn(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - return deprecated; -} +// Generated by `./pycrc.py --algorithm=table-driven --model=jam --generate=c` +// prettier-ignore +var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]; -/** - * Checks `localStorage` for boolean values for the given `name`. - * - * @param {String} name - * @returns {Boolean} - * @api private - */ +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); -function config (name) { - // accessing global.localStorage can trigger a DOMException in sandboxed iframes - try { - if (!global.localStorage) return false; - } catch (_) { - return false; - } - var val = global.localStorage[name]; - if (null == val) return false; - return String(val).toLowerCase() === 'true'; -} +var crcjam = (0, _define_crc2.default)('jam', function (buf) { + var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],77:[function(require,module,exports){ -module.exports = function isBuffer(arg) { - return arg && typeof arg === 'object' - && typeof arg.copy === 'function' - && typeof arg.fill === 'function' - && typeof arg.readUInt8 === 'function'; -} -},{}],78:[function(require,module,exports){ -(function (process,global){ -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -var formatRegExp = /%[sdj%]/g; -exports.format = function(f) { - if (!isString(f)) { - var objects = []; - for (var i = 0; i < arguments.length; i++) { - objects.push(inspect(arguments[i])); - } - return objects.join(' '); - } + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - var i = 1; - var args = arguments; - var len = args.length; - var str = String(f).replace(formatRegExp, function(x) { - if (x === '%%') return '%'; - if (i >= len) return x; - switch (x) { - case '%s': return String(args[i++]); - case '%d': return Number(args[i++]); - case '%j': - try { - return JSON.stringify(args[i++]); - } catch (_) { - return '[Circular]'; - } - default: - return x; - } - }); - for (var x = args[i]; i < len; x = args[++i]) { - if (isNull(x) || !isObject(x)) { - str += ' ' + x; - } else { - str += ' ' + inspect(x); - } + var crc = previous === 0 ? 0 : ~~previous; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8; } - return str; -}; + return crc; +}); -// Mark that a method should not be used. -// Returns a modified function which warns once by default. -// If --no-deprecation is set, then it is a no-op. -exports.deprecate = function(fn, msg) { - // Allow for deprecating things in the process of starting up. - if (isUndefined(global.process)) { - return function() { - return exports.deprecate(fn, msg).apply(this, arguments); - }; - } +exports.default = crcjam; - if (process.noDeprecation === true) { - return fn; - } +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],28:[function(require,module,exports){ +'use strict'; - var warned = false; - function deprecated() { - if (!warned) { - if (process.throwDeprecation) { - throw new Error(msg); - } else if (process.traceDeprecation) { - console.trace(msg); - } else { - console.error(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buffer = require('buffer'); - return deprecated; +var createBuffer = _buffer.Buffer.from && _buffer.Buffer.alloc && _buffer.Buffer.allocUnsafe && _buffer.Buffer.allocUnsafeSlow ? _buffer.Buffer.from : // support for Node < 5.10 +function (val) { + return new _buffer.Buffer(val); }; +exports.default = createBuffer; -var debugs = {}; -var debugEnviron; -exports.debuglog = function(set) { - if (isUndefined(debugEnviron)) - debugEnviron = process.env.NODE_DEBUG || ''; - set = set.toUpperCase(); - if (!debugs[set]) { - if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { - var pid = process.pid; - debugs[set] = function() { - var msg = exports.format.apply(exports, arguments); - console.error('%s %d: %s', set, pid, msg); - }; - } else { - debugs[set] = function() {}; - } - } - return debugs[set]; -}; +},{"buffer":4}],29:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); -/** - * Echos the value of a value. Trys to print the value out - * in the best way possible given the different types. - * - * @param {Object} obj The object to print out. - * @param {Object} opts Optional options object that alters the output. - */ -/* legacy: obj, showHidden, depth, colors*/ -function inspect(obj, opts) { - // default options - var ctx = { - seen: [], - stylize: stylizeNoColor +exports.default = function (model, calc) { + var fn = function fn(buf, previous) { + return calc(buf, previous) >>> 0; }; - // legacy... - if (arguments.length >= 3) ctx.depth = arguments[2]; - if (arguments.length >= 4) ctx.colors = arguments[3]; - if (isBoolean(opts)) { - // legacy... - ctx.showHidden = opts; - } else if (opts) { - // got an "options" object - exports._extend(ctx, opts); - } - // set default options - if (isUndefined(ctx.showHidden)) ctx.showHidden = false; - if (isUndefined(ctx.depth)) ctx.depth = 2; - if (isUndefined(ctx.colors)) ctx.colors = false; - if (isUndefined(ctx.customInspect)) ctx.customInspect = true; - if (ctx.colors) ctx.stylize = stylizeWithColor; - return formatValue(ctx, obj, ctx.depth); -} -exports.inspect = inspect; - - -// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics -inspect.colors = { - 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'inverse' : [7, 27], - 'white' : [37, 39], - 'grey' : [90, 39], - 'black' : [30, 39], - 'blue' : [34, 39], - 'cyan' : [36, 39], - 'green' : [32, 39], - 'magenta' : [35, 39], - 'red' : [31, 39], - 'yellow' : [33, 39] + fn.signed = calc; + fn.unsigned = fn; + fn.model = model; + + return fn; }; -// Don't use 'blue' not visible on cmd.exe -inspect.styles = { - 'special': 'cyan', - 'number': 'yellow', - 'boolean': 'yellow', - 'undefined': 'grey', - 'null': 'bold', - 'string': 'green', - 'date': 'magenta', - // "name": intentionally not styling - 'regexp': 'red' +},{}],30:[function(require,module,exports){ +'use strict'; + +module.exports = { + crc1: require('./crc1'), + crc8: require('./crc8'), + crc81wire: require('./crc8_1wire'), + crc16: require('./crc16'), + crc16ccitt: require('./crc16_ccitt'), + crc16modbus: require('./crc16_modbus'), + crc16xmodem: require('./crc16_xmodem'), + crc16kermit: require('./crc16_kermit'), + crc24: require('./crc24'), + crc32: require('./crc32'), + crcjam: require('./crcjam') }; +},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} -function stylizeWithColor(str, styleType) { - var style = inspect.styles[styleType]; + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} - if (style) { - return '\u001b[' + inspect.colors[style][0] + 'm' + str + - '\u001b[' + inspect.colors[style][1] + 'm'; + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) } else { - return str; + m = m + Math.pow(2, mLen) + e = e - eBias } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) } +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 -function stylizeNoColor(str, styleType) { - return str; -} + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } -function arrayToHash(array) { - var hash = {}; + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - array.forEach(function(val, idx) { - hash[val] = true; - }); + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - return hash; + buffer[offset + i - d] |= s * 128 } +},{}],32:[function(require,module,exports){ +/* + A JavaScript implementation of the SHA family of hashes, as + defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding + HMAC implementation as defined in FIPS PUB 198a -function formatValue(ctx, value, recurseTimes) { - // Provide a hook for user-specified inspect functions. - // Check that value is an object with an inspect function on it - if (ctx.customInspect && - value && - isFunction(value.inspect) && - // Filter out the util module, it's inspect function is special - value.inspect !== exports.inspect && - // Also filter out any prototype objects using the circular check. - !(value.constructor && value.constructor.prototype === value)) { - var ret = value.inspect(recurseTimes, ctx); - if (!isString(ret)) { - ret = formatValue(ctx, ret, recurseTimes); - } - return ret; - } + Copyright Brian Turek 2008-2017 + Distributed under the BSD License + See http://caligatio.github.com/jsSHA/ for more information - // Primitive types cannot have properties - var primitive = formatPrimitive(ctx, value); - if (primitive) { - return primitive; - } + Several functions taken from Paul Johnston +*/ +'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; +b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> +5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); +}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> +6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==k&&k= 0 || keys.indexOf('description') >= 0)) { - return formatError(value); - } +var cachedSetTimeout; +var cachedClearTimeout; - // Some type of object without properties can be shortcutted. - if (keys.length === 0) { - if (isFunction(value)) { - var name = value.name ? ': ' + value.name : ''; - return ctx.stylize('[Function' + name + ']', 'special'); +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; } - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; } - if (isDate(value)) { - return ctx.stylize(Date.prototype.toString.call(value), 'date'); +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); } - if (isError(value)) { - return formatError(value); + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); } - } - - var base = '', array = false, braces = ['{', '}']; - - // Make Array say that they are Array - if (isArray(value)) { - array = true; - braces = ['[', ']']; - } - - // Make functions say that they are functions - if (isFunction(value)) { - var n = value.name ? ': ' + value.name : ''; - base = ' [Function' + n + ']'; - } - - // Make RegExps say that they are RegExps - if (isRegExp(value)) { - base = ' ' + RegExp.prototype.toString.call(value); - } - - // Make dates with properties first say the date - if (isDate(value)) { - base = ' ' + Date.prototype.toUTCString.call(value); - } - - // Make error with message first say the error - if (isError(value)) { - base = ' ' + formatError(value); - } - - if (keys.length === 0 && (!array || value.length == 0)) { - return braces[0] + base + braces[1]; - } - - if (recurseTimes < 0) { - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } else { - return ctx.stylize('[Object]', 'special'); + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } } - } - ctx.seen.push(value); - var output; - if (array) { - output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); - } else { - output = keys.map(function(key) { - return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); - }); - } - - ctx.seen.pop(); - - return reduceToSingleString(output, base, braces); } +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } -function formatPrimitive(ctx, value) { - if (isUndefined(value)) - return ctx.stylize('undefined', 'undefined'); - if (isString(value)) { - var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; - return ctx.stylize(simple, 'string'); - } - if (isNumber(value)) - return ctx.stylize('' + value, 'number'); - if (isBoolean(value)) - return ctx.stylize('' + value, 'boolean'); - // For some reason typeof null is "object", so special case here. - if (isNull(value)) - return ctx.stylize('null', 'null'); -} - -function formatError(value) { - return '[' + Error.prototype.toString.call(value) + ']'; } +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; - -function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { - var output = []; - for (var i = 0, l = value.length; i < l; ++i) { - if (hasOwnProperty(value, String(i))) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - String(i), true)); +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); } else { - output.push(''); + queueIndex = -1; } - } - keys.forEach(function(key) { - if (!key.match(/^\d+$/)) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); + if (queue.length) { + drainQueue(); } - }); - return output; } - -function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { - var name, str, desc; - desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; - if (desc.get) { - if (desc.set) { - str = ctx.stylize('[Getter/Setter]', 'special'); - } else { - str = ctx.stylize('[Getter]', 'special'); - } - } else { - if (desc.set) { - str = ctx.stylize('[Setter]', 'special'); +function drainQueue() { + if (draining) { + return; } - } - if (!hasOwnProperty(visibleKeys, key)) { - name = '[' + key + ']'; - } - if (!str) { - if (ctx.seen.indexOf(desc.value) < 0) { - if (isNull(recurseTimes)) { - str = formatValue(ctx, desc.value, null); - } else { - str = formatValue(ctx, desc.value, recurseTimes - 1); - } - if (str.indexOf('\n') > -1) { - if (array) { - str = str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n').substr(2); - } else { - str = '\n' + str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n'); + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } } - } - } else { - str = ctx.stylize('[Circular]', 'special'); - } - } - if (isUndefined(name)) { - if (array && key.match(/^\d+$/)) { - return str; - } - name = JSON.stringify('' + key); - if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { - name = name.substr(1, name.length - 2); - name = ctx.stylize(name, 'name'); - } else { - name = name.replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'"); - name = ctx.stylize(name, 'string'); + queueIndex = -1; + len = queue.length; } - } - - return name + ': ' + str; -} - - -function reduceToSingleString(output, base, braces) { - var numLinesEst = 0; - var length = output.reduce(function(prev, cur) { - numLinesEst++; - if (cur.indexOf('\n') >= 0) numLinesEst++; - return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; - }, 0); - - if (length > 60) { - return braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; - } - - return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; -} - - -// NOTE: These type checking functions intentionally don't use `instanceof` -// because it is fragile and can be easily faked with `Object.create()`. -function isArray(ar) { - return Array.isArray(ar); -} -exports.isArray = isArray; - -function isBoolean(arg) { - return typeof arg === 'boolean'; + currentQueue = null; + draining = false; + runClearTimeout(timeout); } -exports.isBoolean = isBoolean; -function isNull(arg) { - return arg === null; -} -exports.isNull = isNull; +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; -function isNullOrUndefined(arg) { - return arg == null; +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; } -exports.isNullOrUndefined = isNullOrUndefined; +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; -function isNumber(arg) { - return typeof arg === 'number'; -} -exports.isNumber = isNumber; +function noop() {} -function isString(arg) { - return typeof arg === 'string'; -} -exports.isString = isString; +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; -function isSymbol(arg) { - return typeof arg === 'symbol'; -} -exports.isSymbol = isSymbol; +process.listeners = function (name) { return [] } -function isUndefined(arg) { - return arg === void 0; -} -exports.isUndefined = isUndefined; +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; -function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; -} -exports.isRegExp = isRegExp; +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} -exports.isObject = isObject; +},{}],34:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer -function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } } -exports.isDate = isDate; - -function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer } -exports.isError = isError; -function isFunction(arg) { - return typeof arg === 'function'; -} -exports.isFunction = isFunction; - -function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) } -exports.isPrimitive = isPrimitive; -exports.isBuffer = require('./support/isBuffer'); +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) -function objectToString(o) { - return Object.prototype.toString.call(o); +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) } - -function pad(n) { - return n < 10 ? '0' + n.toString(10) : n.toString(10); +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf } - -var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', - 'Oct', 'Nov', 'Dec']; - -// 26 Feb 16:19:34 -function timestamp() { - var d = new Date(); - var time = [pad(d.getHours()), - pad(d.getMinutes()), - pad(d.getSeconds())].join(':'); - return [d.getDate(), months[d.getMonth()], time].join(' '); +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) } - -// log is just a thin wrapper to console.log that prepends a timestamp -exports.log = function() { - console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); -}; - - -/** - * Inherit the prototype methods from one constructor into another. - * - * The Function.prototype.inherits from lang.js rewritten as a standalone - * function (not on Function.prototype). NOTE: If this file is to be loaded - * during bootstrapping this function needs to be rewritten using some native - * functions as prototype setup using normal JavaScript does not work as - * expected during bootstrapping (see mirror.js in r114903). - * - * @param {function} ctor Constructor function which needs to inherit the - * prototype. - * @param {function} superCtor Constructor function to inherit prototype from. - */ -exports.inherits = require('inherits'); - -exports._extend = function(origin, add) { - // Don't do anything if add isn't an object - if (!add || !isObject(add)) return origin; - - var keys = Object.keys(add); - var i = keys.length; - while (i--) { - origin[keys[i]] = add[keys[i]]; +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') } - return origin; -}; - -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); + return buffer.SlowBuffer(size) } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":77,"_process":52,"inherits":46}],79:[function(require,module,exports){ -var cbor = require('cbor'); +},{"buffer":4}],35:[function(require,module,exports){ +var cbor = require('cbor-js'); var bs58 = require('bs58'); var CRC = require('crc'); +function toArrayBuffer(buf) { + var ab = new ArrayBuffer(buf.length); + var view = new Uint8Array(ab); + for (var i = 0; i < buf.length; ++i) { + view[i] = buf[i]; + } + return ab; +} + function getDecoded(address) { try { var decoded = bs58.decode(address); - return decoded = cbor.decode(decoded); + return decoded = cbor.decode(toArrayBuffer(decoded)); } catch (e) { // if decoding fails, assume invalid address return null; @@ -14102,26 +3386,18 @@ module.exports = { var tagged = decoded[0]; var validCrc = decoded[1]; - if (!tagged instanceof cbor.Tagged) { - return false; - } if (typeof (validCrc) != 'number') { return false; } - // not sure what this is - if (tagged.tag != 24) { - return false; - } - // get crc of the payload - var crc = CRC.crc32(tagged.value); + var crc = CRC.crc32(tagged); return crc == validCrc; } }; -},{"bs58":5,"cbor":7,"crc":43}],80:[function(require,module,exports){ +},{"bs58":3,"cbor-js":5,"crc":30}],36:[function(require,module,exports){ var base58 = require('./crypto/base58'); var segwit = require('./crypto/segwit_addr'); var cryptoUtils = require('./crypto/utils'); @@ -14198,7 +3474,7 @@ module.exports = { } }; -},{"./crypto/base58":81,"./crypto/segwit_addr":86,"./crypto/utils":88}],81:[function(require,module,exports){ +},{"./crypto/base58":37,"./crypto/segwit_addr":42,"./crypto/utils":44}],37:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -14246,7 +3522,7 @@ module.exports = { } }; -},{}],82:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -14364,7 +3640,7 @@ function decode (bechString) { return {hrp: hrp, data: data.slice(0, data.length - 6)}; } -},{}],83:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ /* JavaScript BigInteger library version 0.9.1 http://silentmatt.com/biginteger/ @@ -15815,7 +5091,7 @@ function decode (bechString) { exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt })(typeof exports !== 'undefined' ? exports : this); -},{}],84:[function(require,module,exports){ +},{}],40:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -16006,7 +5282,7 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":6}],85:[function(require,module,exports){ +},{"buffer":4}],41:[function(require,module,exports){ var JSBigInt = require('./biginteger')['JSBigInt']; /** @@ -16233,7 +5509,7 @@ var cnBase58 = (function () { return b58; })(); module.exports = cnBase58; -},{"./biginteger":83}],86:[function(require,module,exports){ +},{"./biginteger":39}],42:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -16329,7 +5605,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":82}],87:[function(require,module,exports){ +},{"./bech32":38}],43:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -16973,7 +6249,7 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":52}],88:[function(require,module,exports){ +},{"_process":33}],44:[function(require,module,exports){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; @@ -17016,7 +6292,7 @@ module.exports = { } }; -},{"./blake256":84,"./sha3":87,"jssha/src/sha256":49}],89:[function(require,module,exports){ +},{"./blake256":40,"./sha3":43,"jssha/src/sha256":32}],45:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); @@ -17346,7 +6622,7 @@ module.exports = { -},{"./ada_validator":79,"./bitcoin_validator":80,"./ethereum_validator":90,"./monero_validator":91,"./ripple_validator":92}],90:[function(require,module,exports){ +},{"./ada_validator":35,"./bitcoin_validator":36,"./ethereum_validator":46,"./monero_validator":47,"./ripple_validator":48}],46:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -17382,7 +6658,7 @@ module.exports = { } }; -},{"./crypto/utils":88}],91:[function(require,module,exports){ +},{"./crypto/utils":44}],47:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var cnBase58 = require('./crypto/cnBase58'); @@ -17444,7 +6720,7 @@ module.exports = { } }; -},{"./crypto/cnBase58":85,"./crypto/utils":88}],92:[function(require,module,exports){ +},{"./crypto/cnBase58":41,"./crypto/utils":44}],48:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -17474,7 +6750,7 @@ module.exports = { } }; -},{"./crypto/utils":88,"base-x":1}],93:[function(require,module,exports){ +},{"./crypto/utils":44,"base-x":1}],49:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -17491,5 +6767,5 @@ module.exports = { }, }; -},{"./currencies":89}]},{},[93])(93) +},{"./currencies":45}]},{},[49])(49) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 6e90c7db..00dc6e99 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function o(s,a,u){function f(e,t){if(!a[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[e]={exports:{}};s[e][0].call(i.exports,function(t){return f(s[e][1][t]||t)},i,i.exports,o,s,a,u)}return a[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===c&&s>16&255,o[s++]=e>>8&255,o[s++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[s++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[s++]=e>>8&255,o[s++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,s=r-n;o>2]+a[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(a[e>>10]+a[e>>4&63]+a[e<<2&63]+"="));return i.join("")};for(var a=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+a[i>>12&63]+a[i>>6&63]+a[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function s(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=s=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,s,a,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,a=r,L(function(t,e){for(var r,n,i,o=[],s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-s),o,s,a);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function S(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(t,e,r,n,i){return e=+e,r>>>=0,i||S(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,i){return e=+e,r>>>=0,i||S(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||T(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||T(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);T(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);T(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;0<=--o&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return U(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return U(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:30}],5:[function(t,e,r){"use strict";e.exports=t("./es6/crc1").default},{"./es6/crc1":16}],6:[function(t,e,r){"use strict";e.exports=t("./es6/crc16").default},{"./es6/crc16":17}],7:[function(t,e,r){"use strict";e.exports=t("./es6/crc16ccitt").default},{"./es6/crc16ccitt":18}],8:[function(t,e,r){"use strict";e.exports=t("./es6/crc16kermit").default},{"./es6/crc16kermit":19}],9:[function(t,e,r){"use strict";e.exports=t("./es6/crc16modbus").default},{"./es6/crc16modbus":20}],10:[function(t,e,r){"use strict";e.exports=t("./es6/crc16xmodem").default},{"./es6/crc16xmodem":21}],11:[function(t,e,r){"use strict";e.exports=t("./es6/crc24").default},{"./es6/crc24":22}],12:[function(t,e,r){"use strict";e.exports=t("./es6/crc32").default},{"./es6/crc32":23}],13:[function(t,e,r){"use strict";e.exports=t("./es6/crc8").default},{"./es6/crc8":24}],14:[function(t,e,r){"use strict";e.exports=t("./es6/crc81wire").default},{"./es6/crc81wire":25}],15:[function(t,e,r){"use strict";e.exports=t("./es6/crcjam").default},{"./es6/crcjam":26}],16:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("crc1",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=~~e,n=0,i=0;i>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],18:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":27,"./define_crc":28,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),s=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var a=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(a=new Int32Array(a));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,s.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:4}],27:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],29:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":5,"./crc16":6,"./crc16_ccitt":7,"./crc16_kermit":8,"./crc16_modbus":9,"./crc16_xmodem":10,"./crc24":11,"./crc32":12,"./crc8":13,"./crc8_1wire":14,"./crcjam":15}],30:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=a;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(e+=1<=s+h?l/u:l*Math.pow(2,1-h))*u&&(s++,u/=2),c<=s+h?(a=0,s=c):1<=s+h?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));8<=i;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,s)},l=function(t,e,r,n){var i,o;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,v)).binLen,r=e.value,e=t>>>5,n=0;n>>5),v=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(g.slice(),v,y,d(a)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,s="",a=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)s+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return s}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],a=(r=r||0)>>>3,n=0;n>>1)+a)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+s%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,s,a,u,f,c,h=0;if(e=e||[0],a=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;e.length<=u;)e.push(0);e[u]|=i[s]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+a)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,s,a,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function T(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,i){return e=+e,r>>>=0,i||T(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,i){return e=+e,r>>>=0,i||T(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,r,e){!function(t,x){"use strict";var k=Math.pow(2,-24),U=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,o=0;o>6):(o<55296?i.push(224|o>>12):(o=(1023&o)<<10,o|=1023&e.charCodeAt(++r),o+=65536,i.push(240|o>>18),i.push(128|o>>12&63)),i.push(128|o>>6&63)),i.push(128|63&o))}return p(3,i.length),d(i);default:var a;if(Array.isArray(e))for(p(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function B(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof d&&(d=function(t){return t}),"function"!=typeof p&&(p=function(){return x});var t=function t(){var e,r,n=w(),i=n>>5,o=31&n;if(7===i)switch(o){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,i=31744&r,o=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==o)return o*k;return e.setUint32(0,n<<16|i<<13|o<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(o))<0&&(i<2||6>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var i,o;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(v.slice(),g,y,d(s)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=i[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i=1.1.9" - safe-buffer "^5.0.1" - ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -82,10 +53,6 @@ ansi-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -152,20 +119,6 @@ asn1.js@^4.0.0: inherits "^2.0.1" minimalistic-assert "^1.0.0" -asn1@~0.2.3: - version "0.2.4" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - -assert-plus@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" - assert@^1.4.0: version "1.4.1" resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91" @@ -180,10 +133,6 @@ assign-symbols@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" -ast-types@0.x.x: - version "0.11.6" - resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.11.6.tgz#4e2266c2658829aef3b40cc33ad599c4e9eb89ef" - async-each@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" @@ -192,38 +141,10 @@ async-limiter@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" -async@~2.6.0: - version "2.6.1" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610" - dependencies: - lodash "^4.17.10" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - atob@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" -aws-sign2@~0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" - -aws-sign2@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" - -aws4@^1.2.1, aws4@^1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" - -axios@^0.15.3: - version "0.15.3" - resolved "http://registry.npmjs.org/axios/-/axios-0.15.3.tgz#2c9d638b2e191a08ea1d6cc988eadd6ba5bdc053" - dependencies: - follow-redirects "1.0.0" - backo2@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" @@ -262,43 +183,21 @@ base@^0.11.1: mixin-deep "^1.2.0" pascalcase "^0.1.1" -bcrypt-pbkdf@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" - dependencies: - tweetnacl "^0.14.3" - better-assert@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" dependencies: callsite "1.0.0" -bignumber.js@^7.2.1: - version "7.2.1" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f" - binary-extensions@^1.0.0: version "1.12.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.12.0.tgz#c2d780f53d45bba8317a8902d4ceeaf3a6385b14" -bitsyntax@~0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/bitsyntax/-/bitsyntax-0.0.4.tgz#eb10cc6f82b8c490e3e85698f07e83d46e0cba82" - dependencies: - buffer-more-ints "0.0.2" - -bl@~1.1.2: - version "1.1.2" - resolved "http://registry.npmjs.org/bl/-/bl-1.1.2.tgz#fdca871a99713aa00d19e3bbba41c44787a65398" - dependencies: - readable-stream "~2.0.5" - blob@0.0.4: version "0.0.4" resolved "http://registry.npmjs.org/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" -bluebird@^3.3.0, bluebird@^3.4.6: +bluebird@^3.3.0: version "3.5.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.2.tgz#1be0908e054a751754549c270489c1505d4ab15a" @@ -321,12 +220,6 @@ body-parser@^1.16.1: raw-body "2.3.3" type-is "~1.6.16" -boom@2.x.x: - version "2.10.1" - resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" - dependencies: - hoek "2.x.x" - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -433,9 +326,9 @@ browserify-zlib@~0.2.0: dependencies: pako "~1.0.5" -browserify@^15.1.0: - version "15.2.0" - resolved "https://registry.yarnpkg.com/browserify/-/browserify-15.2.0.tgz#1e121ba1fa72cf9fd2d8df002f8674b68b45df89" +browserify@^16.2.3: + version "16.2.3" + resolved "https://registry.yarnpkg.com/browserify/-/browserify-16.2.3.tgz#7ee6e654ba4f92bce6ab3599c3485b1cc7a0ad0b" dependencies: JSONStream "^1.0.3" assert "^1.4.0" @@ -444,15 +337,15 @@ browserify@^15.1.0: browserify-zlib "~0.2.0" buffer "^5.0.2" cached-path-relative "^1.0.0" - concat-stream "~1.5.1" + concat-stream "^1.6.0" console-browserify "^1.1.0" constants-browserify "~1.0.0" crypto-browserify "^3.0.0" defined "^1.0.0" deps-sort "^2.0.0" - domain-browser "~1.1.0" + domain-browser "^1.2.0" duplexer2 "~0.1.2" - events "~1.1.0" + events "^2.0.0" glob "^7.1.0" has "^1.0.0" htmlescape "^1.1.0" @@ -461,7 +354,7 @@ browserify@^15.1.0: insert-module-globals "^7.0.0" labeled-stream-splicer "^2.0.0" mkdirp "^0.5.0" - module-deps "^5.0.1" + module-deps "^6.0.0" os-browserify "~0.3.0" parents "^1.0.1" path-browserify "~0.0.0" @@ -475,15 +368,15 @@ browserify@^15.1.0: shell-quote "^1.6.1" stream-browserify "^2.0.0" stream-http "^2.0.0" - string_decoder "~1.0.0" + string_decoder "^1.1.1" subarg "^1.0.0" syntax-error "^1.1.1" through2 "^2.0.0" timers-browserify "^1.0.1" - tty-browserify "~0.0.0" + tty-browserify "0.0.1" url "~0.11.0" util "~0.10.1" - vm-browserify "~0.0.1" + vm-browserify "^1.0.0" xtend "^4.0.0" bs58@^4.0.1: @@ -511,10 +404,6 @@ buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" -buffer-more-ints@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/buffer-more-ints/-/buffer-more-ints-0.0.2.tgz#26b3885d10fa13db7fc01aae3aab870199e0124c" - buffer-xor@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" @@ -526,18 +415,6 @@ buffer@^5.0.2, buffer@^5.1.0: base64-js "^1.0.2" ieee754 "^1.1.4" -buildmail@4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/buildmail/-/buildmail-4.0.1.tgz#877f7738b78729871c9a105e3b837d2be11a7a72" - dependencies: - addressparser "1.0.1" - libbase64 "0.1.0" - libmime "3.0.0" - libqp "1.1.0" - nodemailer-fetch "1.6.0" - nodemailer-shared "1.1.0" - punycode "1.4.1" - builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" @@ -568,24 +445,11 @@ callsite@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" -caseless@~0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" - -caseless@~0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" - -cbor@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/cbor/-/cbor-4.1.1.tgz#a6bc17020b45685d315c6bbc971f3bb3c973fde9" - dependencies: - bignumber.js "^7.2.1" - commander "^2.16.0" - json-text-sequence "^0.1" - nofilter "^0.0.3" +cbor-js@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/cbor-js/-/cbor-js-0.1.0.tgz#c80ce6120f387e8faa74370dfda21d965b8fc7f9" -chai@^4.1.2: +chai@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5" dependencies: @@ -596,16 +460,6 @@ chai@^4.1.2: pathval "^1.1.0" type-detect "^4.0.5" -chalk@^1.1.1: - version "1.1.3" - resolved "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" @@ -640,7 +494,7 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: inherits "^2.0.1" safe-buffer "^5.0.1" -circular-json@^0.5.4: +circular-json@^0.5.5: version "0.5.9" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.5.9.tgz#932763ae88f4f7dead7a0d09c8a51a4743a53b1d" @@ -653,10 +507,6 @@ class-utils@^0.3.5: isobject "^3.0.0" static-extend "^0.1.1" -co@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" - code-point-at@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" @@ -687,20 +537,10 @@ combine-source-map@^0.8.0, combine-source-map@~0.8.0: lodash.memoize "~3.0.3" source-map "~0.5.3" -combined-stream@^1.0.5, combined-stream@^1.0.6, combined-stream@~1.0.5, combined-stream@~1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828" - dependencies: - delayed-stream "~1.0.0" - commander@2.15.1: version "2.15.1" resolved "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" -commander@^2.16.0, commander@^2.9.0: - version "2.19.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" - commander@~2.17.1: version "2.17.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" @@ -721,7 +561,7 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.6.1, concat-stream@~1.6.0: +concat-stream@^1.6.0, concat-stream@^1.6.1, concat-stream@~1.6.0: version "1.6.2" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" dependencies: @@ -730,14 +570,6 @@ concat-stream@^1.6.1, concat-stream@~1.6.0: readable-stream "^2.2.2" typedarray "^0.0.6" -concat-stream@~1.5.1: - version "1.5.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.2.tgz#708978624d856af41a5a741defdd261da752c266" - dependencies: - inherits "~2.0.1" - readable-stream "~2.0.0" - typedarray "~0.0.5" - connect@^3.6.0: version "3.6.6" resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.6.tgz#09eff6c55af7236e137135a72574858b6786f524" @@ -781,7 +613,7 @@ core-js@^2.2.0: version "2.5.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" -core-util-is@1.0.2, core-util-is@~1.0.0: +core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -819,12 +651,6 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" -cryptiles@2.x.x: - version "2.0.5" - resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" - dependencies: - boom "2.x.x" - crypto-browserify@^3.0.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -845,16 +671,6 @@ custom-event@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - dependencies: - assert-plus "^1.0.0" - -data-uri-to-buffer@1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz#77163ea9c20d8641b4707e8f18abdf9a78f34835" - date-format@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/date-format/-/date-format-1.2.0.tgz#615e828e233dd1ab9bb9ae0950e0ceccfa6ecad8" @@ -863,7 +679,7 @@ date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" -debug@2, debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@~2.6.4, debug@~2.6.6: +debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: @@ -895,10 +711,6 @@ deep-extend@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" -deep-is@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" - define-property@^0.2.5: version "0.2.5" resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" @@ -922,26 +734,10 @@ defined@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" -degenerator@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-1.0.4.tgz#fcf490a37ece266464d9cc431ab98c5819ced095" - dependencies: - ast-types "0.x.x" - escodegen "1.x.x" - esprima "3.x.x" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" -delimit-stream@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/delimit-stream/-/delimit-stream-0.1.0.tgz#9b8319477c0e5f8aeb3ce357ae305fc25ea1cd2b" - depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -999,13 +795,9 @@ dom-serialize@^2.2.0: extend "^3.0.0" void-elements "^2.0.0" -domain-browser@~1.1.0: - version "1.1.7" - resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" - -double-ended-queue@^2.1.0-0: - version "2.1.0-0" - resolved "https://registry.yarnpkg.com/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz#103d3527fd31528f40188130c841efdd78264e5c" +domain-browser@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda" duplexer2@^0.1.2, duplexer2@~0.1.0, duplexer2@~0.1.2: version "0.1.4" @@ -1013,13 +805,6 @@ duplexer2@^0.1.2, duplexer2@~0.1.0, duplexer2@~0.1.2: dependencies: readable-stream "^2.0.2" -ecc-jsbn@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -1040,9 +825,9 @@ encodeurl@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" -engine.io-client@~3.1.0: - version "3.1.6" - resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.1.6.tgz#5bdeb130f8b94a50ac5cbeb72583e7a4a063ddfd" +engine.io-client@~3.2.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.2.1.tgz#6f54c0475de487158a1a7c77d10178708b6add36" dependencies: component-emitter "1.2.1" component-inherit "0.0.3" @@ -1066,9 +851,9 @@ engine.io-parser@~2.1.0, engine.io-parser@~2.1.1: blob "0.0.4" has-binary2 "~1.0.2" -engine.io@~3.1.0: - version "3.1.5" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.1.5.tgz#0e7ef9d690eb0b35597f1d4ad02a26ca2dba3845" +engine.io@~3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.2.0.tgz#54332506f42f2edc71690d2f2a42349359f3bf7d" dependencies: accepts "~1.3.4" base64id "1.0.0" @@ -1076,61 +861,26 @@ engine.io@~3.1.0: debug "~3.1.0" engine.io-parser "~2.1.0" ws "~3.3.1" - optionalDependencies: - uws "~9.14.0" ent@~2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" -es6-promise@^4.0.3: - version "4.2.5" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.5.tgz#da6d0d5692efb461e082c14817fe2427d8f5d054" - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "http://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - dependencies: - es6-promise "^4.0.3" - escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2: +escape-string-regexp@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -escodegen@1.x.x: - version "1.11.0" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.11.0.tgz#b27a9389481d5bfd5bec76f7bb1eb3f8f4556589" - dependencies: - esprima "^3.1.3" - estraverse "^4.2.0" - esutils "^2.0.2" - optionator "^0.8.1" - optionalDependencies: - source-map "~0.6.1" - -esprima@3.x.x, esprima@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" - -estraverse@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" - -esutils@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" - eventemitter3@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.0.tgz#090b4d6cdbd645ed10bf750d4b5407942d7ba163" -events@~1.1.0: - version "1.1.1" - resolved "http://registry.npmjs.org/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" +events@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/events/-/events-2.1.0.tgz#2a9a1e18e6106e0e812aa9ebd4a819b3c29c0ba5" evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: version "1.0.3" @@ -1179,7 +929,7 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" -extend@3, extend@^3.0.0, extend@~3.0.0, extend@~3.0.2: +extend@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" @@ -1196,30 +946,6 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -extsprintf@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" - -extsprintf@^1.2.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" - -fast-deep-equal@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614" - -fast-json-stable-stringify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" - -fast-levenshtein@~2.0.4: - version "2.0.6" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - -file-uri-to-path@1: - version "1.0.0" - resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" - fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -1241,12 +967,6 @@ finalhandler@1.1.0: statuses "~1.3.1" unpipe "~1.0.0" -follow-redirects@1.0.0: - version "1.0.0" - resolved "http://registry.npmjs.org/follow-redirects/-/follow-redirects-1.0.0.tgz#8e34298cbd2e176f254effec75a1c78cc849fd37" - dependencies: - debug "^2.2.0" - follow-redirects@^1.0.0: version "1.5.9" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.9.tgz#c9ed9d748b814a39535716e531b9196a845d89c6" @@ -1257,26 +977,6 @@ for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" - -form-data@~2.0.0: - version "2.0.0" - resolved "http://registry.npmjs.org/form-data/-/form-data-2.0.0.tgz#6f0aebadcc5da16c13e1ecc11137d85f9b883b25" - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.5" - mime-types "^2.1.11" - -form-data@~2.3.0, form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - fragment-cache@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" @@ -1306,13 +1006,6 @@ fsevents@^1.2.2: nan "^2.9.2" node-pre-gyp "^0.10.0" -ftp@~0.3.10: - version "0.3.10" - resolved "https://registry.yarnpkg.com/ftp/-/ftp-0.3.10.tgz#9197d861ad8142f3e63d5a83bfe4c59f7330885d" - dependencies: - readable-stream "1.1.x" - xregexp "2.0.0" - function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" @@ -1330,18 +1023,6 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" -generate-function@^2.0.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.3.1.tgz#f069617690c10c868e73b8465746764f97c3479f" - dependencies: - is-property "^1.0.2" - -generate-object-property@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" - dependencies: - is-property "^1.0.0" - get-assigned-identifiers@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz#6dbf411de648cbaf8d9169ebb0d2d576191e2ff1" @@ -1350,27 +1031,10 @@ get-func-name@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" -get-uri@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-2.0.2.tgz#5c795e71326f6ca1286f2fc82575cd2bab2af578" - dependencies: - data-uri-to-buffer "1" - debug "2" - extend "3" - file-uri-to-path "1" - ftp "~0.3.10" - readable-stream "2" - get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" -getpass@^0.1.1: - version "0.1.7" - resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" - dependencies: - assert-plus "^1.0.0" - glob-parent@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" @@ -1408,32 +1072,6 @@ growl@1.10.5: version "1.10.5" resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" - -har-validator@~2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" - dependencies: - chalk "^1.1.1" - commander "^2.9.0" - is-my-json-valid "^2.12.4" - pinkie-promise "^2.0.0" - -har-validator@~5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.0.tgz#44657f5688a22cfd4b72486e81b3a3fb11742c29" - dependencies: - ajv "^5.3.0" - har-schema "^2.0.0" - -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - dependencies: - ansi-regex "^2.0.0" - has-binary2@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/has-binary2/-/has-binary2-1.0.3.tgz#7776ac627f3ea77250cfc332dab7ddf5e4f5d11d" @@ -1499,26 +1137,10 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.1" -hawk@~3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" - dependencies: - boom "2.x.x" - cryptiles "2.x.x" - hoek "2.x.x" - sntp "1.x.x" - he@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" -hipchat-notifier@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/hipchat-notifier/-/hipchat-notifier-1.1.0.tgz#b6d249755437c191082367799d3ba9a0f23b231e" - dependencies: - lodash "^4.0.0" - request "^2.0.0" - hmac-drbg@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" @@ -1527,10 +1149,6 @@ hmac-drbg@^1.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hoek@2.x.x: - version "2.16.3" - resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" - htmlescape@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/htmlescape/-/htmlescape-1.1.1.tgz#3a03edc2214bca3b66424a3e7959349509cb0351" @@ -1544,13 +1162,6 @@ http-errors@1.6.3, http-errors@~1.6.3: setprototypeof "1.1.0" statuses ">= 1.4.0 < 2" -http-proxy-agent@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405" - dependencies: - agent-base "4" - debug "3.1.0" - http-proxy@^1.13.0: version "1.17.0" resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.17.0.tgz#7ad38494658f84605e2f6db4436df410f4e5be9a" @@ -1559,48 +1170,10 @@ http-proxy@^1.13.0: follow-redirects "^1.0.0" requires-port "^1.0.0" -http-signature@~1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" - dependencies: - assert-plus "^0.2.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -httpntlm@1.6.1: - version "1.6.1" - resolved "https://registry.yarnpkg.com/httpntlm/-/httpntlm-1.6.1.tgz#ad01527143a2e8773cfae6a96f58656bb52a34b2" - dependencies: - httpreq ">=0.4.22" - underscore "~1.7.0" - -httpreq@>=0.4.22: - version "0.4.24" - resolved "https://registry.yarnpkg.com/httpreq/-/httpreq-0.4.24.tgz#4335ffd82cd969668a39465c929ac61d6393627f" - https-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" -https-proxy-agent@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0" - dependencies: - agent-base "^4.1.0" - debug "^3.1.0" - -iconv-lite@0.4.15: - version "0.4.15" - resolved "http://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" - iconv-lite@0.4.23: version "0.4.23" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63" @@ -1627,14 +1200,6 @@ indexof@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" -inflection@~1.12.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.12.0.tgz#a200935656d6f5f6bc4dc7502e1aecb703228416" - -inflection@~1.3.0: - version "1.3.8" - resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.3.8.tgz#cbd160da9f75b14c3cc63578d4f396784bf3014e" - inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -1675,10 +1240,6 @@ insert-module-globals@^7.0.0: undeclared-identifiers "^1.1.2" xtend "^4.0.0" -ip@^1.1.2, ip@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" - is-accessor-descriptor@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" @@ -1765,20 +1326,6 @@ is-glob@^4.0.0: dependencies: is-extglob "^2.1.1" -is-my-ip-valid@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz#7b351b8e8edd4d3995d4d066680e664d94696824" - -is-my-json-valid@^2.12.4: - version "2.19.0" - resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.19.0.tgz#8fd6e40363cd06b963fa877d444bfb5eddc62175" - dependencies: - generate-function "^2.0.0" - generate-object-property "^1.1.0" - is-my-ip-valid "^1.0.0" - jsonpointer "^4.0.0" - xtend "^4.0.0" - is-number@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-number/-/is-number-0.1.1.tgz#69a7af116963d47206ec9bd9b48a14216f1e3806" @@ -1795,26 +1342,10 @@ is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" -is-property@^1.0.0, is-property@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" - -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - -is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" -isarray@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - isarray@1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -1847,38 +1378,12 @@ isobject@^3.0.0, isobject@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - -jsbn@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" - -json-schema-traverse@^0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" - -json-schema@0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" - json-stable-stringify@~0.0.0: version "0.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz#611c23e814db375527df851193db59dd2af27f45" dependencies: jsonify "~0.0.0" -json-stringify-safe@5.0.x, json-stringify-safe@~5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - -json-text-sequence@^0.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/json-text-sequence/-/json-text-sequence-0.1.1.tgz#a72f217dc4afc4629fff5feb304dc1bd51a2f3d2" - dependencies: - delimit-stream "0.1.0" - jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" @@ -1887,19 +1392,6 @@ jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" -jsonpointer@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" - -jsprim@^1.2.2: - version "1.4.1" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.2.3" - verror "1.10.0" - jssha@2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/jssha/-/jssha-2.3.1.tgz#147b2125369035ca4b2f7d210dc539f009b3de9a" @@ -1921,9 +1413,9 @@ karma-mocha@^1.3.0: dependencies: minimist "1.2.0" -karma@^2.0.0: - version "2.0.5" - resolved "https://registry.yarnpkg.com/karma/-/karma-2.0.5.tgz#3710c7a2e71b1c439313f283846d88e04e4f918c" +karma@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/karma/-/karma-3.1.1.tgz#94c8edd20fb9597ccde343326da009737fb0423a" dependencies: bluebird "^3.3.0" body-parser "^1.16.1" @@ -1940,15 +1432,15 @@ karma@^2.0.0: http-proxy "^1.13.0" isbinaryfile "^3.0.0" lodash "^4.17.4" - log4js "^2.5.3" - mime "^1.3.4" + log4js "^3.0.0" + mime "^2.3.1" minimatch "^3.0.2" optimist "^0.6.1" qjobs "^1.1.4" range-parser "^1.2.0" rimraf "^2.6.0" safe-buffer "^5.0.1" - socket.io "2.0.4" + socket.io "2.1.1" source-map "^0.6.1" tmp "0.0.33" useragent "2.2.1" @@ -1981,29 +1473,6 @@ labeled-stream-splicer@^2.0.0: isarray "^2.0.4" stream-splicer "^2.0.0" -levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" - -libbase64@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/libbase64/-/libbase64-0.1.0.tgz#62351a839563ac5ff5bd26f12f60e9830bb751e6" - -libmime@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/libmime/-/libmime-3.0.0.tgz#51a1a9e7448ecbd32cda54421675bb21bc093da6" - dependencies: - iconv-lite "0.4.15" - libbase64 "0.1.0" - libqp "1.1.0" - -libqp@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/libqp/-/libqp-1.1.0.tgz#f5e6e06ad74b794fb5b5b66988bf728ef1dedbe8" - lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" @@ -2012,69 +1481,24 @@ lodash.memoize@~3.0.3: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" -lodash@^4.0.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.5.0: +lodash@^4.17.4, lodash@^4.5.0: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" -log4js@^2.5.3: - version "2.11.0" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-2.11.0.tgz#bf3902eff65c6923d9ce9cfbd2db54160e34005a" +log4js@^3.0.0: + version "3.0.6" + resolved "https://registry.yarnpkg.com/log4js/-/log4js-3.0.6.tgz#e6caced94967eeeb9ce399f9f8682a4b2b28c8ff" dependencies: - circular-json "^0.5.4" + circular-json "^0.5.5" date-format "^1.2.0" debug "^3.1.0" - semver "^5.5.0" + rfdc "^1.1.2" streamroller "0.7.0" - optionalDependencies: - amqplib "^0.5.2" - axios "^0.15.3" - hipchat-notifier "^1.1.0" - loggly "^1.1.0" - mailgun-js "^0.18.0" - nodemailer "^2.5.0" - redis "^2.7.1" - slack-node "~0.2.0" - -loggly@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/loggly/-/loggly-1.1.1.tgz#0a0fc1d3fa3a5ec44fdc7b897beba2a4695cebee" - dependencies: - json-stringify-safe "5.0.x" - request "2.75.x" - timespan "2.3.x" lru-cache@2.2.x: version "2.2.4" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d" -lru-cache@^4.1.2: - version "4.1.3" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c" - dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" - -mailcomposer@4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/mailcomposer/-/mailcomposer-4.0.1.tgz#0e1c44b2a07cf740ee17dc149ba009f19cadfeb4" - dependencies: - buildmail "4.0.1" - libmime "3.0.0" - -mailgun-js@^0.18.0: - version "0.18.1" - resolved "https://registry.yarnpkg.com/mailgun-js/-/mailgun-js-0.18.1.tgz#ee39aa18d7bb598a5ce9ede84afb681defc8a6b0" - dependencies: - async "~2.6.0" - debug "~3.1.0" - form-data "~2.3.0" - inflection "~1.12.0" - is-stream "^1.1.0" - path-proxy "~1.0.0" - promisify-call "^2.0.2" - proxy-agent "~3.0.0" - tsscmp "~1.0.0" - map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -2126,15 +1550,15 @@ mime-db@~1.37.0: version "1.37.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8" -mime-types@^2.1.11, mime-types@^2.1.12, mime-types@~2.1.18, mime-types@~2.1.19, mime-types@~2.1.7: +mime-types@~2.1.18: version "2.1.21" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.21.tgz#28995aa1ecb770742fe6ae7e58f9181c744b3f96" dependencies: mime-db "~1.37.0" -mime@^1.3.4: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" +mime@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369" minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" @@ -2188,7 +1612,7 @@ mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1: dependencies: minimist "0.0.8" -mocha@^5.0.2: +mocha@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6" dependencies: @@ -2204,9 +1628,9 @@ mocha@^5.0.2: mkdirp "0.5.1" supports-color "5.4.0" -module-deps@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-5.0.1.tgz#3bc47c14b0a6d925aff2ec4a177b456a96ae0396" +module-deps@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-6.1.0.tgz#d1e1efc481c6886269f7112c52c3236188e16479" dependencies: JSONStream "^1.0.3" browser-resolve "^1.7.0" @@ -2218,7 +1642,7 @@ module-deps@^5.0.1: inherits "^2.0.1" parents "^1.0.0" readable-stream "^2.0.2" - resolve "^1.1.3" + resolve "^1.4.0" stream-combiner2 "^1.1.1" subarg "^1.0.0" through2 "^2.0.0" @@ -2264,10 +1688,6 @@ negotiator@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" -netmask@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35" - node-pre-gyp@^0.10.0: version "0.10.3" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc" @@ -2283,63 +1703,6 @@ node-pre-gyp@^0.10.0: semver "^5.3.0" tar "^4" -node-uuid@~1.4.7: - version "1.4.8" - resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" - -nodemailer-direct-transport@3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/nodemailer-direct-transport/-/nodemailer-direct-transport-3.3.2.tgz#e96fafb90358560947e569017d97e60738a50a86" - dependencies: - nodemailer-shared "1.1.0" - smtp-connection "2.12.0" - -nodemailer-fetch@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/nodemailer-fetch/-/nodemailer-fetch-1.6.0.tgz#79c4908a1c0f5f375b73fe888da9828f6dc963a4" - -nodemailer-shared@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/nodemailer-shared/-/nodemailer-shared-1.1.0.tgz#cf5994e2fd268d00f5cf0fa767a08169edb07ec0" - dependencies: - nodemailer-fetch "1.6.0" - -nodemailer-smtp-pool@2.8.2: - version "2.8.2" - resolved "https://registry.yarnpkg.com/nodemailer-smtp-pool/-/nodemailer-smtp-pool-2.8.2.tgz#2eb94d6cf85780b1b4725ce853b9cbd5e8da8c72" - dependencies: - nodemailer-shared "1.1.0" - nodemailer-wellknown "0.1.10" - smtp-connection "2.12.0" - -nodemailer-smtp-transport@2.7.2: - version "2.7.2" - resolved "https://registry.yarnpkg.com/nodemailer-smtp-transport/-/nodemailer-smtp-transport-2.7.2.tgz#03d71c76314f14ac7dbc7bf033a6a6d16d67fb77" - dependencies: - nodemailer-shared "1.1.0" - nodemailer-wellknown "0.1.10" - smtp-connection "2.12.0" - -nodemailer-wellknown@0.1.10: - version "0.1.10" - resolved "https://registry.yarnpkg.com/nodemailer-wellknown/-/nodemailer-wellknown-0.1.10.tgz#586db8101db30cb4438eb546737a41aad0cf13d5" - -nodemailer@^2.5.0: - version "2.7.2" - resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-2.7.2.tgz#f242e649aeeae39b6c7ed740ef7b061c404d30f9" - dependencies: - libmime "3.0.0" - mailcomposer "4.0.1" - nodemailer-direct-transport "3.3.2" - nodemailer-shared "1.1.0" - nodemailer-smtp-pool "2.8.2" - nodemailer-smtp-transport "2.7.2" - socks "1.1.9" - -nofilter@^0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-0.0.3.tgz#241e342078177a8693a3043e83f37567e276410c" - nopt@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" @@ -2381,14 +1744,6 @@ number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" -oauth-sign@~0.8.1: - version "0.8.2" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" - -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" - object-assign@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -2436,17 +1791,6 @@ optimist@^0.6.1: minimist "~0.0.1" wordwrap "~0.0.2" -optionator@^0.8.1: - version "0.8.2" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" - dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.4" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - wordwrap "~1.0.0" - os-browserify@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" @@ -2466,29 +1810,6 @@ osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -pac-proxy-agent@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-3.0.0.tgz#11d578b72a164ad74bf9d5bac9ff462a38282432" - dependencies: - agent-base "^4.2.0" - debug "^3.1.0" - get-uri "^2.0.0" - http-proxy-agent "^2.1.0" - https-proxy-agent "^2.2.1" - pac-resolver "^3.0.0" - raw-body "^2.2.0" - socks-proxy-agent "^4.0.1" - -pac-resolver@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-3.0.0.tgz#6aea30787db0a891704deb7800a722a7615a6f26" - dependencies: - co "^4.6.0" - degenerator "^1.0.4" - ip "^1.1.5" - netmask "^1.0.6" - thunkify "^2.1.2" - pako@~1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258" @@ -2549,12 +1870,6 @@ path-platform@~0.11.15: version "0.11.15" resolved "https://registry.yarnpkg.com/path-platform/-/path-platform-0.11.15.tgz#e864217f74c36850f0852b78dc7bf7d4a5721bf2" -path-proxy@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/path-proxy/-/path-proxy-1.0.0.tgz#18e8a36859fc9d2f1a53b48dee138543c020de5e" - dependencies: - inflection "~1.3.0" - pathval@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" @@ -2569,32 +1884,10 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" - -pinkie-promise@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" - dependencies: - pinkie "^2.0.0" - -pinkie@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" - posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - -process-nextick-args@~1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" - process-nextick-args@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" @@ -2603,37 +1896,6 @@ process@~0.11.0: version "0.11.10" resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" -promisify-call@^2.0.2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/promisify-call/-/promisify-call-2.0.4.tgz#d48c2d45652ccccd52801ddecbd533a6d4bd5fba" - dependencies: - with-callback "^1.0.2" - -proxy-agent@~3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-3.0.3.tgz#1c1a33db60ef5f2e9e35b876fd63c2bc681c611d" - dependencies: - agent-base "^4.2.0" - debug "^3.1.0" - http-proxy-agent "^2.1.0" - https-proxy-agent "^2.2.1" - lru-cache "^4.1.2" - pac-proxy-agent "^3.0.0" - proxy-from-env "^1.0.0" - socks-proxy-agent "^4.0.1" - -proxy-from-env@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" - -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - -psl@^1.1.24: - version "1.1.29" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.29.tgz#60f580d360170bb722a797cc704411e6da850c67" - public-encrypt@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" @@ -2649,7 +1911,7 @@ punycode@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" -punycode@1.4.1, punycode@^1.3.2, punycode@^1.4.1: +punycode@^1.3.2: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" @@ -2657,14 +1919,10 @@ qjobs@^1.1.4: version "1.2.0" resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" -qs@6.5.2, qs@~6.5.2: +qs@6.5.2: version "6.5.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" -qs@~6.2.0: - version "6.2.3" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.3.tgz#1cfcb25c10a9b2b483053ff39f5dfc9233908cfe" - querystring-es3@~0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" @@ -2690,7 +1948,7 @@ range-parser@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" -raw-body@2.3.3, raw-body@^2.2.0: +raw-body@2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.3.tgz#1b324ece6b5706e153855bc1148c65bb7f6ea0c3" dependencies: @@ -2714,16 +1972,7 @@ read-only-stream@^2.0.0: dependencies: readable-stream "^2.0.2" -readable-stream@1.1.x, "readable-stream@1.x >=1.1.9": - version "1.1.14" - resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readable-stream@2, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.6: +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.6: version "2.3.6" resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" dependencies: @@ -2735,17 +1984,6 @@ readable-stream@2, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stre string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@~2.0.0, readable-stream@~2.0.5: - version "2.0.6" - resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - string_decoder "~0.10.x" - util-deprecate "~1.0.1" - readdirp@^2.0.0: version "2.2.1" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525" @@ -2754,22 +1992,6 @@ readdirp@^2.0.0: micromatch "^3.1.10" readable-stream "^2.0.2" -redis-commands@^1.2.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.4.0.tgz#52f9cf99153efcce56a8f86af986bd04e988602f" - -redis-parser@^2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/redis-parser/-/redis-parser-2.6.0.tgz#52ed09dacac108f1a631c07e9b69941e7a19504b" - -redis@^2.7.1: - version "2.8.0" - resolved "https://registry.yarnpkg.com/redis/-/redis-2.8.0.tgz#202288e3f58c49f6079d97af7a10e1303ae14b02" - dependencies: - double-ended-queue "^2.1.0-0" - redis-commands "^1.2.0" - redis-parser "^2.6.0" - regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" @@ -2793,66 +2015,6 @@ repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" -request@2.75.x: - version "2.75.0" - resolved "http://registry.npmjs.org/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93" - dependencies: - aws-sign2 "~0.6.0" - aws4 "^1.2.1" - bl "~1.1.2" - caseless "~0.11.0" - combined-stream "~1.0.5" - extend "~3.0.0" - forever-agent "~0.6.1" - form-data "~2.0.0" - har-validator "~2.0.6" - hawk "~3.1.3" - http-signature "~1.1.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.7" - node-uuid "~1.4.7" - oauth-sign "~0.8.1" - qs "~6.2.0" - stringstream "~0.0.4" - tough-cookie "~2.3.0" - tunnel-agent "~0.4.1" - -request@^2.0.0, request@^2.74.0: - version "2.88.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.0" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.4.3" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - -requestretry@^1.2.2: - version "1.13.0" - resolved "https://registry.yarnpkg.com/requestretry/-/requestretry-1.13.0.tgz#213ec1006eeb750e8b8ce54176283d15a8d55d94" - dependencies: - extend "^3.0.0" - lodash "^4.15.0" - request "^2.74.0" - when "^3.7.7" - requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" @@ -2865,7 +2027,7 @@ resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" -resolve@^1.1.3, resolve@^1.1.4: +resolve@^1.1.4, resolve@^1.4.0: version "1.8.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" dependencies: @@ -2875,6 +2037,10 @@ ret@~0.1.10: version "0.1.15" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" +rfdc@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.1.2.tgz#e6e72d74f5dc39de8f538f65e00c36c18018e349" + rimraf@^2.6.0, rimraf@^2.6.1: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" @@ -2898,7 +2064,7 @@ safe-regex@^1.1.0: dependencies: ret "~0.1.10" -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: +"safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -2906,7 +2072,7 @@ sax@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" -semver@^5.3.0, semver@^5.5.0: +semver@^5.3.0: version "5.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" @@ -2967,27 +2133,6 @@ simple-concat@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6" -slack-node@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/slack-node/-/slack-node-0.2.0.tgz#de4b8dddaa8b793f61dbd2938104fdabf37dfa30" - dependencies: - requestretry "^1.2.2" - -smart-buffer@^1.0.4: - version "1.1.15" - resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-1.1.15.tgz#7f114b5b65fab3e2a35aa775bb12f0d1c649bf16" - -smart-buffer@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.0.1.tgz#07ea1ca8d4db24eb4cac86537d7d18995221ace3" - -smtp-connection@2.12.0: - version "2.12.0" - resolved "https://registry.yarnpkg.com/smtp-connection/-/smtp-connection-2.12.0.tgz#d76ef9127cb23c2259edb1e8349c2e8d5e2d74c1" - dependencies: - httpntlm "1.6.1" - nodemailer-shared "1.1.0" - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -3015,73 +2160,47 @@ snapdragon@^0.8.1: source-map-resolve "^0.5.0" use "^3.1.0" -sntp@1.x.x: - version "1.0.9" - resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" - dependencies: - hoek "2.x.x" - socket.io-adapter@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz#2a805e8a14d6372124dd9159ad4502f8cb07f06b" -socket.io-client@2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.0.4.tgz#0918a552406dc5e540b380dcd97afc4a64332f8e" +socket.io-client@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.1.1.tgz#dcb38103436ab4578ddb026638ae2f21b623671f" dependencies: backo2 "1.0.2" base64-arraybuffer "0.1.5" component-bind "1.0.0" component-emitter "1.2.1" - debug "~2.6.4" - engine.io-client "~3.1.0" + debug "~3.1.0" + engine.io-client "~3.2.0" + has-binary2 "~1.0.2" has-cors "1.1.0" indexof "0.0.1" object-component "0.0.3" parseqs "0.0.5" parseuri "0.0.5" - socket.io-parser "~3.1.1" + socket.io-parser "~3.2.0" to-array "0.1.4" -socket.io-parser@~3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.1.3.tgz#ed2da5ee79f10955036e3da413bfd7f1e4d86c8e" +socket.io-parser@~3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.2.0.tgz#e7c6228b6aa1f814e6148aea325b51aa9499e077" dependencies: component-emitter "1.2.1" debug "~3.1.0" - has-binary2 "~1.0.2" isarray "2.0.1" -socket.io@2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.0.4.tgz#c1a4590ceff87ecf13c72652f046f716b29e6014" +socket.io@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.1.1.tgz#a069c5feabee3e6b214a75b40ce0652e1cfb9980" dependencies: - debug "~2.6.6" - engine.io "~3.1.0" + debug "~3.1.0" + engine.io "~3.2.0" + has-binary2 "~1.0.2" socket.io-adapter "~1.1.0" - socket.io-client "2.0.4" - socket.io-parser "~3.1.1" - -socks-proxy-agent@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-4.0.1.tgz#5936bf8b707a993079c6f37db2091821bffa6473" - dependencies: - agent-base "~4.2.0" - socks "~2.2.0" - -socks@1.1.9: - version "1.1.9" - resolved "https://registry.yarnpkg.com/socks/-/socks-1.1.9.tgz#628d7e4d04912435445ac0b6e459376cb3e6d691" - dependencies: - ip "^1.1.2" - smart-buffer "^1.0.4" - -socks@~2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/socks/-/socks-2.2.1.tgz#68ad678b3642fbc5d99c64c165bc561eab0215f9" - dependencies: - ip "^1.1.5" - smart-buffer "^4.0.1" + socket.io-client "2.1.1" + socket.io-parser "~3.2.0" source-map-resolve@^0.5.0: version "0.5.2" @@ -3111,20 +2230,6 @@ split-string@^3.0.1, split-string@^3.0.2: dependencies: extend-shallow "^3.0.0" -sshpk@^1.7.0: - version "1.15.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.15.1.tgz#b79a089a732e346c6e0714830f36285cd38191a2" - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - bcrypt-pbkdf "^1.0.0" - dashdash "^1.12.0" - ecc-jsbn "~0.1.1" - getpass "^0.1.1" - jsbn "~0.1.0" - safer-buffer "^2.0.2" - tweetnacl "~0.14.0" - static-extend@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -3195,26 +2300,12 @@ string-width@^1.0.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string_decoder@~0.10.x: - version "0.10.31" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" - -string_decoder@~1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" - dependencies: - safe-buffer "~5.1.0" - -string_decoder@~1.1.1: +string_decoder@^1.1.1, string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" dependencies: safe-buffer "~5.1.0" -stringstream@~0.0.4: - version "0.0.6" - resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.6.tgz#7880225b0d4ad10e30927d167a1d6f2fd3b33a72" - strip-ansi@^3.0.0, strip-ansi@^3.0.1: version "3.0.1" resolved "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" @@ -3243,10 +2334,6 @@ supports-color@5.4.0: dependencies: has-flag "^3.0.0" -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - syntax-error@^1.1.1: version "1.4.0" resolved "https://registry.yarnpkg.com/syntax-error/-/syntax-error-1.4.0.tgz#2d9d4ff5c064acb711594a3e3b95054ad51d907c" @@ -3276,20 +2363,12 @@ through2@^2.0.0: version "2.3.8" resolved "http://registry.npmjs.org/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" -thunkify@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/thunkify/-/thunkify-2.1.2.tgz#faa0e9d230c51acc95ca13a361ac05ca7e04553d" - timers-browserify@^1.0.1: version "1.4.2" resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-1.4.2.tgz#c9c58b575be8407375cb5e2462dacee74359f41d" dependencies: process "~0.11.0" -timespan@2.3.x: - version "2.3.0" - resolved "https://registry.yarnpkg.com/timespan/-/timespan-2.3.0.tgz#4902ce040bd13d845c8f59b27e9d59bad6f39929" - tmp@0.0.33, tmp@0.0.x: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -3326,47 +2405,10 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" -tough-cookie@~2.3.0: - version "2.3.4" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655" - dependencies: - punycode "^1.4.1" - -tough-cookie@~2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" - dependencies: - psl "^1.1.24" - punycode "^1.4.1" - -tsscmp@~1.0.0: - version "1.0.6" - resolved "https://registry.yarnpkg.com/tsscmp/-/tsscmp-1.0.6.tgz#85b99583ac3589ec4bfef825b5000aa911d605eb" - -tty-browserify@~0.0.0: +tty-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" - dependencies: - safe-buffer "^5.0.1" - -tunnel-agent@~0.4.1: - version "0.4.3" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" - -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - dependencies: - prelude-ls "~1.1.2" - type-detect@^4.0.0, type-detect@^4.0.5: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" @@ -3378,11 +2420,11 @@ type-is@~1.6.16: media-typer "0.3.0" mime-types "~2.1.18" -typedarray@^0.0.6, typedarray@~0.0.5: +typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -uglify-js@^3.3.13: +uglify-js@^3.4.9: version "3.4.9" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3" dependencies: @@ -3406,10 +2448,6 @@ undeclared-identifiers@^1.1.2: simple-concat "^1.0.0" xtend "^4.0.1" -underscore@~1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.7.0.tgz#6bbaf0877500d36be34ecaa584e0db9fef035209" - union-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" @@ -3476,36 +2514,14 @@ utils-merge@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" -uuid@^3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" - -uws@~9.14.0: - version "9.14.0" - resolved "https://registry.yarnpkg.com/uws/-/uws-9.14.0.tgz#fac8386befc33a7a3705cbd58dc47b430ca4dd95" - -verror@1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" - dependencies: - assert-plus "^1.0.0" - core-util-is "1.0.2" - extsprintf "^1.2.0" - -vm-browserify@~0.0.1: - version "0.0.4" - resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73" - dependencies: - indexof "0.0.1" +vm-browserify@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.0.tgz#bd76d6a23323e2ca8ffa12028dc04559c75f9019" void-elements@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" -when@^3.7.7: - version "3.7.8" - resolved "https://registry.yarnpkg.com/when/-/when-3.7.8.tgz#c7130b6a7ea04693e842cdc9e7a1f2aa39a39f82" - which@^1.2.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" @@ -3518,18 +2534,10 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2 || 2" -with-callback@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/with-callback/-/with-callback-1.0.2.tgz#a09629b9a920028d721404fb435bdcff5c91bc21" - wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" -wordwrap@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" - wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -3546,18 +2554,10 @@ xmlhttprequest-ssl@~1.5.4: version "1.5.5" resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e" -xregexp@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943" - xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" -yallist@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - yallist@^3.0.0, yallist@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" From 33e4f47ae36bbe01ba35c6d8cd22a1bf648ac56e Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 26 Oct 2018 01:34:12 +0200 Subject: [PATCH 058/108] updated readme.md to reflect current coins --- README.md | 124 ++++++++++++++++++++++++---------------------- package.json | 8 +-- src/currencies.js | 95 ++++++++++++++++++----------------- 3 files changed, 118 insertions(+), 109 deletions(-) diff --git a/README.md b/README.md index 77d8e619..479a6fdd 100644 --- a/README.md +++ b/README.md @@ -30,66 +30,70 @@ npm install wallet-address-validator ### Supported crypto currencies -* Auroracoin/AUR, `'auroracoin'` or `'AUR'` - -* Bankex/BKX, `'bankex'` or `'BKX'` -* BeaverCoin/BVC, `'beavercoin'` or `'BVC'` -* Biocoin/BIO, `'biocoin'` or `'BIO'` -* Bitcoin/BTC, `'bitcoin'` or `'BTC'` -* BitcoinCash/BCH, `'bitcoincash'` or `'BCH'` -* BitcoinGold/BTG, `'bitcoingold'` or `'BTG'` -* BitcoinPrivate/BTCP, `'bitcoinprivate'` or `'BTCP'` -* BitcoinZ/BTCZ, `'bitcoinz'` or `'BTCZ'` - -* Callisto/CLO, `'callisto'` or `'CLO'` - -* Dash, `'dash'` or `'DASH'` -* Decred/DCR, `'decred'` or `'DCR'` -* Digibyte/DGB, `'digibyte'` or `'DGB'` -* Dogecoin/DOGE, `'dogecoin'` or `'DOGE'` - -* Ethereum/ETH, `'ethereum'` or `'ETH'` -* EthereumClassic/ETH, `'ethereumclassic'` or `'ETC'` -* EthereumZero/ETZ, `'etherzero'` or `'ETZ'` - -* Freicoin/FRC, `'freicoin'` or `'FRC'` - -* Garlicoin/GRLC, `'garlicoin'` or `'GRLC'` - -* Hush/HUSH, `'hush'` or `'HUSH'` - -* Komodo/KMD, `'komodo'` or `'KMD'` - -* Litecoin/LTC, `'litecoin'` or `'LTC'` - -* Megacoin/MEC, `'megacoin'` or `'MEC'` - -* Monero/XMR, `'monero'` or `'XMR'` - -* Namecoin/NMC, `'namecoin'` or `'NMC'` -* NEO/NEO, `'NEO'` or `'NEO'` -* NeoGas/GAS, `'neogas'` or `'GAS'` - -* Peercoin/PPCoin/PPC, `'peercoin'` or `'PPC'` -* Primecoin/XPM, `'primecoin'` or `'XPM'` -* Protoshares/PTS, `'protoshares'` or `'PTS'` - -* Qtum/QTUM, `'qtum'` or `'QTUM'` - -* Ripple/XRP, `'ripple'` or `'XRP'` - -* Snowgem/SNG, `'snowgem'` or `'SNG'` - -* Vertcoin/VTC, `'vertcoin'` or `'VTC'` - -* Votecoin/VTC, `'votecoin'` or `'VOT'` - -* Zcash/ZEC, `'zcash'` or `'ZEC'` - -* Zclassic/ZCL, `'zclassic'` or `'ZCL'` - -* ZenCash/ZEN, `'zencash'` or `'ZEN'` - +* 0x/zrx `'0x'` or `'zrx'` +* Aragon/ant `'Aragon'` or `'ant'` +* Augur/rep `'Augur'` or `'rep'` +* AuroraCoin/aur `'AuroraCoin'` or `'aur'` +* Bancor/bnt `'Bancor'` or `'bnt'` +* Bankex/bkx `'Bankex'` or `'bkx'` +* Basic Attention Token/bat `'Basic Attention Token'` or `'bat'` +* BeaverCoin/bvc `'BeaverCoin'` or `'bvc'` +* BioCoin/bio `'BioCoin'` or `'bio'` +* Bitcoin/btc `'Bitcoin'` or `'btc'` +* BitcoinCash/bch `'BitcoinCash'` or `'bch'` +* BitcoinGold/btg `'BitcoinGold'` or `'btg'` +* BitcoinPrivate/btcp `'BitcoinPrivate'` or `'btcp'` +* BitcoinZ/btcz `'BitcoinZ'` or `'btcz'` +* Callisto/clo `'Callisto'` or `'clo'` +* Cardano/ada `'Cardano'` or `'ada'` +* Civic/cvc `'Civic'` or `'cvc'` +* Dash/dash `'Dash'` or `'dash'` +* Decred/dcr `'Decred'` or `'dcr'` +* DigiByte/dgb `'DigiByte'` or `'dgb'` +* District0x/dnt `'District0x'` or `'dnt'` +* DogeCoin/doge `'DogeCoin'` or `'doge'` +* Ethereum/eth `'Ethereum'` or `'eth'` +* EthereumClassic/etc `'EthereumClassic'` or `'etc'` +* EtherZero/etz `'EtherZero'` or `'etz'` +* Expanse/exp `'Expanse'` or `'exp'` +* FreiCoin/frc `'FreiCoin'` or `'frc'` +* GameCredits/game `'GameCredits'` or `'game'` +* GarliCoin/grlc `'GarliCoin'` or `'grlc'` +* Gnosis/gno `'Gnosis'` or `'gno'` +* Golem/gnt `'Golem'` or `'gnt'` +* Hush/hush `'Hush'` or `'hush'` +* Komodo/kmd `'Komodo'` or `'kmd'` +* LiteCoin/ltc `'LiteCoin'` or `'ltc'` +* Matchpool/gup `'Matchpool'` or `'gup'` +* MegaCoin/mec `'MegaCoin'` or `'mec'` +* Melon/mln `'Melon'` or `'mln'` +* MonaCoin/mona `'MonaCoin'` or `'mona'` +* Monero/xmr `'Monero'` or `'xmr'` +* NameCoin/nmc `'NameCoin'` or `'nmc'` +* Neo/neo `'Neo'` or `'neo'` +* NeoGas/gas `'NeoGas'` or `'gas'` +* Numeraire/nmr `'Numeraire'` or `'nmr'` +* OmiseGO/omg `'OmiseGO'` or `'omg'` +* PeerCoin/ppc `'PeerCoin'` or `'ppc'` +* PIVX/pivx `'PIVX'` or `'pivx'` +* PrimeCoin/xpm `'PrimeCoin'` or `'xpm'` +* ProtoShares/pts `'ProtoShares'` or `'pts'` +* Qtum/qtum `'Qtum'` or `'qtum'` +* Ripio Credit Network/rcn `'Ripio Credit Network'` or `'rcn'` +* Ripple/xrp `'Ripple'` or `'xrp'` +* SnowGem/sng `'SnowGem'` or `'sng'` +* SolarCoin/slr `'SolarCoin'` or `'slr'` +* Status/snt `'Status'` or `'snt'` +* Swarm City/swt `'Swarm City'` or `'swt'` +* TenX/pay `'TenX'` or `'pay'` +* Tether/usdt `'Tether'` or `'usdt'` +* TrueUSD/tusd `'TrueUSD'` or `'tusd'` +* VertCoin/vtc `'VertCoin'` or `'vtc'` +* VoteCoin/vot `'VoteCoin'` or `'vot'` +* Wings/wings `'Wings'` or `'wings'` +* ZCash/zec `'ZCash'` or `'zec'` +* ZClassic/zcl `'ZClassic'` or `'zcl'` +* ZenCash/zen `'ZenCash'` or `'zen'` ### Usage example diff --git a/package.json b/package.json index e58d7356..17b36e68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "wallet-address-validator", - "description": "Wallet address validator for Bitcoin and other Altcoins.", + "name": "multicoin-address-validator", + "description": "Multicoin address validator for Bitcoin and other Altcoins.", "keywords": [ "ada", "btc", @@ -29,8 +29,8 @@ "browser", "nodejs" ], - "version": "0.2.1", - "author": "Tomek Kolasa ", + "version": "0.3.0", + "author": "Chris Tsimogiannis ", "homepage": "https://github.com/ognus/wallet-address-validator", "license": "MIT", "repository": { diff --git a/src/currencies.js b/src/currencies.js index 0dbfb6c1..b5296881 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -6,152 +6,152 @@ var XMRValidator = require('./monero_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ - name: 'bitcoin', + name: 'Bitcoin', symbol: 'btc', addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'bitcoincash', + name: 'BitcoinCash', symbol: 'bch', addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'litecoin', + name: 'LiteCoin', symbol: 'ltc', addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']}, validator: BTCValidator },{ - name: 'peercoin', + name: 'PeerCoin', symbol: 'ppc', addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'dogecoin', + name: 'DogeCoin', symbol: 'doge', addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']}, validator: BTCValidator },{ - name: 'beavercoin', + name: 'BeaverCoin', symbol: 'bvc', addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator, },{ - name: 'freicoin', + name: 'FreiCoin', symbol: 'frc', addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'protoshares', + name: 'ProtoShares', symbol: 'pts', addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'megacoin', + name: 'MegaCoin', symbol: 'mec', addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'primecoin', + name: 'PrimeCoin', symbol: 'xpm', addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'auroracoin', + name: 'AuroraCoin', symbol: 'aur', addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'namecoin', + name: 'NameCoin', symbol: 'nmc', addressTypes: {prod: ['34'], testnet: []}, validator: BTCValidator },{ - name: 'biocoin', + name: 'BioCoin', symbol: 'bio', addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'garlicoin', + name: 'GarliCoin', symbol: 'grlc', addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'vertcoin', + name: 'VertCoin', symbol: 'vtc', addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'bitcoingold', + name: 'BitcoinGold', symbol: 'btg', addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'komodo', + name: 'Komodo', symbol: 'kmd', addressTypes: {prod: ['3c', '55'], testnet: ['0','5']}, validator: BTCValidator },{ - name: 'bitcoinz', + name: 'BitcoinZ', symbol: 'btcz', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'bitcoinprivate', + name: 'BitcoinPrivate', symbol: 'btcp', expectedLength: 26, addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']}, validator: BTCValidator },{ - name: 'hush', + name: 'Hush', symbol: 'hush', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'snowgem', + name: 'SnowGem', symbol: 'sng', expectedLength: 26, addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'zcash', + name: 'ZCash', symbol: 'zec', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'zclassic', + name: 'ZClassic', symbol: 'zcl', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'zencash', + name: 'ZenCash', symbol: 'zen', expectedLength: 26, addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']}, validator: BTCValidator },{ - name: 'votecoin', + name: 'VoteCoin', symbol: 'vot', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'decred', + name: 'Decred', symbol: 'dcr', addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, hashFunction: 'blake256', expectedLength: 26, validator: BTCValidator },{ - name: 'gamecredits', + name: 'GameCredits', symbol: 'game', addressTypes: {prod: ['26', '05'], testnet: []}, validator: BTCValidator },{ - name: 'pivx', + name: 'PIVX', symbol: 'pivx', addressTypes: {prod: ['1e', '0d'], testnet: []}, validator: BTCValidator @@ -166,7 +166,7 @@ var CURRENCIES = [{ addressTypes: {prod: ['32', '37'], testnet: []}, validator: BTCValidator },{ - name: 'digibyte', + name: 'DigiByte', symbol: 'dgb', addressTypes: {prod: ['1e'], testnet: []}, validator: BTCValidator @@ -176,55 +176,55 @@ var CURRENCIES = [{ addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'ripple', + name: 'Ripple', symbol: 'xrp', validator: XRPValidator, },{ - name: 'dash', + name: 'Dash', symbol: 'dash', addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']}, validator: BTCValidator },{ - name: 'neo', + name: 'Neo', symbol: 'neo', addressTypes: {prod: ['17'], testnet: []}, validator: BTCValidator },{ - name: 'neogas', + name: 'NeoGas', symbol: 'gas', addressTypes: {prod: ['17'], testnet: []}, validator: BTCValidator },{ - name: 'qtum', + name: 'Qtum', symbol: 'qtum', addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'ethereum', + name: 'Ethereum', symbol: 'eth', validator: ETHValidator, },{ - name: 'etherzero', + name: 'EtherZero', symbol: 'etz', validator: ETHValidator, },{ - name: 'ethereumclassic', + name: 'EthereumClassic', symbol: 'etc', validator: ETHValidator, },{ - name: 'callisto', + name: 'Callisto', symbol: 'clo', validator: ETHValidator, },{ - name: 'bankex', + name: 'Bankex', symbol: 'bkx', validator: ETHValidator },{ - name: 'cardano', + name: 'Cardano', symbol: 'ada', validator: ADAValidator },{ - name: 'monero', + name: 'Monero', symbol: 'xmr', addressTypes: {prod: ['18'], testnet: ['53']}, iAddressTypes: {prod: ['19'], testnet: ['54']}, @@ -242,12 +242,12 @@ var CURRENCIES = [{ symbol: 'bnt', validator: ETHValidator },{ - name: 'cvc', - symbol: 'Civic', + name: 'Civic', + symbol: 'cvc', validator: ETHValidator },{ - name: 'dnt', - symbol: 'District0x', + name: 'District0x', + symbol: 'dnt', validator: ETHValidator },{ name: 'Gnosis', @@ -325,4 +325,9 @@ module.exports = { } }; +// spit out details for readme.md +// CURRENCIES +// .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) +// .forEach(c => console.log(`* ${c.name}/${c.symbol} \`'${c.name}'\` or \`'${c.symbol}'\` `)); + From 932a2ab6d60d5278771dcf9efc03318264f80006 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 26 Oct 2018 16:01:51 +0200 Subject: [PATCH 059/108] publicshing to npm --- package-lock.json | 5796 ++------------------------------------------- package.json | 4 +- 2 files changed, 167 insertions(+), 5633 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1b3231b..72cacfc2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,562 +1,21 @@ { - "name": "wallet-address-validator", - "version": "0.1.7", + "name": "multicoin-address-validator", + "version": "0.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { - "JSONStream": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.3.tgz", - "integrity": "sha512-3Sp6WZZ/lXl+nTDoGpGWHEpTnnC6X5fnkolYZR6nwIfzbxxvA8utPWe1gCt7i0m9uVGsSz2IS8K8mJ7HmlduMg==", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, - "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", - "dev": true, - "requires": { - "mime-types": "2.1.19", - "negotiator": "0.6.1" - } - }, - "acorn": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", - "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", - "dev": true - }, - "acorn-dynamic-import": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz", - "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==", - "dev": true, - "requires": { - "acorn": "5.7.1" - } - }, - "acorn-node": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.5.2.tgz", - "integrity": "sha512-krFKvw/d1F17AN3XZbybIUzEY4YEPNiGo05AfP3dBlfVKrMHETKpgjpuZkSF8qDNt9UkQcqj7am8yJLseklCMg==", - "dev": true, - "requires": { - "acorn": "5.7.1", - "acorn-dynamic-import": "3.0.0", - "xtend": "4.0.1" - } - }, - "addressparser": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/addressparser/-/addressparser-1.0.1.tgz", - "integrity": "sha1-R6++GiqSYhkdtoOOT9HTm0CCF0Y=", - "dev": true, - "optional": true - }, - "after": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", - "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", - "dev": true - }, - "agent-base": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", - "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", - "dev": true, - "requires": { - "es6-promisify": "5.0.0" - } - }, - "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", - "dev": true, - "optional": true, - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.1.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" - } - }, - "amqplib": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/amqplib/-/amqplib-0.5.2.tgz", - "integrity": "sha512-l9mCs6LbydtHqRniRwYkKdqxVa6XMz3Vw1fh+2gJaaVgTM6Jk3o8RccAKWKtlhT1US5sWrFh+KKxsVUALURSIA==", - "dev": true, - "optional": true, - "requires": { - "bitsyntax": "0.0.4", - "bluebird": "3.5.1", - "buffer-more-ints": "0.0.2", - "readable-stream": "1.1.14", - "safe-buffer": "5.1.2" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true - } - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true, - "optional": true - }, - "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", - "dev": true, - "requires": { - "micromatch": "3.1.10", - "normalize-path": "2.1.1" - } - }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-filter": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz", - "integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=", - "dev": true - }, - "array-map": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", - "integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=", - "dev": true - }, - "array-reduce": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz", - "integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=", - "dev": true - }, - "array-slice": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", - "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "arraybuffer.slice": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", - "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==", - "dev": true - }, - "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", - "dev": true, - "optional": true - }, - "asn1.js": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" - } - }, - "assert": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", - "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", - "dev": true, - "requires": { - "util": "0.10.3" - }, - "dependencies": { - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true - }, - "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", - "dev": true, - "requires": { - "inherits": "2.0.1" - } - } - } - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true - }, - "ast-types": { - "version": "0.11.5", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.11.5.tgz", - "integrity": "sha512-oJjo+5e7/vEc2FBK8gUalV0pba4L3VdBIs2EKhOLHLcOd2FgQIVQN9xb0eZ9IjEWyAL7vq6fGJxOvVvdCHNyMw==", - "dev": true, - "optional": true - }, - "async": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", - "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", - "dev": true, - "optional": true, - "requires": { - "lodash": "4.17.10" - } - }, - "async-each": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", - "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", - "dev": true - }, - "async-limiter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", - "dev": true - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true, - "optional": true - }, - "atob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", - "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", - "dev": true - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "dev": true, - "optional": true - }, - "aws4": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", - "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==", - "dev": true, - "optional": true - }, - "axios": { - "version": "0.15.3", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.15.3.tgz", - "integrity": "sha1-LJ1jiy4ZGgjqHWzJiOrda6W9wFM=", - "dev": true, - "optional": true, - "requires": { - "follow-redirects": "1.0.0" - }, - "dependencies": { - "follow-redirects": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.0.0.tgz", - "integrity": "sha1-jjQpjL0uF28lTv/sdaHHjMhJ/Tc=", - "dev": true, - "optional": true, - "requires": { - "debug": "2.6.9" - } - } - } - }, - "backo2": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", - "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=", - "dev": true - }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "requires": { - "cache-base": "1.0.1", - "class-utils": "0.3.6", - "component-emitter": "1.2.1", - "define-property": "1.0.0", - "isobject": "3.0.1", - "mixin-deep": "1.3.1", - "pascalcase": "0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - } - } - }, "base-x": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.4.tgz", "integrity": "sha512-UYOadoSIkEI/VrRGSG6qp93rp2WdokiAiNYDfGW5qURAY8GiAQkvMbwNNSDYiVJopqv4gCna7xqf4rrNGp+5AA==", "requires": { - "safe-buffer": "5.1.2" - } - }, - "base64-arraybuffer": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", - "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=", - "dev": true - }, - "base64-js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", - "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", - "dev": true - }, - "base64id": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", - "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=", - "dev": true - }, - "bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "dev": true, - "optional": true, - "requires": { - "tweetnacl": "0.14.5" - } - }, - "better-assert": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", - "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", - "dev": true, - "requires": { - "callsite": "1.0.0" - } - }, - "binary-extensions": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", - "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", - "dev": true - }, - "bitsyntax": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/bitsyntax/-/bitsyntax-0.0.4.tgz", - "integrity": "sha1-6xDMb4K4xJDj6FaY8H6D1G4MuoI=", - "dev": true, - "optional": true, - "requires": { - "buffer-more-ints": "0.0.2" - } - }, - "bl": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.1.2.tgz", - "integrity": "sha1-/cqHGplxOqANGeO7ukHER4emU5g=", - "dev": true, - "optional": true, - "requires": { - "readable-stream": "2.0.6" - }, - "dependencies": { - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true, - "optional": true - }, - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", - "util-deprecate": "1.0.2" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true - } - } - }, - "blob": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", - "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=", - "dev": true - }, - "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", - "dev": true - }, - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true - }, - "body-parser": { - "version": "1.18.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", - "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", - "dev": true, - "requires": { - "bytes": "3.0.0", - "content-type": "1.0.4", - "debug": "2.6.9", - "depd": "1.1.2", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", - "on-finished": "2.3.0", - "qs": "6.5.2", - "raw-body": "2.3.3", - "type-is": "1.6.16" - } - }, - "boom": { - "version": "2.10.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "dev": true, - "requires": { - "hoek": "2.16.3" + "safe-buffer": "^5.0.1" } }, "brace-expansion": { @@ -565,5114 +24,246 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", - "dev": true - }, - "browser-pack": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", - "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", - "dev": true, - "requires": { - "JSONStream": "1.3.3", - "combine-source-map": "0.8.0", - "defined": "1.0.0", - "safe-buffer": "5.1.2", - "through2": "2.0.3", - "umd": "3.0.3" - } - }, - "browser-resolve": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", - "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", - "dev": true, - "requires": { - "resolve": "1.1.7" - }, - "dependencies": { - "resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true - } - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "browserify": { - "version": "15.2.0", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-15.2.0.tgz", - "integrity": "sha512-IHYyFPm2XjJCL+VV0ZtFv8wn/sAHVOm83q3yfSn8YWbZ9jcybgPKxSDdiuMU+35jUL1914l74RnXXPD9Iyo9yg==", - "dev": true, - "requires": { - "JSONStream": "1.3.3", - "assert": "1.4.1", - "browser-pack": "6.1.0", - "browser-resolve": "1.11.3", - "browserify-zlib": "0.2.0", - "buffer": "5.1.0", - "cached-path-relative": "1.0.1", - "concat-stream": "1.5.2", - "console-browserify": "1.1.0", - "constants-browserify": "1.0.0", - "crypto-browserify": "3.12.0", - "defined": "1.0.0", - "deps-sort": "2.0.0", - "domain-browser": "1.1.7", - "duplexer2": "0.1.4", - "events": "1.1.1", - "glob": "7.1.2", - "has": "1.0.3", - "htmlescape": "1.1.1", - "https-browserify": "1.0.0", - "inherits": "2.0.3", - "insert-module-globals": "7.2.0", - "labeled-stream-splicer": "2.0.1", - "mkdirp": "0.5.1", - "module-deps": "5.0.1", - "os-browserify": "0.3.0", - "parents": "1.0.1", - "path-browserify": "0.0.1", - "process": "0.11.10", - "punycode": "1.4.1", - "querystring-es3": "0.2.1", - "read-only-stream": "2.0.0", - "readable-stream": "2.3.6", - "resolve": "1.8.1", - "shasum": "1.0.2", - "shell-quote": "1.6.1", - "stream-browserify": "2.0.1", - "stream-http": "2.8.3", - "string_decoder": "1.0.3", - "subarg": "1.0.0", - "syntax-error": "1.4.0", - "through2": "2.0.3", - "timers-browserify": "1.4.2", - "tty-browserify": "0.0.1", - "url": "0.11.0", - "util": "0.10.4", - "vm-browserify": "0.0.4", - "xtend": "4.0.1" - } - }, - "browserify-aes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", - "dev": true, - "requires": { - "buffer-xor": "1.0.3", - "cipher-base": "1.0.4", - "create-hash": "1.2.0", - "evp_bytestokey": "1.0.3", - "inherits": "2.0.3", - "safe-buffer": "5.1.2" - } - }, - "browserify-cipher": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", - "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", - "dev": true, - "requires": { - "browserify-aes": "1.2.0", - "browserify-des": "1.0.2", - "evp_bytestokey": "1.0.3" - } - }, - "browserify-des": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", - "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", - "dev": true, - "requires": { - "cipher-base": "1.0.4", - "des.js": "1.0.0", - "inherits": "2.0.3", - "safe-buffer": "5.1.2" - } - }, - "browserify-rsa": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", - "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "randombytes": "2.0.6" - } - }, - "browserify-sign": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", - "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "elliptic": "6.4.0", - "inherits": "2.0.3", - "parse-asn1": "5.1.1" - } - }, - "browserify-zlib": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", - "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", - "dev": true, - "requires": { - "pako": "1.0.6" - } - }, - "buffer": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.1.0.tgz", - "integrity": "sha512-YkIRgwsZwJWTnyQrsBTWefizHh+8GYj3kbL1BTiAQ/9pwpino0G7B2gp5tx/FUBqUlvtxV85KNR3mwfAtv15Yw==", - "dev": true, - "requires": { - "base64-js": "1.3.0", - "ieee754": "1.1.12" - } - }, - "buffer-from": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz", - "integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==", - "dev": true - }, - "buffer-more-ints": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/buffer-more-ints/-/buffer-more-ints-0.0.2.tgz", - "integrity": "sha1-JrOIXRD6E9t/wBquOquHAZngEkw=", - "dev": true - }, - "buffer-xor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", - "dev": true - }, - "buildmail": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/buildmail/-/buildmail-4.0.1.tgz", - "integrity": "sha1-h393OLeHKYccmhBeO4N9K+EaenI=", - "dev": true, - "optional": true, - "requires": { - "addressparser": "1.0.1", - "libbase64": "0.1.0", - "libmime": "3.0.0", - "libqp": "1.1.0", - "nodemailer-fetch": "1.6.0", - "nodemailer-shared": "1.1.0", - "punycode": "1.4.1" - } - }, - "builtin-status-codes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", - "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", - "dev": true - }, - "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", - "dev": true - }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "requires": { - "collection-visit": "1.0.0", - "component-emitter": "1.2.1", - "get-value": "2.0.6", - "has-value": "1.0.0", - "isobject": "3.0.1", - "set-value": "2.0.0", - "to-object-path": "0.3.0", - "union-value": "1.0.0", - "unset-value": "1.0.0" - } - }, - "cached-path-relative": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz", - "integrity": "sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc=", - "dev": true - }, - "callsite": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", - "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=", - "dev": true - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true, - "optional": true - }, - "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", - "dev": true, - "requires": { - "assertion-error": "1.1.0", - "check-error": "1.0.2", - "deep-eql": "3.0.1", - "get-func-name": "2.0.0", - "pathval": "1.1.0", - "type-detect": "4.0.8" - } - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "optional": true, - "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" - } - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, - "chokidar": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz", - "integrity": "sha512-z9n7yt9rOvIJrMhvDtDictKrkFHeihkNl6uWMmZlmL6tJtX9Cs+87oK+teBx+JIgzvbX3yZHT3eF8vpbDxHJXQ==", - "dev": true, - "requires": { - "anymatch": "2.0.0", - "async-each": "1.0.1", - "braces": "2.3.2", - "fsevents": "1.2.4", - "glob-parent": "3.1.0", - "inherits": "2.0.3", - "is-binary-path": "1.0.1", - "is-glob": "4.0.0", - "lodash.debounce": "4.0.8", - "normalize-path": "2.1.1", - "path-is-absolute": "1.0.1", - "readdirp": "2.1.0", - "upath": "1.1.0" - } - }, - "cipher-base": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", - "dev": true, - "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.2" - } - }, - "circular-json": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.5.tgz", - "integrity": "sha512-13YaR6kiz0kBNmIVM87Io8Hp7bWOo4r61vkEANy8iH9R9bc6avud/1FT0SBpqR1RpIQADOh/Q+yHZDA1iL6ysA==", - "dev": true - }, - "class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, - "requires": { - "arr-union": "3.1.0", - "define-property": "0.2.5", - "isobject": "3.0.1", - "static-extend": "0.1.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - } - } - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true, - "optional": true - }, - "collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, - "requires": { - "map-visit": "1.0.0", - "object-visit": "1.0.1" - } - }, - "colors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.0.tgz", - "integrity": "sha512-EDpX3a7wHMWFA7PUHWPHNWqOxIIRSJetuwl0AS5Oi/5FMV8kWm69RTlgm00GKjBO1xFHMtBbL49yRtMMdticBw==", - "dev": true - }, - "combine-lists": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/combine-lists/-/combine-lists-1.0.1.tgz", - "integrity": "sha1-RYwH4J4NkA/Ci3Cj/sLazR0st/Y=", - "dev": true, - "requires": { - "lodash": "4.17.10" - } - }, - "combine-source-map": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", - "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", - "dev": true, - "requires": { - "convert-source-map": "1.1.3", - "inline-source-map": "0.6.2", - "lodash.memoize": "3.0.4", - "source-map": "0.5.7" - } - }, - "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", - "dev": true, - "requires": { - "delayed-stream": "1.0.0" - } - }, - "commander": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.16.0.tgz", - "integrity": "sha512-sVXqklSaotK9at437sFlFpyOcJonxe0yST/AG9DkQKUdIE6IqGIMv4SfAQSKaJbSdVEJYItASCrBiVQHq1HQew==", - "dev": true - }, - "component-bind": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", - "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=", - "dev": true - }, - "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", - "dev": true - }, - "component-inherit": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", - "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "concat-stream": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", - "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.0.6", - "typedarray": "0.0.6" - }, - "dependencies": { - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", - "util-deprecate": "1.0.2" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } - }, - "connect": { - "version": "3.6.6", - "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.6.tgz", - "integrity": "sha1-Ce/2xVr3I24TcTWnJXSFi2eG9SQ=", - "dev": true, - "requires": { - "debug": "2.6.9", - "finalhandler": "1.1.0", - "parseurl": "1.3.2", - "utils-merge": "1.0.1" - } - }, - "console-browserify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", - "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", - "dev": true, - "requires": { - "date-now": "0.1.4" - } - }, - "constants-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", - "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", - "dev": true - }, - "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", - "dev": true - }, - "convert-source-map": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", - "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", - "dev": true - }, - "cookie": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", - "dev": true - }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true - }, - "core-js": { - "version": "2.5.7", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", - "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==", - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "create-ecdh": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", - "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "elliptic": "6.4.0" - } - }, - "create-hash": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", - "dev": true, - "requires": { - "cipher-base": "1.0.4", - "inherits": "2.0.3", - "md5.js": "1.3.4", - "ripemd160": "2.0.2", - "sha.js": "2.4.11" - } - }, - "create-hmac": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", - "dev": true, - "requires": { - "cipher-base": "1.0.4", - "create-hash": "1.2.0", - "inherits": "2.0.3", - "ripemd160": "2.0.2", - "safe-buffer": "5.1.2", - "sha.js": "2.4.11" - } - }, - "cryptiles": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "dev": true, - "optional": true, - "requires": { - "boom": "2.10.1" - } - }, - "crypto-browserify": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", - "dev": true, - "requires": { - "browserify-cipher": "1.0.1", - "browserify-sign": "4.0.4", - "create-ecdh": "4.0.3", - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "diffie-hellman": "5.0.3", - "inherits": "2.0.3", - "pbkdf2": "3.0.16", - "public-encrypt": "4.0.2", - "randombytes": "2.0.6", - "randomfill": "1.0.4" - } - }, - "custom-event": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", - "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", - "dev": true - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - } - }, - "data-uri-to-buffer": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz", - "integrity": "sha512-vKQ9DTQPN1FLYiiEEOQ6IBGFqvjCa5rSK3cWMy/Nespm5d/x3dGFT9UBZnkLxCwua/IXBi2TYnwTEpsOvhC4UQ==", - "dev": true, - "optional": true - }, - "date-format": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-1.2.0.tgz", - "integrity": "sha1-YV6CjiM90aubua4JUODOzPpuytg=", - "dev": true - }, - "date-now": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", - "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", - "dev": true - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true - }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "requires": { - "type-detect": "4.0.8" - } - }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", - "dev": true, - "optional": true - }, - "define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "requires": { - "is-descriptor": "1.0.2", - "isobject": "3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - } - } - }, - "defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true - }, - "degenerator": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-1.0.4.tgz", - "integrity": "sha1-/PSQo37OJmRk2cxDGrmMWBnO0JU=", - "dev": true, - "optional": true, - "requires": { - "ast-types": "0.11.5", - "escodegen": "1.11.0", - "esprima": "3.1.3" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", - "dev": true - }, - "deps-sort": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz", - "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", - "dev": true, - "requires": { - "JSONStream": "1.3.3", - "shasum": "1.0.2", - "subarg": "1.0.0", - "through2": "2.0.3" - } - }, - "des.js": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", - "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" - } - }, - "detective": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-5.1.0.tgz", - "integrity": "sha512-TFHMqfOvxlgrfVzTEkNBSh9SvSNX/HfF4OFI2QFGCyPm02EsyILqnUeb5P6q7JZ3SFNTBL5t2sePRgrN4epUWQ==", - "dev": true, - "requires": { - "acorn-node": "1.5.2", - "defined": "1.0.0", - "minimist": "1.2.0" - } - }, - "di": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", - "integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=", - "dev": true - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "diffie-hellman": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", - "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "miller-rabin": "4.0.1", - "randombytes": "2.0.6" - } - }, - "dom-serialize": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", - "integrity": "sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=", - "dev": true, - "requires": { - "custom-event": "1.0.1", - "ent": "2.2.0", - "extend": "3.0.1", - "void-elements": "2.0.1" - } - }, - "domain-browser": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", - "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", - "dev": true - }, - "double-ended-queue": { - "version": "2.1.0-0", - "resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz", - "integrity": "sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw=", - "dev": true, - "optional": true - }, - "duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", - "dev": true, - "requires": { - "readable-stream": "2.3.6" - } - }, - "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "dev": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", - "dev": true - }, - "elliptic": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", - "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0", - "hash.js": "1.1.5", - "hmac-drbg": "1.0.1", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1", - "minimalistic-crypto-utils": "1.0.1" - } - }, - "encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", - "dev": true - }, - "engine.io": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.1.5.tgz", - "integrity": "sha512-D06ivJkYxyRrcEe0bTpNnBQNgP9d3xog+qZlLbui8EsMr/DouQpf5o9FzJnWYHEYE0YsFHllUv2R1dkgYZXHcA==", - "dev": true, - "requires": { - "accepts": "1.3.5", - "base64id": "1.0.0", - "cookie": "0.3.1", - "debug": "3.1.0", - "engine.io-parser": "2.1.2", - "uws": "9.14.0", - "ws": "3.3.3" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "engine.io-client": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.1.6.tgz", - "integrity": "sha512-hnuHsFluXnsKOndS4Hv6SvUrgdYx1pk2NqfaDMW+GWdgfU3+/V25Cj7I8a0x92idSpa5PIhJRKxPvp9mnoLsfg==", - "dev": true, - "requires": { - "component-emitter": "1.2.1", - "component-inherit": "0.0.3", - "debug": "3.1.0", - "engine.io-parser": "2.1.2", - "has-cors": "1.1.0", - "indexof": "0.0.1", - "parseqs": "0.0.5", - "parseuri": "0.0.5", - "ws": "3.3.3", - "xmlhttprequest-ssl": "1.5.5", - "yeast": "0.1.2" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "engine.io-parser": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.2.tgz", - "integrity": "sha512-dInLFzr80RijZ1rGpx1+56/uFoH7/7InhH3kZt+Ms6hT8tNx3NGW/WNSA/f8As1WkOfkuyb3tnRyuXGxusclMw==", - "dev": true, - "requires": { - "after": "0.8.2", - "arraybuffer.slice": "0.0.7", - "base64-arraybuffer": "0.1.5", - "blob": "0.0.4", - "has-binary2": "1.0.3" - } - }, - "ent": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", - "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=", - "dev": true - }, - "es6-promise": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", - "dev": true - }, - "es6-promisify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", - "dev": true, - "requires": { - "es6-promise": "4.2.4" - } - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "escodegen": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.11.0.tgz", - "integrity": "sha512-IeMV45ReixHS53K/OmfKAIztN/igDHzTJUhZM3k1jMhIZWjk45SMwAtBsEXiJp3vSPmTcu6CXn7mDvFHRN66fw==", - "dev": true, - "optional": true, - "requires": { - "esprima": "3.1.3", - "estraverse": "4.2.0", - "esutils": "2.0.2", - "optionator": "0.8.2", - "source-map": "0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true - } - } - }, - "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", - "dev": true - }, - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true, - "optional": true - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true, - "optional": true - }, - "eventemitter3": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz", - "integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==", - "dev": true - }, - "events": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", - "dev": true - }, - "evp_bytestokey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", - "dev": true, - "requires": { - "md5.js": "1.3.4", - "safe-buffer": "5.1.2" - } - }, - "expand-braces": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/expand-braces/-/expand-braces-0.1.2.tgz", - "integrity": "sha1-SIsdHSRRyz06axks/AMPRMWFX+o=", - "dev": true, - "requires": { - "array-slice": "0.2.3", - "array-unique": "0.2.1", - "braces": "0.1.5" - }, - "dependencies": { - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, - "braces": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-0.1.5.tgz", - "integrity": "sha1-wIVxEIUpHYt1/ddOqw+FlygHEeY=", - "dev": true, - "requires": { - "expand-range": "0.1.1" - } - } - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "expand-range": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-0.1.1.tgz", - "integrity": "sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ=", - "dev": true, - "requires": { - "is-number": "0.1.1", - "repeat-string": "0.2.2" - }, - "dependencies": { - "is-number": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-0.1.1.tgz", - "integrity": "sha1-aaevEWlj1HIG7JvZtIoUIW8eOAY=", - "dev": true - }, - "repeat-string": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-0.2.2.tgz", - "integrity": "sha1-x6jTI2BoNiBZp+RlH8aITosftK4=", - "dev": true - } - } - }, - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", - "dev": true - }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "requires": { - "assign-symbols": "1.0.0", - "is-extendable": "1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "2.0.4" - } - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - } - } - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true - }, - "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", - "dev": true, - "optional": true - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", - "dev": true, - "optional": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true, - "optional": true - }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "dev": true, - "optional": true - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "finalhandler": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", - "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", - "dev": true, - "requires": { - "debug": "2.6.9", - "encodeurl": "1.0.2", - "escape-html": "1.0.3", - "on-finished": "2.3.0", - "parseurl": "1.3.2", - "statuses": "1.3.1", - "unpipe": "1.0.0" - }, - "dependencies": { - "statuses": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", - "dev": true - } - } - }, - "follow-redirects": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.1.tgz", - "integrity": "sha512-v9GI1hpaqq1ZZR6pBD1+kI7O24PhDvNGNodjS3MdcEqyrahCp8zbtpv+2B/krUnSmUH80lbAS7MrdeK5IylgKg==", - "dev": true, - "requires": { - "debug": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true, - "optional": true - }, - "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", - "dev": true, - "optional": true, - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.6", - "mime-types": "2.1.19" - } - }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, - "requires": { - "map-cache": "0.2.2" - } - }, - "fs-access": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", - "integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", - "dev": true, - "requires": { - "null-check": "1.0.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "fsevents": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz", - "integrity": "sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==", - "dev": true, - "optional": true, - "requires": { - "nan": "2.10.0", - "node-pre-gyp": "0.10.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "delegates": "1.0.0", - "readable-stream": "2.3.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } - }, - "chownr": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "dev": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "debug": { - "version": "2.6.9", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "optional": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "2.2.4" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aproba": "1.2.0", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" - } - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "iconv-lite": { - "version": "0.4.21", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safer-buffer": "2.1.2" - } - }, - "ignore-walk": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minimatch": "3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "dev": true - }, - "ini": { - "version": "1.3.5", - "bundled": true, - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "dev": true, - "requires": { - "brace-expansion": "1.1.11" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true - }, - "minipass": { - "version": "2.2.4", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.1.1", - "yallist": "3.0.2" - } - }, - "minizlib": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "2.2.4" - } - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "needle": { - "version": "2.2.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "debug": "2.6.9", - "iconv-lite": "0.4.21", - "sax": "1.2.4" - } - }, - "node-pre-gyp": { - "version": "0.10.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "detect-libc": "1.0.3", - "mkdirp": "0.5.1", - "needle": "2.2.0", - "nopt": "4.0.1", - "npm-packlist": "1.1.10", - "npmlog": "4.1.2", - "rc": "1.2.7", - "rimraf": "2.6.2", - "semver": "5.5.0", - "tar": "4.4.1" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "abbrev": "1.1.1", - "osenv": "0.1.5" - } - }, - "npm-bundled": { - "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "npm-packlist": { - "version": "1.1.10", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ignore-walk": "3.0.1", - "npm-bundled": "1.0.3" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.7", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "deep-extend": "0.5.1", - "ini": "1.3.5", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.1", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" - } - }, - "rimraf": { - "version": "2.6.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "glob": "7.1.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "bundled": true, - "dev": true - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "sax": { - "version": "1.2.4", - "bundled": true, - "dev": true, - "optional": true - }, - "semver": { - "version": "5.5.0", - "bundled": true, - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "tar": { - "version": "4.4.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "chownr": "1.0.1", - "fs-minipass": "1.2.5", - "minipass": "2.2.4", - "minizlib": "1.1.0", - "mkdirp": "0.5.1", - "safe-buffer": "5.1.1", - "yallist": "3.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "wide-align": { - "version": "1.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "string-width": "1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "yallist": { - "version": "3.0.2", - "bundled": true, - "dev": true - } - } - }, - "ftp": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", - "integrity": "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=", - "dev": true, - "optional": true, - "requires": { - "readable-stream": "1.1.14", - "xregexp": "2.0.0" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true - } - } - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "generate-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", - "dev": true, - "optional": true - }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "dev": true, - "optional": true, - "requires": { - "is-property": "1.0.2" - } - }, - "get-assigned-identifiers": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", - "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", - "dev": true - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, - "get-uri": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-2.0.2.tgz", - "integrity": "sha512-ZD325dMZOgerGqF/rF6vZXyFGTAay62svjQIT+X/oU2PtxYpFxvSkbsdi+oxIrsNxlZVd4y8wUDqkaExWTI/Cw==", - "dev": true, - "optional": true, - "requires": { - "data-uri-to-buffer": "1.2.0", - "debug": "2.6.9", - "extend": "3.0.1", - "file-uri-to-path": "1.0.0", - "ftp": "0.3.10", - "readable-stream": "2.3.6" - } - }, - "get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - } - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "dev": true, - "requires": { - "is-glob": "3.1.0", - "path-dirname": "1.0.2" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "2.1.1" - } - } - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true, - "optional": true - }, - "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", - "dev": true, - "optional": true, - "requires": { - "ajv": "5.5.2", - "har-schema": "2.0.0" - } - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "1.1.1" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "optional": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "has-binary2": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", - "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", - "dev": true, - "requires": { - "isarray": "2.0.1" - }, - "dependencies": { - "isarray": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", - "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=", - "dev": true - } - } - }, - "has-cors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", - "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "requires": { - "get-value": "2.0.6", - "has-values": "1.0.0", - "isobject": "3.0.1" - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "hash-base": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", - "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.2" - } - }, - "hash.js": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz", - "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==", - "dev": true, - "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" - } - }, - "hawk": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "dev": true, - "optional": true, - "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" - } - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, - "hipchat-notifier": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/hipchat-notifier/-/hipchat-notifier-1.1.0.tgz", - "integrity": "sha1-ttJJdVQ3wZEII2d5nTupoPI7Ix4=", - "dev": true, - "optional": true, - "requires": { - "lodash": "4.17.10", - "request": "2.87.0" - } - }, - "hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", - "dev": true, - "requires": { - "hash.js": "1.1.5", - "minimalistic-assert": "1.0.1", - "minimalistic-crypto-utils": "1.0.1" - } - }, - "hoek": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true - }, - "htmlescape": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", - "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", - "dev": true - }, - "http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", - "dev": true, - "requires": { - "depd": "1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": "1.5.0" - } - }, - "http-proxy": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.17.0.tgz", - "integrity": "sha512-Taqn+3nNvYRfJ3bGvKfBSRwy1v6eePlm3oc/aWVxZp57DQr5Eq3xhKJi7Z4hZpS8PC3H4qI+Yly5EmFacGuA/g==", - "dev": true, - "requires": { - "eventemitter3": "3.1.0", - "follow-redirects": "1.5.1", - "requires-port": "1.0.0" - } - }, - "http-proxy-agent": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", - "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", - "dev": true, - "requires": { - "agent-base": "4.2.1", - "debug": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.14.2" - } - }, - "httpntlm": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.6.1.tgz", - "integrity": "sha1-rQFScUOi6Hc8+uapb1hla7UqNLI=", - "dev": true, - "requires": { - "httpreq": "0.4.24", - "underscore": "1.7.0" - } - }, - "httpreq": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz", - "integrity": "sha1-QzX/2CzZaWaKOUZckprGHWOTYn8=", - "dev": true - }, - "https-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", - "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", - "dev": true - }, - "https-proxy-agent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", - "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", - "dev": true, - "requires": { - "agent-base": "4.2.1", - "debug": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", - "dev": true, - "requires": { - "safer-buffer": "2.1.2" - } - }, - "ieee754": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", - "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==", - "dev": true - }, - "indexof": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", - "dev": true - }, - "inflection": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.12.0.tgz", - "integrity": "sha1-ogCTVlbW9fa8TcdQLhrstwMihBY=", - "dev": true, - "optional": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "inline-source-map": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", - "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", - "dev": true, - "requires": { - "source-map": "0.5.7" - } - }, - "insert-module-globals": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", - "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", - "dev": true, - "requires": { - "JSONStream": "1.3.3", - "acorn-node": "1.5.2", - "combine-source-map": "0.8.0", - "concat-stream": "1.6.2", - "is-buffer": "1.1.6", - "path-is-absolute": "1.0.1", - "process": "0.11.10", - "through2": "2.0.3", - "undeclared-identifiers": "1.1.2", - "xtend": "4.0.1" - }, - "dependencies": { - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "1.1.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "typedarray": "0.0.6" - } - } - } - }, - "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", - "dev": true - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", - "dev": true, - "requires": { - "binary-extensions": "1.11.0" - } - }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-glob": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", - "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", - "dev": true, - "requires": { - "is-extglob": "2.1.1" - } - }, - "is-my-ip-valid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz", - "integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ==", - "dev": true, - "optional": true - }, - "is-my-json-valid": { - "version": "2.17.2", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz", - "integrity": "sha512-IBhBslgngMQN8DDSppmgDv7RNrlFotuuDsKcrCP3+HbFaVivIBU7u9oiiErw8sH4ynx3+gOGQ3q2otkgiSi6kg==", - "dev": true, - "optional": true, - "requires": { - "generate-function": "2.0.0", - "generate-object-property": "1.2.0", - "is-my-ip-valid": "1.0.0", - "jsonpointer": "4.0.1", - "xtend": "4.0.1" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "requires": { - "isobject": "3.0.1" - } - }, - "is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", - "dev": true, - "optional": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true, - "optional": true - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true, - "optional": true - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isbinaryfile": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-3.0.2.tgz", - "integrity": "sha1-Sj6XTsDLqQBNP8bN5yCeppNopiE=", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "dev": true, - "optional": true - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", - "dev": true, - "optional": true - }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true, - "optional": true - }, - "json-stable-stringify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", - "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", - "dev": true, - "requires": { - "jsonify": "0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true - }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true - }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", - "dev": true, - "optional": true - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, - "jssha": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/jssha/-/jssha-2.3.1.tgz", - "integrity": "sha1-FHshJTaQNcpLL30hDcU58Amz3po=" - }, - "karma": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/karma/-/karma-2.0.4.tgz", - "integrity": "sha512-32yhTwoi6BZgJZhR78GwhzyFABbYG/1WwQqYgY7Vh96Demvua2jM3+FyRltIMTUH/Kd5xaQvDw2L7jTvkYFeXg==", - "dev": true, - "requires": { - "bluebird": "3.5.1", - "body-parser": "1.18.3", - "chokidar": "2.0.4", - "colors": "1.3.0", - "combine-lists": "1.0.1", - "connect": "3.6.6", - "core-js": "2.5.7", - "di": "0.0.1", - "dom-serialize": "2.2.1", - "expand-braces": "0.1.2", - "glob": "7.1.2", - "graceful-fs": "4.1.11", - "http-proxy": "1.17.0", - "isbinaryfile": "3.0.2", - "lodash": "4.17.10", - "log4js": "2.11.0", - "mime": "1.6.0", - "minimatch": "3.0.4", - "optimist": "0.6.1", - "qjobs": "1.2.0", - "range-parser": "1.2.0", - "rimraf": "2.6.2", - "safe-buffer": "5.1.2", - "socket.io": "2.0.4", - "source-map": "0.6.1", - "tmp": "0.0.33", - "useragent": "2.2.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "karma-chai": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/karma-chai/-/karma-chai-0.1.0.tgz", - "integrity": "sha1-vuWtQEAFF4Ea40u5RfdikJEIt5o=", - "dev": true - }, - "karma-chrome-launcher": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz", - "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==", - "dev": true, - "requires": { - "fs-access": "1.0.1", - "which": "1.3.1" - } - }, - "karma-mocha": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-1.3.0.tgz", - "integrity": "sha1-7qrH/8DiAetjxGdEDStpx883eL8=", - "dev": true, - "requires": { - "minimist": "1.2.0" - } - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, - "labeled-stream-splicer": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz", - "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", - "dev": true, - "requires": { - "inherits": "2.0.3", - "isarray": "2.0.4", - "stream-splicer": "2.0.0" - }, - "dependencies": { - "isarray": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz", - "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==", - "dev": true - } - } - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "optional": true, - "requires": { - "prelude-ls": "1.1.2", - "type-check": "0.3.2" - } - }, - "libbase64": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/libbase64/-/libbase64-0.1.0.tgz", - "integrity": "sha1-YjUag5VjrF/1vSbxL2Dpgwu3UeY=", - "dev": true - }, - "libmime": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/libmime/-/libmime-3.0.0.tgz", - "integrity": "sha1-UaGp50SOy9Ms2lRCFnW7IbwJPaY=", - "dev": true, - "requires": { - "iconv-lite": "0.4.15", - "libbase64": "0.1.0", - "libqp": "1.1.0" - }, - "dependencies": { - "iconv-lite": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", - "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=", - "dev": true - } - } - }, - "libqp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/libqp/-/libqp-1.1.0.tgz", - "integrity": "sha1-9ebgatdLeU+1tbZpiL9yjvHe2+g=", - "dev": true - }, - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true - }, - "lodash.debounce": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", - "dev": true - }, - "lodash.memoize": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", - "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", - "dev": true - }, - "log4js": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-2.11.0.tgz", - "integrity": "sha512-z1XdwyGFg8/WGkOyF6DPJjivCWNLKrklGdViywdYnSKOvgtEBo2UyEMZS5sD2mZrQlU3TvO8wDWLc8mzE1ncBQ==", - "dev": true, - "requires": { - "amqplib": "0.5.2", - "axios": "0.15.3", - "circular-json": "0.5.5", - "date-format": "1.2.0", - "debug": "3.1.0", - "hipchat-notifier": "1.1.0", - "loggly": "1.1.1", - "mailgun-js": "0.18.1", - "nodemailer": "2.7.2", - "redis": "2.8.0", - "semver": "5.5.0", - "slack-node": "0.2.0", - "streamroller": "0.7.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "loggly": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/loggly/-/loggly-1.1.1.tgz", - "integrity": "sha1-Cg/B0/o6XsRP3HuJe+uipGlc6+4=", - "dev": true, - "optional": true, - "requires": { - "json-stringify-safe": "5.0.1", - "request": "2.75.0", - "timespan": "2.3.0" - }, - "dependencies": { - "assert-plus": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", - "dev": true, - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "dev": true, - "optional": true - }, - "caseless": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", - "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", - "dev": true, - "optional": true - }, - "form-data": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.0.0.tgz", - "integrity": "sha1-bwrrrcxdoWwT4ezBETfYX5uIOyU=", - "dev": true, - "optional": true, - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.6", - "mime-types": "2.1.19" - } - }, - "har-validator": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", - "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", - "dev": true, - "optional": true, - "requires": { - "chalk": "1.1.3", - "commander": "2.16.0", - "is-my-json-valid": "2.17.2", - "pinkie-promise": "2.0.1" - } - }, - "http-signature": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.1", - "sshpk": "1.14.2" - } - }, - "node-uuid": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", - "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=", - "dev": true, - "optional": true - }, - "qs": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.2.3.tgz", - "integrity": "sha1-HPyyXBCpsrSDBT/zn138kjOQjP4=", - "dev": true, - "optional": true - }, - "request": { - "version": "2.75.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.75.0.tgz", - "integrity": "sha1-0rgmiihtoT6qXQGt9dGMyQ9lfZM=", - "dev": true, - "optional": true, - "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.7.0", - "bl": "1.1.2", - "caseless": "0.11.0", - "combined-stream": "1.0.6", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.0.0", - "har-validator": "2.0.6", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.19", - "node-uuid": "1.4.8", - "oauth-sign": "0.8.2", - "qs": "6.2.3", - "stringstream": "0.0.6", - "tough-cookie": "2.3.4", - "tunnel-agent": "0.4.3" - } - }, - "tunnel-agent": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", - "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", - "dev": true, - "optional": true - } - } - }, - "lru-cache": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", - "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", - "dev": true, - "optional": true, - "requires": { - "pseudomap": "1.0.2", - "yallist": "2.1.2" - } - }, - "mailcomposer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/mailcomposer/-/mailcomposer-4.0.1.tgz", - "integrity": "sha1-DhxEsqB890DuF9wUm6AJ8Zyt/rQ=", - "dev": true, - "optional": true, - "requires": { - "buildmail": "4.0.1", - "libmime": "3.0.0" - } - }, - "mailgun-js": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/mailgun-js/-/mailgun-js-0.18.1.tgz", - "integrity": "sha512-lvuMP14u24HS2uBsJEnzSyPMxzU2b99tQsIx1o6QNjqxjk8b3WvR+vq5oG1mjqz/IBYo+5gF+uSoDS0RkMVHmg==", - "dev": true, - "optional": true, - "requires": { - "async": "2.6.1", - "debug": "3.1.0", - "form-data": "2.3.2", - "inflection": "1.12.0", - "is-stream": "1.1.0", - "path-proxy": "1.0.0", - "promisify-call": "2.0.4", - "proxy-agent": "3.0.1", - "tsscmp": "1.0.5" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "requires": { - "object-visit": "1.0.1" - } - }, - "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", - "dev": true, - "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" - } - }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.13", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - } - }, - "miller-rabin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0" - } - }, - "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true - }, - "mime-db": { - "version": "1.35.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", - "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==", - "dev": true - }, - "mime-types": { - "version": "2.1.19", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", - "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", - "dev": true, - "requires": { - "mime-db": "1.35.0" - } - }, - "minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "dev": true - }, - "minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.11" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", - "dev": true, - "requires": { - "for-in": "1.0.2", - "is-extendable": "1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "2.0.4" - } - } - } - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } - } - }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "dev": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - }, - "dependencies": { - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "requires": { - "has-flag": "3.0.0" - } - } - } - }, - "module-deps": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-5.0.1.tgz", - "integrity": "sha512-sigq/hm/L+Z5IGi1DDl0x2ptkw7S86aFh213QhPLD8v9Opv90IHzKIuWJrRa5bJ77DVKHco2CfIEuThcT/vDJA==", - "dev": true, - "requires": { - "JSONStream": "1.3.3", - "browser-resolve": "1.11.3", - "cached-path-relative": "1.0.1", - "concat-stream": "1.6.2", - "defined": "1.0.0", - "detective": "5.1.0", - "duplexer2": "0.1.4", - "inherits": "2.0.3", - "parents": "1.0.1", - "readable-stream": "2.3.6", - "resolve": "1.8.1", - "stream-combiner2": "1.1.1", - "subarg": "1.0.0", - "through2": "2.0.3", - "xtend": "4.0.1" - }, - "dependencies": { - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "1.1.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "typedarray": "0.0.6" - } - } - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", - "dev": true, - "optional": true - }, - "nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "dev": true, - "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "fragment-cache": "0.2.1", - "is-windows": "1.0.2", - "kind-of": "6.0.2", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - } - }, - "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", - "dev": true - }, - "netmask": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/netmask/-/netmask-1.0.6.tgz", - "integrity": "sha1-ICl+idhvb2QA8lDZ9Pa0wZRfzTU=", - "dev": true, - "optional": true - }, - "nodemailer": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-2.7.2.tgz", - "integrity": "sha1-8kLmSa7q45tsftdA73sGHEBNMPk=", - "dev": true, - "optional": true, - "requires": { - "libmime": "3.0.0", - "mailcomposer": "4.0.1", - "nodemailer-direct-transport": "3.3.2", - "nodemailer-shared": "1.1.0", - "nodemailer-smtp-pool": "2.8.2", - "nodemailer-smtp-transport": "2.7.2", - "socks": "1.1.9" - }, - "dependencies": { - "socks": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/socks/-/socks-1.1.9.tgz", - "integrity": "sha1-Yo1+TQSRJDVEWsC25Fk3bLPm1pE=", - "dev": true, - "optional": true, - "requires": { - "ip": "1.1.5", - "smart-buffer": "1.1.15" - } - } - } - }, - "nodemailer-direct-transport": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/nodemailer-direct-transport/-/nodemailer-direct-transport-3.3.2.tgz", - "integrity": "sha1-6W+vuQNYVglH5WkBfZfmBzilCoY=", - "dev": true, - "optional": true, - "requires": { - "nodemailer-shared": "1.1.0", - "smtp-connection": "2.12.0" - } - }, - "nodemailer-fetch": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/nodemailer-fetch/-/nodemailer-fetch-1.6.0.tgz", - "integrity": "sha1-ecSQihwPXzdbc/6IjamCj23JY6Q=", - "dev": true - }, - "nodemailer-shared": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/nodemailer-shared/-/nodemailer-shared-1.1.0.tgz", - "integrity": "sha1-z1mU4v0mjQD1zw+nZ6CBae2wfsA=", - "dev": true, - "requires": { - "nodemailer-fetch": "1.6.0" - } - }, - "nodemailer-smtp-pool": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/nodemailer-smtp-pool/-/nodemailer-smtp-pool-2.8.2.tgz", - "integrity": "sha1-LrlNbPhXgLG0clzoU7nL1ejajHI=", - "dev": true, - "optional": true, - "requires": { - "nodemailer-shared": "1.1.0", - "nodemailer-wellknown": "0.1.10", - "smtp-connection": "2.12.0" - } - }, - "nodemailer-smtp-transport": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/nodemailer-smtp-transport/-/nodemailer-smtp-transport-2.7.2.tgz", - "integrity": "sha1-A9ccdjFPFKx9vHvwM6am0W1n+3c=", - "dev": true, - "optional": true, - "requires": { - "nodemailer-shared": "1.1.0", - "nodemailer-wellknown": "0.1.10", - "smtp-connection": "2.12.0" - } - }, - "nodemailer-wellknown": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/nodemailer-wellknown/-/nodemailer-wellknown-0.1.10.tgz", - "integrity": "sha1-WG24EB2zDLRDjrVGc3pBqtDPE9U=", - "dev": true - }, - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "1.1.0" - } - }, - "null-check": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", - "integrity": "sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=", - "dev": true - }, - "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", - "dev": true, - "optional": true - }, - "object-component": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", - "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=", - "dev": true - }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "requires": { - "copy-descriptor": "0.1.1", - "define-property": "0.2.5", - "kind-of": "3.2.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "requires": { - "isobject": "3.0.1" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "requires": { - "isobject": "3.0.1" - } - }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "dev": true, - "requires": { - "ee-first": "1.1.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "optimist": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", - "dev": true, - "requires": { - "minimist": "0.0.10", - "wordwrap": "0.0.3" - }, - "dependencies": { - "minimist": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", - "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", - "dev": true - }, - "wordwrap": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", - "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", - "dev": true - } - } - }, - "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", - "dev": true, - "optional": true, - "requires": { - "deep-is": "0.1.3", - "fast-levenshtein": "2.0.6", - "levn": "0.3.0", - "prelude-ls": "1.1.2", - "type-check": "0.3.2", - "wordwrap": "1.0.0" - } - }, - "os-browserify": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", - "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", - "dev": true - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, - "pac-proxy-agent": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-2.0.2.tgz", - "integrity": "sha512-cDNAN1Ehjbf5EHkNY5qnRhGPUCp6SnpyVof5fRzN800QV1Y2OkzbH9rmjZkbBRa8igof903yOnjIl6z0SlAhxA==", - "dev": true, - "optional": true, - "requires": { - "agent-base": "4.2.1", - "debug": "3.1.0", - "get-uri": "2.0.2", - "http-proxy-agent": "2.1.0", - "https-proxy-agent": "2.2.1", - "pac-resolver": "3.0.0", - "raw-body": "2.3.3", - "socks-proxy-agent": "3.0.1" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "socks-proxy-agent": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-3.0.1.tgz", - "integrity": "sha512-ZwEDymm204mTzvdqyUqOdovVr2YRd2NYskrYrF2LXyZ9qDiMAoFESGK8CRphiO7rtbo2Y757k2Nia3x2hGtalA==", - "dev": true, - "optional": true, - "requires": { - "agent-base": "4.2.1", - "socks": "1.1.10" - } - } - } - }, - "pac-resolver": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-3.0.0.tgz", - "integrity": "sha512-tcc38bsjuE3XZ5+4vP96OfhOugrX+JcnpUbhfuc4LuXBLQhoTthOstZeoQJBDnQUDYzYmdImKsbz0xSl1/9qeA==", - "dev": true, - "optional": true, - "requires": { - "co": "4.6.0", - "degenerator": "1.0.4", - "ip": "1.1.5", - "netmask": "1.0.6", - "thunkify": "2.1.2" - } - }, - "pako": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==", - "dev": true - }, - "parents": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", - "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", - "dev": true, - "requires": { - "path-platform": "0.11.15" - } - }, - "parse-asn1": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", - "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", - "dev": true, - "requires": { - "asn1.js": "4.10.1", - "browserify-aes": "1.2.0", - "create-hash": "1.2.0", - "evp_bytestokey": "1.0.3", - "pbkdf2": "3.0.16" - } - }, - "parseqs": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", - "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", - "dev": true, - "requires": { - "better-assert": "1.0.2" - } - }, - "parseuri": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", - "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", - "dev": true, - "requires": { - "better-assert": "1.0.2" - } - }, - "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", - "dev": true - }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true - }, - "path-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", - "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", - "dev": true - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true - }, - "path-platform": { - "version": "0.11.15", - "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", - "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", - "dev": true - }, - "path-proxy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/path-proxy/-/path-proxy-1.0.0.tgz", - "integrity": "sha1-GOijaFn8nS8aU7SN7hOFQ8Ag3l4=", - "dev": true, - "optional": true, - "requires": { - "inflection": "1.3.8" - }, - "dependencies": { - "inflection": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.3.8.tgz", - "integrity": "sha1-y9Fg2p91sUw8xjV41POWeEvzAU4=", - "dev": true, - "optional": true - } - } - }, - "pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", - "dev": true - }, - "pbkdf2": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.16.tgz", - "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", - "dev": true, - "requires": { - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "ripemd160": "2.0.2", - "safe-buffer": "5.1.2", - "sha.js": "2.4.11" - } - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true, - "optional": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true, - "optional": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "optional": true, - "requires": { - "pinkie": "2.0.4" - } - }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true - }, - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", - "dev": true - }, - "promisify-call": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/promisify-call/-/promisify-call-2.0.4.tgz", - "integrity": "sha1-1IwtRWUszM1SgB3ey9UzptS9X7o=", - "dev": true, - "optional": true, - "requires": { - "with-callback": "1.0.2" - } - }, - "proxy-agent": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-3.0.1.tgz", - "integrity": "sha512-mAZexaz9ZxQhYPWfAjzlrloEjW+JHiBFryE4AJXFDTnaXfmH/FKqC1swTRKuEPbHWz02flQNXFOyDUF7zfEG6A==", - "dev": true, - "optional": true, - "requires": { - "agent-base": "4.2.1", - "debug": "3.1.0", - "http-proxy-agent": "2.1.0", - "https-proxy-agent": "2.2.1", - "lru-cache": "4.1.3", - "pac-proxy-agent": "2.0.2", - "proxy-from-env": "1.0.0", - "socks-proxy-agent": "4.0.1" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "proxy-from-env": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", - "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", - "dev": true, - "optional": true - }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", - "dev": true, - "optional": true - }, - "public-encrypt": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz", - "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.2.0", - "parse-asn1": "5.1.1", - "randombytes": "2.0.6" - } - }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true - }, - "qjobs": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", - "integrity": "sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg==", - "dev": true - }, - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", - "dev": true - }, - "querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true - }, - "querystring-es3": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", - "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", - "dev": true - }, - "randombytes": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", - "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } - }, - "randomfill": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", - "dev": true, - "requires": { - "randombytes": "2.0.6", - "safe-buffer": "5.1.2" - } - }, - "range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=", - "dev": true - }, - "raw-body": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", - "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", - "dev": true, - "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", - "unpipe": "1.0.0" - } - }, - "read-only-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", - "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", - "dev": true, - "requires": { - "readable-stream": "2.3.6" - } - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.2", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" - }, - "dependencies": { - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } - } - } - }, - "readdirp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "minimatch": "3.0.4", - "readable-stream": "2.3.6", - "set-immediate-shim": "1.0.1" - } - }, - "redis": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz", - "integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==", - "dev": true, - "optional": true, - "requires": { - "double-ended-queue": "2.1.0-0", - "redis-commands": "1.3.5", - "redis-parser": "2.6.0" - } - }, - "redis-commands": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.5.tgz", - "integrity": "sha512-foGF8u6MXGFF++1TZVC6icGXuMYPftKXt1FBT2vrfU9ZATNtZJ8duRC5d1lEfE8hyVe3jhelHGB91oB7I6qLsA==", - "dev": true, - "optional": true - }, - "redis-parser": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz", - "integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs=", - "dev": true, - "optional": true - }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "requires": { - "extend-shallow": "3.0.2", - "safe-regex": "1.1.0" - } - }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "request": { - "version": "2.87.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", - "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", - "dev": true, - "optional": true, - "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.7.0", - "caseless": "0.12.0", - "combined-stream": "1.0.6", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.2", - "har-validator": "5.0.3", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.19", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.2", - "safe-buffer": "5.1.2", - "tough-cookie": "2.3.4", - "tunnel-agent": "0.6.0", - "uuid": "3.3.2" - } - }, - "requestretry": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/requestretry/-/requestretry-1.13.0.tgz", - "integrity": "sha512-Lmh9qMvnQXADGAQxsXHP4rbgO6pffCfuR8XUBdP9aitJcLQJxhp7YZK4xAVYXnPJ5E52mwrfiKQtKonPL8xsmg==", - "dev": true, - "optional": true, - "requires": { - "extend": "3.0.1", - "lodash": "4.17.10", - "request": "2.87.0", - "when": "3.7.8" - } - }, - "requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", - "dev": true - }, - "resolve": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", - "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", - "dev": true, - "requires": { - "path-parse": "1.0.5" - } - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "dev": true, - "requires": { - "glob": "7.1.2" - } - }, - "ripemd160": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", - "dev": true, - "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "requires": { - "ret": "0.1.15" - } - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, - "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", - "dev": true - }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true - }, - "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "split-string": "3.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", - "dev": true - }, - "sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "dev": true, - "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.2" - } - }, - "shasum": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", - "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", - "dev": true, - "requires": { - "json-stable-stringify": "0.0.1", - "sha.js": "2.4.11" - } - }, - "shell-quote": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", - "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", - "dev": true, - "requires": { - "array-filter": "0.0.1", - "array-map": "0.0.0", - "array-reduce": "0.0.0", - "jsonify": "0.0.0" - } - }, - "simple-concat": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", - "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", - "dev": true - }, - "slack-node": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/slack-node/-/slack-node-0.2.0.tgz", - "integrity": "sha1-3kuN3aqLeT9h29KTgQT9q/N9+jA=", - "dev": true, - "optional": true, - "requires": { - "requestretry": "1.13.0" - } - }, - "smart-buffer": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-1.1.15.tgz", - "integrity": "sha1-fxFLW2X6s+KjWqd1uxLw0cZJvxY=", - "dev": true, - "optional": true - }, - "smtp-connection": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/smtp-connection/-/smtp-connection-2.12.0.tgz", - "integrity": "sha1-1275EnyyPCJZ7bHoNJwujV4tdME=", - "dev": true, - "requires": { - "httpntlm": "1.6.1", - "nodemailer-shared": "1.1.0" - } - }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "requires": { - "base": "0.11.2", - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "map-cache": "0.2.2", - "source-map": "0.5.7", - "source-map-resolve": "0.5.2", - "use": "3.1.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "requires": { - "define-property": "1.0.0", - "isobject": "3.0.1", - "snapdragon-util": "3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } - }, - "sntp": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", - "dev": true, - "optional": true, - "requires": { - "hoek": "2.16.3" - } - }, - "socket.io": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.0.4.tgz", - "integrity": "sha1-waRZDO/4fs8TxyZS8Eb3FrKeYBQ=", - "dev": true, - "requires": { - "debug": "2.6.9", - "engine.io": "3.1.5", - "socket.io-adapter": "1.1.1", - "socket.io-client": "2.0.4", - "socket.io-parser": "3.1.3" - } - }, - "socket.io-adapter": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz", - "integrity": "sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs=", - "dev": true - }, - "socket.io-client": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.0.4.tgz", - "integrity": "sha1-CRilUkBtxeVAs4Dc2Xr8SmQzL44=", - "dev": true, - "requires": { - "backo2": "1.0.2", - "base64-arraybuffer": "0.1.5", - "component-bind": "1.0.0", - "component-emitter": "1.2.1", - "debug": "2.6.9", - "engine.io-client": "3.1.6", - "has-cors": "1.1.0", - "indexof": "0.0.1", - "object-component": "0.0.3", - "parseqs": "0.0.5", - "parseuri": "0.0.5", - "socket.io-parser": "3.1.3", - "to-array": "0.1.4" - } - }, - "socket.io-parser": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.1.3.tgz", - "integrity": "sha512-g0a2HPqLguqAczs3dMECuA1RgoGFPyvDqcbaDEdCWY9g59kdUAz3YRmaJBNKXflrHNwB7Q12Gkf/0CZXfdHR7g==", - "dev": true, - "requires": { - "component-emitter": "1.2.1", - "debug": "3.1.0", - "has-binary2": "1.0.3", - "isarray": "2.0.1" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "isarray": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", - "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=", - "dev": true - } - } - }, - "socks": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/socks/-/socks-1.1.10.tgz", - "integrity": "sha1-W4t/x8jzQcU+0FbpKbe/Tei6e1o=", - "dev": true, - "optional": true, - "requires": { - "ip": "1.1.5", - "smart-buffer": "1.1.15" - } - }, - "socks-proxy-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-4.0.1.tgz", - "integrity": "sha512-Kezx6/VBguXOsEe5oU3lXYyKMi4+gva72TwJ7pQY5JfqUx2nMk7NXA6z/mpNqIlfQjWYVfeuNvQjexiTaTn6Nw==", - "dev": true, - "optional": true, - "requires": { - "agent-base": "4.2.1", - "socks": "2.2.1" - }, - "dependencies": { - "smart-buffer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.0.1.tgz", - "integrity": "sha512-RFqinRVJVcCAL9Uh1oVqE6FZkqsyLiVOYEZ20TqIOjuX7iFVJ+zsbs4RIghnw/pTs7mZvt8ZHhvm1ZUrR4fykg==", - "dev": true, - "optional": true - }, - "socks": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.2.1.tgz", - "integrity": "sha512-0GabKw7n9mI46vcNrVfs0o6XzWzjVa3h6GaSo2UPxtWAROXUWavfJWh1M4PR5tnE0dcnQXZIDFP4yrAysLze/w==", - "dev": true, - "optional": true, - "requires": { - "ip": "1.1.5", - "smart-buffer": "4.0.1" - } - } - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - }, - "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", - "dev": true, - "requires": { - "atob": "2.1.1", - "decode-uri-component": "0.2.0", - "resolve-url": "0.2.1", - "source-map-url": "0.4.0", - "urix": "0.1.0" - } - }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true - }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "requires": { - "extend-shallow": "3.0.2" - } - }, - "sshpk": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", - "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", - "dev": true, - "optional": true, - "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.2", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "safer-buffer": "2.1.2", - "tweetnacl": "0.14.5" - } - }, - "static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "requires": { - "define-property": "0.2.5", - "object-copy": "0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - } - } - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "dev": true - }, - "stream-browserify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", - "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.6" - } - }, - "stream-combiner2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", - "dev": true, - "requires": { - "duplexer2": "0.1.4", - "readable-stream": "2.3.6" - } - }, - "stream-http": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", - "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", - "dev": true, - "requires": { - "builtin-status-codes": "3.0.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "to-arraybuffer": "1.0.1", - "xtend": "4.0.1" - } - }, - "stream-splicer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz", - "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.6" - } - }, - "streamroller": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-0.7.0.tgz", - "integrity": "sha512-WREzfy0r0zUqp3lGO096wRuUp7ho1X6uo/7DJfTlEi0Iv/4gT7YHqXDjKC2ioVGBZtE8QzsQD9nx1nIuoZ57jQ==", - "dev": true, - "requires": { - "date-format": "1.2.0", - "debug": "3.1.0", - "mkdirp": "0.5.1", - "readable-stream": "2.3.6" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } - }, - "stringstream": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz", - "integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==", - "dev": true, - "optional": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "optional": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "subarg": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", - "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", - "dev": true, - "requires": { - "minimist": "1.2.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true, - "optional": true - }, - "syntax-error": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", - "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", - "dev": true, - "requires": { - "acorn-node": "1.5.2" - } - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.6", - "xtend": "4.0.1" - } + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, - "thunkify": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/thunkify/-/thunkify-2.1.2.tgz", - "integrity": "sha1-+qDp0jDFGsyVyhOjYawFyn4EVT0=", - "dev": true, - "optional": true + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true }, - "timers-browserify": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", - "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", + "fs-access": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", + "integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", "dev": true, "requires": { - "process": "0.11.10" + "null-check": "^1.0.0" } }, - "timespan": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/timespan/-/timespan-2.3.0.tgz", - "integrity": "sha1-SQLOBAvRPYRcj1myfp1ZutbzmSk=", - "dev": true, - "optional": true + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "os-tmpdir": "1.0.2" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, - "to-array": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", - "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, - "to-arraybuffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", - "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "regex-not": "1.0.2", - "safe-regex": "1.1.0" + "once": "^1.3.0", + "wrappy": "1" } }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "3.0.0", - "repeat-string": "1.6.1" - } + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true }, - "tough-cookie": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", - "dev": true, - "optional": true, - "requires": { - "punycode": "1.4.1" - } + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true }, - "tsscmp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.5.tgz", - "integrity": "sha1-fcSjOvcVgatDN9qR2FylQn69mpc=", - "dev": true, - "optional": true + "jssha": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/jssha/-/jssha-2.3.1.tgz", + "integrity": "sha1-FHshJTaQNcpLL30hDcU58Amz3po=" }, - "tty-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", - "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", + "karma-chai": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/karma-chai/-/karma-chai-0.1.0.tgz", + "integrity": "sha1-vuWtQEAFF4Ea40u5RfdikJEIt5o=", "dev": true }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "karma-chrome-launcher": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz", + "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==", "dev": true, - "optional": true, "requires": { - "safe-buffer": "5.1.2" + "fs-access": "^1.0.0", + "which": "^1.2.1" } }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true, - "optional": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "karma-mocha": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-1.3.0.tgz", + "integrity": "sha1-7qrH/8DiAetjxGdEDStpx883eL8=", "dev": true, "requires": { - "prelude-ls": "1.1.2" + "minimist": "1.2.0" } }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, - "type-is": { - "version": "1.6.16", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "media-typer": "0.3.0", - "mime-types": "2.1.19" + "brace-expansion": "^1.1.7" } }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, - "uglify-js": { - "version": "3.4.5", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.5.tgz", - "integrity": "sha512-Fm52gLqJqFBnT+Sn411NPDnsgaWiYeRLw42x7Va/mS8TKgaepwoGY7JLXHSEef3d3PmdFXSz1Zx7KMLL89E2QA==", + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { - "commander": "2.16.0", - "source-map": "0.6.1" + "minimist": "0.0.8" }, "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true } } }, - "ultron": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", - "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", - "dev": true - }, - "umd": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", - "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", - "dev": true - }, - "undeclared-identifiers": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz", - "integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==", - "dev": true, - "requires": { - "acorn-node": "1.5.2", - "get-assigned-identifiers": "1.2.0", - "simple-concat": "1.0.0", - "xtend": "4.0.1" - } - }, - "underscore": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", - "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=", - "dev": true - }, - "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", "dev": true, "requires": { - "arr-union": "3.1.0", - "get-value": "2.0.6", - "is-extendable": "0.1.1", - "set-value": "0.4.3" + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" }, "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { - "is-extendable": "0.1.1" + "ms": "2.0.0" } }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "to-object-path": "0.3.0" + "has-flag": "^3.0.0" } } } }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "unset-value": { + "null-check": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "requires": { - "has-value": "0.3.1", - "isobject": "3.0.1" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "requires": { - "get-value": "2.0.6", - "has-values": "0.1.4", - "isobject": "2.1.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true - } - } - }, - "upath": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.0.tgz", - "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", - "dev": true - }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, - "url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", - "dev": true, - "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true - } - } - }, - "use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", + "integrity": "sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=", "dev": true }, - "useragent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.2.1.tgz", - "integrity": "sha1-z1k+9PLRdYdei7ZY6pLhik/QbY4=", - "dev": true, - "requires": { - "lru-cache": "2.2.4", - "tmp": "0.0.33" - }, - "dependencies": { - "lru-cache": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.2.4.tgz", - "integrity": "sha1-bGWGGb7PFAMdDQtZSxYELOTcBj0=", - "dev": true - } - } - }, - "util": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", - "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "inherits": "2.0.3" + "wrappy": "1" } }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "utils-merge": { + "path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", - "dev": true, - "optional": true - }, - "uws": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/uws/-/uws-9.14.0.tgz", - "integrity": "sha512-HNMztPP5A1sKuVFmdZ6BPVpBQd5bUjNC8EFMFiICK+oho/OQsAJy5hnIx4btMHiOk8j04f/DbIlqnEZ9d72dqg==", - "dev": true, - "optional": true - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "1.3.0" - } - }, - "vm-browserify": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", - "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", - "dev": true, - "requires": { - "indexof": "0.0.1" - } - }, - "void-elements": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", - "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", - "dev": true + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, - "when": { - "version": "3.7.8", - "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", - "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=", - "dev": true, - "optional": true + "user": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/user/-/user-0.0.0.tgz", + "integrity": "sha1-8n8bI/xRHyqO+kDbVc+6Ejgk4Co=" }, "which": { "version": "1.3.1", @@ -5680,71 +271,14 @@ "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, "requires": { - "isexe": "2.0.0" + "isexe": "^2.0.0" } }, - "with-callback": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/with-callback/-/with-callback-1.0.2.tgz", - "integrity": "sha1-oJYpuakgAo1yFAT7Q1vc/1yRvCE=", - "dev": true, - "optional": true - }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true, - "optional": true - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true - }, - "ws": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", - "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", - "dev": true, - "requires": { - "async-limiter": "1.0.0", - "safe-buffer": "5.1.2", - "ultron": "1.1.1" - } - }, - "xmlhttprequest-ssl": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", - "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=", - "dev": true - }, - "xregexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", - "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=", - "dev": true, - "optional": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - }, - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true, - "optional": true - }, - "yeast": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", - "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=", - "dev": true } } } diff --git a/package.json b/package.json index 17b36e68..684b4356 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "nodejs" ], "version": "0.3.0", - "author": "Chris Tsimogiannis ", + "author": "Chris ", "homepage": "https://github.com/ognus/wallet-address-validator", "license": "MIT", "repository": { @@ -54,7 +54,7 @@ "bs58": "^4.0.1", "cbor-js": "^0.1.0", "crc": "^3.8.0", - "jssha": "2.3.1" + "jssha": "2.3.1", }, "devDependencies": { "browserify": "^16.2.3", From 70b1b4e285e541227af081686f3695fd9c4edd64 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 26 Oct 2018 16:02:44 +0200 Subject: [PATCH 060/108] fixed trailing comma --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 684b4356..68907469 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "bs58": "^4.0.1", "cbor-js": "^0.1.0", "crc": "^3.8.0", - "jssha": "2.3.1", + "jssha": "2.3.1" }, "devDependencies": { "browserify": "^16.2.3", From 34aca981bbc69b4609aa9feed3629e3f6564c10e Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 27 Oct 2018 08:26:50 +0200 Subject: [PATCH 061/108] updated package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 68907469..3f64d0c7 100644 --- a/package.json +++ b/package.json @@ -29,13 +29,13 @@ "browser", "nodejs" ], - "version": "0.3.0", + "version": "0.3.1", "author": "Chris ", - "homepage": "https://github.com/ognus/wallet-address-validator", + "homepage": "https://github.com/christsim/multicoin-address-validator", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/ognus/wallet-address-validator.git" + "url": "https://github.com/christsim/multicoin-address-validator.git" }, "main": "src/wallet_address_validator", "engines": { From 092b3cbf4b2428ec336fd20fe8dffff2ffd1e269 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 30 Oct 2018 01:46:46 +0200 Subject: [PATCH 062/108] this commit adds waves support --- README.md | 7 +- dist/wallet-address-validator.js | 441 +++++++++++++++++++++++---- dist/wallet-address-validator.min.js | 2 +- package.json | 3 +- src/bitcoin_validator.js | 13 +- src/crypto/blake2b.js | 296 ++++++++++++++++++ src/crypto/utils.js | 4 + src/currencies.js | 8 + test/wallet_address_validator.js | 8 + 9 files changed, 720 insertions(+), 62 deletions(-) create mode 100644 src/crypto/blake2b.js diff --git a/README.md b/README.md index 479a6fdd..34378fbb 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Forked from [ryanralph/altcoin-address](https://github.com/ryanralph/altcoin-add ### NPM ``` -npm install wallet-address-validator +npm install multicoin-address-validator ``` ### Browser @@ -90,6 +90,7 @@ npm install wallet-address-validator * TrueUSD/tusd `'TrueUSD'` or `'tusd'` * VertCoin/vtc `'VertCoin'` or `'vtc'` * VoteCoin/vot `'VoteCoin'` or `'vot'` +* Waves/waves `'Waves'` or `'waves'` * Wings/wings `'Wings'` or `'wings'` * ZCash/zec `'ZCash'` or `'zec'` * ZClassic/zcl `'ZClassic'` or `'zcl'` @@ -99,7 +100,7 @@ npm install wallet-address-validator #### Node ```javascript -var WAValidator = require('wallet-address-validator'); +var WAValidator = require('multicoin-address-validator'); var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'BTC'); if(valid) @@ -111,7 +112,7 @@ else ``` ```javascript -var WAValidator = require('wallet-address-validator'); +var WAValidator = require('multicoin-address-validator'); var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'litecoin', 'testnet'); if(valid) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 98f7b6e4..42cf9b4c 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -3398,6 +3398,7 @@ module.exports = { }; },{"bs58":3,"cbor-js":5,"crc":30}],36:[function(require,module,exports){ +(function (Buffer){ var base58 = require('./crypto/base58'); var segwit = require('./crypto/segwit_addr'); var cryptoUtils = require('./crypto/utils'); @@ -3416,9 +3417,14 @@ function getDecoded(address) { function getChecksum(hashFunction, payload) { // Each currency may implement different hashing algorithm switch (hashFunction) { + // blake the keccak + case 'blake256keccak256': + var blake = cryptoUtils.blake2b256(Buffer.from(payload, 'hex')); + return cryptoUtils.keccak256Checksum(Buffer.from(blake, 'hex')); case 'blake256': return cryptoUtils.blake256Checksum(payload); - break; + case 'keccak256': + return cryptoUtils.keccak256Checksum(payload); case 'sha256': default: return cryptoUtils.sha256Checksum(payload); @@ -3439,6 +3445,12 @@ function getAddressType(address, currency) { return null; } + if(currency.regex) { + if(!currency.regex.test(address)) { + return false; + } + } + var checksum = cryptoUtils.toHex(decoded.slice(length - 4, length)), body = cryptoUtils.toHex(decoded.slice(0, length - 4)), goodChecksum = getChecksum(hashFunction, body); @@ -3474,7 +3486,8 @@ module.exports = { } }; -},{"./crypto/base58":37,"./crypto/segwit_addr":42,"./crypto/utils":44}],37:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) +},{"./crypto/base58":37,"./crypto/segwit_addr":43,"./crypto/utils":45,"buffer":4}],37:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -5283,6 +5296,305 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) },{"buffer":4}],41:[function(require,module,exports){ +(function (Buffer){ +// Blake2B in pure Javascript +// Adapted from the reference implementation in RFC7693 +// Ported to Javascript by DC - https://github.com/dcposch +// credit: https://github.com/dcposch/blakejs/blob/master/blake2b.js + +// var util = require('./util') +// For convenience, let people hash a string, not just a Uint8Array +function normalizeInput (input) { + var ret + if (input instanceof Uint8Array) { + ret = input + } else if (input instanceof Buffer) { + ret = new Uint8Array(input) + } else if (typeof (input) === 'string') { + ret = new Uint8Array(Buffer.from(input, 'utf8')) + } else { + throw new Error(ERROR_MSG_INPUT) + } + return ret +} + +// Converts a Uint8Array to a hexadecimal string +// For example, toHex([255, 0, 255]) returns "ff00ff" +function toHex (bytes) { + return Array.prototype.map.call(bytes, function (n) { + return (n < 16 ? '0' : '') + n.toString(16) + }).join('') +} + +// 64-bit unsigned addition +// Sets v[a,a+1] += v[b,b+1] +// v should be a Uint32Array +function ADD64AA (v, a, b) { + var o0 = v[a] + v[b] + var o1 = v[a + 1] + v[b + 1] + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// 64-bit unsigned addition +// Sets v[a,a+1] += b +// b0 is the low 32 bits of b, b1 represents the high 32 bits +function ADD64AC (v, a, b0, b1) { + var o0 = v[a] + b0 + if (b0 < 0) { + o0 += 0x100000000 + } + var o1 = v[a + 1] + b1 + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// Little-endian byte access +function B2B_GET32 (arr, i) { + return (arr[i] ^ + (arr[i + 1] << 8) ^ + (arr[i + 2] << 16) ^ + (arr[i + 3] << 24)) +} + +// G Mixing function +// The ROTRs are inlined for speed +function B2B_G (a, b, c, d, ix, iy) { + var x0 = m[ix] + var x1 = m[ix + 1] + var y0 = m[iy] + var y1 = m[iy + 1] + + ADD64AA(v, a, b) // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s + ADD64AC(v, a, x0, x1) // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits + var xor0 = v[d] ^ v[a] + var xor1 = v[d + 1] ^ v[a + 1] + v[d] = xor1 + v[d + 1] = xor0 + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor0 >>> 24) ^ (xor1 << 8) + v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8) + + ADD64AA(v, a, b) + ADD64AC(v, a, y0, y1) + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits + xor0 = v[d] ^ v[a] + xor1 = v[d + 1] ^ v[a + 1] + v[d] = (xor0 >>> 16) ^ (xor1 << 16) + v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16) + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor1 >>> 31) ^ (xor0 << 1) + v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1) +} + +// Initialization Vector +var BLAKE2B_IV32 = new Uint32Array([ + 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, + 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, + 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, + 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 +]) + +var SIGMA8 = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 +] + +// These are offsets into a uint64 buffer. +// Multiply them all by 2 to make them offsets into a uint32 buffer, +// because this is Javascript and we don't have uint64s +var SIGMA82 = new Uint8Array(SIGMA8.map(function (x) { return x * 2 })) + +// Compression function. 'last' flag indicates last block. +// Note we're representing 16 uint64s as 32 uint32s +var v = new Uint32Array(32) +var m = new Uint32Array(32) +function blake2bCompress (ctx, last) { + var i = 0 + + // init work variables + for (i = 0; i < 16; i++) { + v[i] = ctx.h[i] + v[i + 16] = BLAKE2B_IV32[i] + } + + // low 64 bits of offset + v[24] = v[24] ^ ctx.t + v[25] = v[25] ^ (ctx.t / 0x100000000) + // high 64 bits not supported, offset may not be higher than 2**53-1 + + // last block flag set ? + if (last) { + v[28] = ~v[28] + v[29] = ~v[29] + } + + // get little-endian words + for (i = 0; i < 32; i++) { + m[i] = B2B_GET32(ctx.b, 4 * i) + } + + // twelve rounds of mixing + // uncomment the DebugPrint calls to log the computation + // and match the RFC sample documentation + // util.debugPrint(' m[16]', m, 64) + for (i = 0; i < 12; i++) { + // util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64) + B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]) + B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]) + B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]) + B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]) + B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]) + B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]) + B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]) + B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]) + } + // util.debugPrint(' (i=12) v[16]', v, 64) + + for (i = 0; i < 16; i++) { + ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16] + } + // util.debugPrint('h[8]', ctx.h, 64) +} + +// Creates a BLAKE2b hashing context +// Requires an output length between 1 and 64 bytes +// Takes an optional Uint8Array key +function blake2bInit (outlen, key) { + if (outlen === 0 || outlen > 64) { + throw new Error('Illegal output length, expected 0 < length <= 64') + } + if (key && key.length > 64) { + throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64') + } + + // state, 'param block' + var ctx = { + b: new Uint8Array(128), + h: new Uint32Array(16), + t: 0, // input count + c: 0, // pointer within buffer + outlen: outlen // output length in bytes + } + + // initialize hash state + for (var i = 0; i < 16; i++) { + ctx.h[i] = BLAKE2B_IV32[i] + } + var keylen = key ? key.length : 0 + ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen + + // key the hash, if applicable + if (key) { + blake2bUpdate(ctx, key) + // at the end + ctx.c = 128 + } + + return ctx +} + +// Updates a BLAKE2b streaming hash +// Requires hash context and Uint8Array (byte array) +function blake2bUpdate (ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 128) { // buffer full ? + ctx.t += ctx.c // add counters + blake2bCompress(ctx, false) // compress (not last) + ctx.c = 0 // counter to zero + } + ctx.b[ctx.c++] = input[i] + } +} + +// Completes a BLAKE2b streaming hash +// Returns a Uint8Array containing the message digest +function blake2bFinal (ctx) { + ctx.t += ctx.c // mark last block offset + + while (ctx.c < 128) { // fill up with zeros + ctx.b[ctx.c++] = 0 + } + blake2bCompress(ctx, true) // final block flag = 1 + + // little endian convert and store + var out = new Uint8Array(ctx.outlen) + for (var i = 0; i < ctx.outlen; i++) { + out[i] = ctx.h[i >> 2] >> (8 * (i & 3)) + } + return out +} + +// Computes the BLAKE2B hash of a string or byte array, and returns a Uint8Array +// +// Returns a n-byte Uint8Array +// +// Parameters: +// - input - the input bytes, as a string, Buffer or Uint8Array +// - key - optional key Uint8Array, up to 64 bytes +// - outlen - optional output length in bytes, default 64 +function blake2b (input, key, outlen) { + // preprocess inputs + outlen = outlen || 64 + input = normalizeInput(input) + + // do the math + var ctx = blake2bInit(outlen, key) + blake2bUpdate(ctx, input) + return blake2bFinal(ctx) +} + +// Computes the BLAKE2B hash of a string or byte array +// +// Returns an n-byte hash in hex, all lowercase +// +// Parameters: +// - input - the input bytes, as a string, Buffer, or Uint8Array +// - key - optional key Uint8Array, up to 64 bytes +// - outlen - optional output length in bytes, default 64 +function blake2bHex (input, key, outlen) { + var output = blake2b(input, key, outlen) + return toHex(output) +} + +module.exports = { + blake2b: blake2b, + blake2bHex: blake2bHex, + blake2bInit: blake2bInit, + blake2bUpdate: blake2bUpdate, + blake2bFinal: blake2bFinal +} +}).call(this,require("buffer").Buffer) +},{"buffer":4}],42:[function(require,module,exports){ var JSBigInt = require('./biginteger')['JSBigInt']; /** @@ -5509,7 +5821,7 @@ var cnBase58 = (function () { return b58; })(); module.exports = cnBase58; -},{"./biginteger":39}],42:[function(require,module,exports){ +},{"./biginteger":39}],43:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -5605,7 +5917,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":38}],43:[function(require,module,exports){ +},{"./bech32":38}],44:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -6249,10 +6561,11 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":33}],44:[function(require,module,exports){ +},{"_process":33}],45:[function(require,module,exports){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; +var blake2b = require('./blake2b'); function numberToHex (number) { var hex = Math.round(number).toString(16); @@ -6289,10 +6602,13 @@ module.exports = { }, keccak256Checksum: function (payload) { return keccak256(payload).toString().substr(0, 8); + }, + blake2b256: function(payload) { + return blake2b.blake2bHex(payload, null, 32); } }; -},{"./blake256":40,"./sha3":43,"jssha/src/sha256":32}],45:[function(require,module,exports){ +},{"./blake256":40,"./blake2b":41,"./sha3":44,"jssha/src/sha256":32}],46:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); @@ -6301,152 +6617,152 @@ var XMRValidator = require('./monero_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ - name: 'bitcoin', + name: 'Bitcoin', symbol: 'btc', addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'bitcoincash', + name: 'BitcoinCash', symbol: 'bch', addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'litecoin', + name: 'LiteCoin', symbol: 'ltc', addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']}, validator: BTCValidator },{ - name: 'peercoin', + name: 'PeerCoin', symbol: 'ppc', addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'dogecoin', + name: 'DogeCoin', symbol: 'doge', addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']}, validator: BTCValidator },{ - name: 'beavercoin', + name: 'BeaverCoin', symbol: 'bvc', addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator, },{ - name: 'freicoin', + name: 'FreiCoin', symbol: 'frc', addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'protoshares', + name: 'ProtoShares', symbol: 'pts', addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'megacoin', + name: 'MegaCoin', symbol: 'mec', addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'primecoin', + name: 'PrimeCoin', symbol: 'xpm', addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'auroracoin', + name: 'AuroraCoin', symbol: 'aur', addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'namecoin', + name: 'NameCoin', symbol: 'nmc', addressTypes: {prod: ['34'], testnet: []}, validator: BTCValidator },{ - name: 'biocoin', + name: 'BioCoin', symbol: 'bio', addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'garlicoin', + name: 'GarliCoin', symbol: 'grlc', addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'vertcoin', + name: 'VertCoin', symbol: 'vtc', addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'bitcoingold', + name: 'BitcoinGold', symbol: 'btg', addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'komodo', + name: 'Komodo', symbol: 'kmd', addressTypes: {prod: ['3c', '55'], testnet: ['0','5']}, validator: BTCValidator },{ - name: 'bitcoinz', + name: 'BitcoinZ', symbol: 'btcz', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'bitcoinprivate', + name: 'BitcoinPrivate', symbol: 'btcp', expectedLength: 26, addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']}, validator: BTCValidator },{ - name: 'hush', + name: 'Hush', symbol: 'hush', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'snowgem', + name: 'SnowGem', symbol: 'sng', expectedLength: 26, addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'zcash', + name: 'ZCash', symbol: 'zec', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'zclassic', + name: 'ZClassic', symbol: 'zcl', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'zencash', + name: 'ZenCash', symbol: 'zen', expectedLength: 26, addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']}, validator: BTCValidator },{ - name: 'votecoin', + name: 'VoteCoin', symbol: 'vot', expectedLength: 26, addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, validator: BTCValidator },{ - name: 'decred', + name: 'Decred', symbol: 'dcr', addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, hashFunction: 'blake256', expectedLength: 26, validator: BTCValidator },{ - name: 'gamecredits', + name: 'GameCredits', symbol: 'game', addressTypes: {prod: ['26', '05'], testnet: []}, validator: BTCValidator },{ - name: 'pivx', + name: 'PIVX', symbol: 'pivx', addressTypes: {prod: ['1e', '0d'], testnet: []}, validator: BTCValidator @@ -6461,7 +6777,7 @@ var CURRENCIES = [{ addressTypes: {prod: ['32', '37'], testnet: []}, validator: BTCValidator },{ - name: 'digibyte', + name: 'DigiByte', symbol: 'dgb', addressTypes: {prod: ['1e'], testnet: []}, validator: BTCValidator @@ -6471,55 +6787,63 @@ var CURRENCIES = [{ addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'ripple', + name: 'Ripple', symbol: 'xrp', validator: XRPValidator, },{ - name: 'dash', + name: 'Dash', symbol: 'dash', addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']}, validator: BTCValidator },{ - name: 'neo', + name: 'Neo', symbol: 'neo', addressTypes: {prod: ['17'], testnet: []}, validator: BTCValidator },{ - name: 'neogas', + name: 'NeoGas', symbol: 'gas', addressTypes: {prod: ['17'], testnet: []}, validator: BTCValidator },{ - name: 'qtum', + name: 'Qtum', symbol: 'qtum', addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ - name: 'ethereum', + name: 'Waves', + symbol: 'waves', + addressTypes: {prod: ['0157'], testnet: ['0154']}, + expectedLength: 26, + hashFunction: 'blake256keccak256', + regex: /^[a-zA-Z0-9]{35}$/, + validator: BTCValidator +}, { + name: 'Ethereum', symbol: 'eth', validator: ETHValidator, },{ - name: 'etherzero', + name: 'EtherZero', symbol: 'etz', validator: ETHValidator, },{ - name: 'ethereumclassic', + name: 'EthereumClassic', symbol: 'etc', validator: ETHValidator, },{ - name: 'callisto', + name: 'Callisto', symbol: 'clo', validator: ETHValidator, },{ - name: 'bankex', + name: 'Bankex', symbol: 'bkx', validator: ETHValidator },{ - name: 'cardano', + name: 'Cardano', symbol: 'ada', validator: ADAValidator },{ - name: 'monero', + name: 'Monero', symbol: 'xmr', addressTypes: {prod: ['18'], testnet: ['53']}, iAddressTypes: {prod: ['19'], testnet: ['54']}, @@ -6537,12 +6861,12 @@ var CURRENCIES = [{ symbol: 'bnt', validator: ETHValidator },{ - name: 'cvc', - symbol: 'Civic', + name: 'Civic', + symbol: 'cvc', validator: ETHValidator },{ - name: 'dnt', - symbol: 'District0x', + name: 'District0x', + symbol: 'dnt', validator: ETHValidator },{ name: 'Gnosis', @@ -6620,9 +6944,14 @@ module.exports = { } }; +// spit out details for readme.md +// CURRENCIES +// .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) +// .forEach(c => console.log(`* ${c.name}/${c.symbol} \`'${c.name}'\` or \`'${c.symbol}'\` `)); + -},{"./ada_validator":35,"./bitcoin_validator":36,"./ethereum_validator":46,"./monero_validator":47,"./ripple_validator":48}],46:[function(require,module,exports){ +},{"./ada_validator":35,"./bitcoin_validator":36,"./ethereum_validator":47,"./monero_validator":48,"./ripple_validator":49}],47:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -6658,7 +6987,7 @@ module.exports = { } }; -},{"./crypto/utils":44}],47:[function(require,module,exports){ +},{"./crypto/utils":45}],48:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var cnBase58 = require('./crypto/cnBase58'); @@ -6720,7 +7049,7 @@ module.exports = { } }; -},{"./crypto/cnBase58":41,"./crypto/utils":44}],48:[function(require,module,exports){ +},{"./crypto/cnBase58":42,"./crypto/utils":45}],49:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -6750,7 +7079,7 @@ module.exports = { } }; -},{"./crypto/utils":44,"base-x":1}],49:[function(require,module,exports){ +},{"./crypto/utils":45,"base-x":1}],50:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -6767,5 +7096,5 @@ module.exports = { }, }; -},{"./currencies":45}]},{},[49])(49) +},{"./currencies":46}]},{},[50])(50) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 00dc6e99..10c39266 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function o(a,s,u){function f(e,t){if(!s[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var i=s[e]={exports:{}};a[e][0].call(i.exports,function(t){return f(a[e][1][t]||t)},i,i.exports,o,a,s,u)}return s[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function T(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,i){return e=+e,r>>>=0,i||T(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,i){return e=+e,r>>>=0,i||T(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,r,e){!function(t,x){"use strict";var k=Math.pow(2,-24),U=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,o=0;o>6):(o<55296?i.push(224|o>>12):(o=(1023&o)<<10,o|=1023&e.charCodeAt(++r),o+=65536,i.push(240|o>>18),i.push(128|o>>12&63)),i.push(128|o>>6&63)),i.push(128|63&o))}return p(3,i.length),d(i);default:var a;if(Array.isArray(e))for(p(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function B(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof d&&(d=function(t){return t}),"function"!=typeof p&&(p=function(){return x});var t=function t(){var e,r,n=w(),i=n>>5,o=31&n;if(7===i)switch(o){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,i=31744&r,o=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==o)return o*k;return e.setUint32(0,n<<16|i<<13|o<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(o))<0&&(i<2||6>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var i,o;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(v.slice(),g,y,d(s)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=i[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,r,e){!function(t,x){"use strict";var k=Math.pow(2,-24),U=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,o=0;o>6):(o<55296?i.push(224|o>>12):(o=(1023&o)<<10,o|=1023&e.charCodeAt(++r),o+=65536,i.push(240|o>>18),i.push(128|o>>12&63)),i.push(128|o>>6&63)),i.push(128|63&o))}return p(3,i.length),d(i);default:var a;if(Array.isArray(e))for(p(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function B(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof d&&(d=function(t){return t}),"function"!=typeof p&&(p=function(){return x});var t=function t(){var e,r,n=w(),i=n>>5,o=31&n;if(7===i)switch(o){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,i=31744&r,o=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==o)return o*k;return e.setUint32(0,n<<16|i<<13|o<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(o))<0&&(i<2||6>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var i,o;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(v.slice(),g,y,d(s)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=i[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// 64-bit unsigned addition +// Sets v[a,a+1] += b +// b0 is the low 32 bits of b, b1 represents the high 32 bits +function ADD64AC (v, a, b0, b1) { + var o0 = v[a] + b0 + if (b0 < 0) { + o0 += 0x100000000 + } + var o1 = v[a + 1] + b1 + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// Little-endian byte access +function B2B_GET32 (arr, i) { + return (arr[i] ^ + (arr[i + 1] << 8) ^ + (arr[i + 2] << 16) ^ + (arr[i + 3] << 24)) +} + +// G Mixing function +// The ROTRs are inlined for speed +function B2B_G (a, b, c, d, ix, iy) { + var x0 = m[ix] + var x1 = m[ix + 1] + var y0 = m[iy] + var y1 = m[iy + 1] + + ADD64AA(v, a, b) // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s + ADD64AC(v, a, x0, x1) // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits + var xor0 = v[d] ^ v[a] + var xor1 = v[d + 1] ^ v[a + 1] + v[d] = xor1 + v[d + 1] = xor0 + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor0 >>> 24) ^ (xor1 << 8) + v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8) + + ADD64AA(v, a, b) + ADD64AC(v, a, y0, y1) + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits + xor0 = v[d] ^ v[a] + xor1 = v[d + 1] ^ v[a + 1] + v[d] = (xor0 >>> 16) ^ (xor1 << 16) + v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16) + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor1 >>> 31) ^ (xor0 << 1) + v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1) +} + +// Initialization Vector +var BLAKE2B_IV32 = new Uint32Array([ + 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, + 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, + 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, + 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 +]) + +var SIGMA8 = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 +] + +// These are offsets into a uint64 buffer. +// Multiply them all by 2 to make them offsets into a uint32 buffer, +// because this is Javascript and we don't have uint64s +var SIGMA82 = new Uint8Array(SIGMA8.map(function (x) { return x * 2 })) + +// Compression function. 'last' flag indicates last block. +// Note we're representing 16 uint64s as 32 uint32s +var v = new Uint32Array(32) +var m = new Uint32Array(32) +function blake2bCompress (ctx, last) { + var i = 0 + + // init work variables + for (i = 0; i < 16; i++) { + v[i] = ctx.h[i] + v[i + 16] = BLAKE2B_IV32[i] + } + + // low 64 bits of offset + v[24] = v[24] ^ ctx.t + v[25] = v[25] ^ (ctx.t / 0x100000000) + // high 64 bits not supported, offset may not be higher than 2**53-1 + + // last block flag set ? + if (last) { + v[28] = ~v[28] + v[29] = ~v[29] + } + + // get little-endian words + for (i = 0; i < 32; i++) { + m[i] = B2B_GET32(ctx.b, 4 * i) + } + + // twelve rounds of mixing + // uncomment the DebugPrint calls to log the computation + // and match the RFC sample documentation + // util.debugPrint(' m[16]', m, 64) + for (i = 0; i < 12; i++) { + // util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64) + B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]) + B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]) + B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]) + B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]) + B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]) + B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]) + B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]) + B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]) + } + // util.debugPrint(' (i=12) v[16]', v, 64) + + for (i = 0; i < 16; i++) { + ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16] + } + // util.debugPrint('h[8]', ctx.h, 64) +} + +// Creates a BLAKE2b hashing context +// Requires an output length between 1 and 64 bytes +// Takes an optional Uint8Array key +function blake2bInit (outlen, key) { + if (outlen === 0 || outlen > 64) { + throw new Error('Illegal output length, expected 0 < length <= 64') + } + if (key && key.length > 64) { + throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64') + } + + // state, 'param block' + var ctx = { + b: new Uint8Array(128), + h: new Uint32Array(16), + t: 0, // input count + c: 0, // pointer within buffer + outlen: outlen // output length in bytes + } + + // initialize hash state + for (var i = 0; i < 16; i++) { + ctx.h[i] = BLAKE2B_IV32[i] + } + var keylen = key ? key.length : 0 + ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen + + // key the hash, if applicable + if (key) { + blake2bUpdate(ctx, key) + // at the end + ctx.c = 128 + } + + return ctx +} + +// Updates a BLAKE2b streaming hash +// Requires hash context and Uint8Array (byte array) +function blake2bUpdate (ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 128) { // buffer full ? + ctx.t += ctx.c // add counters + blake2bCompress(ctx, false) // compress (not last) + ctx.c = 0 // counter to zero + } + ctx.b[ctx.c++] = input[i] + } +} + +// Completes a BLAKE2b streaming hash +// Returns a Uint8Array containing the message digest +function blake2bFinal (ctx) { + ctx.t += ctx.c // mark last block offset + + while (ctx.c < 128) { // fill up with zeros + ctx.b[ctx.c++] = 0 + } + blake2bCompress(ctx, true) // final block flag = 1 + + // little endian convert and store + var out = new Uint8Array(ctx.outlen) + for (var i = 0; i < ctx.outlen; i++) { + out[i] = ctx.h[i >> 2] >> (8 * (i & 3)) + } + return out +} + +// Computes the BLAKE2B hash of a string or byte array, and returns a Uint8Array +// +// Returns a n-byte Uint8Array +// +// Parameters: +// - input - the input bytes, as a string, Buffer or Uint8Array +// - key - optional key Uint8Array, up to 64 bytes +// - outlen - optional output length in bytes, default 64 +function blake2b (input, key, outlen) { + // preprocess inputs + outlen = outlen || 64 + input = normalizeInput(input) + + // do the math + var ctx = blake2bInit(outlen, key) + blake2bUpdate(ctx, input) + return blake2bFinal(ctx) +} + +// Computes the BLAKE2B hash of a string or byte array +// +// Returns an n-byte hash in hex, all lowercase +// +// Parameters: +// - input - the input bytes, as a string, Buffer, or Uint8Array +// - key - optional key Uint8Array, up to 64 bytes +// - outlen - optional output length in bytes, default 64 +function blake2bHex (input, key, outlen) { + var output = blake2b(input, key, outlen) + return toHex(output) +} + +module.exports = { + blake2b: blake2b, + blake2bHex: blake2bHex, + blake2bInit: blake2bInit, + blake2bUpdate: blake2bUpdate, + blake2bFinal: blake2bFinal +} \ No newline at end of file diff --git a/src/crypto/utils.js b/src/crypto/utils.js index 3cc39bdf..8e0d35d1 100644 --- a/src/crypto/utils.js +++ b/src/crypto/utils.js @@ -1,6 +1,7 @@ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; +var blake2b = require('./blake2b'); function numberToHex (number) { var hex = Math.round(number).toString(16); @@ -37,5 +38,8 @@ module.exports = { }, keccak256Checksum: function (payload) { return keccak256(payload).toString().substr(0, 8); + }, + blake2b256: function(payload) { + return blake2b.blake2bHex(payload, null, 32); } }; diff --git a/src/currencies.js b/src/currencies.js index b5296881..175f1aca 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -200,6 +200,14 @@ var CURRENCIES = [{ addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, validator: BTCValidator },{ + name: 'Waves', + symbol: 'waves', + addressTypes: {prod: ['0157'], testnet: ['0154']}, + expectedLength: 26, + hashFunction: 'blake256keccak256', + regex: /^[a-zA-Z0-9]{35}$/, + validator: BTCValidator +}, { name: 'Ethereum', symbol: 'eth', validator: ETHValidator, diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index ed9553fa..60a5222d 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -409,6 +409,14 @@ describe('WAValidator.validate()', function () { valid('0xbab463743603a253bdf1f84975b1a9517505ae05', 'exp'); valid('0x5d0777cb5d6977873904864c6ab531f4b3261f0b', 'expanse'); }); + + it('should return true for correct waves addresses', function () { + valid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); + valid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHajj', 'waves'); + + valid('3Myrq5QDgRq3nBVRSSv9UYrP36xTtpJND5y', 'waves', 'testnet'); + valid('3My3KZgFQ3CrVHgz6vGRt8687sH4oAA1qp8', 'waves', 'testnet'); + }); }); describe('invalid results', function () { From efa54e3cbe29236e2cc0dd80bb8b9b8d5025bd6e Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Tue, 30 Oct 2018 11:51:48 +0100 Subject: [PATCH 063/108] Regenerate dist --- dist/wallet-address-validator.js | 344 ++++++++++++++++++++++++++- dist/wallet-address-validator.min.js | 2 +- 2 files changed, 337 insertions(+), 9 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 9eba6b47..b46aae2f 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -2427,7 +2427,7 @@ module.exports = { } }; -},{"./crypto/base58":9,"./crypto/segwit_addr":12,"./crypto/utils":14}],9:[function(require,module,exports){ +},{"./crypto/base58":9,"./crypto/segwit_addr":13,"./crypto/utils":15}],9:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -2785,6 +2785,283 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) },{"buffer":3}],12:[function(require,module,exports){ +'use strict'; + +/** + * Credits to https://github.com/emilbayes/blake2b + * + * Copyright (c) 2017, Emil Bay github@tixz.dk + * + * Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// 64-bit unsigned addition +// Sets v[a,a+1] += v[b,b+1] +// v should be a Uint32Array +function ADD64AA (v, a, b) { + var o0 = v[a] + v[b] + var o1 = v[a + 1] + v[b + 1] + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// 64-bit unsigned addition +// Sets v[a,a+1] += b +// b0 is the low 32 bits of b, b1 represents the high 32 bits +function ADD64AC (v, a, b0, b1) { + var o0 = v[a] + b0 + if (b0 < 0) { + o0 += 0x100000000 + } + var o1 = v[a + 1] + b1 + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// Little-endian byte access +function B2B_GET32 (arr, i) { + return (arr[i] ^ + (arr[i + 1] << 8) ^ + (arr[i + 2] << 16) ^ + (arr[i + 3] << 24)) +} + +// G Mixing function +// The ROTRs are inlined for speed +function B2B_G (a, b, c, d, ix, iy) { + var x0 = m[ix] + var x1 = m[ix + 1] + var y0 = m[iy] + var y1 = m[iy + 1] + + ADD64AA(v, a, b) // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s + ADD64AC(v, a, x0, x1) // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits + var xor0 = v[d] ^ v[a] + var xor1 = v[d + 1] ^ v[a + 1] + v[d] = xor1 + v[d + 1] = xor0 + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor0 >>> 24) ^ (xor1 << 8) + v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8) + + ADD64AA(v, a, b) + ADD64AC(v, a, y0, y1) + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits + xor0 = v[d] ^ v[a] + xor1 = v[d + 1] ^ v[a + 1] + v[d] = (xor0 >>> 16) ^ (xor1 << 16) + v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16) + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor1 >>> 31) ^ (xor0 << 1) + v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1) +} + +// Initialization Vector +var BLAKE2B_IV32 = new Uint32Array([ + 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, + 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, + 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, + 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 +]) + +var SIGMA8 = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 +] + +// These are offsets into a uint64 buffer. +// Multiply them all by 2 to make them offsets into a uint32 buffer, +// because this is Javascript and we don't have uint64s +var SIGMA82 = new Uint8Array(SIGMA8.map(function (x) { return x * 2 })) + +// Compression function. 'last' flag indicates last block. +// Note we're representing 16 uint64s as 32 uint32s +var v = new Uint32Array(32) +var m = new Uint32Array(32) +function blake2bCompress (ctx, last) { + var i = 0 + + // init work variables + for (i = 0; i < 16; i++) { + v[i] = ctx.h[i] + v[i + 16] = BLAKE2B_IV32[i] + } + + // low 64 bits of offset + v[24] = v[24] ^ ctx.t + v[25] = v[25] ^ (ctx.t / 0x100000000) + // high 64 bits not supported, offset may not be higher than 2**53-1 + + // last block flag set ? + if (last) { + v[28] = ~v[28] + v[29] = ~v[29] + } + + // get little-endian words + for (i = 0; i < 32; i++) { + m[i] = B2B_GET32(ctx.b, 4 * i) + } + + // twelve rounds of mixing + for (i = 0; i < 12; i++) { + B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]) + B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]) + B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]) + B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]) + B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]) + B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]) + B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]) + B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]) + } + + for (i = 0; i < 16; i++) { + ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16] + } +} + +// reusable parameter_block +var parameter_block = new Uint8Array([ + 0, 0, 0, 0, // 0: outlen, keylen, fanout, depth + 0, 0, 0, 0, // 4: leaf length, sequential mode + 0, 0, 0, 0, // 8: node offset + 0, 0, 0, 0, // 12: node offset + 0, 0, 0, 0, // 16: node depth, inner length, rfu + 0, 0, 0, 0, // 20: rfu + 0, 0, 0, 0, // 24: rfu + 0, 0, 0, 0, // 28: rfu + 0, 0, 0, 0, // 32: salt + 0, 0, 0, 0, // 36: salt + 0, 0, 0, 0, // 40: salt + 0, 0, 0, 0, // 44: salt + 0, 0, 0, 0, // 48: personal + 0, 0, 0, 0, // 52: personal + 0, 0, 0, 0, // 56: personal + 0, 0, 0, 0 // 60: personal +]) + +// Creates a BLAKE2b hashing context +// Requires an output length between 1 and 64 bytes +// Takes an optional Uint8Array key +function Blake2b (outlen, key, salt, personal) { + // zero out parameter_block before usage + parameter_block.fill(0) + // state, 'param block' + + this.b = new Uint8Array(128) + this.h = new Uint32Array(16) + this.t = 0 // input count + this.c = 0 // pointer within buffer + this.outlen = outlen // output length in bytes + + parameter_block[0] = outlen + if (key) parameter_block[1] = key.length + parameter_block[2] = 1 // fanout + parameter_block[3] = 1 // depth + + if (salt) parameter_block.set(salt, 32) + if (personal) parameter_block.set(personal, 48) + + // initialize hash state + for (var i = 0; i < 16; i++) { + this.h[i] = BLAKE2B_IV32[i] ^ B2B_GET32(parameter_block, i * 4) + } + + // key the hash, if applicable + if (key) { + blake2bUpdate(this, key) + // at the end + this.c = 128 + } +} + +Blake2b.prototype.update = function (input) { + blake2bUpdate(this, input) + return this +} + +Blake2b.prototype.digest = function (out) { + var buf = (!out || out === 'binary' || out === 'hex') ? new Uint8Array(this.outlen) : out + blake2bFinal(this, buf) + if (out === 'hex') return hexSlice(buf) + return buf +} + +Blake2b.prototype.final = Blake2b.prototype.digest + +// Updates a BLAKE2b streaming hash +// Requires hash context and Uint8Array (byte array) +function blake2bUpdate (ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 128) { // buffer full ? + ctx.t += ctx.c // add counters + blake2bCompress(ctx, false) // compress (not last) + ctx.c = 0 // counter to zero + } + ctx.b[ctx.c++] = input[i] + } +} + +// Completes a BLAKE2b streaming hash +// Returns a Uint8Array containing the message digest +function blake2bFinal (ctx, out) { + ctx.t += ctx.c // mark last block offset + + while (ctx.c < 128) { // fill up with zeros + ctx.b[ctx.c++] = 0 + } + blake2bCompress(ctx, true) // final block flag = 1 + + for (var i = 0; i < ctx.outlen; i++) { + out[i] = ctx.h[i >> 2] >> (8 * (i & 3)) + } + return out +} + +function hexSlice (buf) { + var str = '' + for (var i = 0; i < buf.length; i++) str += toHex(buf[i]) + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +module.exports = Blake2b; +},{}],13:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -2880,7 +3157,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":10}],13:[function(require,module,exports){ +},{"./bech32":10}],14:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -3524,10 +3801,11 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":6}],14:[function(require,module,exports){ +},{"_process":6}],15:[function(require,module,exports){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; +var Blake2B = require('./blake2b'); function numberToHex (number) { var hex = Math.round(number).toString(16); @@ -3537,6 +3815,15 @@ function numberToHex (number) { return hex; } +function hexToUint8(hexString) { + var arr = []; + for (var i = 0; i < hexString.length; i += 2) { + arr.push(parseInt(hexString.substr(i, 2), 16)); + } + + return new Uint8Array(arr); +} + module.exports = { toHex: function (arrayOfBytes) { var hex = ''; @@ -3559,15 +3846,19 @@ module.exports = { blake256Checksum: function (payload) { return this.blake256(this.blake256(payload)).substr(0, 8); }, + blake2b: function (hexString, outlen) { + return new Blake2B(outlen).update(hexToUint8(hexString)).digest('hex'); + }, keccak256: function (hexString) { return keccak256(hexString); } }; -},{"./blake256":11,"./sha3":13,"jssha/src/sha256":5}],15:[function(require,module,exports){ +},{"./blake256":11,"./blake2b":12,"./sha3":14,"jssha/src/sha256":5}],16:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); +var NANOValidator = require('./nano_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -3759,6 +4050,14 @@ var CURRENCIES = [{ name: 'bankex', symbol: 'bkx', validator: ETHValidator +},{ + name: 'nano', + symbol: 'nano', + validator: NANOValidator, +},{ + name: 'raiblocks', + symbol: 'xrb', + validator: NANOValidator, }]; @@ -3775,7 +4074,7 @@ module.exports = { } }; -},{"./bitcoin_validator":8,"./ethereum_validator":16,"./ripple_validator":17}],16:[function(require,module,exports){ +},{"./bitcoin_validator":8,"./ethereum_validator":17,"./nano_validator":18,"./ripple_validator":19}],17:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -3811,7 +4110,36 @@ module.exports = { } }; -},{"./crypto/utils":14}],17:[function(require,module,exports){ +},{"./crypto/utils":15}],18:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var baseX = require('base-x'); + +var ALLOWED_CHARS = '13456789abcdefghijkmnopqrstuwxyz'; + +var codec = baseX(ALLOWED_CHARS); +// https://github.com/nanocurrency/raiblocks/wiki/Accounts,-Keys,-Seeds,-and-Wallet-Identifiers +var regexp = new RegExp('^(xrb|nano)_([' + ALLOWED_CHARS + ']{60})$'); + +module.exports = { + isValidAddress: function (address) { + if (regexp.test(address)) { + return this.verifyChecksum(address); + } + + return false; + }, + + verifyChecksum: function (address) { + var bytes = codec.decode(regexp.exec(address)[2]).slice(-37); + // https://github.com/nanocurrency/raiblocks/blob/master/rai/lib/numbers.cpp#L73 + var computedChecksum = cryptoUtils.blake2b(cryptoUtils.toHex(bytes.slice(0, -5)), 5); + var checksum = cryptoUtils.toHex(bytes.slice(-5).reverse()); + + return computedChecksum === checksum + } +}; + +},{"./crypto/utils":15,"base-x":1}],19:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -3841,7 +4169,7 @@ module.exports = { } }; -},{"./crypto/utils":14,"base-x":1}],18:[function(require,module,exports){ +},{"./crypto/utils":15,"base-x":1}],20:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -3858,5 +4186,5 @@ module.exports = { }, }; -},{"./currencies":15}]},{},[18])(18) +},{"./currencies":16}]},{},[20])(20) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index ec0dbbbc..05c82cdc 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,a,u){function f(r,t){if(!a[r]){if(!s[r]){var e="function"==typeof require&&require;if(!t&&e)return e(r,!0);if(h)return h(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[r]={exports:{}};s[r][0].call(o.exports,function(t){return f(s[r][1][t]||t)},o,o.exports,i,s,a,u)}return a[r].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[s++]=r>>8&255,i[s++]=255&r;var f,h;2===o&&(r=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,i[s++]=255&r);1===o&&(r=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,i[s++]=r>>8&255,i[s++]=255&r);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o=[],i=0,s=e-n;i>2]+a[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],o.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"="));return o.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return w(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,O(R(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return u=this,f=r,h=e,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,O(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function U(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function S(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=0,s=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,o),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,g,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,f,o)};break;case"B64":e=function(t){return E(t,f,o)};break;case"BYTES":e=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",a=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[s++]=r>>8&255,i[s++]=255&r;var f,h;2===o&&(r=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,i[s++]=255&r);1===o&&(r=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,i[s++]=r>>8&255,i[s++]=255&r);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o=[],i=0,s=e-n;i>2]+a[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],o.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"="));return o.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return w(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,O(R(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return u=this,f=r,h=e,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,O(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function U(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function S(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||x(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||x(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||x(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||x(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||x(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||x(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||x(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||x(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||x(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||x(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||T(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||T(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);T(this,t,r,e,o-1,-o)}var i=0,s=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);T(this,t,r,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,o),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,g,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,f,o)};break;case"B64":e=function(t){return E(t,f,o)};break;case"BYTES":e=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",a=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function x(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Thu, 1 Nov 2018 08:49:45 +0200 Subject: [PATCH 066/108] added more erc20 coins (Viberate, Odyssey, Polymath, Storm) --- README.md | 8 ++++-- dist/wallet-address-validator.js | 42 ++++++++++++++++++++++------ dist/wallet-address-validator.min.js | 2 +- package.json | 2 +- src/currencies.js | 34 ++++++++++++++-------- 5 files changed, 64 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 47a1167a..a4c1d58a 100644 --- a/README.md +++ b/README.md @@ -71,17 +71,19 @@ npm install multicoin-address-validator * MonaCoin/mona `'MonaCoin'` or `'mona'` * Monero/xmr `'Monero'` or `'xmr'` * NameCoin/nmc `'NameCoin'` or `'nmc'` -* nano/nano `'nano'` or `'nano'` +* Nano/nano `'Nano'` or `'nano'` * Neo/neo `'Neo'` or `'neo'` * NeoGas/gas `'NeoGas'` or `'gas'` * Numeraire/nmr `'Numeraire'` or `'nmr'` +* Odyssey/ocn `'Odyssey'` or `'ocn'` * OmiseGO/omg `'OmiseGO'` or `'omg'` * PeerCoin/ppc `'PeerCoin'` or `'ppc'` * PIVX/pivx `'PIVX'` or `'pivx'` +* Polymath/poly `'Polymath'` or `'poly'` * PrimeCoin/xpm `'PrimeCoin'` or `'xpm'` * ProtoShares/pts `'ProtoShares'` or `'pts'` * Qtum/qtum `'Qtum'` or `'qtum'` -* raiblocks/xrb `'raiblocks'` or `'xrb'` +* RaiBlocks/xrb `'RaiBlocks'` or `'xrb'` * Ripio Credit Network/rcn `'Ripio Credit Network'` or `'rcn'` * Ripple/xrp `'Ripple'` or `'xrp'` * Salt/salt `'Salt'` or `'salt'` @@ -89,11 +91,13 @@ npm install multicoin-address-validator * SolarCoin/slr `'SolarCoin'` or `'slr'` * Status/snt `'Status'` or `'snt'` * Storj/storj `'Storj'` or `'storj'` +* Storm/storm `'Storm'` or `'storm'` * Swarm City/swt `'Swarm City'` or `'swt'` * TenX/pay `'TenX'` or `'pay'` * Tether/usdt `'Tether'` or `'usdt'` * TrueUSD/tusd `'TrueUSD'` or `'tusd'` * VertCoin/vtc `'VertCoin'` or `'vtc'` +* Viberate/vib `'Viberate'` or `'vib'` * VoteCoin/vot `'VoteCoin'` or `'vot'` * Waves/waves `'Waves'` or `'waves'` * Wings/wings `'Wings'` or `'wings'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 06a12cae..a7e8d811 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -6889,10 +6889,22 @@ var CURRENCIES = [{ name: 'Augur', symbol: 'rep', validator: ETHValidator +}, { + name: 'iExec RLC', + symbol: 'rlc', + validator: ETHValidator +}, { + name: 'Salt', + symbol: 'salt', + validator: ETHValidator }, { name: 'Status', symbol: 'snt', validator: ETHValidator +}, { + name: 'Storj', + symbol: 'storj', + validator: ETHValidator }, { name: 'Swarm City', symbol: 'swt', @@ -6914,11 +6926,27 @@ var CURRENCIES = [{ symbol: 'exp', validator: ETHValidator }, { - name: 'nano', + name: 'Viberate', + symbol: 'vib', + validator: ETHValidator +}, { + name: 'Odyssey', + symbol: 'ocn', + validator: ETHValidator +}, { + name: 'Polymath', + symbol: 'poly', + validator: ETHValidator +}, { + name: 'Storm', + symbol: 'storm', + validator: ETHValidator +}, { + name: 'Nano', symbol: 'nano', validator: NANOValidator, }, { - name: 'raiblocks', + name: 'RaiBlocks', symbol: 'xrb', validator: NANOValidator, }]; @@ -6927,13 +6955,9 @@ var CURRENCIES = [{ module.exports = { getByNameOrSymbol: function (currencyNameOrSymbol) { var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); - for (var i = 0; i < CURRENCIES.length; i++) { - var currency = CURRENCIES[i]; - if (currency.name.toLowerCase() === nameOrSymbol || currency.symbol.toLowerCase() === nameOrSymbol) { - return currency; - } - } - return null; + return CURRENCIES.find(function (currency) { + return currency.name.toLowerCase() === nameOrSymbol || currency.symbol.toLowerCase() === nameOrSymbol + }); } }; diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 5ac64cc1..42db798b 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function o(a,s,u){function f(e,t){if(!s[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var i=s[e]={exports:{}};a[e][0].call(i.exports,function(t){return f(a[e][1][t]||t)},i,i.exports,o,a,s,u)}return s[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,r,e){!function(t,x){"use strict";var k=Math.pow(2,-24),U=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,o=0;o>6):(o<55296?i.push(224|o>>12):(o=(1023&o)<<10,o|=1023&e.charCodeAt(++r),o+=65536,i.push(240|o>>18),i.push(128|o>>12&63)),i.push(128|o>>6&63)),i.push(128|63&o))}return p(3,i.length),d(i);default:var a;if(Array.isArray(e))for(p(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function B(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof d&&(d=function(t){return t}),"function"!=typeof p&&(p=function(){return x});var t=function t(){var e,r,n=w(),i=n>>5,o=31&n;if(7===i)switch(o){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,i=31744&r,o=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==o)return o*k;return e.setUint32(0,n<<16|i<<13|o<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(o))<0&&(i<2||6>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var i,o;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(v.slice(),g,y,d(s)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=i[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,r,e){!function(t,x){"use strict";var k=Math.pow(2,-24),U=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,o=0;o>6):(o<55296?i.push(224|o>>12):(o=(1023&o)<<10,o|=1023&e.charCodeAt(++r),o+=65536,i.push(240|o>>18),i.push(128|o>>12&63)),i.push(128|o>>6&63)),i.push(128|63&o))}return p(3,i.length),d(i);default:var a;if(Array.isArray(e))for(p(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function B(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof d&&(d=function(t){return t}),"function"!=typeof p&&(p=function(){return x});var t=function t(){var e,r,n=w(),i=n>>5,o=31&n;if(7===i)switch(o){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,i=31744&r,o=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==o)return o*k;return e.setUint32(0,n<<16|i<<13|o<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(o))<0&&(i<2||6>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var i,o;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(v.slice(),g,y,d(s)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=i[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i Date: Mon, 5 Nov 2018 18:20:43 +0200 Subject: [PATCH 067/108] removed unneccesary toArrayBuffer method --- dist/wallet-address-validator.js | 10 +--------- dist/wallet-address-validator.min.js | 2 +- src/ada_validator.js | 10 +--------- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index a7e8d811..67857ac6 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -3357,19 +3357,11 @@ var cbor = require('cbor-js'); var bs58 = require('bs58'); var CRC = require('crc'); -function toArrayBuffer(buf) { - var ab = new ArrayBuffer(buf.length); - var view = new Uint8Array(ab); - for (var i = 0; i < buf.length; ++i) { - view[i] = buf[i]; - } - return ab; -} function getDecoded(address) { try { var decoded = bs58.decode(address); - return decoded = cbor.decode(toArrayBuffer(decoded)); + return cbor.decode(new Uint8Array(decoded).buffer); } catch (e) { // if decoding fails, assume invalid address return null; diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 42db798b..4c047a4d 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function o(a,s,u){function f(e,t){if(!s[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var i=s[e]={exports:{}};a[e][0].call(i.exports,function(t){return f(a[e][1][t]||t)},i,i.exports,o,a,s,u)}return s[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,r,e){!function(t,x){"use strict";var k=Math.pow(2,-24),U=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,o=0;o>6):(o<55296?i.push(224|o>>12):(o=(1023&o)<<10,o|=1023&e.charCodeAt(++r),o+=65536,i.push(240|o>>18),i.push(128|o>>12&63)),i.push(128|o>>6&63)),i.push(128|63&o))}return p(3,i.length),d(i);default:var a;if(Array.isArray(e))for(p(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function B(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof d&&(d=function(t){return t}),"function"!=typeof p&&(p=function(){return x});var t=function t(){var e,r,n=w(),i=n>>5,o=31&n;if(7===i)switch(o){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,i=31744&r,o=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==o)return o*k;return e.setUint32(0,n<<16|i<<13|o<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(o))<0&&(i<2||6>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var i,o;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(v.slice(),g,y,d(s)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=i[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,r,e){!function(t,x){"use strict";var k=Math.pow(2,-24),U=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,o=0;o>6):(o<55296?i.push(224|o>>12):(o=(1023&o)<<10,o|=1023&e.charCodeAt(++r),o+=65536,i.push(240|o>>18),i.push(128|o>>12&63)),i.push(128|o>>6&63)),i.push(128|63&o))}return p(3,i.length),d(i);default:var a;if(Array.isArray(e))for(p(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function B(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof d&&(d=function(t){return t}),"function"!=typeof p&&(p=function(){return x});var t=function t(){var e,r,n=w(),i=n>>5,o=31&n;if(7===i)switch(o){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,i=31744&r,o=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==o)return o*k;return e.setUint32(0,n<<16|i<<13|o<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(o))<0&&(i<2||6>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var i,o;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(v.slice(),g,y,d(s)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=i[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i Date: Mon, 5 Nov 2018 18:23:04 +0200 Subject: [PATCH 068/108] removed duplicate base58 decoding package --- dist/wallet-address-validator.js | 108 +++++++++++++-------------- dist/wallet-address-validator.min.js | 2 +- package.json | 1 - src/ada_validator.js | 4 +- yarn.lock | 9 +-- 5 files changed, 55 insertions(+), 69 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 67857ac6..4dda9ce5 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -92,7 +92,7 @@ module.exports = function base (ALPHABET) { } } -},{"safe-buffer":34}],2:[function(require,module,exports){ +},{"safe-buffer":33}],2:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -246,12 +246,6 @@ function fromByteArray (uint8) { } },{}],3:[function(require,module,exports){ -var basex = require('base-x') -var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' - -module.exports = basex(ALPHABET) - -},{"base-x":1}],4:[function(require,module,exports){ /*! * The buffer module from node.js, for the browser. * @@ -2030,7 +2024,7 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -},{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ +},{"base64-js":2,"ieee754":30}],4:[function(require,module,exports){ /* * The MIT License (MIT) * @@ -2438,62 +2432,62 @@ else if (!global.CBOR) })(this); -},{}],6:[function(require,module,exports){ +},{}],5:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc1').default; -},{"./es6/crc1":17}],7:[function(require,module,exports){ +},{"./es6/crc1":16}],6:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16').default; -},{"./es6/crc16":18}],8:[function(require,module,exports){ +},{"./es6/crc16":17}],7:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16ccitt').default; -},{"./es6/crc16ccitt":19}],9:[function(require,module,exports){ +},{"./es6/crc16ccitt":18}],8:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16kermit').default; -},{"./es6/crc16kermit":20}],10:[function(require,module,exports){ +},{"./es6/crc16kermit":19}],9:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16modbus').default; -},{"./es6/crc16modbus":21}],11:[function(require,module,exports){ +},{"./es6/crc16modbus":20}],10:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16xmodem').default; -},{"./es6/crc16xmodem":22}],12:[function(require,module,exports){ +},{"./es6/crc16xmodem":21}],11:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc24').default; -},{"./es6/crc24":23}],13:[function(require,module,exports){ +},{"./es6/crc24":22}],12:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc32').default; -},{"./es6/crc32":24}],14:[function(require,module,exports){ +},{"./es6/crc32":23}],13:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc8').default; -},{"./es6/crc8":25}],15:[function(require,module,exports){ +},{"./es6/crc8":24}],14:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc81wire').default; -},{"./es6/crc81wire":26}],16:[function(require,module,exports){ +},{"./es6/crc81wire":25}],15:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crcjam').default; -},{"./es6/crcjam":27}],17:[function(require,module,exports){ +},{"./es6/crcjam":26}],16:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2529,7 +2523,7 @@ var crc1 = (0, _define_crc2.default)('crc1', function (buf, previous) { exports.default = crc1; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],18:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],17:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2569,7 +2563,7 @@ var crc16 = (0, _define_crc2.default)('crc-16', function (buf, previous) { exports.default = crc16; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],19:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],18:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2609,7 +2603,7 @@ var crc16ccitt = (0, _define_crc2.default)('ccitt', function (buf, previous) { exports.default = crc16ccitt; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],20:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],19:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2649,7 +2643,7 @@ var crc16kermit = (0, _define_crc2.default)('kermit', function (buf, previous) { exports.default = crc16kermit; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],21:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],20:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2689,7 +2683,7 @@ var crc16modbus = (0, _define_crc2.default)('crc-16-modbus', function (buf, prev exports.default = crc16modbus; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],22:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],21:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2732,7 +2726,7 @@ var crc16xmodem = (0, _define_crc2.default)('xmodem', function (buf, previous) { exports.default = crc16xmodem; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],23:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],22:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2772,7 +2766,7 @@ var crc24 = (0, _define_crc2.default)('crc-24', function (buf, previous) { exports.default = crc24; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],24:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],23:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2812,7 +2806,7 @@ var crc32 = (0, _define_crc2.default)('crc-32', function (buf, previous) { exports.default = crc32; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],25:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],24:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2852,7 +2846,7 @@ var crc8 = (0, _define_crc2.default)('crc-8', function (buf, previous) { exports.default = crc8; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],26:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],25:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2892,7 +2886,7 @@ var crc81wire = (0, _define_crc2.default)('dallas-1-wire', function (buf, previo exports.default = crc81wire; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],27:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],26:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2934,7 +2928,7 @@ var crcjam = (0, _define_crc2.default)('jam', function (buf) { exports.default = crcjam; -},{"./create_buffer":28,"./define_crc":29,"buffer":4}],28:[function(require,module,exports){ +},{"./create_buffer":27,"./define_crc":28,"buffer":3}],27:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2950,7 +2944,7 @@ function (val) { exports.default = createBuffer; -},{"buffer":4}],29:[function(require,module,exports){ +},{"buffer":3}],28:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -2968,7 +2962,7 @@ exports.default = function (model, calc) { return fn; }; -},{}],30:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ 'use strict'; module.exports = { @@ -2985,7 +2979,7 @@ module.exports = { crcjam: require('./crcjam') }; -},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(require,module,exports){ +},{"./crc1":5,"./crc16":6,"./crc16_ccitt":7,"./crc16_kermit":8,"./crc16_modbus":9,"./crc16_xmodem":10,"./crc24":11,"./crc32":12,"./crc8":13,"./crc8_1wire":14,"./crcjam":15}],30:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -3071,7 +3065,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],32:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ /* A JavaScript implementation of the SHA family of hashes, as defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding @@ -3102,7 +3096,7 @@ new m,new m,new m,new m,new m,new m];break;case "SHA-512":a=[new m,new m,new m,n 2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474, 2756734187,3204031479,3329325298];"function"===typeof define&&define.amd?define(function(){return w}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(module.exports=w),exports=w):I.jsSHA=w})(this); -},{}],33:[function(require,module,exports){ +},{}],32:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -3288,7 +3282,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],34:[function(require,module,exports){ +},{}],33:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -3352,15 +3346,15 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":4}],35:[function(require,module,exports){ +},{"buffer":3}],34:[function(require,module,exports){ var cbor = require('cbor-js'); -var bs58 = require('bs58'); var CRC = require('crc'); +var base58 = require('./crypto/base58'); function getDecoded(address) { try { - var decoded = bs58.decode(address); + var decoded = base58.decode(address); return cbor.decode(new Uint8Array(decoded).buffer); } catch (e) { // if decoding fails, assume invalid address @@ -3389,7 +3383,7 @@ module.exports = { } }; -},{"bs58":3,"cbor-js":5,"crc":30}],36:[function(require,module,exports){ +},{"./crypto/base58":36,"cbor-js":4,"crc":29}],35:[function(require,module,exports){ (function (Buffer){ var base58 = require('./crypto/base58'); var segwit = require('./crypto/segwit_addr'); @@ -3479,7 +3473,7 @@ module.exports = { }; }).call(this,require("buffer").Buffer) -},{"./crypto/base58":37,"./crypto/segwit_addr":43,"./crypto/utils":45,"buffer":4}],37:[function(require,module,exports){ +},{"./crypto/base58":36,"./crypto/segwit_addr":42,"./crypto/utils":44,"buffer":3}],36:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -3527,7 +3521,7 @@ module.exports = { } }; -},{}],38:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -3645,7 +3639,7 @@ function decode (bechString) { return {hrp: hrp, data: data.slice(0, data.length - 6)}; } -},{}],39:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ /* JavaScript BigInteger library version 0.9.1 http://silentmatt.com/biginteger/ @@ -5096,7 +5090,7 @@ function decode (bechString) { exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt })(typeof exports !== 'undefined' ? exports : this); -},{}],40:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -5287,7 +5281,7 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":4}],41:[function(require,module,exports){ +},{"buffer":3}],40:[function(require,module,exports){ 'use strict'; /** @@ -5565,7 +5559,7 @@ function toHex (n) { module.exports = Blake2b; -},{}],42:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ var JSBigInt = require('./biginteger')['JSBigInt']; /** @@ -5792,7 +5786,7 @@ var cnBase58 = (function () { return b58; })(); module.exports = cnBase58; -},{"./biginteger":39}],43:[function(require,module,exports){ +},{"./biginteger":38}],42:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -5888,7 +5882,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":38}],44:[function(require,module,exports){ +},{"./bech32":37}],43:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -6532,7 +6526,7 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":33}],45:[function(require,module,exports){ +},{"_process":32}],44:[function(require,module,exports){ (function (Buffer){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); @@ -6584,7 +6578,7 @@ module.exports = { }; }).call(this,require("buffer").Buffer) -},{"./blake256":40,"./blake2b":41,"./sha3":44,"buffer":4,"jssha/src/sha256":32}],46:[function(require,module,exports){ +},{"./blake256":39,"./blake2b":40,"./sha3":43,"buffer":3,"jssha/src/sha256":31}],45:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); @@ -6960,7 +6954,7 @@ module.exports = { -},{"./ada_validator":35,"./bitcoin_validator":36,"./ethereum_validator":47,"./monero_validator":48,"./nano_validator":49,"./ripple_validator":50}],47:[function(require,module,exports){ +},{"./ada_validator":34,"./bitcoin_validator":35,"./ethereum_validator":46,"./monero_validator":47,"./nano_validator":48,"./ripple_validator":49}],46:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -6996,7 +6990,7 @@ module.exports = { } }; -},{"./crypto/utils":45}],48:[function(require,module,exports){ +},{"./crypto/utils":44}],47:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var cnBase58 = require('./crypto/cnBase58'); @@ -7058,7 +7052,7 @@ module.exports = { } }; -},{"./crypto/cnBase58":42,"./crypto/utils":45}],49:[function(require,module,exports){ +},{"./crypto/cnBase58":41,"./crypto/utils":44}],48:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -7087,7 +7081,7 @@ module.exports = { } }; -},{"./crypto/utils":45,"base-x":1}],50:[function(require,module,exports){ +},{"./crypto/utils":44,"base-x":1}],49:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -7117,7 +7111,7 @@ module.exports = { } }; -},{"./crypto/utils":45,"base-x":1}],51:[function(require,module,exports){ +},{"./crypto/utils":44,"base-x":1}],50:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -7134,5 +7128,5 @@ module.exports = { }, }; -},{"./currencies":46}]},{},[51])(51) +},{"./currencies":45}]},{},[50])(50) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 4c047a4d..0dac6d5a 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function o(a,s,u){function f(e,t){if(!s[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var i=s[e]={exports:{}};a[e][0].call(i.exports,function(t){return f(a[e][1][t]||t)},i,i.exports,o,a,s,u)}return s[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":1}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,r,e){!function(t,x){"use strict";var k=Math.pow(2,-24),U=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,o=0;o>6):(o<55296?i.push(224|o>>12):(o=(1023&o)<<10,o|=1023&e.charCodeAt(++r),o+=65536,i.push(240|o>>18),i.push(128|o>>12&63)),i.push(128|o>>6&63)),i.push(128|63&o))}return p(3,i.length),d(i);default:var a;if(Array.isArray(e))for(p(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function B(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof d&&(d=function(t){return t}),"function"!=typeof p&&(p=function(){return x});var t=function t(){var e,r,n=w(),i=n>>5,o=31&n;if(7===i)switch(o){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,i=31744&r,o=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==o)return o*k;return e.setUint32(0,n<<16|i<<13|o<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(o))<0&&(i<2||6>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var i,o;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(v.slice(),g,y,d(s)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=i[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:R(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,d,p=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,d=r,L(R(t,(h=this).length-l),h,l,d);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(O(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;it.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}},{"base64-js":2,ieee754:30}],4:[function(t,r,e){!function(t,x){"use strict";var k=Math.pow(2,-24),U=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,o=0;o>6):(o<55296?i.push(224|o>>12):(o=(1023&o)<<10,o|=1023&e.charCodeAt(++r),o+=65536,i.push(240|o>>18),i.push(128|o>>12&63)),i.push(128|o>>6&63)),i.push(128|63&o))}return p(3,i.length),d(i);default:var a;if(Array.isArray(e))for(p(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function B(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof d&&(d=function(t){return t}),"function"!=typeof p&&(p=function(){return x});var t=function t(){var e,r,n=w(),i=n>>5,o=31&n;if(7===i)switch(o){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,i=31744&r,o=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==o)return o*k;return e.setUint32(0,n<<16|i<<13|o<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(o))<0&&(i<2||6>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],18:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("xmodem",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;i^=255&t[n],r=r<<8&65535,r^=i^=i>>>4,r^=i=i<<5&65535,r^=i=i<<7&65535}return r});r.default=i},{"./create_buffer":27,"./define_crc":28,buffer:3}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^i)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],27:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:3}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],29:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":5,"./crc16":6,"./crc16_ccitt":7,"./crc16_kermit":8,"./crc16_modbus":9,"./crc16_xmodem":10,"./crc24":11,"./crc32":12,"./crc8":13,"./crc8_1wire":14,"./crcjam":15}],30:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var i,o;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(e+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[i]=4294967295&e,t[i-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,i,o;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(i=x(e),t){case"HEX":r=function(t){return _(t,f,i)};break;case"B64":r=function(t){return A(t,f,i)};break;case"BYTES":r=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(v.slice(),g,y,d(s)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function A(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function E(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function x(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function k(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,i,o,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=i[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i Date: Sat, 10 Nov 2018 20:40:21 -0500 Subject: [PATCH 069/108] add sc and xsc --- .prettierrc | 8 + dist/wallet-address-validator.js | 3547 ++++++++++++++++++++++++-- dist/wallet-address-validator.min.js | 2 +- package-lock.json | 1798 ++++++------- package.json | 4 +- src/crypto/utils.js | 4 +- src/currencies.js | 226 +- src/siacoin_validator.js | 30 + test/wallet_address_validator.js | 1111 ++++---- 9 files changed, 4992 insertions(+), 1738 deletions(-) create mode 100644 .prettierrc create mode 100644 src/siacoin_validator.js diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..d9b167e5 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "printWidth": 100, + "singleQuote": true, + "useTabs": false, + "semi": false, + "tabWidth": 2, + "trailingComma": "none" + } diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 9eba6b47..b0d5c8f3 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -92,7 +92,7 @@ module.exports = function base (ALPHABET) { } } -},{"safe-buffer":7}],2:[function(require,module,exports){ +},{"safe-buffer":100}],2:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -246,6 +246,575 @@ function fromByteArray (uint8) { } },{}],3:[function(require,module,exports){ +// Blake2B in pure Javascript +// Adapted from the reference implementation in RFC7693 +// Ported to Javascript by DC - https://github.com/dcposch + +var util = require('./util') + +// 64-bit unsigned addition +// Sets v[a,a+1] += v[b,b+1] +// v should be a Uint32Array +function ADD64AA (v, a, b) { + var o0 = v[a] + v[b] + var o1 = v[a + 1] + v[b + 1] + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// 64-bit unsigned addition +// Sets v[a,a+1] += b +// b0 is the low 32 bits of b, b1 represents the high 32 bits +function ADD64AC (v, a, b0, b1) { + var o0 = v[a] + b0 + if (b0 < 0) { + o0 += 0x100000000 + } + var o1 = v[a + 1] + b1 + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 +} + +// Little-endian byte access +function B2B_GET32 (arr, i) { + return (arr[i] ^ + (arr[i + 1] << 8) ^ + (arr[i + 2] << 16) ^ + (arr[i + 3] << 24)) +} + +// G Mixing function +// The ROTRs are inlined for speed +function B2B_G (a, b, c, d, ix, iy) { + var x0 = m[ix] + var x1 = m[ix + 1] + var y0 = m[iy] + var y1 = m[iy + 1] + + ADD64AA(v, a, b) // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s + ADD64AC(v, a, x0, x1) // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits + var xor0 = v[d] ^ v[a] + var xor1 = v[d + 1] ^ v[a + 1] + v[d] = xor1 + v[d + 1] = xor0 + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor0 >>> 24) ^ (xor1 << 8) + v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8) + + ADD64AA(v, a, b) + ADD64AC(v, a, y0, y1) + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits + xor0 = v[d] ^ v[a] + xor1 = v[d + 1] ^ v[a + 1] + v[d] = (xor0 >>> 16) ^ (xor1 << 16) + v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16) + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor1 >>> 31) ^ (xor0 << 1) + v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1) +} + +// Initialization Vector +var BLAKE2B_IV32 = new Uint32Array([ + 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, + 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, + 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, + 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 +]) + +var SIGMA8 = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 +] + +// These are offsets into a uint64 buffer. +// Multiply them all by 2 to make them offsets into a uint32 buffer, +// because this is Javascript and we don't have uint64s +var SIGMA82 = new Uint8Array(SIGMA8.map(function (x) { return x * 2 })) + +// Compression function. 'last' flag indicates last block. +// Note we're representing 16 uint64s as 32 uint32s +var v = new Uint32Array(32) +var m = new Uint32Array(32) +function blake2bCompress (ctx, last) { + var i = 0 + + // init work variables + for (i = 0; i < 16; i++) { + v[i] = ctx.h[i] + v[i + 16] = BLAKE2B_IV32[i] + } + + // low 64 bits of offset + v[24] = v[24] ^ ctx.t + v[25] = v[25] ^ (ctx.t / 0x100000000) + // high 64 bits not supported, offset may not be higher than 2**53-1 + + // last block flag set ? + if (last) { + v[28] = ~v[28] + v[29] = ~v[29] + } + + // get little-endian words + for (i = 0; i < 32; i++) { + m[i] = B2B_GET32(ctx.b, 4 * i) + } + + // twelve rounds of mixing + // uncomment the DebugPrint calls to log the computation + // and match the RFC sample documentation + // util.debugPrint(' m[16]', m, 64) + for (i = 0; i < 12; i++) { + // util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64) + B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]) + B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]) + B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]) + B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]) + B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]) + B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]) + B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]) + B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]) + } + // util.debugPrint(' (i=12) v[16]', v, 64) + + for (i = 0; i < 16; i++) { + ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16] + } + // util.debugPrint('h[8]', ctx.h, 64) +} + +// Creates a BLAKE2b hashing context +// Requires an output length between 1 and 64 bytes +// Takes an optional Uint8Array key +function blake2bInit (outlen, key) { + if (outlen === 0 || outlen > 64) { + throw new Error('Illegal output length, expected 0 < length <= 64') + } + if (key && key.length > 64) { + throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64') + } + + // state, 'param block' + var ctx = { + b: new Uint8Array(128), + h: new Uint32Array(16), + t: 0, // input count + c: 0, // pointer within buffer + outlen: outlen // output length in bytes + } + + // initialize hash state + for (var i = 0; i < 16; i++) { + ctx.h[i] = BLAKE2B_IV32[i] + } + var keylen = key ? key.length : 0 + ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen + + // key the hash, if applicable + if (key) { + blake2bUpdate(ctx, key) + // at the end + ctx.c = 128 + } + + return ctx +} + +// Updates a BLAKE2b streaming hash +// Requires hash context and Uint8Array (byte array) +function blake2bUpdate (ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 128) { // buffer full ? + ctx.t += ctx.c // add counters + blake2bCompress(ctx, false) // compress (not last) + ctx.c = 0 // counter to zero + } + ctx.b[ctx.c++] = input[i] + } +} + +// Completes a BLAKE2b streaming hash +// Returns a Uint8Array containing the message digest +function blake2bFinal (ctx) { + ctx.t += ctx.c // mark last block offset + + while (ctx.c < 128) { // fill up with zeros + ctx.b[ctx.c++] = 0 + } + blake2bCompress(ctx, true) // final block flag = 1 + + // little endian convert and store + var out = new Uint8Array(ctx.outlen) + for (var i = 0; i < ctx.outlen; i++) { + out[i] = ctx.h[i >> 2] >> (8 * (i & 3)) + } + return out +} + +// Computes the BLAKE2B hash of a string or byte array, and returns a Uint8Array +// +// Returns a n-byte Uint8Array +// +// Parameters: +// - input - the input bytes, as a string, Buffer or Uint8Array +// - key - optional key Uint8Array, up to 64 bytes +// - outlen - optional output length in bytes, default 64 +function blake2b (input, key, outlen) { + // preprocess inputs + outlen = outlen || 64 + input = util.normalizeInput(input) + + // do the math + var ctx = blake2bInit(outlen, key) + blake2bUpdate(ctx, input) + return blake2bFinal(ctx) +} + +// Computes the BLAKE2B hash of a string or byte array +// +// Returns an n-byte hash in hex, all lowercase +// +// Parameters: +// - input - the input bytes, as a string, Buffer, or Uint8Array +// - key - optional key Uint8Array, up to 64 bytes +// - outlen - optional output length in bytes, default 64 +function blake2bHex (input, key, outlen) { + var output = blake2b(input, key, outlen) + return util.toHex(output) +} + +module.exports = { + blake2b: blake2b, + blake2bHex: blake2bHex, + blake2bInit: blake2bInit, + blake2bUpdate: blake2bUpdate, + blake2bFinal: blake2bFinal +} + +},{"./util":6}],4:[function(require,module,exports){ +// BLAKE2s hash function in pure Javascript +// Adapted from the reference implementation in RFC7693 +// Ported to Javascript by DC - https://github.com/dcposch + +var util = require('./util') + +// Little-endian byte access. +// Expects a Uint8Array and an index +// Returns the little-endian uint32 at v[i..i+3] +function B2S_GET32 (v, i) { + return v[i] ^ (v[i + 1] << 8) ^ (v[i + 2] << 16) ^ (v[i + 3] << 24) +} + +// Mixing function G. +function B2S_G (a, b, c, d, x, y) { + v[a] = v[a] + v[b] + x + v[d] = ROTR32(v[d] ^ v[a], 16) + v[c] = v[c] + v[d] + v[b] = ROTR32(v[b] ^ v[c], 12) + v[a] = v[a] + v[b] + y + v[d] = ROTR32(v[d] ^ v[a], 8) + v[c] = v[c] + v[d] + v[b] = ROTR32(v[b] ^ v[c], 7) +} + +// 32-bit right rotation +// x should be a uint32 +// y must be between 1 and 31, inclusive +function ROTR32 (x, y) { + return (x >>> y) ^ (x << (32 - y)) +} + +// Initialization Vector. +var BLAKE2S_IV = new Uint32Array([ + 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, + 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19]) + +var SIGMA = new Uint8Array([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0]) + +// Compression function. "last" flag indicates last block +var v = new Uint32Array(16) +var m = new Uint32Array(16) +function blake2sCompress (ctx, last) { + var i = 0 + for (i = 0; i < 8; i++) { // init work variables + v[i] = ctx.h[i] + v[i + 8] = BLAKE2S_IV[i] + } + + v[12] ^= ctx.t // low 32 bits of offset + v[13] ^= (ctx.t / 0x100000000) // high 32 bits + if (last) { // last block flag set ? + v[14] = ~v[14] + } + + for (i = 0; i < 16; i++) { // get little-endian words + m[i] = B2S_GET32(ctx.b, 4 * i) + } + + // ten rounds of mixing + // uncomment the DebugPrint calls to log the computation + // and match the RFC sample documentation + // util.debugPrint(' m[16]', m, 32) + for (i = 0; i < 10; i++) { + // util.debugPrint(' (i=' + i + ') v[16]', v, 32) + B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]) + B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]) + B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]) + B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]) + B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]) + B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]) + B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]) + B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]) + } + // util.debugPrint(' (i=10) v[16]', v, 32) + + for (i = 0; i < 8; i++) { + ctx.h[i] ^= v[i] ^ v[i + 8] + } + // util.debugPrint('h[8]', ctx.h, 32) +} + +// Creates a BLAKE2s hashing context +// Requires an output length between 1 and 32 bytes +// Takes an optional Uint8Array key +function blake2sInit (outlen, key) { + if (!(outlen > 0 && outlen <= 32)) { + throw new Error('Incorrect output length, should be in [1, 32]') + } + var keylen = key ? key.length : 0 + if (key && !(keylen > 0 && keylen <= 32)) { + throw new Error('Incorrect key length, should be in [1, 32]') + } + + var ctx = { + h: new Uint32Array(BLAKE2S_IV), // hash state + b: new Uint32Array(64), // input block + c: 0, // pointer within block + t: 0, // input count + outlen: outlen // output length in bytes + } + ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen + + if (keylen > 0) { + blake2sUpdate(ctx, key) + ctx.c = 64 // at the end + } + + return ctx +} + +// Updates a BLAKE2s streaming hash +// Requires hash context and Uint8Array (byte array) +function blake2sUpdate (ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 64) { // buffer full ? + ctx.t += ctx.c // add counters + blake2sCompress(ctx, false) // compress (not last) + ctx.c = 0 // counter to zero + } + ctx.b[ctx.c++] = input[i] + } +} + +// Completes a BLAKE2s streaming hash +// Returns a Uint8Array containing the message digest +function blake2sFinal (ctx) { + ctx.t += ctx.c // mark last block offset + while (ctx.c < 64) { // fill up with zeros + ctx.b[ctx.c++] = 0 + } + blake2sCompress(ctx, true) // final block flag = 1 + + // little endian convert and store + var out = new Uint8Array(ctx.outlen) + for (var i = 0; i < ctx.outlen; i++) { + out[i] = (ctx.h[i >> 2] >> (8 * (i & 3))) & 0xFF + } + return out +} + +// Computes the BLAKE2S hash of a string or byte array, and returns a Uint8Array +// +// Returns a n-byte Uint8Array +// +// Parameters: +// - input - the input bytes, as a string, Buffer, or Uint8Array +// - key - optional key Uint8Array, up to 32 bytes +// - outlen - optional output length in bytes, default 64 +function blake2s (input, key, outlen) { + // preprocess inputs + outlen = outlen || 32 + input = util.normalizeInput(input) + + // do the math + var ctx = blake2sInit(outlen, key) + blake2sUpdate(ctx, input) + return blake2sFinal(ctx) +} + +// Computes the BLAKE2S hash of a string or byte array +// +// Returns an n-byte hash in hex, all lowercase +// +// Parameters: +// - input - the input bytes, as a string, Buffer, or Uint8Array +// - key - optional key Uint8Array, up to 32 bytes +// - outlen - optional output length in bytes, default 64 +function blake2sHex (input, key, outlen) { + var output = blake2s(input, key, outlen) + return util.toHex(output) +} + +module.exports = { + blake2s: blake2s, + blake2sHex: blake2sHex, + blake2sInit: blake2sInit, + blake2sUpdate: blake2sUpdate, + blake2sFinal: blake2sFinal +} + +},{"./util":6}],5:[function(require,module,exports){ +var b2b = require('./blake2b') +var b2s = require('./blake2s') + +module.exports = { + blake2b: b2b.blake2b, + blake2bHex: b2b.blake2bHex, + blake2bInit: b2b.blake2bInit, + blake2bUpdate: b2b.blake2bUpdate, + blake2bFinal: b2b.blake2bFinal, + blake2s: b2s.blake2s, + blake2sHex: b2s.blake2sHex, + blake2sInit: b2s.blake2sInit, + blake2sUpdate: b2s.blake2sUpdate, + blake2sFinal: b2s.blake2sFinal +} + +},{"./blake2b":3,"./blake2s":4}],6:[function(require,module,exports){ +(function (Buffer){ +var ERROR_MSG_INPUT = 'Input must be an string, Buffer or Uint8Array' + +// For convenience, let people hash a string, not just a Uint8Array +function normalizeInput (input) { + var ret + if (input instanceof Uint8Array) { + ret = input + } else if (input instanceof Buffer) { + ret = new Uint8Array(input) + } else if (typeof (input) === 'string') { + ret = new Uint8Array(Buffer.from(input, 'utf8')) + } else { + throw new Error(ERROR_MSG_INPUT) + } + return ret +} + +// Converts a Uint8Array to a hexadecimal string +// For example, toHex([255, 0, 255]) returns "ff00ff" +function toHex (bytes) { + return Array.prototype.map.call(bytes, function (n) { + return (n < 16 ? '0' : '') + n.toString(16) + }).join('') +} + +// Converts any value in [0...2^32-1] to an 8-character hex string +function uint32ToHex (val) { + return (0x100000000 + val).toString(16).substring(1) +} + +// For debugging: prints out hash state in the same format as the RFC +// sample computation exactly, so that you can diff +function debugPrint (label, arr, size) { + var msg = '\n' + label + ' = ' + for (var i = 0; i < arr.length; i += 2) { + if (size === 32) { + msg += uint32ToHex(arr[i]).toUpperCase() + msg += ' ' + msg += uint32ToHex(arr[i + 1]).toUpperCase() + } else if (size === 64) { + msg += uint32ToHex(arr[i + 1]).toUpperCase() + msg += uint32ToHex(arr[i]).toUpperCase() + } else throw new Error('Invalid size ' + size) + if (i % 6 === 4) { + msg += '\n' + new Array(label.length + 4).join(' ') + } else if (i < arr.length - 2) { + msg += ' ' + } + } + console.log(msg) +} + +// For performance testing: generates N bytes of input, hashes M times +// Measures and prints MB/second hash performance each time +function testSpeed (hashFn, N, M) { + var startMs = new Date().getTime() + + var input = new Uint8Array(N) + for (var i = 0; i < N; i++) { + input[i] = i % 256 + } + var genMs = new Date().getTime() + console.log('Generated random input in ' + (genMs - startMs) + 'ms') + startMs = genMs + + for (i = 0; i < M; i++) { + var hashHex = hashFn(input) + var hashMs = new Date().getTime() + var ms = hashMs - startMs + startMs = hashMs + console.log('Hashed in ' + ms + 'ms: ' + hashHex.substring(0, 20) + '...') + console.log(Math.round(N / (1 << 20) / (ms / 1000) * 100) / 100 + ' MB PER SECOND') + } +} + +module.exports = { + normalizeInput: normalizeInput, + toHex: toHex, + debugPrint: debugPrint, + testSpeed: testSpeed +} + +}).call(this,require("buffer").Buffer) +},{"buffer":7}],7:[function(require,module,exports){ /*! * The buffer module from node.js, for the browser. * @@ -1983,7 +2552,7 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -},{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){ +},{"base64-js":2,"ieee754":8}],8:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -2069,7 +2638,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],5:[function(require,module,exports){ +},{}],9:[function(require,module,exports){ /* A JavaScript implementation of the SHA family of hashes, as defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding @@ -2100,124 +2669,2600 @@ new m,new m,new m,new m,new m,new m];break;case "SHA-512":a=[new m,new m,new m,n 2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474, 2756734187,3204031479,3329325298];"function"===typeof define&&define.amd?define(function(){return w}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(module.exports=w),exports=w):I.jsSHA=w})(this); -},{}],6:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; +},{}],10:[function(require,module,exports){ +var getNative = require('./_getNative'), + root = require('./_root'); -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. +/* Built-in method references that are verified to be native. */ +var DataView = getNative(root, 'DataView'); -var cachedSetTimeout; -var cachedClearTimeout; +module.exports = DataView; -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); +},{"./_getNative":45,"./_root":75}],11:[function(require,module,exports){ +var hashClear = require('./_hashClear'), + hashDelete = require('./_hashDelete'), + hashGet = require('./_hashGet'), + hashHas = require('./_hashHas'), + hashSet = require('./_hashSet'); + +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); + +// Add methods to `Hash`. +Hash.prototype.clear = hashClear; +Hash.prototype['delete'] = hashDelete; +Hash.prototype.get = hashGet; +Hash.prototype.has = hashHas; +Hash.prototype.set = hashSet; + +module.exports = Hash; + +},{"./_hashClear":50,"./_hashDelete":51,"./_hashGet":52,"./_hashHas":53,"./_hashSet":54}],12:[function(require,module,exports){ +var listCacheClear = require('./_listCacheClear'), + listCacheDelete = require('./_listCacheDelete'), + listCacheGet = require('./_listCacheGet'), + listCacheHas = require('./_listCacheHas'), + listCacheSet = require('./_listCacheSet'); + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; + +module.exports = ListCache; + +},{"./_listCacheClear":59,"./_listCacheDelete":60,"./_listCacheGet":61,"./_listCacheHas":62,"./_listCacheSet":63}],13:[function(require,module,exports){ +var getNative = require('./_getNative'), + root = require('./_root'); + +/* Built-in method references that are verified to be native. */ +var Map = getNative(root, 'Map'); + +module.exports = Map; +},{"./_getNative":45,"./_root":75}],14:[function(require,module,exports){ +var mapCacheClear = require('./_mapCacheClear'), + mapCacheDelete = require('./_mapCacheDelete'), + mapCacheGet = require('./_mapCacheGet'), + mapCacheHas = require('./_mapCacheHas'), + mapCacheSet = require('./_mapCacheSet'); + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; + +module.exports = MapCache; + +},{"./_mapCacheClear":64,"./_mapCacheDelete":65,"./_mapCacheGet":66,"./_mapCacheHas":67,"./_mapCacheSet":68}],15:[function(require,module,exports){ +var getNative = require('./_getNative'), + root = require('./_root'); + +/* Built-in method references that are verified to be native. */ +var Promise = getNative(root, 'Promise'); +module.exports = Promise; + +},{"./_getNative":45,"./_root":75}],16:[function(require,module,exports){ +var getNative = require('./_getNative'), + root = require('./_root'); + +/* Built-in method references that are verified to be native. */ +var Set = getNative(root, 'Set'); + +module.exports = Set; + +},{"./_getNative":45,"./_root":75}],17:[function(require,module,exports){ +var MapCache = require('./_MapCache'), + setCacheAdd = require('./_setCacheAdd'), + setCacheHas = require('./_setCacheHas'); + +/** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ +function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); + } } -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } +// Add methods to `SetCache`. +SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; +SetCache.prototype.has = setCacheHas; + +module.exports = SetCache; + +},{"./_MapCache":14,"./_setCacheAdd":76,"./_setCacheHas":77}],18:[function(require,module,exports){ +var ListCache = require('./_ListCache'), + stackClear = require('./_stackClear'), + stackDelete = require('./_stackDelete'), + stackGet = require('./_stackGet'), + stackHas = require('./_stackHas'), + stackSet = require('./_stackSet'); + +/** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; } -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; +// Add methods to `Stack`. +Stack.prototype.clear = stackClear; +Stack.prototype['delete'] = stackDelete; +Stack.prototype.get = stackGet; +Stack.prototype.has = stackHas; +Stack.prototype.set = stackSet; - var len = queue.length; +module.exports = Stack; + +},{"./_ListCache":12,"./_stackClear":79,"./_stackDelete":80,"./_stackGet":81,"./_stackHas":82,"./_stackSet":83}],19:[function(require,module,exports){ +var root = require('./_root'); + +/** Built-in value references. */ +var Symbol = root.Symbol; + +module.exports = Symbol; + +},{"./_root":75}],20:[function(require,module,exports){ +var root = require('./_root'); + +/** Built-in value references. */ +var Uint8Array = root.Uint8Array; + +module.exports = Uint8Array; + +},{"./_root":75}],21:[function(require,module,exports){ +var getNative = require('./_getNative'), + root = require('./_root'); + +/* Built-in method references that are verified to be native. */ +var WeakMap = getNative(root, 'WeakMap'); + +module.exports = WeakMap; + +},{"./_getNative":45,"./_root":75}],22:[function(require,module,exports){ +/** + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ +function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; +} + +module.exports = arrayFilter; + +},{}],23:[function(require,module,exports){ +var baseTimes = require('./_baseTimes'), + isArguments = require('./isArguments'), + isArray = require('./isArray'), + isBuffer = require('./isBuffer'), + isIndex = require('./_isIndex'), + isTypedArray = require('./isTypedArray'); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ +function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; +} + +module.exports = arrayLikeKeys; + +},{"./_baseTimes":35,"./_isIndex":55,"./isArguments":86,"./isArray":87,"./isBuffer":89,"./isTypedArray":95}],24:[function(require,module,exports){ +/** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ +function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; +} + +module.exports = arrayPush; + +},{}],25:[function(require,module,exports){ +/** + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ +function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; +} + +module.exports = arraySome; + +},{}],26:[function(require,module,exports){ +var eq = require('./eq'); + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; +} + +module.exports = assocIndexOf; + +},{"./eq":85}],27:[function(require,module,exports){ +var arrayPush = require('./_arrayPush'), + isArray = require('./isArray'); + +/** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ +function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); +} + +module.exports = baseGetAllKeys; + +},{"./_arrayPush":24,"./isArray":87}],28:[function(require,module,exports){ +var Symbol = require('./_Symbol'), + getRawTag = require('./_getRawTag'), + objectToString = require('./_objectToString'); + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +module.exports = baseGetTag; + +},{"./_Symbol":19,"./_getRawTag":46,"./_objectToString":73}],29:[function(require,module,exports){ +var baseGetTag = require('./_baseGetTag'), + isObjectLike = require('./isObjectLike'); + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]'; + +/** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ +function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; +} + +module.exports = baseIsArguments; + +},{"./_baseGetTag":28,"./isObjectLike":94}],30:[function(require,module,exports){ +var baseIsEqualDeep = require('./_baseIsEqualDeep'), + isObjectLike = require('./isObjectLike'); + +/** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ +function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); +} + +module.exports = baseIsEqual; + +},{"./_baseIsEqualDeep":31,"./isObjectLike":94}],31:[function(require,module,exports){ +var Stack = require('./_Stack'), + equalArrays = require('./_equalArrays'), + equalByTag = require('./_equalByTag'), + equalObjects = require('./_equalObjects'), + getTag = require('./_getTag'), + isArray = require('./isArray'), + isBuffer = require('./isBuffer'), + isTypedArray = require('./isTypedArray'); + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1; + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + objectTag = '[object Object]'; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); + + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); +} + +module.exports = baseIsEqualDeep; + +},{"./_Stack":18,"./_equalArrays":39,"./_equalByTag":40,"./_equalObjects":41,"./_getTag":48,"./isArray":87,"./isBuffer":89,"./isTypedArray":95}],32:[function(require,module,exports){ +var isFunction = require('./isFunction'), + isMasked = require('./_isMasked'), + isObject = require('./isObject'), + toSource = require('./_toSource'); + +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** Used for built-in method references. */ +var funcProto = Function.prototype, + objectProto = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); +} + +module.exports = baseIsNative; + +},{"./_isMasked":57,"./_toSource":84,"./isFunction":91,"./isObject":93}],33:[function(require,module,exports){ +var baseGetTag = require('./_baseGetTag'), + isLength = require('./isLength'), + isObjectLike = require('./isObjectLike'); + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + mapTag = '[object Map]', + numberTag = '[object Number]', + objectTag = '[object Object]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + weakMapTag = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = +typedArrayTags[errorTag] = typedArrayTags[funcTag] = +typedArrayTags[mapTag] = typedArrayTags[numberTag] = +typedArrayTags[objectTag] = typedArrayTags[regexpTag] = +typedArrayTags[setTag] = typedArrayTags[stringTag] = +typedArrayTags[weakMapTag] = false; + +/** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ +function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; +} + +module.exports = baseIsTypedArray; + +},{"./_baseGetTag":28,"./isLength":92,"./isObjectLike":94}],34:[function(require,module,exports){ +var isPrototype = require('./_isPrototype'), + nativeKeys = require('./_nativeKeys'); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; +} + +module.exports = baseKeys; + +},{"./_isPrototype":58,"./_nativeKeys":71}],35:[function(require,module,exports){ +/** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} + +module.exports = baseTimes; + +},{}],36:[function(require,module,exports){ +/** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ +function baseUnary(func) { + return function(value) { + return func(value); + }; +} + +module.exports = baseUnary; + +},{}],37:[function(require,module,exports){ +/** + * Checks if a `cache` value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function cacheHas(cache, key) { + return cache.has(key); +} + +module.exports = cacheHas; + +},{}],38:[function(require,module,exports){ +var root = require('./_root'); + +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; + +module.exports = coreJsData; + +},{"./_root":75}],39:[function(require,module,exports){ +var SetCache = require('./_SetCache'), + arraySome = require('./_arraySome'), + cacheHas = require('./_cacheHas'); + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + +/** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ +function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(array); + if (stacked && stack.get(other)) { + return stacked == other; + } + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; + + stack.set(array, other); + stack.set(other, array); + + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } + } + stack['delete'](array); + stack['delete'](other); + return result; +} + +module.exports = equalArrays; + +},{"./_SetCache":17,"./_arraySome":25,"./_cacheHas":37}],40:[function(require,module,exports){ +var Symbol = require('./_Symbol'), + Uint8Array = require('./_Uint8Array'), + eq = require('./eq'), + equalArrays = require('./_equalArrays'), + mapToArray = require('./_mapToArray'), + setToArray = require('./_setToArray'); + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + +/** `Object#toString` result references. */ +var boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + mapTag = '[object Map]', + numberTag = '[object Number]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]'; + +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]'; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; + +/** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; + + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); + + case errorTag: + return object.name == other.name && object.message == other.message; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); + + case mapTag: + var convert = mapToArray; + + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; +} + +module.exports = equalByTag; + +},{"./_Symbol":19,"./_Uint8Array":20,"./_equalArrays":39,"./_mapToArray":69,"./_setToArray":78,"./eq":85}],41:[function(require,module,exports){ +var getAllKeys = require('./_getAllKeys'); + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; + + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked && stack.get(other)) { + return stacked == other; + } + var result = true; + stack.set(object, other); + stack.set(other, object); + + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } + } + stack['delete'](object); + stack['delete'](other); + return result; +} + +module.exports = equalObjects; + +},{"./_getAllKeys":43}],42:[function(require,module,exports){ +(function (global){ +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +module.exports = freeGlobal; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],43:[function(require,module,exports){ +var baseGetAllKeys = require('./_baseGetAllKeys'), + getSymbols = require('./_getSymbols'), + keys = require('./keys'); + +/** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); +} + +module.exports = getAllKeys; + +},{"./_baseGetAllKeys":27,"./_getSymbols":47,"./keys":96}],44:[function(require,module,exports){ +var isKeyable = require('./_isKeyable'); + +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +module.exports = getMapData; + +},{"./_isKeyable":56}],45:[function(require,module,exports){ +var baseIsNative = require('./_baseIsNative'), + getValue = require('./_getValue'); + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; +} + +module.exports = getNative; + +},{"./_baseIsNative":32,"./_getValue":49}],46:[function(require,module,exports){ +var Symbol = require('./_Symbol'); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; +} + +module.exports = getRawTag; + +},{"./_Symbol":19}],47:[function(require,module,exports){ +var arrayFilter = require('./_arrayFilter'), + stubArray = require('./stubArray'); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto.propertyIsEnumerable; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols = Object.getOwnPropertySymbols; + +/** + * Creates an array of the own enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ +var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); +}; + +module.exports = getSymbols; + +},{"./_arrayFilter":22,"./stubArray":97}],48:[function(require,module,exports){ +var DataView = require('./_DataView'), + Map = require('./_Map'), + Promise = require('./_Promise'), + Set = require('./_Set'), + WeakMap = require('./_WeakMap'), + baseGetTag = require('./_baseGetTag'), + toSource = require('./_toSource'); + +/** `Object#toString` result references. */ +var mapTag = '[object Map]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + setTag = '[object Set]', + weakMapTag = '[object WeakMap]'; + +var dataViewTag = '[object DataView]'; + +/** Used to detect maps, sets, and weakmaps. */ +var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map), + promiseCtorString = toSource(Promise), + setCtorString = toSource(Set), + weakMapCtorString = toSource(WeakMap); + +/** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +var getTag = baseGetTag; + +// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. +if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || + (Set && getTag(new Set) != setTag) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = baseGetTag(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; +} + +module.exports = getTag; + +},{"./_DataView":10,"./_Map":13,"./_Promise":15,"./_Set":16,"./_WeakMap":21,"./_baseGetTag":28,"./_toSource":84}],49:[function(require,module,exports){ +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue(object, key) { + return object == null ? undefined : object[key]; +} + +module.exports = getValue; + +},{}],50:[function(require,module,exports){ +var nativeCreate = require('./_nativeCreate'); + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; +} + +module.exports = hashClear; + +},{"./_nativeCreate":70}],51:[function(require,module,exports){ +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +module.exports = hashDelete; + +},{}],52:[function(require,module,exports){ +var nativeCreate = require('./_nativeCreate'); + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty.call(data, key) ? data[key] : undefined; +} + +module.exports = hashGet; + +},{"./_nativeCreate":70}],53:[function(require,module,exports){ +var nativeCreate = require('./_nativeCreate'); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); +} + +module.exports = hashHas; + +},{"./_nativeCreate":70}],54:[function(require,module,exports){ +var nativeCreate = require('./_nativeCreate'); + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; +} + +module.exports = hashSet; + +},{"./_nativeCreate":70}],55:[function(require,module,exports){ +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +module.exports = isIndex; + +},{}],56:[function(require,module,exports){ +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +module.exports = isKeyable; + +},{}],57:[function(require,module,exports){ +var coreJsData = require('./_coreJsData'); + +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} + +module.exports = isMasked; + +},{"./_coreJsData":38}],58:[function(require,module,exports){ +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; + + return value === proto; +} + +module.exports = isPrototype; + +},{}],59:[function(require,module,exports){ +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} + +module.exports = listCacheClear; + +},{}],60:[function(require,module,exports){ +var assocIndexOf = require('./_assocIndexOf'); + +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; +} + +module.exports = listCacheDelete; + +},{"./_assocIndexOf":26}],61:[function(require,module,exports){ +var assocIndexOf = require('./_assocIndexOf'); + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +module.exports = listCacheGet; + +},{"./_assocIndexOf":26}],62:[function(require,module,exports){ +var assocIndexOf = require('./_assocIndexOf'); + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; +} + +module.exports = listCacheHas; + +},{"./_assocIndexOf":26}],63:[function(require,module,exports){ +var assocIndexOf = require('./_assocIndexOf'); + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +module.exports = listCacheSet; + +},{"./_assocIndexOf":26}],64:[function(require,module,exports){ +var Hash = require('./_Hash'), + ListCache = require('./_ListCache'), + Map = require('./_Map'); + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; +} + +module.exports = mapCacheClear; + +},{"./_Hash":11,"./_ListCache":12,"./_Map":13}],65:[function(require,module,exports){ +var getMapData = require('./_getMapData'); + +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +module.exports = mapCacheDelete; + +},{"./_getMapData":44}],66:[function(require,module,exports){ +var getMapData = require('./_getMapData'); + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return getMapData(this, key).get(key); +} + +module.exports = mapCacheGet; + +},{"./_getMapData":44}],67:[function(require,module,exports){ +var getMapData = require('./_getMapData'); + +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return getMapData(this, key).has(key); +} + +module.exports = mapCacheHas; + +},{"./_getMapData":44}],68:[function(require,module,exports){ +var getMapData = require('./_getMapData'); + +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +module.exports = mapCacheSet; + +},{"./_getMapData":44}],69:[function(require,module,exports){ +/** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ +function mapToArray(map) { + var index = -1, + result = Array(map.size); + + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; +} + +module.exports = mapToArray; + +},{}],70:[function(require,module,exports){ +var getNative = require('./_getNative'); + +/* Built-in method references that are verified to be native. */ +var nativeCreate = getNative(Object, 'create'); + +module.exports = nativeCreate; + +},{"./_getNative":45}],71:[function(require,module,exports){ +var overArg = require('./_overArg'); + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeKeys = overArg(Object.keys, Object); + +module.exports = nativeKeys; + +},{"./_overArg":74}],72:[function(require,module,exports){ +var freeGlobal = require('./_freeGlobal'); + +/** Detect free variable `exports`. */ +var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; + +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports && freeGlobal.process; + +/** Used to access faster Node.js helpers. */ +var nodeUtil = (function() { + try { + // Use `util.types` for Node.js 10+. + var types = freeModule && freeModule.require && freeModule.require('util').types; + + if (types) { + return types; + } + + // Legacy `process.binding('util')` for Node.js < 10. + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} +}()); + +module.exports = nodeUtil; + +},{"./_freeGlobal":42}],73:[function(require,module,exports){ +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +module.exports = objectToString; + +},{}],74:[function(require,module,exports){ +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} + +module.exports = overArg; + +},{}],75:[function(require,module,exports){ +var freeGlobal = require('./_freeGlobal'); + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +module.exports = root; + +},{"./_freeGlobal":42}],76:[function(require,module,exports){ +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ +function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; +} + +module.exports = setCacheAdd; + +},{}],77:[function(require,module,exports){ +/** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ +function setCacheHas(value) { + return this.__data__.has(value); +} + +module.exports = setCacheHas; + +},{}],78:[function(require,module,exports){ +/** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ +function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; +} + +module.exports = setToArray; + +},{}],79:[function(require,module,exports){ +var ListCache = require('./_ListCache'); + +/** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ +function stackClear() { + this.__data__ = new ListCache; + this.size = 0; +} + +module.exports = stackClear; + +},{"./_ListCache":12}],80:[function(require,module,exports){ +/** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; + return result; +} + +module.exports = stackDelete; + +},{}],81:[function(require,module,exports){ +/** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function stackGet(key) { + return this.__data__.get(key); +} + +module.exports = stackGet; + +},{}],82:[function(require,module,exports){ +/** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function stackHas(key) { + return this.__data__.has(key); +} + +module.exports = stackHas; + +},{}],83:[function(require,module,exports){ +var ListCache = require('./_ListCache'), + Map = require('./_Map'), + MapCache = require('./_MapCache'); + +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; + +/** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ +function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; +} + +module.exports = stackSet; + +},{"./_ListCache":12,"./_Map":13,"./_MapCache":14}],84:[function(require,module,exports){ +/** Used for built-in method references. */ +var funcProto = Function.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ +function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} + +module.exports = toSource; + +},{}],85:[function(require,module,exports){ +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} + +module.exports = eq; + +},{}],86:[function(require,module,exports){ +var baseIsArguments = require('./_baseIsArguments'), + isObjectLike = require('./isObjectLike'); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto.propertyIsEnumerable; + +/** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); +}; + +module.exports = isArguments; + +},{"./_baseIsArguments":29,"./isObjectLike":94}],87:[function(require,module,exports){ +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +module.exports = isArray; + +},{}],88:[function(require,module,exports){ +var isFunction = require('./isFunction'), + isLength = require('./isLength'); + +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); +} + +module.exports = isArrayLike; + +},{"./isFunction":91,"./isLength":92}],89:[function(require,module,exports){ +var root = require('./_root'), + stubFalse = require('./stubFalse'); + +/** Detect free variable `exports`. */ +var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; + +/** Built-in value references. */ +var Buffer = moduleExports ? root.Buffer : undefined; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; + +/** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ +var isBuffer = nativeIsBuffer || stubFalse; + +module.exports = isBuffer; + +},{"./_root":75,"./stubFalse":98}],90:[function(require,module,exports){ +var baseIsEqual = require('./_baseIsEqual'); + +/** + * Performs a deep comparison between two values to determine if they are + * equivalent. + * + * **Note:** This method supports comparing arrays, array buffers, booleans, + * date objects, error objects, maps, numbers, `Object` objects, regexes, + * sets, strings, symbols, and typed arrays. `Object` objects are compared + * by their own, not inherited, enumerable properties. Functions and DOM + * nodes are compared by strict equality, i.e. `===`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.isEqual(object, other); + * // => true + * + * object === other; + * // => false + */ +function isEqual(value, other) { + return baseIsEqual(value, other); +} + +module.exports = isEqual; + +},{"./_baseIsEqual":30}],91:[function(require,module,exports){ +var baseGetTag = require('./_baseGetTag'), + isObject = require('./isObject'); + +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + proxyTag = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +module.exports = isFunction; + +},{"./_baseGetTag":28,"./isObject":93}],92:[function(require,module,exports){ +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +module.exports = isLength; + +},{}],93:[function(require,module,exports){ +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +module.exports = isObject; + +},{}],94:[function(require,module,exports){ +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +module.exports = isObjectLike; + +},{}],95:[function(require,module,exports){ +var baseIsTypedArray = require('./_baseIsTypedArray'), + baseUnary = require('./_baseUnary'), + nodeUtil = require('./_nodeUtil'); + +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + +/** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + +module.exports = isTypedArray; + +},{"./_baseIsTypedArray":33,"./_baseUnary":36,"./_nodeUtil":72}],96:[function(require,module,exports){ +var arrayLikeKeys = require('./_arrayLikeKeys'), + baseKeys = require('./_baseKeys'), + isArrayLike = require('./isArrayLike'); + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +} + +module.exports = keys; + +},{"./_arrayLikeKeys":23,"./_baseKeys":34,"./isArrayLike":88}],97:[function(require,module,exports){ +/** + * This method returns a new empty array. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Array} Returns the new empty array. + * @example + * + * var arrays = _.times(2, _.stubArray); + * + * console.log(arrays); + * // => [[], []] + * + * console.log(arrays[0] === arrays[1]); + * // => false + */ +function stubArray() { + return []; +} + +module.exports = stubArray; + +},{}],98:[function(require,module,exports){ +/** + * This method returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2, _.stubFalse); + * // => [false, false] + */ +function stubFalse() { + return false; +} + +module.exports = stubFalse; + +},{}],99:[function(require,module,exports){ +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; while(len) { currentQueue = queue; queue = []; @@ -2286,7 +5331,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],7:[function(require,module,exports){ +},{}],100:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -2350,7 +5395,7 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":3}],8:[function(require,module,exports){ +},{"buffer":7}],101:[function(require,module,exports){ var base58 = require('./crypto/base58'); var segwit = require('./crypto/segwit_addr'); var cryptoUtils = require('./crypto/utils'); @@ -2427,7 +5472,7 @@ module.exports = { } }; -},{"./crypto/base58":9,"./crypto/segwit_addr":12,"./crypto/utils":14}],9:[function(require,module,exports){ +},{"./crypto/base58":102,"./crypto/segwit_addr":105,"./crypto/utils":107}],102:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -2475,7 +5520,7 @@ module.exports = { } }; -},{}],10:[function(require,module,exports){ +},{}],103:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -2593,7 +5638,7 @@ function decode (bechString) { return {hrp: hrp, data: data.slice(0, data.length - 6)}; } -},{}],11:[function(require,module,exports){ +},{}],104:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2784,7 +5829,7 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":3}],12:[function(require,module,exports){ +},{"buffer":7}],105:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -2880,7 +5925,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":10}],13:[function(require,module,exports){ +},{"./bech32":103}],106:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -3524,10 +6569,11 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":6}],14:[function(require,module,exports){ +},{"_process":99}],107:[function(require,module,exports){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; +var blake = require('blakejs') function numberToHex (number) { var hex = Math.round(number).toString(16); @@ -3561,221 +6607,265 @@ module.exports = { }, keccak256: function (hexString) { return keccak256(hexString); - } + }, + blake2b: blake.blake2b }; -},{"./blake256":11,"./sha3":13,"jssha/src/sha256":5}],15:[function(require,module,exports){ -var XRPValidator = require('./ripple_validator'); -var ETHValidator = require('./ethereum_validator'); -var BTCValidator = require('./bitcoin_validator'); +},{"./blake256":104,"./sha3":106,"blakejs":5,"jssha/src/sha256":9}],108:[function(require,module,exports){ +var XRPValidator = require('./ripple_validator') +var ETHValidator = require('./ethereum_validator') +var BTCValidator = require('./bitcoin_validator') +var SCValidator = require('./siacoin_validator') // defines P2PKH and P2SH address types for standard (prod) and testnet networks -var CURRENCIES = [{ +var CURRENCIES = [ + { name: 'bitcoin', symbol: 'btc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'bitcoincash', symbol: 'bch', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'litecoin', symbol: 'ltc', - addressTypes: {prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a']}, + addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, validator: BTCValidator -},{ + }, + { name: 'peercoin', symbol: 'ppc', - addressTypes: {prod: ['37', '75'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['37', '75'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'dogecoin', symbol: 'doge', - addressTypes: {prod: ['1e', '16'], testnet: ['71', 'c4']}, + addressTypes: { prod: ['1e', '16'], testnet: ['71', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'beavercoin', symbol: 'bvc', - addressTypes: {prod: ['19', '05'], testnet: ['6f', 'c4']}, - validator: BTCValidator, -},{ + addressTypes: { prod: ['19', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, + { name: 'freicoin', symbol: 'frc', - addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'protoshares', symbol: 'pts', - addressTypes: {prod: ['38', '05'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['38', '05'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'megacoin', symbol: 'mec', - addressTypes: {prod: ['32', '05'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['32', '05'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'primecoin', symbol: 'xpm', - addressTypes: {prod: ['17', '53'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['17', '53'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'auroracoin', symbol: 'aur', - addressTypes: {prod: ['17', '05'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['17', '05'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'namecoin', symbol: 'nmc', - addressTypes: {prod: ['34'], testnet: []}, + addressTypes: { prod: ['34'], testnet: [] }, validator: BTCValidator -},{ + }, + { name: 'biocoin', symbol: 'bio', - addressTypes: {prod: ['19', '14'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['19', '14'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'garlicoin', symbol: 'grlc', - addressTypes: {prod: ['26', '05'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['26', '05'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'vertcoin', symbol: 'vtc', - addressTypes: {prod: ['0x', '47'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['0x', '47'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'bitcoingold', symbol: 'btg', - addressTypes: {prod: ['26', '17'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { name: 'komodo', symbol: 'kmd', - addressTypes: {prod: ['3c', '55'], testnet: ['0','5']}, + addressTypes: { prod: ['3c', '55'], testnet: ['0', '5'] }, validator: BTCValidator -},{ + }, + { name: 'bitcoinz', symbol: 'btcz', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, validator: BTCValidator -},{ + }, + { name: 'bitcoinprivate', symbol: 'btcp', expectedLength: 26, - addressTypes: {prod: ['1325','13af'], testnet: ['1957', '19e0']}, + addressTypes: { prod: ['1325', '13af'], testnet: ['1957', '19e0'] }, validator: BTCValidator -},{ + }, + { name: 'hush', symbol: 'hush', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, validator: BTCValidator -},{ + }, + { name: 'snowgem', symbol: 'sng', expectedLength: 26, - addressTypes: {prod: ['1c28','1c2d'], testnet: ['1d25', '1cba']}, + addressTypes: { prod: ['1c28', '1c2d'], testnet: ['1d25', '1cba'] }, validator: BTCValidator -},{ + }, + { name: 'zcash', symbol: 'zec', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, validator: BTCValidator -},{ + }, + { name: 'zclassic', symbol: 'zcl', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, validator: BTCValidator -},{ + }, + { name: 'zencash', symbol: 'zen', expectedLength: 26, - addressTypes: {prod: ['2089','2096'], testnet: ['2092','2098']}, + addressTypes: { prod: ['2089', '2096'], testnet: ['2092', '2098'] }, validator: BTCValidator -},{ + }, + { name: 'votecoin', symbol: 'vot', expectedLength: 26, - addressTypes: {prod: ['1cb8','1cbd'], testnet: ['1d25', '1cba']}, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, validator: BTCValidator -},{ + }, + { name: 'decred', symbol: 'dcr', - addressTypes: {prod: ['073f', '071a'], testnet: ['0f21', '0efc']}, + addressTypes: { prod: ['073f', '071a'], testnet: ['0f21', '0efc'] }, hashFunction: 'blake256', expectedLength: 26, validator: BTCValidator -},{ + }, + { name: 'digibyte', symbol: 'dgb', - addressTypes: {prod: ['1e'], testnet: []}, + addressTypes: { prod: ['1e'], testnet: [] }, validator: BTCValidator -},{ + }, + { name: 'ethereum', symbol: 'eth', - validator: ETHValidator, -},{ + validator: ETHValidator + }, + { name: 'etherzero', symbol: 'etz', - validator: ETHValidator, -},{ + validator: ETHValidator + }, + { name: 'ethereumclassic', symbol: 'etc', - validator: ETHValidator, -},{ + validator: ETHValidator + }, + { name: 'callisto', symbol: 'clo', - validator: ETHValidator, -},{ + validator: ETHValidator + }, + { name: 'ripple', symbol: 'xrp', - validator: XRPValidator, -},{ + validator: XRPValidator + }, + { name: 'dash', symbol: 'dash', - addressTypes: {prod: ['4c', '10'], testnet: ['8c', '13']}, + addressTypes: { prod: ['4c', '10'], testnet: ['8c', '13'] }, validator: BTCValidator -},{ + }, + { name: 'neo', symbol: 'neo', - addressTypes: {prod: ['17'], testnet: []}, + addressTypes: { prod: ['17'], testnet: [] }, validator: BTCValidator -},{ + }, + { name: 'neogas', symbol: 'gas', - addressTypes: {prod: ['17'], testnet: []}, + addressTypes: { prod: ['17'], testnet: [] }, validator: BTCValidator -},{ + }, + { name: 'qtum', symbol: 'qtum', - addressTypes: {prod: ['3a', '32'], testnet: ['6f', 'c4']}, + addressTypes: { prod: ['3a', '32'], testnet: ['6f', 'c4'] }, validator: BTCValidator -},{ + }, + { + name: 'siacoin', + symbol: 'sc', + validator: SCValidator + }, + { name: 'bankex', symbol: 'bkx', validator: ETHValidator -}]; - + } +] module.exports = { - getByNameOrSymbol: function (currencyNameOrSymbol) { - var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); - for (var i = 0; i < CURRENCIES.length; i++) { - var currency = CURRENCIES[i]; - if(currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { - return currency; - } - } - return null; + getByNameOrSymbol: function(currencyNameOrSymbol) { + var nameOrSymbol = currencyNameOrSymbol.toLowerCase() + for (var i = 0; i < CURRENCIES.length; i++) { + var currency = CURRENCIES[i] + if (currency.name === nameOrSymbol || currency.symbol === nameOrSymbol) { + return currency + } } -}; + return null + } +} -},{"./bitcoin_validator":8,"./ethereum_validator":16,"./ripple_validator":17}],16:[function(require,module,exports){ +},{"./bitcoin_validator":101,"./ethereum_validator":109,"./ripple_validator":110,"./siacoin_validator":111}],109:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -3811,7 +6901,7 @@ module.exports = { } }; -},{"./crypto/utils":14}],17:[function(require,module,exports){ +},{"./crypto/utils":107}],110:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -3841,7 +6931,48 @@ module.exports = { } }; -},{"./crypto/utils":14,"base-x":1}],18:[function(require,module,exports){ +},{"./crypto/utils":107,"base-x":1}],111:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils') +var isEqual = require('lodash/isEqual') + +// Convert a byte array to a hex string +function bytesToHex(bytes) { + var hex = [] + for (var b in bytes) { + hex.push((b >>> 4).toString(16)) + hex.push((b & 0xf).toString(16)) + } + return hex.join('') +} + +function hexToBytes(hex) { + var bytes = [] + for (var c = 0; c < hex.length; c += 2) { + bytes.push(parseInt(hex.substr(c, 2), 16)) + } + return bytes +} + +module.exports = { + isValidAddress: function(address) { + if (address.length !== 76) { + // Check if it has the basic requirements of an address + return false + } + + // Otherwise check each case + return this.verifyChecksum(address) + }, + verifyChecksum: function(address) { + var aBytes = hexToBytes(address) + var checksumBytes = Uint8Array.from(aBytes.slice(0, 32)) + var check = Uint8Array.from(aBytes.slice(32, 38)) + var blakeHash = cryptoUtils.blake2b(checksumBytes, null, 32).slice(0, 6) + return isEqual(blakeHash, check) + } +} + +},{"./crypto/utils":107,"lodash/isEqual":90}],112:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -3858,5 +6989,5 @@ module.exports = { }, }; -},{"./currencies":15}]},{},[18])(18) +},{"./currencies":108}]},{},[112])(112) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index ec0dbbbc..56640250 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(s,a,u){function f(r,t){if(!a[r]){if(!s[r]){var e="function"==typeof require&&require;if(!t&&e)return e(r,!0);if(h)return h(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[r]={exports:{}};s[r][0].call(o.exports,function(t){return f(s[r][1][t]||t)},o,o.exports,i,s,a,u)}return a[r].exports}for(var h="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[s++]=r>>8&255,i[s++]=255&r;var f,h;2===o&&(r=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,i[s++]=255&r);1===o&&(r=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,i[s++]=r>>8&255,i[s++]=255&r);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o=[],i=0,s=e-n;i>2]+a[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],o.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"="));return o.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return w(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,O(R(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return u=this,f=r,h=e,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,O(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function U(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function S(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=0,s=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,o),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,g,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,f,o)};break;case"B64":e=function(t){return E(t,f,o)};break;case"BYTES":e=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",a=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,i[a++]=e>>8&255,i[a++]=255&e;var f,c;2===o&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,i[a++]=255&e);1===o&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,a=r-n;i>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return o.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var o=t("./util");function l(t,e,r){var n=t[e]+t[r],o=t[e+1]+t[r+1];4294967296<=n&&o++,t[e]=n,t[e+1]=o}function p(t,e,r,n){var o=t[e]+r;r<0&&(o+=4294967296);var i=t[e+1]+n;4294967296<=o&&i++,t[e]=o,t[e+1]=i}function i(t,e,r,n,o,i){var a=y[o],s=y[o+1],u=y[i],f=y[i+1];l(d,t,e),p(d,t,a,s);var c=d[n]^d[t],h=d[n+1]^d[t+1];d[n]=h,d[n+1]=c,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=c>>>24^h<<8,d[e+1]=h>>>24^c<<8,l(d,t,e),p(d,t,u,f),c=d[n]^d[t],h=d[n+1]^d[t+1],d[n]=c>>>16^h<<16,d[n+1]=h>>>16^c<<16,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=h>>>31^c<<1,d[e+1]=c>>>31^h<<1}var a=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),s=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map(function(t){return 2*t})),d=new Uint32Array(32),y=new Uint32Array(32);function n(t,e){var r,n,o=0;for(o=0;o<16;o++)d[o]=t.h[o],d[o+16]=a[o];for(d[24]=d[24]^t.t,d[25]=d[25]^t.t/4294967296,e&&(d[28]=~d[28],d[29]=~d[29]),o=0;o<32;o++)y[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<12;o++)i(0,8,16,24,s[16*o+0],s[16*o+1]),i(2,10,18,26,s[16*o+2],s[16*o+3]),i(4,12,20,28,s[16*o+4],s[16*o+5]),i(6,14,22,30,s[16*o+6],s[16*o+7]),i(0,10,20,30,s[16*o+8],s[16*o+9]),i(2,12,22,24,s[16*o+10],s[16*o+11]),i(4,14,16,26,s[16*o+12],s[16*o+13]),i(6,8,18,28,s[16*o+14],s[16*o+15]);for(o=0;o<16;o++)t.h[o]=t.h[o]^d[o]^d[o+16]}function u(t,e){if(0===t||64>2]>>8*(3&r);return e}function h(t,e,r){r=r||64,t=o.normalizeInput(t);var n=u(r,e);return f(n,t),c(n)}e.exports={blake2b:h,blake2bHex:function(t,e,r){var n=h(t,e,r);return o.toHex(n)},blake2bInit:u,blake2bUpdate:f,blake2bFinal:c}},{"./util":6}],4:[function(t,e,r){var o=t("./util");function i(t,e,r,n,o,i){f[t]=f[t]+f[e]+o,f[n]=a(f[n]^f[t],16),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],12),f[t]=f[t]+f[e]+i,f[n]=a(f[n]^f[t],8),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],7)}function a(t,e){return t>>>e^t<<32-e}var s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),f=new Uint32Array(16),c=new Uint32Array(16);function n(t,e){var r,n,o=0;for(o=0;o<8;o++)f[o]=t.h[o],f[o+8]=s[o];for(f[12]^=t.t,f[13]^=t.t/4294967296,e&&(f[14]=~f[14]),o=0;o<16;o++)c[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<10;o++)i(0,4,8,12,c[u[16*o+0]],c[u[16*o+1]]),i(1,5,9,13,c[u[16*o+2]],c[u[16*o+3]]),i(2,6,10,14,c[u[16*o+4]],c[u[16*o+5]]),i(3,7,11,15,c[u[16*o+6]],c[u[16*o+7]]),i(0,5,10,15,c[u[16*o+8]],c[u[16*o+9]]),i(1,6,11,12,c[u[16*o+10]],c[u[16*o+11]]),i(2,7,8,13,c[u[16*o+12]],c[u[16*o+13]]),i(3,4,9,14,c[u[16*o+14]],c[u[16*o+15]]);for(o=0;o<8;o++)t.h[o]^=f[o]^f[o+8]}function h(t,e){if(!(0>2]>>8*(3&r)&255;return e}function d(t,e,r){r=r||32,t=o.normalizeInput(t);var n=h(r,e);return l(n,t),p(n)}e.exports={blake2s:d,blake2sHex:function(t,e,r){var n=d(t,e,r);return o.toHex(n)},blake2sInit:h,blake2sUpdate:l,blake2sFinal:p}},{"./util":6}],5:[function(t,e,r){var n=t("./blake2b"),o=t("./blake2s");e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:o.blake2s,blake2sHex:o.blake2sHex,blake2sInit:o.blake2sInit,blake2sUpdate:o.blake2sUpdate,blake2sFinal:o.blake2sFinal}},{"./blake2b":3,"./blake2s":4}],6:[function(t,e,r){(function(r){function i(t){return(4294967296+t).toString(16).substring(1)}e.exports={normalizeInput:function(t){var e;if(t instanceof Uint8Array)e=t;else if(t instanceof r)e=new Uint8Array(t);else{if("string"!=typeof t)throw new Error("Input must be an string, Buffer or Uint8Array");e=new Uint8Array(r.from(t,"utf8"))}return e},toHex:function(t){return Array.prototype.map.call(t,function(t){return(t<16?"0":"")+t.toString(16)}).join("")},debugPrint:function(t,e,r){for(var n="\n"+t+" = ",o=0;o>>1;case"base64":return L(t).length;default:if(n)return I(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;i>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(t){var e=t.length;if(e<=m)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},h.prototype.compare=function(t,e,r,n,o){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,a,s,u,f,c,h,l,p,d=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,H(I(t,(h=this).length-l),h,l,p);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return u=this,f=e,c=r,H(L(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,H(function(t,e){for(var r,n,o,i=[],a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-a),i,a,s);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var m=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function B(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,8),i.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||T(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||T(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);T(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);T(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;0<=--i&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function L(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function M(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function F(t){return t!=t}},{"base64-js":2,ieee754:8}],8:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,h=r?o-1:0,l=r?-1:1,p=t[e+h];for(h+=l,i=p&(1<<-c)-1,p>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,o),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,o),a=0));8<=o;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var o,i;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,b,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,w=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===v)throw Error("Cannot call getHash after setting HMAC key");switch(o=E(e),t){case"HEX":r=function(t){return m(t,f,o)};break;case"B64":r=function(t){return A(t,f,o)};break;case"BYTES":r=function(t){return x(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return k(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(b.slice(),g,y,p(s)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function A(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function x(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function k(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function E(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function C(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=o[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Sat, 10 Nov 2018 21:14:19 -0500 Subject: [PATCH 070/108] add lbry --- dist/wallet-address-validator.js | 371 +++++++++------------------ dist/wallet-address-validator.min.js | 8 +- src/currencies.js | 6 + src/siacoin_validator.js | 3 +- test/wallet_address_validator.js | 65 +++++ 5 files changed, 200 insertions(+), 253 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 86683c47..aefd9fe9 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -863,7 +863,7 @@ function typedArraySupport () { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1) - arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} return arr.foo() === 42 } catch (e) { return false @@ -871,24 +871,26 @@ function typedArraySupport () { } Object.defineProperty(Buffer.prototype, 'parent', { - enumerable: true, get: function () { - if (!Buffer.isBuffer(this)) return undefined + if (!(this instanceof Buffer)) { + return undefined + } return this.buffer } }) Object.defineProperty(Buffer.prototype, 'offset', { - enumerable: true, get: function () { - if (!Buffer.isBuffer(this)) return undefined + if (!(this instanceof Buffer)) { + return undefined + } return this.byteOffset } }) function createBuffer (length) { if (length > K_MAX_LENGTH) { - throw new RangeError('The value "' + length + '" is invalid for option "size"') + throw new RangeError('Invalid typed array length') } // Return an augmented `Uint8Array` instance var buf = new Uint8Array(length) @@ -910,8 +912,8 @@ function Buffer (arg, encodingOrOffset, length) { // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { - throw new TypeError( - 'The "string" argument must be of type string. Received type number' + throw new Error( + 'If encoding is specified then the first argument must be a string' ) } return allocUnsafe(arg) @@ -920,7 +922,7 @@ function Buffer (arg, encodingOrOffset, length) { } // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species != null && +if (typeof Symbol !== 'undefined' && Symbol.species && Buffer[Symbol.species] === Buffer) { Object.defineProperty(Buffer, Symbol.species, { value: null, @@ -933,51 +935,19 @@ if (typeof Symbol !== 'undefined' && Symbol.species != null && Buffer.poolSize = 8192 // not used by this implementation function from (value, encodingOrOffset, length) { - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } - - if (ArrayBuffer.isView(value)) { - return fromArrayLike(value) - } - - if (value == null) { - throw TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) - } - - if (isInstance(value, ArrayBuffer) || - (value && isInstance(value.buffer, ArrayBuffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - if (typeof value === 'number') { - throw new TypeError( - 'The "value" argument must not be of type number. Received type number' - ) + throw new TypeError('"value" argument must not be a number') } - var valueOf = value.valueOf && value.valueOf() - if (valueOf != null && valueOf !== value) { - return Buffer.from(valueOf, encodingOrOffset, length) + if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) } - var b = fromObject(value) - if (b) return b - - if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && - typeof value[Symbol.toPrimitive] === 'function') { - return Buffer.from( - value[Symbol.toPrimitive]('string'), encodingOrOffset, length - ) + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) } - throw new TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) + return fromObject(value) } /** @@ -1001,7 +971,7 @@ function assertSize (size) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be of type number') } else if (size < 0) { - throw new RangeError('The value "' + size + '" is invalid for option "size"') + throw new RangeError('"size" argument must not be negative') } } @@ -1116,16 +1086,20 @@ function fromObject (obj) { return buf } - if (obj.length !== undefined) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) + if (obj) { + if (ArrayBuffer.isView(obj) || 'length' in obj) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) } - return fromArrayLike(obj) - } - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } } + + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.') } function checked (length) { @@ -1146,17 +1120,12 @@ function SlowBuffer (length) { } Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true && - b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false + return b != null && b._isBuffer === true } Buffer.compare = function compare (a, b) { - if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) - if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError( - 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' - ) + throw new TypeError('Arguments must be Buffers') } if (a === b) return 0 @@ -1217,7 +1186,7 @@ Buffer.concat = function concat (list, length) { var pos = 0 for (i = 0; i < list.length; ++i) { var buf = list[i] - if (isInstance(buf, Uint8Array)) { + if (ArrayBuffer.isView(buf)) { buf = Buffer.from(buf) } if (!Buffer.isBuffer(buf)) { @@ -1233,19 +1202,15 @@ function byteLength (string, encoding) { if (Buffer.isBuffer(string)) { return string.length } - if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { return string.byteLength } if (typeof string !== 'string') { - throw new TypeError( - 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + - 'Received type ' + typeof string - ) + string = '' + string } var len = string.length - var mustMatch = (arguments.length > 2 && arguments[2] === true) - if (!mustMatch && len === 0) return 0 + if (len === 0) return 0 // Use a for loop to avoid recursion var loweredCase = false @@ -1257,6 +1222,7 @@ function byteLength (string, encoding) { return len case 'utf8': case 'utf-8': + case undefined: return utf8ToBytes(string).length case 'ucs2': case 'ucs-2': @@ -1268,9 +1234,7 @@ function byteLength (string, encoding) { case 'base64': return base64ToBytes(string).length default: - if (loweredCase) { - return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 - } + if (loweredCase) return utf8ToBytes(string).length // assume utf8 encoding = ('' + encoding).toLowerCase() loweredCase = true } @@ -1417,20 +1381,16 @@ Buffer.prototype.equals = function equals (b) { Buffer.prototype.inspect = function inspect () { var str = '' var max = exports.INSPECT_MAX_BYTES - str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() - if (this.length > max) str += ' ... ' + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } return '' } Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (isInstance(target, Uint8Array)) { - target = Buffer.from(target, target.offset, target.byteLength) - } if (!Buffer.isBuffer(target)) { - throw new TypeError( - 'The "target" argument must be one of type Buffer or Uint8Array. ' + - 'Received type ' + (typeof target) - ) + throw new TypeError('Argument must be a Buffer') } if (start === undefined) { @@ -1509,7 +1469,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { } else if (byteOffset < -0x80000000) { byteOffset = -0x80000000 } - byteOffset = +byteOffset // Coerce to Number. + byteOffset = +byteOffset // Coerce to Number. if (numberIsNaN(byteOffset)) { // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer byteOffset = dir ? 0 : (buffer.length - 1) @@ -1761,8 +1721,8 @@ function utf8Slice (buf, start, end) { var codePoint = null var bytesPerSequence = (firstByte > 0xEF) ? 4 : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 + : (firstByte > 0xBF) ? 2 + : 1 if (i + bytesPerSequence <= end) { var secondByte, thirdByte, fourthByte, tempCodePoint @@ -2425,7 +2385,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) { } else { var bytes = Buffer.isBuffer(val) ? val - : Buffer.from(val, encoding) + : new Buffer(val, encoding) var len = bytes.length if (len === 0) { throw new TypeError('The value "' + val + @@ -2580,16 +2540,15 @@ function blitBuffer (src, dst, offset, length) { return i } -// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass -// the `instanceof` check but they should be treated as of that type. -// See: https://github.com/feross/buffer/issues/166 -function isInstance (obj, type) { - return obj instanceof type || - (obj != null && obj.constructor != null && obj.constructor.name != null && - obj.constructor.name === type.name) +// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check +// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 +function isArrayBuffer (obj) { + return obj instanceof ArrayBuffer || + (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && + typeof obj.byteLength === 'number') } + function numberIsNaN (obj) { - // For IE11 support return obj !== obj // eslint-disable-line no-self-compare } @@ -5513,13 +5472,7 @@ module.exports = { } }; -<<<<<<< HEAD -},{"./crypto/base58":102,"./crypto/segwit_addr":105,"./crypto/utils":107}],102:[function(require,module,exports){ -||||||| merged common ancestors -},{"./crypto/base58":9,"./crypto/segwit_addr":12,"./crypto/utils":14}],9:[function(require,module,exports){ -======= -},{"./crypto/base58":9,"./crypto/segwit_addr":14,"./crypto/utils":16}],9:[function(require,module,exports){ ->>>>>>> monero +},{"./crypto/base58":102,"./crypto/segwit_addr":107,"./crypto/utils":109}],102:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -5685,12 +5638,7 @@ function decode (bechString) { return {hrp: hrp, data: data.slice(0, data.length - 6)}; } -<<<<<<< HEAD },{}],104:[function(require,module,exports){ -||||||| merged common ancestors -},{}],11:[function(require,module,exports){ -======= -},{}],11:[function(require,module,exports){ /* JavaScript BigInteger library version 0.9.1 http://silentmatt.com/biginteger/ @@ -7141,8 +7089,7 @@ function decode (bechString) { exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt })(typeof exports !== 'undefined' ? exports : this); -},{}],12:[function(require,module,exports){ ->>>>>>> monero +},{}],105:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -7333,12 +7280,7 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -<<<<<<< HEAD -},{"buffer":7}],105:[function(require,module,exports){ -||||||| merged common ancestors -},{"buffer":3}],12:[function(require,module,exports){ -======= -},{"buffer":3}],13:[function(require,module,exports){ +},{"buffer":7}],106:[function(require,module,exports){ var JSBigInt = require('./biginteger')['JSBigInt']; /** @@ -7565,8 +7507,7 @@ var cnBase58 = (function () { return b58; })(); module.exports = cnBase58; -},{"./biginteger":11}],14:[function(require,module,exports){ ->>>>>>> monero +},{"./biginteger":104}],107:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -7662,13 +7603,7 @@ module.exports = { isValidAddress: isValidAddress, }; -<<<<<<< HEAD -},{"./bech32":103}],106:[function(require,module,exports){ -||||||| merged common ancestors -},{"./bech32":10}],13:[function(require,module,exports){ -======= -},{"./bech32":10}],15:[function(require,module,exports){ ->>>>>>> monero +},{"./bech32":103}],108:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -8312,81 +8247,59 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -<<<<<<< HEAD -},{"_process":99}],107:[function(require,module,exports){ -||||||| merged common ancestors -},{"_process":6}],14:[function(require,module,exports){ -======= -},{"_process":6}],16:[function(require,module,exports){ ->>>>>>> monero -var jsSHA = require('jssha/src/sha256'); -var Blake256 = require('./blake256'); -var keccak256 = require('./sha3')['keccak256']; +},{"_process":99}],109:[function(require,module,exports){ +var jsSHA = require('jssha/src/sha256') +var Blake256 = require('./blake256') +var keccak256 = require('./sha3')['keccak256'] var blake = require('blakejs') -function numberToHex (number) { - var hex = Math.round(number).toString(16); - if(hex.length === 1) { - hex = '0' + hex; - } - return hex; +function numberToHex(number) { + var hex = Math.round(number).toString(16) + if (hex.length === 1) { + hex = '0' + hex + } + return hex } module.exports = { - toHex: function (arrayOfBytes) { - var hex = ''; - for(var i = 0; i < arrayOfBytes.length; i++) { - hex += numberToHex(arrayOfBytes[i]); - } - return hex; - }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX'); - sha.update(hexString); - return sha.getHash('HEX'); - }, - sha256Checksum: function (payload) { - return this.sha256(this.sha256(payload)).substr(0, 8); - }, - blake256: function (hexString) { - return new Blake256().update(hexString, 'hex').digest('hex'); - }, - blake256Checksum: function (payload) { - return this.blake256(this.blake256(payload)).substr(0, 8); - }, - keccak256: function (hexString) { - return keccak256(hexString); -<<<<<<< HEAD - }, - blake2b: blake.blake2b -||||||| merged common ancestors - } -======= - }, - keccak256Checksum: function (payload) { - return keccak256(payload).toString().substr(0, 8); + toHex: function(arrayOfBytes) { + var hex = '' + for (var i = 0; i < arrayOfBytes.length; i++) { + hex += numberToHex(arrayOfBytes[i]) } ->>>>>>> monero -}; + return hex + }, + sha256: function(hexString) { + var sha = new jsSHA('SHA-256', 'HEX') + sha.update(hexString) + return sha.getHash('HEX') + }, + sha256Checksum: function(payload) { + return this.sha256(this.sha256(payload)).substr(0, 8) + }, + blake256: function(hexString) { + return new Blake256().update(hexString, 'hex').digest('hex') + }, + blake256Checksum: function(payload) { + return this.blake256(this.blake256(payload)).substr(0, 8) + }, + keccak256: function(hexString) { + return keccak256(hexString) + }, + blake2b: blake.blake2b, + keccak256Checksum: function(payload) { + return keccak256(payload) + .toString() + .substr(0, 8) + } +} -<<<<<<< HEAD -},{"./blake256":104,"./sha3":106,"blakejs":5,"jssha/src/sha256":9}],108:[function(require,module,exports){ +},{"./blake256":105,"./sha3":108,"blakejs":5,"jssha/src/sha256":9}],110:[function(require,module,exports){ var XRPValidator = require('./ripple_validator') var ETHValidator = require('./ethereum_validator') var BTCValidator = require('./bitcoin_validator') var SCValidator = require('./siacoin_validator') -||||||| merged common ancestors -},{"./blake256":11,"./sha3":13,"jssha/src/sha256":5}],15:[function(require,module,exports){ -var XRPValidator = require('./ripple_validator'); -var ETHValidator = require('./ethereum_validator'); -var BTCValidator = require('./bitcoin_validator'); -======= -},{"./blake256":12,"./sha3":15,"jssha/src/sha256":5}],17:[function(require,module,exports){ -var XRPValidator = require('./ripple_validator'); -var ETHValidator = require('./ethereum_validator'); -var BTCValidator = require('./bitcoin_validator'); -var XMRValidator = require('./monero_validator'); ->>>>>>> monero +var XMRValidator = require('./monero_validator') // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [ @@ -8611,31 +8524,35 @@ var CURRENCIES = [ addressTypes: { prod: ['3a', '32'], testnet: ['6f', 'c4'] }, validator: BTCValidator }, + { + name: 'bankex', + symbol: 'bkx', + validator: ETHValidator + }, { name: 'siacoin', symbol: 'sc', validator: SCValidator }, { - name: 'bankex', - symbol: 'bkx', - validator: ETHValidator -<<<<<<< HEAD - } -] -||||||| merged common ancestors -}]; - -======= -},{ + name: 'hyperspace', + symbol: 'xsc', + validator: SCValidator + }, + { name: 'monero', symbol: 'xmr', - addressTypes: {prod: ['18'], testnet: ['53']}, - iAddressTypes: {prod: ['19'], testnet: ['54']}, + addressTypes: { prod: ['18'], testnet: ['53'] }, + iAddressTypes: { prod: ['19'], testnet: ['54'] }, validator: XMRValidator -}]; - ->>>>>>> monero + }, + { + name: 'lbry', + symbol: 'lbc', + addressTypes: { prod: ['55'], testnet: [] }, + validator: BTCValidator + } +] module.exports = { getByNameOrSymbol: function(currencyNameOrSymbol) { @@ -8650,13 +8567,7 @@ module.exports = { } } -<<<<<<< HEAD -},{"./bitcoin_validator":101,"./ethereum_validator":109,"./ripple_validator":110,"./siacoin_validator":111}],109:[function(require,module,exports){ -||||||| merged common ancestors -},{"./bitcoin_validator":8,"./ethereum_validator":16,"./ripple_validator":17}],16:[function(require,module,exports){ -======= -},{"./bitcoin_validator":8,"./ethereum_validator":18,"./monero_validator":19,"./ripple_validator":20}],18:[function(require,module,exports){ ->>>>>>> monero +},{"./bitcoin_validator":101,"./ethereum_validator":111,"./monero_validator":112,"./ripple_validator":113,"./siacoin_validator":114}],111:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -8692,12 +8603,7 @@ module.exports = { } }; -<<<<<<< HEAD -},{"./crypto/utils":107}],110:[function(require,module,exports){ -||||||| merged common ancestors -},{"./crypto/utils":14}],17:[function(require,module,exports){ -======= -},{"./crypto/utils":16}],19:[function(require,module,exports){ +},{"./crypto/utils":109}],112:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var cnBase58 = require('./crypto/cnBase58'); @@ -8759,8 +8665,7 @@ module.exports = { } }; -},{"./crypto/cnBase58":13,"./crypto/utils":16}],20:[function(require,module,exports){ ->>>>>>> monero +},{"./crypto/cnBase58":106,"./crypto/utils":109}],113:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -8790,21 +8695,10 @@ module.exports = { } }; -<<<<<<< HEAD -},{"./crypto/utils":107,"base-x":1}],111:[function(require,module,exports){ +},{"./crypto/utils":109,"base-x":1}],114:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils') var isEqual = require('lodash/isEqual') -// Convert a byte array to a hex string -function bytesToHex(bytes) { - var hex = [] - for (var b in bytes) { - hex.push((b >>> 4).toString(16)) - hex.push((b & 0xf).toString(16)) - } - return hex.join('') -} - function hexToBytes(hex) { var bytes = [] for (var c = 0; c < hex.length; c += 2) { @@ -8828,16 +8722,11 @@ module.exports = { var checksumBytes = Uint8Array.from(aBytes.slice(0, 32)) var check = Uint8Array.from(aBytes.slice(32, 38)) var blakeHash = cryptoUtils.blake2b(checksumBytes, null, 32).slice(0, 6) - return isEqual(blakeHash, check) + return !!isEqual(blakeHash, check) } } -},{"./crypto/utils":107,"lodash/isEqual":90}],112:[function(require,module,exports){ -||||||| merged common ancestors -},{"./crypto/utils":14,"base-x":1}],18:[function(require,module,exports){ -======= -},{"./crypto/utils":16,"base-x":1}],21:[function(require,module,exports){ ->>>>>>> monero +},{"./crypto/utils":109,"lodash/isEqual":90}],115:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -8854,11 +8743,5 @@ module.exports = { }, }; -<<<<<<< HEAD -},{"./currencies":108}]},{},[112])(112) -||||||| merged common ancestors -},{"./currencies":15}]},{},[18])(18) -======= -},{"./currencies":17}]},{},[21])(21) ->>>>>>> monero +},{"./currencies":110}]},{},[115])(115) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 784ced0e..867ca419 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1,7 +1 @@ -<<<<<<< HEAD -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(a,s,u){function f(e,t){if(!s[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=s[e]={exports:{}};a[e][0].call(o.exports,function(t){return f(a[e][1][t]||t)},o,o.exports,i,a,s,u)}return s[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,i[a++]=e>>8&255,i[a++]=255&e;var f,c;2===o&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,i[a++]=255&e);1===o&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,a=r-n;i>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return o.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var o=t("./util");function l(t,e,r){var n=t[e]+t[r],o=t[e+1]+t[r+1];4294967296<=n&&o++,t[e]=n,t[e+1]=o}function p(t,e,r,n){var o=t[e]+r;r<0&&(o+=4294967296);var i=t[e+1]+n;4294967296<=o&&i++,t[e]=o,t[e+1]=i}function i(t,e,r,n,o,i){var a=y[o],s=y[o+1],u=y[i],f=y[i+1];l(d,t,e),p(d,t,a,s);var c=d[n]^d[t],h=d[n+1]^d[t+1];d[n]=h,d[n+1]=c,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=c>>>24^h<<8,d[e+1]=h>>>24^c<<8,l(d,t,e),p(d,t,u,f),c=d[n]^d[t],h=d[n+1]^d[t+1],d[n]=c>>>16^h<<16,d[n+1]=h>>>16^c<<16,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=h>>>31^c<<1,d[e+1]=c>>>31^h<<1}var a=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),s=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map(function(t){return 2*t})),d=new Uint32Array(32),y=new Uint32Array(32);function n(t,e){var r,n,o=0;for(o=0;o<16;o++)d[o]=t.h[o],d[o+16]=a[o];for(d[24]=d[24]^t.t,d[25]=d[25]^t.t/4294967296,e&&(d[28]=~d[28],d[29]=~d[29]),o=0;o<32;o++)y[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<12;o++)i(0,8,16,24,s[16*o+0],s[16*o+1]),i(2,10,18,26,s[16*o+2],s[16*o+3]),i(4,12,20,28,s[16*o+4],s[16*o+5]),i(6,14,22,30,s[16*o+6],s[16*o+7]),i(0,10,20,30,s[16*o+8],s[16*o+9]),i(2,12,22,24,s[16*o+10],s[16*o+11]),i(4,14,16,26,s[16*o+12],s[16*o+13]),i(6,8,18,28,s[16*o+14],s[16*o+15]);for(o=0;o<16;o++)t.h[o]=t.h[o]^d[o]^d[o+16]}function u(t,e){if(0===t||64>2]>>8*(3&r);return e}function h(t,e,r){r=r||64,t=o.normalizeInput(t);var n=u(r,e);return f(n,t),c(n)}e.exports={blake2b:h,blake2bHex:function(t,e,r){var n=h(t,e,r);return o.toHex(n)},blake2bInit:u,blake2bUpdate:f,blake2bFinal:c}},{"./util":6}],4:[function(t,e,r){var o=t("./util");function i(t,e,r,n,o,i){f[t]=f[t]+f[e]+o,f[n]=a(f[n]^f[t],16),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],12),f[t]=f[t]+f[e]+i,f[n]=a(f[n]^f[t],8),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],7)}function a(t,e){return t>>>e^t<<32-e}var s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),f=new Uint32Array(16),c=new Uint32Array(16);function n(t,e){var r,n,o=0;for(o=0;o<8;o++)f[o]=t.h[o],f[o+8]=s[o];for(f[12]^=t.t,f[13]^=t.t/4294967296,e&&(f[14]=~f[14]),o=0;o<16;o++)c[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<10;o++)i(0,4,8,12,c[u[16*o+0]],c[u[16*o+1]]),i(1,5,9,13,c[u[16*o+2]],c[u[16*o+3]]),i(2,6,10,14,c[u[16*o+4]],c[u[16*o+5]]),i(3,7,11,15,c[u[16*o+6]],c[u[16*o+7]]),i(0,5,10,15,c[u[16*o+8]],c[u[16*o+9]]),i(1,6,11,12,c[u[16*o+10]],c[u[16*o+11]]),i(2,7,8,13,c[u[16*o+12]],c[u[16*o+13]]),i(3,4,9,14,c[u[16*o+14]],c[u[16*o+15]]);for(o=0;o<8;o++)t.h[o]^=f[o]^f[o+8]}function h(t,e){if(!(0>2]>>8*(3&r)&255;return e}function d(t,e,r){r=r||32,t=o.normalizeInput(t);var n=h(r,e);return l(n,t),p(n)}e.exports={blake2s:d,blake2sHex:function(t,e,r){var n=d(t,e,r);return o.toHex(n)},blake2sInit:h,blake2sUpdate:l,blake2sFinal:p}},{"./util":6}],5:[function(t,e,r){var n=t("./blake2b"),o=t("./blake2s");e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:o.blake2s,blake2sHex:o.blake2sHex,blake2sInit:o.blake2sInit,blake2sUpdate:o.blake2sUpdate,blake2sFinal:o.blake2sFinal}},{"./blake2b":3,"./blake2s":4}],6:[function(t,e,r){(function(r){function i(t){return(4294967296+t).toString(16).substring(1)}e.exports={normalizeInput:function(t){var e;if(t instanceof Uint8Array)e=t;else if(t instanceof r)e=new Uint8Array(t);else{if("string"!=typeof t)throw new Error("Input must be an string, Buffer or Uint8Array");e=new Uint8Array(r.from(t,"utf8"))}return e},toHex:function(t){return Array.prototype.map.call(t,function(t){return(t<16?"0":"")+t.toString(16)}).join("")},debugPrint:function(t,e,r){for(var n="\n"+t+" = ",o=0;o>>1;case"base64":return L(t).length;default:if(n)return I(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;i>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(t){var e=t.length;if(e<=m)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},h.prototype.compare=function(t,e,r,n,o){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,a,s,u,f,c,h,l,p,d=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,H(I(t,(h=this).length-l),h,l,p);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return u=this,f=e,c=r,H(L(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,H(function(t,e){for(var r,n,o,i=[],a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-a),i,a,s);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var m=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function B(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,8),i.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||T(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||T(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);T(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);T(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;0<=--i&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function L(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function M(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function F(t){return t!=t}},{"base64-js":2,ieee754:8}],8:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,h=r?o-1:0,l=r?-1:1,p=t[e+h];for(h+=l,i=p&(1<<-c)-1,p>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,o),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,o),a=0));8<=o;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return F(t,e,a)},l=function(t,e,r,n){var o,i;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,b,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,w=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===v)throw Error("Cannot call getHash after setting HMAC key");switch(o=E(e),t){case"HEX":r=function(t){return m(t,f,o)};break;case"B64":r=function(t){return A(t,f,o)};break;case"BYTES":r=function(t){return x(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return k(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(b.slice(),g,y,p(s)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function A(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function x(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function k(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function E(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function C(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=o[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,i[s++]=r>>8&255,i[s++]=255&r;var f,h;2===o&&(r=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,i[s++]=255&r);1===o&&(r=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,i[s++]=r>>8&255,i[s++]=255&r);return i},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,o=[],i=0,s=e-n;i>2]+a[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],o.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"="));return o.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),i=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(o>>1;case"base64":return H(t).length;default:if(n)return R(t).length;r=(""+r).toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(o){var h=-1;for(i=e;i>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=A)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return E(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return w(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0r&&(t+=" ... ")),""},c.prototype.compare=function(t,r,e,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(i,s),u=this.slice(n,o),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,O(R(t,(c=this).length-l),c,l,p);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return b(this,t,r,e);case"base64":return u=this,f=r,h=e,O(H(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,O(function(t,r){for(var e,n,o,i=[],s=0;s>8,o=e%256,i.push(o),i.push(n);return i}(t,(i=this).length-s),i,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function E(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;ot.length)throw new RangeError("Index out of range")}function U(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function C(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,4),i.write(t,r,e,n,23,4),e+4}function S(t,r,e,n,o){return r=+r,e>>>=0,o||U(t,0,e,8),i.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t+--r],o=1;0>>=0,r||T(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||T(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||T(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||x(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=0,s=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[r+i]=255&t;0<=--i&&(s*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function F(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function M(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,o),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[e+p]=255&a,p+=d,a/=256,o-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return M(t,r,s)},l=function(t,r,e,n){var o,i;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[o]=4294967295&r,t[o-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,g,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(r),t){case"HEX":e=function(t){return A(t,f,o)};break;case"B64":e=function(t){return E(t,f,o)};break;case"BYTES":e=function(t){return B(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return _(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return e.outputUpper?i.toUpperCase():i}function E(t,r,e){var n,o,i,s="",a=r/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)s+=8*n+6*o<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):e.b64Pad;return s}function B(t,r){var e,n,o="",i=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,o+=String.fromCharCode(n);return o}function _(t,r){var e,n,o=r/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),e=0;e>>2]>>>8*(3+e%4*-1)&255;return i}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function T(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,o,i,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=i;)r.push(0);r[i]|=o<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,o,i,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=o[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,o,i,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var s=0;t[s]===h&&s>16&255,o[s++]=r>>8&255,o[s++]=255&r;var f,h;2===i&&(r=c[t.charCodeAt(u)]<<2|c[t.charCodeAt(u+1)]>>4,o[s++]=255&r);1===i&&(r=c[t.charCodeAt(u)]<<10|c[t.charCodeAt(u+1)]<<4|c[t.charCodeAt(u+2)]>>2,o[s++]=r>>8&255,o[s++]=255&r);return o},e.fromByteArray=function(t){for(var r,e=t.length,n=e%3,i=[],o=0,s=e-n;o>2]+a[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],i.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"="));return i.join("")};for(var a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i>18&63]+a[i>>12&63]+a[i>>6&63]+a[63&i]);return o.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(t,r,e){"use strict";var n=t("base64-js"),o=t("ieee754");e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;var i=2147483647;function s(t){if(i>>1;case"base64":return O(t).length;default:if(i)return n?-1:L(t).length;r=(""+r).toLowerCase(),i=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function g(t,r,e,n,i){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if("string"==typeof r&&(r=c.from(r,n)),c.isBuffer(r))return 0===r.length?-1:y(t,r,e,n,i);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):y(t,[r],e,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,r,e,n,i){var o,s=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=s=2,u/=2,e/=2}function f(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(i){var h=-1;for(o=e;o>>10&1023|55296),h=56320|1023&h),n.push(h),i+=c}return function(t){var r=t.length;if(r<=_)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return A(this,r,e);case"latin1":case"binary":return E(this,r,e);case"base64":return b(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),""},c.prototype.compare=function(t,r,e,n,i){if(H(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&e<=r)return 0;if(i<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(e>>>=0)-(r>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=t.slice(r,e),h=0;h>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,s,a,u,f,h,c,l,p,d=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return l=r,p=e,M(L(t,(c=this).length-l),c,l,p);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return w(this,t,r,e);case"base64":return u=this,f=r,h=e,M(O(t),u,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=r,a=e,M(function(t,r){for(var e,n,i,o=[],s=0;s>8,i=e%256,o.push(i),o.push(n);return o}(t,(o=this).length-s),o,s,a);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,r,e){var n="";e=Math.min(t.length,e);for(var i=r;it.length)throw new RangeError("Index out of range")}function U(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function S(t,r,e,n,i){return r=+r,e>>>=0,i||U(t,0,e,4),o.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,i){return r=+r,e>>>=0,i||U(t,0,e,8),o.write(t,r,e,n,52,8),e+8}c.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):e>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t],i=1,o=0;++o>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t+--r],i=1;0>>=0,r||x(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return t>>>=0,r||x(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return t>>>=0,r||x(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return t>>>=0,r||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,r){return t>>>=0,r||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t],i=1,o=0;++o>>=0,r>>>=0,e||x(t,r,this.length);for(var n=r,i=1,o=this[t+--n];0>>=0,r||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,r){t>>>=0,r||x(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,r){t>>>=0,r||x(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,r){return t>>>=0,r||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return t>>>=0,r||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return t>>>=0,r||x(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return t>>>=0,r||x(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return t>>>=0,r||x(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return t>>>=0,r||x(t,8,this.length),o.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||T(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o>>=0,e>>>=0,n)||T(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;0<=--i&&(o*=256);)this[r+i]=t/o&255;return r+e},c.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,1,255,0),this[r]=255&t,r+1},c.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},c.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var i=Math.pow(2,8*e-1);T(this,t,r,e,i-1,-i)}var o=0,s=1,a=0;for(this[r]=255&t;++o>0)-a&255;return r+e},c.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var i=Math.pow(2,8*e-1);T(this,t,r,e,i-1,-i)}var o=e-1,s=1,a=0;for(this[r+o]=255&t;0<=--o&&(s*=256);)t<0&&0===a&&0!==this[r+o+1]&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+e},c.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},c.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},c.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},c.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},c.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||T(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},c.prototype.writeFloatLE=function(t,r,e){return S(this,t,r,!0,e)},c.prototype.writeFloatBE=function(t,r,e){return S(this,t,r,!1,e)},c.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},c.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},c.prototype.copy=function(t,r,e,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(o=r;o>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function O(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function M(t,r,e,n){for(var i=0;i=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function H(t,r){return t instanceof r||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===r.name}function F(t){return t!=t}},{"base64-js":2,ieee754:4}],4:[function(t,r,e){e.read=function(t,r,e,n,i){var o,s,a=8*i-n-1,u=(1<>1,h=-7,c=e?i-1:0,l=e?-1:1,p=t[r+c];for(c+=l,o=p&(1<<-h)-1,p>>=-h,h+=a;0>=-h,h+=n;0>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,s=h):(s=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-s))<1&&(s--,u*=2),2<=(r+=1<=s+c?l/u:l*Math.pow(2,1-c))*u&&(s++,u/=2),h<=s+c?(a=0,s=h):1<=s+c?(a=(r*u-1)*Math.pow(2,i),s+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,i),s=0));8<=i;t[e+p]=255&a,p+=d,a/=256,i-=8);for(s=s<= 1");if(0!==s.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(c=function(t,r){return F(t,r,s)},l=function(t,r,e,n){var i,o;if("SHA-224"!==s&&"SHA-256"!==s)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),o=16;t.length<=i;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=e,t[i]=4294967295&r,t[i-1]=r/4294967296|0,e=t.length,r=0;r>>3)/4-1,n>>5;for(t=(r=u(t,y,v)).binLen,e=r.value,r=t>>>5,n=0;n>>5),v=t%h,m=!0},this.getHash=function(t,r){var e,n,i,o;if(!0===w)throw Error("Cannot call getHash after setting HMAC key");switch(i=k(r),t){case"HEX":e=function(t){return _(t,f,i)};break;case"B64":e=function(t){return A(t,f,i)};break;case"BYTES":e=function(t){return E(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}e=function(t){return B(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(o=l(y.slice(),v,g,p(a)),n=1;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return e.outputUpper?o.toUpperCase():o}function A(t,r,e){var n,i,o,s="",a=r/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;i<4;i+=1)s+=8*n+6*i<=r?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):e.b64Pad;return s}function E(t,r){var e,n,i="",o=r/8;for(e=0;e>>2]>>>8*(3+e%4*-1)&255,i+=String.fromCharCode(n);return i}function B(t,r){var e,n,i=r/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),e=0;e>>2]>>>8*(3+e%4*-1)&255;return o}function k(t){var r={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},r.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(r.b64Pad=t.b64Pad),"boolean"!=typeof r.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw Error("Invalid b64Pad formatting option");return r}function x(t,l){var r;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,r,e){var n,i,o,s,a,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(r=r||[0],a=(e=e||0)>>>3,n=0;n>>1)+a)>>>2;r.length<=o;)r.push(0);r[o]|=i<<8*(3+s%4*-1)}return{value:r,binLen:4*u+e}};break;case"TEXT":r=function(t,r,e){var n,i,o,s,a,u,f,h,c=0;if(r=r||[0],a=(e=e||0)>>>3,"UTF8"===l)for(h=3,o=0;o>>6),i.push(128|63&n)):n<55296||57344<=n?i.push(224|n>>>12,128|n>>>6&63,128|63&n):(o+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(o)),i.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),s=0;s>>2;r.length<=u;)r.push(0);r[u]|=i[s]<<8*(h+f%4*-1),c+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(h=2,i="UTF16LE"===l||"UTF16LE"!==l&&!1,o=0;o>>8),u=(f=c+a)>>>2;r.length<=u;)r.push(0);r[u]|=n<<8*(h+f%4*-1),c+=2}return{value:r,binLen:8*c+e}};break;case"B64":r=function(t,r,e){var n,i,o,s,a,u,f,h=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,i[a++]=e>>8&255,i[a++]=255&e;var f,c;2===o&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,i[a++]=255&e);1===o&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,a=r-n;i>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return o.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var o=t("./util");function l(t,e,r){var n=t[e]+t[r],o=t[e+1]+t[r+1];4294967296<=n&&o++,t[e]=n,t[e+1]=o}function p(t,e,r,n){var o=t[e]+r;r<0&&(o+=4294967296);var i=t[e+1]+n;4294967296<=o&&i++,t[e]=o,t[e+1]=i}function i(t,e,r,n,o,i){var a=y[o],s=y[o+1],u=y[i],f=y[i+1];l(d,t,e),p(d,t,a,s);var c=d[n]^d[t],h=d[n+1]^d[t+1];d[n]=h,d[n+1]=c,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=c>>>24^h<<8,d[e+1]=h>>>24^c<<8,l(d,t,e),p(d,t,u,f),c=d[n]^d[t],h=d[n+1]^d[t+1],d[n]=c>>>16^h<<16,d[n+1]=h>>>16^c<<16,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=h>>>31^c<<1,d[e+1]=c>>>31^h<<1}var a=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),s=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map(function(t){return 2*t})),d=new Uint32Array(32),y=new Uint32Array(32);function n(t,e){var r,n,o=0;for(o=0;o<16;o++)d[o]=t.h[o],d[o+16]=a[o];for(d[24]=d[24]^t.t,d[25]=d[25]^t.t/4294967296,e&&(d[28]=~d[28],d[29]=~d[29]),o=0;o<32;o++)y[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<12;o++)i(0,8,16,24,s[16*o+0],s[16*o+1]),i(2,10,18,26,s[16*o+2],s[16*o+3]),i(4,12,20,28,s[16*o+4],s[16*o+5]),i(6,14,22,30,s[16*o+6],s[16*o+7]),i(0,10,20,30,s[16*o+8],s[16*o+9]),i(2,12,22,24,s[16*o+10],s[16*o+11]),i(4,14,16,26,s[16*o+12],s[16*o+13]),i(6,8,18,28,s[16*o+14],s[16*o+15]);for(o=0;o<16;o++)t.h[o]=t.h[o]^d[o]^d[o+16]}function u(t,e){if(0===t||64>2]>>8*(3&r);return e}function h(t,e,r){r=r||64,t=o.normalizeInput(t);var n=u(r,e);return f(n,t),c(n)}e.exports={blake2b:h,blake2bHex:function(t,e,r){var n=h(t,e,r);return o.toHex(n)},blake2bInit:u,blake2bUpdate:f,blake2bFinal:c}},{"./util":6}],4:[function(t,e,r){var o=t("./util");function i(t,e,r,n,o,i){f[t]=f[t]+f[e]+o,f[n]=a(f[n]^f[t],16),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],12),f[t]=f[t]+f[e]+i,f[n]=a(f[n]^f[t],8),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],7)}function a(t,e){return t>>>e^t<<32-e}var s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),f=new Uint32Array(16),c=new Uint32Array(16);function n(t,e){var r,n,o=0;for(o=0;o<8;o++)f[o]=t.h[o],f[o+8]=s[o];for(f[12]^=t.t,f[13]^=t.t/4294967296,e&&(f[14]=~f[14]),o=0;o<16;o++)c[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<10;o++)i(0,4,8,12,c[u[16*o+0]],c[u[16*o+1]]),i(1,5,9,13,c[u[16*o+2]],c[u[16*o+3]]),i(2,6,10,14,c[u[16*o+4]],c[u[16*o+5]]),i(3,7,11,15,c[u[16*o+6]],c[u[16*o+7]]),i(0,5,10,15,c[u[16*o+8]],c[u[16*o+9]]),i(1,6,11,12,c[u[16*o+10]],c[u[16*o+11]]),i(2,7,8,13,c[u[16*o+12]],c[u[16*o+13]]),i(3,4,9,14,c[u[16*o+14]],c[u[16*o+15]]);for(o=0;o<8;o++)t.h[o]^=f[o]^f[o+8]}function h(t,e){if(!(0>2]>>8*(3&r)&255;return e}function d(t,e,r){r=r||32,t=o.normalizeInput(t);var n=h(r,e);return l(n,t),p(n)}e.exports={blake2s:d,blake2sHex:function(t,e,r){var n=d(t,e,r);return o.toHex(n)},blake2sInit:h,blake2sUpdate:l,blake2sFinal:p}},{"./util":6}],5:[function(t,e,r){var n=t("./blake2b"),o=t("./blake2s");e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:o.blake2s,blake2sHex:o.blake2sHex,blake2sInit:o.blake2sInit,blake2sUpdate:o.blake2sUpdate,blake2sFinal:o.blake2sFinal}},{"./blake2b":3,"./blake2s":4}],6:[function(t,e,r){(function(r){function i(t){return(4294967296+t).toString(16).substring(1)}e.exports={normalizeInput:function(t){var e;if(t instanceof Uint8Array)e=t;else if(t instanceof r)e=new Uint8Array(t);else{if("string"!=typeof t)throw new Error("Input must be an string, Buffer or Uint8Array");e=new Uint8Array(r.from(t,"utf8"))}return e},toHex:function(t){return Array.prototype.map.call(t,function(t){return(t<16?"0":"")+t.toString(16)}).join("")},debugPrint:function(t,e,r){for(var n="\n"+t+" = ",o=0;o>>1;case"base64":return L(t).length;default:if(n)return I(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;i>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(t){var e=t.length;if(e<=m)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return E(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},h.prototype.compare=function(t,e,r,n,o){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,a,s,u,f,c,h,l,p,d=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,M(I(t,(h=this).length-l),h,l,p);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,M(L(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,M(function(t,e){for(var r,n,o,i=[],a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-a),i,a,s);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var m=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function B(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,8),i.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;0<=--i&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function L(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function M(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function R(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function H(t){return t!=t}},{"base64-js":2,ieee754:8}],8:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,h=r?o-1:0,l=r?-1:1,p=t[e+h];for(h+=l,i=p&(1<<-c)-1,p>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,o),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,o),a=0));8<=o;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return H(t,e,a)},l=function(t,e,r,n){var o,i;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,v)).binLen,r=e.value,e=t>>>5,n=0;n>>5),v=t%c,w=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(e),t){case"HEX":r=function(t){return m(t,f,o)};break;case"B64":r=function(t){return A(t,f,o)};break;case"BYTES":r=function(t){return x(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return E(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(s)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function A(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function x(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function E(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function k(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function C(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=o[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Sun, 11 Nov 2018 10:17:39 -0500 Subject: [PATCH 071/108] add loki --- dist/wallet-address-validator.js | 111 +++++++++++++++------------ dist/wallet-address-validator.min.js | 2 +- src/currencies.js | 7 ++ src/monero_validator.js | 108 +++++++++++++------------- test/wallet_address_validator.js | 53 ++++++++++++- 5 files changed, 175 insertions(+), 106 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index aefd9fe9..7509375b 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -8546,6 +8546,13 @@ var CURRENCIES = [ iAddressTypes: { prod: ['19'], testnet: ['54'] }, validator: XMRValidator }, + { + name: 'loki', + symbol: 'loki', + addressTypes: { prod: ['114', '116'], testnet: [] }, + iAddressTypes: { prod: ['115'], testnet: [] }, + validator: XMRValidator + }, { name: 'lbry', symbol: 'lbc', @@ -8604,66 +8611,68 @@ module.exports = { }; },{"./crypto/utils":109}],112:[function(require,module,exports){ -var cryptoUtils = require('./crypto/utils'); -var cnBase58 = require('./crypto/cnBase58'); - -var DEFAULT_NETWORK_TYPE = 'prod'; -var addressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$'); -var integratedAddressRegTest = new RegExp('^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$'); - -function validateNetwork(decoded, currency, networkType, addressType){ - var network = currency.addressTypes; - if(addressType == 'integrated'){ - network = currency.iAddressTypes; - } - - switch(networkType){ - case 'prod': - return parseInt(decoded.substr(0,2), 16) == network.prod[0]; - case 'testnet': - return parseInt(decoded.substr(0,2), 16) == network.testnet[0]; - case 'both': - return parseInt(decoded.substr(0,2), 16) == network.prod[0] || parseInt(decoded.substr(0,2), 16) == network.testnet[0]; - default: - return false; - } +var cryptoUtils = require('./crypto/utils') +var cnBase58 = require('./crypto/cnBase58') + +var DEFAULT_NETWORK_TYPE = 'prod' +var addressRegTest = new RegExp( + '^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$' +) +var integratedAddressRegTest = new RegExp( + '^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$' +) + +function validateNetwork(decoded, currency, networkType, addressType) { + var network = currency.addressTypes + if (addressType == 'integrated') { + network = currency.iAddressTypes + } + var at = parseInt(decoded.substr(0, 2), 16).toString() + + switch (networkType) { + case 'prod': + return network.prod.indexOf(at) >= 0 + case 'testnet': + return network.testnet.indexOf(at) >= 0 + case 'both': + return network.prod.indexOf(at) >= 0 || network.testnet.indexOf(at) >= 0 + default: + return false + } } function hextobin(hex) { - if (hex.length % 2 !== 0) return null; - var res = new Uint8Array(hex.length / 2); - for (var i = 0; i < hex.length / 2; ++i) { - res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); - } - return res; + if (hex.length % 2 !== 0) return null + var res = new Uint8Array(hex.length / 2) + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16) + } + return res } module.exports = { - isValidAddress: function (address, currency, networkType) { - networkType = networkType || DEFAULT_NETWORK_TYPE; - var addressType = 'standard'; - if(!addressRegTest.test(address)){ - if(integratedAddressRegTest.test(address)){ - addressType = 'integrated'; - } - else{ - return false; - } - } + isValidAddress: function(address, currency, networkType) { + networkType = networkType || DEFAULT_NETWORK_TYPE + var addressType = 'standard' + if (!addressRegTest.test(address)) { + if (integratedAddressRegTest.test(address)) { + addressType = 'integrated' + } else { + return false + } + } - var decodedAddrStr = cnBase58.decode(address); - if(!decodedAddrStr) - return false; + var decodedAddrStr = cnBase58.decode(address) + if (!decodedAddrStr) return false - if(!validateNetwork(decodedAddrStr, currency, networkType, addressType)) - return false; + if (!validateNetwork(decodedAddrStr, currency, networkType, addressType)) return false - var addrChecksum = decodedAddrStr.slice(-8); - var hashChecksum = cryptoUtils.keccak256Checksum(hextobin(decodedAddrStr.slice(0, -8))); - - return addrChecksum === hashChecksum; - } -}; + var addrChecksum = decodedAddrStr.slice(-8) + var hashChecksum = cryptoUtils.keccak256Checksum(hextobin(decodedAddrStr.slice(0, -8))) + + return addrChecksum === hashChecksum + } +} },{"./crypto/cnBase58":106,"./crypto/utils":109}],113:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 867ca419..3ef1b11a 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(a,s,u){function f(e,t){if(!s[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=s[e]={exports:{}};a[e][0].call(o.exports,function(t){return f(a[e][1][t]||t)},o,o.exports,i,a,s,u)}return s[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,i[a++]=e>>8&255,i[a++]=255&e;var f,c;2===o&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,i[a++]=255&e);1===o&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,a=r-n;i>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return o.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var o=t("./util");function l(t,e,r){var n=t[e]+t[r],o=t[e+1]+t[r+1];4294967296<=n&&o++,t[e]=n,t[e+1]=o}function p(t,e,r,n){var o=t[e]+r;r<0&&(o+=4294967296);var i=t[e+1]+n;4294967296<=o&&i++,t[e]=o,t[e+1]=i}function i(t,e,r,n,o,i){var a=y[o],s=y[o+1],u=y[i],f=y[i+1];l(d,t,e),p(d,t,a,s);var c=d[n]^d[t],h=d[n+1]^d[t+1];d[n]=h,d[n+1]=c,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=c>>>24^h<<8,d[e+1]=h>>>24^c<<8,l(d,t,e),p(d,t,u,f),c=d[n]^d[t],h=d[n+1]^d[t+1],d[n]=c>>>16^h<<16,d[n+1]=h>>>16^c<<16,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=h>>>31^c<<1,d[e+1]=c>>>31^h<<1}var a=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),s=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map(function(t){return 2*t})),d=new Uint32Array(32),y=new Uint32Array(32);function n(t,e){var r,n,o=0;for(o=0;o<16;o++)d[o]=t.h[o],d[o+16]=a[o];for(d[24]=d[24]^t.t,d[25]=d[25]^t.t/4294967296,e&&(d[28]=~d[28],d[29]=~d[29]),o=0;o<32;o++)y[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<12;o++)i(0,8,16,24,s[16*o+0],s[16*o+1]),i(2,10,18,26,s[16*o+2],s[16*o+3]),i(4,12,20,28,s[16*o+4],s[16*o+5]),i(6,14,22,30,s[16*o+6],s[16*o+7]),i(0,10,20,30,s[16*o+8],s[16*o+9]),i(2,12,22,24,s[16*o+10],s[16*o+11]),i(4,14,16,26,s[16*o+12],s[16*o+13]),i(6,8,18,28,s[16*o+14],s[16*o+15]);for(o=0;o<16;o++)t.h[o]=t.h[o]^d[o]^d[o+16]}function u(t,e){if(0===t||64>2]>>8*(3&r);return e}function h(t,e,r){r=r||64,t=o.normalizeInput(t);var n=u(r,e);return f(n,t),c(n)}e.exports={blake2b:h,blake2bHex:function(t,e,r){var n=h(t,e,r);return o.toHex(n)},blake2bInit:u,blake2bUpdate:f,blake2bFinal:c}},{"./util":6}],4:[function(t,e,r){var o=t("./util");function i(t,e,r,n,o,i){f[t]=f[t]+f[e]+o,f[n]=a(f[n]^f[t],16),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],12),f[t]=f[t]+f[e]+i,f[n]=a(f[n]^f[t],8),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],7)}function a(t,e){return t>>>e^t<<32-e}var s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),f=new Uint32Array(16),c=new Uint32Array(16);function n(t,e){var r,n,o=0;for(o=0;o<8;o++)f[o]=t.h[o],f[o+8]=s[o];for(f[12]^=t.t,f[13]^=t.t/4294967296,e&&(f[14]=~f[14]),o=0;o<16;o++)c[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<10;o++)i(0,4,8,12,c[u[16*o+0]],c[u[16*o+1]]),i(1,5,9,13,c[u[16*o+2]],c[u[16*o+3]]),i(2,6,10,14,c[u[16*o+4]],c[u[16*o+5]]),i(3,7,11,15,c[u[16*o+6]],c[u[16*o+7]]),i(0,5,10,15,c[u[16*o+8]],c[u[16*o+9]]),i(1,6,11,12,c[u[16*o+10]],c[u[16*o+11]]),i(2,7,8,13,c[u[16*o+12]],c[u[16*o+13]]),i(3,4,9,14,c[u[16*o+14]],c[u[16*o+15]]);for(o=0;o<8;o++)t.h[o]^=f[o]^f[o+8]}function h(t,e){if(!(0>2]>>8*(3&r)&255;return e}function d(t,e,r){r=r||32,t=o.normalizeInput(t);var n=h(r,e);return l(n,t),p(n)}e.exports={blake2s:d,blake2sHex:function(t,e,r){var n=d(t,e,r);return o.toHex(n)},blake2sInit:h,blake2sUpdate:l,blake2sFinal:p}},{"./util":6}],5:[function(t,e,r){var n=t("./blake2b"),o=t("./blake2s");e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:o.blake2s,blake2sHex:o.blake2sHex,blake2sInit:o.blake2sInit,blake2sUpdate:o.blake2sUpdate,blake2sFinal:o.blake2sFinal}},{"./blake2b":3,"./blake2s":4}],6:[function(t,e,r){(function(r){function i(t){return(4294967296+t).toString(16).substring(1)}e.exports={normalizeInput:function(t){var e;if(t instanceof Uint8Array)e=t;else if(t instanceof r)e=new Uint8Array(t);else{if("string"!=typeof t)throw new Error("Input must be an string, Buffer or Uint8Array");e=new Uint8Array(r.from(t,"utf8"))}return e},toHex:function(t){return Array.prototype.map.call(t,function(t){return(t<16?"0":"")+t.toString(16)}).join("")},debugPrint:function(t,e,r){for(var n="\n"+t+" = ",o=0;o>>1;case"base64":return L(t).length;default:if(n)return I(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;i>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(t){var e=t.length;if(e<=m)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return E(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},h.prototype.compare=function(t,e,r,n,o){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,a,s,u,f,c,h,l,p,d=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,M(I(t,(h=this).length-l),h,l,p);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,M(L(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,M(function(t,e){for(var r,n,o,i=[],a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-a),i,a,s);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var m=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function B(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,8),i.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;0<=--i&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function L(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function M(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function R(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function H(t){return t!=t}},{"base64-js":2,ieee754:8}],8:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,h=r?o-1:0,l=r?-1:1,p=t[e+h];for(h+=l,i=p&(1<<-c)-1,p>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,o),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,o),a=0));8<=o;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return H(t,e,a)},l=function(t,e,r,n){var o,i;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,v)).binLen,r=e.value,e=t>>>5,n=0;n>>5),v=t%c,w=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=k(e),t){case"HEX":r=function(t){return m(t,f,o)};break;case"B64":r=function(t){return A(t,f,o)};break;case"BYTES":r=function(t){return x(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return E(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(s)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function A(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function x(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function E(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function k(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function C(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=o[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,i[a++]=e>>8&255,i[a++]=255&e;var f,c;2===o&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,i[a++]=255&e);1===o&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,a=r-n;i>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return o.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var o=t("./util");function l(t,e,r){var n=t[e]+t[r],o=t[e+1]+t[r+1];4294967296<=n&&o++,t[e]=n,t[e+1]=o}function p(t,e,r,n){var o=t[e]+r;r<0&&(o+=4294967296);var i=t[e+1]+n;4294967296<=o&&i++,t[e]=o,t[e+1]=i}function i(t,e,r,n,o,i){var a=y[o],s=y[o+1],u=y[i],f=y[i+1];l(d,t,e),p(d,t,a,s);var c=d[n]^d[t],h=d[n+1]^d[t+1];d[n]=h,d[n+1]=c,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=c>>>24^h<<8,d[e+1]=h>>>24^c<<8,l(d,t,e),p(d,t,u,f),c=d[n]^d[t],h=d[n+1]^d[t+1],d[n]=c>>>16^h<<16,d[n+1]=h>>>16^c<<16,l(d,r,n),c=d[e]^d[r],h=d[e+1]^d[r+1],d[e]=h>>>31^c<<1,d[e+1]=c>>>31^h<<1}var a=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),s=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map(function(t){return 2*t})),d=new Uint32Array(32),y=new Uint32Array(32);function n(t,e){var r,n,o=0;for(o=0;o<16;o++)d[o]=t.h[o],d[o+16]=a[o];for(d[24]=d[24]^t.t,d[25]=d[25]^t.t/4294967296,e&&(d[28]=~d[28],d[29]=~d[29]),o=0;o<32;o++)y[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<12;o++)i(0,8,16,24,s[16*o+0],s[16*o+1]),i(2,10,18,26,s[16*o+2],s[16*o+3]),i(4,12,20,28,s[16*o+4],s[16*o+5]),i(6,14,22,30,s[16*o+6],s[16*o+7]),i(0,10,20,30,s[16*o+8],s[16*o+9]),i(2,12,22,24,s[16*o+10],s[16*o+11]),i(4,14,16,26,s[16*o+12],s[16*o+13]),i(6,8,18,28,s[16*o+14],s[16*o+15]);for(o=0;o<16;o++)t.h[o]=t.h[o]^d[o]^d[o+16]}function u(t,e){if(0===t||64>2]>>8*(3&r);return e}function h(t,e,r){r=r||64,t=o.normalizeInput(t);var n=u(r,e);return f(n,t),c(n)}e.exports={blake2b:h,blake2bHex:function(t,e,r){var n=h(t,e,r);return o.toHex(n)},blake2bInit:u,blake2bUpdate:f,blake2bFinal:c}},{"./util":6}],4:[function(t,e,r){var o=t("./util");function i(t,e,r,n,o,i){f[t]=f[t]+f[e]+o,f[n]=a(f[n]^f[t],16),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],12),f[t]=f[t]+f[e]+i,f[n]=a(f[n]^f[t],8),f[r]=f[r]+f[n],f[e]=a(f[e]^f[r],7)}function a(t,e){return t>>>e^t<<32-e}var s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),f=new Uint32Array(16),c=new Uint32Array(16);function n(t,e){var r,n,o=0;for(o=0;o<8;o++)f[o]=t.h[o],f[o+8]=s[o];for(f[12]^=t.t,f[13]^=t.t/4294967296,e&&(f[14]=~f[14]),o=0;o<16;o++)c[o]=(r=t.b)[n=4*o]^r[n+1]<<8^r[n+2]<<16^r[n+3]<<24;for(o=0;o<10;o++)i(0,4,8,12,c[u[16*o+0]],c[u[16*o+1]]),i(1,5,9,13,c[u[16*o+2]],c[u[16*o+3]]),i(2,6,10,14,c[u[16*o+4]],c[u[16*o+5]]),i(3,7,11,15,c[u[16*o+6]],c[u[16*o+7]]),i(0,5,10,15,c[u[16*o+8]],c[u[16*o+9]]),i(1,6,11,12,c[u[16*o+10]],c[u[16*o+11]]),i(2,7,8,13,c[u[16*o+12]],c[u[16*o+13]]),i(3,4,9,14,c[u[16*o+14]],c[u[16*o+15]]);for(o=0;o<8;o++)t.h[o]^=f[o]^f[o+8]}function h(t,e){if(!(0>2]>>8*(3&r)&255;return e}function d(t,e,r){r=r||32,t=o.normalizeInput(t);var n=h(r,e);return l(n,t),p(n)}e.exports={blake2s:d,blake2sHex:function(t,e,r){var n=d(t,e,r);return o.toHex(n)},blake2sInit:h,blake2sUpdate:l,blake2sFinal:p}},{"./util":6}],5:[function(t,e,r){var n=t("./blake2b"),o=t("./blake2s");e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:o.blake2s,blake2sHex:o.blake2sHex,blake2sInit:o.blake2sInit,blake2sUpdate:o.blake2sUpdate,blake2sFinal:o.blake2sFinal}},{"./blake2b":3,"./blake2s":4}],6:[function(t,e,r){(function(r){function i(t){return(4294967296+t).toString(16).substring(1)}e.exports={normalizeInput:function(t){var e;if(t instanceof Uint8Array)e=t;else if(t instanceof r)e=new Uint8Array(t);else{if("string"!=typeof t)throw new Error("Input must be an string, Buffer or Uint8Array");e=new Uint8Array(r.from(t,"utf8"))}return e},toHex:function(t){return Array.prototype.map.call(t,function(t){return(t<16?"0":"")+t.toString(16)}).join("")},debugPrint:function(t,e,r){for(var n="\n"+t+" = ",o=0;o>>1;case"base64":return L(t).length;default:if(n)return I(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;i>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(t){var e=t.length;if(e<=m)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0e&&(t+=" ... ")),""},h.prototype.compare=function(t,e,r,n,o){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,a,s,u,f,c,h,l,p,d=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,M(I(t,(h=this).length-l),h,l,p);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,M(L(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,M(function(t,e){for(var r,n,o,i=[],a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-a),i,a,s);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var m=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function B(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,o){return e=+e,r>>>=0,o||B(t,0,r,8),i.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||C(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;0<=--i&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function L(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function M(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function R(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function H(t){return t!=t}},{"base64-js":2,ieee754:8}],8:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,h=r?o-1:0,l=r?-1:1,p=t[e+h];for(h+=l,i=p&(1<<-c)-1,p>>=-c,c+=s;0>=-c,c+=n;0>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+h?l/u:l*Math.pow(2,1-h))*u&&(a++,u/=2),c<=a+h?(s=0,a=c):1<=a+h?(s=(e*u-1)*Math.pow(2,o),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,o),a=0));8<=o;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(h=function(t,e){return H(t,e,a)},l=function(t,e,r,n){var o,i;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,g,v)).binLen,r=e.value,e=t>>>5,n=0;n>>5),v=t%c,w=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=E(e),t){case"HEX":r=function(t){return m(t,f,o)};break;case"B64":r=function(t){return A(t,f,o)};break;case"BYTES":r=function(t){return x(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return k(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=l(g.slice(),v,y,p(s)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function A(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function x(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function k(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function E(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function C(t,l){var e;switch(l){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,a,s,u,f,c,h=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===l)for(c=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=o[a]<<8*(c+f%4*-1),h+=1}else if("UTF16BE"===l||"UTF16LE"===l)for(c=2,o="UTF16LE"===l||"UTF16LE"!==l&&!1,i=0;i>>8),u=(f=h+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),h+=2}return{value:e,binLen:8*h+r}};break;case"B64":e=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o= 0 + case 'testnet': + return network.testnet.indexOf(at) >= 0 + case 'both': + return network.prod.indexOf(at) >= 0 || network.testnet.indexOf(at) >= 0 + default: + return false + } } function hextobin(hex) { - if (hex.length % 2 !== 0) return null; - var res = new Uint8Array(hex.length / 2); - for (var i = 0; i < hex.length / 2; ++i) { - res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); - } - return res; + if (hex.length % 2 !== 0) return null + var res = new Uint8Array(hex.length / 2) + for (var i = 0; i < hex.length / 2; ++i) { + res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16) + } + return res } module.exports = { - isValidAddress: function (address, currency, networkType) { - networkType = networkType || DEFAULT_NETWORK_TYPE; - var addressType = 'standard'; - if(!addressRegTest.test(address)){ - if(integratedAddressRegTest.test(address)){ - addressType = 'integrated'; - } - else{ - return false; - } - } - - var decodedAddrStr = cnBase58.decode(address); - if(!decodedAddrStr) - return false; - - if(!validateNetwork(decodedAddrStr, currency, networkType, addressType)) - return false; - - var addrChecksum = decodedAddrStr.slice(-8); - var hashChecksum = cryptoUtils.keccak256Checksum(hextobin(decodedAddrStr.slice(0, -8))); - - return addrChecksum === hashChecksum; + isValidAddress: function(address, currency, networkType) { + networkType = networkType || DEFAULT_NETWORK_TYPE + var addressType = 'standard' + if (!addressRegTest.test(address)) { + if (integratedAddressRegTest.test(address)) { + addressType = 'integrated' + } else { + return false + } } -}; + + var decodedAddrStr = cnBase58.decode(address) + if (!decodedAddrStr) return false + + if (!validateNetwork(decodedAddrStr, currency, networkType, addressType)) return false + + var addrChecksum = decodedAddrStr.slice(-8) + var hashChecksum = cryptoUtils.keccak256Checksum(hextobin(decodedAddrStr.slice(0, -8))) + + return addrChecksum === hashChecksum + } +} diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index f64d570e..0f89e700 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -384,7 +384,6 @@ describe('WAValidator.validate()', function() { 'monero', 'testnet' ) - //integrated addresses valid( '4Gd4DLiXzBmbVX2FZZ3Cvu6fUaWACup1qDowprUCje1kSP4FmbftiJMSfV8kWZXNqmVwj4m52xqtgFNUudVmsmGkGvkLcCibWfVUfUFVB7', @@ -396,6 +395,32 @@ describe('WAValidator.validate()', function() { ) }) + it('should return true for correct loki addresses', function() { + // public + valid( + 'L63ymg8cb5aRz1PhXrEQ22PWw9KBhBS8rMsgqbABhTGFfh53U3Rc2iWCJpCPsHZT5hfyt7fPQa612a5Z1tBnGYEA9h6YHnn', + 'loki' + ) + valid( + 'L5QKRGMNpQU3eCAdjMVTCR631bRKqnW1oEWWBEHAtFJLieA5VvuxyyubCd9FczEEatg8jfy39UJZ13npLJqZG6dtMtM99ha', + 'loki' + ) + // integrated + valid( + 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiD1xbPb6dpYo7toNRqk', + 'loki' + ) + valid( + 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiCtWq1AYo1oJTVqgUcQ', + 'loki' + ) + // subaddress + valid( + 'LW1VMYcvWPZZJ2h1pKGEku2y9WeDiAU2VhgrgVgvjybaRuCdcEkg6FhXjVNSd37Bp7fhYH8tVa5T9VmRaYiWyxYdCpEGBg8', + 'loki' + ) + }) + it('should return true for correct lbry addresses', function() { valid('bNEMVqeUZUqTrYUxud5ehnUhtTAiWDXQ5e', 'lbry') valid('bDb6NmobyDVeNGpizWQQBZkYjKCRQBdKdG', 'LBC') @@ -627,6 +652,32 @@ describe('WAValidator.validate()', function() { ) }) + it('should return false for incorrect loki addresses', function() { + commonTests('loki') + invalid( + '4AWygwA3hHNE4e4Yr9PtRWJiorXTjZkCi57g4ExYzfXDFFQ8DRFEFyui1dLqVknpqQjGUBdTMbgaFAZaDbrVHdk3GAKBZ3E', + 'loki' + ) + invalid( + '44643dtxcxjgMWEQLo6mh1c4d9Zxx9GbgK9hEj9iGSiFEryCkbwHyJ3JqxZJRqeC3Hb7ZBLKq5NkaJwR1x95EYnR1bTgN6d', + 'loki' + ) + invalid( + 'A17N9ztrxjQD3v3JJtHGvHVnq6BAbujDNEuensB6PFwBYFpkjAicih8hDtX76HBuEag5NeaCuMZmRMe6eE5NMRGxFTQn8nJ', + 'loki' + ) + + //integrated + invalid( + '4LNSCKNSTPNbJYkyAEgL966eHJHLDHiq1PpwKoiFBybcSqNGYfLBJApC62uQEeGAFxfYEd29uXBBrJFo7DhKqFVNi3GhmN79EtD5dgycYz', + 'monero' + ) + invalid( + '4JpzTwf3i1GeCV76beVr19179oa8j1L8xNSC1bXMtAxxdf4aTTLqubL8EvXfQmUGKt9MMigFtKy91VtoTTSfg1LU7LocPruT6KcGC9RKJV', + 'xmr' + ) + }) + it('should return false for incorrect siacoin addresses', function() { commonTests('siacoin') invalid( From 16f18601845a901a3350db9c19317173906f19e4 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Mon, 12 Nov 2018 10:23:34 +0200 Subject: [PATCH 072/108] v0.3.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2117ba7d..fadb1529 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "browser", "nodejs" ], - "version": "0.3.4", + "version": "0.3.5", "author": "Chris ", "homepage": "https://github.com/christsim/multicoin-address-validator", "license": "MIT", From 44d23747feaf76daa67c911e5fa4fe5107070116 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Fri, 16 Nov 2018 08:54:08 +0200 Subject: [PATCH 073/108] fixed qtum testnet --- dist/wallet-address-validator.js | 2 +- dist/wallet-address-validator.min.js | 2 +- src/currencies.js | 2 +- test/wallet_address_validator.js | 12 +++++++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 08d3ecbc..bb71d182 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -9278,7 +9278,7 @@ var CURRENCIES = [{ }, { name: 'Qtum', symbol: 'qtum', - addressTypes: { prod: ['3a', '32'], testnet: ['6f', 'c4'] }, + addressTypes: { prod: ['3a', '32'], testnet: ['78', '6e'] }, validator: BTCValidator }, { name: 'Waves', diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 6988fab1..e2611426 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(a,s,u){function f(e,t){if(!s[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=s[e]={exports:{}};a[e][0].call(o.exports,function(t){return f(a[e][1][t]||t)},o,o.exports,i,a,s,u)}return s[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,i[a++]=e>>8&255,i[a++]=255&e;var f,c;2===o&&(e=l[t.charCodeAt(u)]<<2|l[t.charCodeAt(u+1)]>>4,i[a++]=255&e);1===o&&(e=l[t.charCodeAt(u)]<<10|l[t.charCodeAt(u+1)]<<4|l[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,a=r-n;i>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return o.join("")};for(var s=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=l,r.SlowBuffer=function(t){+t!=t&&(t=0);return l.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(o>>1;case"base64":return M(t).length;default:if(o)return n?-1:I(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=l.from(e,n)),l.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;i>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=w)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},l.prototype.equals=function(t){if(!l.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===l.compare(this,t)},l.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},l.prototype.compare=function(t,e,r,n,o){if(R(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,a,s,u,f,c,l,h,p,d=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return h=e,p=r,L(I(t,(l=this).length-h),l,h,p);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(M(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,o,i=[],a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-a),i,a,s);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function S(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,o){return e=+e,r>>>=0,o||S(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,o){return e=+e,r>>>=0,o||S(t,0,r,8),i.write(t,e,r,n,52,8),r+8}l.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||B(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||B(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||B(t,1,this.length),this[t]},l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||B(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||B(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt16BE=function(t,e){t>>>=0,e||B(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!1,52,8)},l.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},l.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},l.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;0<=--i&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},l.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},l.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},l.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},l.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},l.prototype.copy=function(t,e,r,n){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function M(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function R(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:30}],4:[function(t,r,e){!function(t,E){"use strict";var B=Math.pow(2,-24),C=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,i=0;i>6):(i<55296?o.push(224|i>>12):(i=(1023&i)<<10,i|=1023&e.charCodeAt(++r),i+=65536,o.push(240|i>>18),o.push(128|i>>12&63)),o.push(128|i>>6&63)),o.push(128|63&i))}return d(3,o.length),p(o);default:var a;if(Array.isArray(e))for(d(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function k(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof p&&(p=function(t){return t}),"function"!=typeof d&&(d=function(){return E});var t=function t(){var e,r,n=_(),o=n>>5,i=31&n;if(7===o)switch(i){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,o=31744&r,i=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==i)return i*B;return e.setUint32(0,n<<16|o<<13|i<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(i))<0&&(o<2||6>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],18:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^o)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var o=(0,n(t("./define_crc")).default)("xmodem",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;o^=255&t[n],r=r<<8&65535,r^=o^=o>>>4,r^=o=o<<5&65535,r^=o=o<<7&65535}return r});r.default=o},{"./create_buffer":27,"./define_crc":28,buffer:3}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^o)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],27:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:3}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],29:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":5,"./crc16":6,"./crc16_ccitt":7,"./crc16_kermit":8,"./crc16_modbus":9,"./crc16_xmodem":10,"./crc24":11,"./crc32":12,"./crc8":13,"./crc8_1wire":14,"./crcjam":15}],30:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;0>=-c,c+=n;0>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+l?h/u:h*Math.pow(2,1-l))*u&&(a++,u/=2),c<=a+l?(s=0,a=c):1<=a+l?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));8<=o;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(l=function(t,e){return H(t,e,a)},h=function(t,e,r,n){var o,i;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=E(e),t){case"HEX":r=function(t){return w(t,f,o)};break;case"B64":r=function(t){return A(t,f,o)};break;case"BYTES":r=function(t){return x(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return k(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=h(v.slice(),g,y,p(s)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function A(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function x(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function k(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function E(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function B(t,h){var e;switch(h){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,a,s,u,f,c,l=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===h)for(c=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=o[a]<<8*(c+f%4*-1),l+=1}else if("UTF16BE"===h||"UTF16LE"===h)for(c=2,o="UTF16LE"===h||"UTF16LE"!==h&&!1,i=0;i>>8),u=(f=l+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),l+=2}return{value:e,binLen:8*l+r}};break;case"B64":e=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,i[a++]=e>>8&255,i[a++]=255&e;var f,c;2===o&&(e=l[t.charCodeAt(u)]<<2|l[t.charCodeAt(u+1)]>>4,i[a++]=255&e);1===o&&(e=l[t.charCodeAt(u)]<<10|l[t.charCodeAt(u+1)]<<4|l[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,a=r-n;i>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return o.join("")};for(var s=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=l,r.SlowBuffer=function(t){+t!=t&&(t=0);return l.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(o>>1;case"base64":return M(t).length;default:if(o)return n?-1:I(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=l.from(e,n)),l.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;i>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=w)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},l.prototype.equals=function(t){if(!l.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===l.compare(this,t)},l.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},l.prototype.compare=function(t,e,r,n,o){if(R(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,a,s,u,f,c,l,h,p,d=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return h=e,p=r,L(I(t,(l=this).length-h),l,h,p);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(M(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,o,i=[],a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-a),i,a,s);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function S(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,o){return e=+e,r>>>=0,o||S(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,o){return e=+e,r>>>=0,o||S(t,0,r,8),i.write(t,e,r,n,52,8),r+8}l.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||B(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||B(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||B(t,1,this.length),this[t]},l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||B(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||B(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt16BE=function(t,e){t>>>=0,e||B(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!1,52,8)},l.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},l.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},l.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;0<=--i&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},l.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},l.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},l.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},l.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},l.prototype.copy=function(t,e,r,n){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function M(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function R(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:30}],4:[function(t,r,e){!function(t,E){"use strict";var B=Math.pow(2,-24),C=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,i=0;i>6):(i<55296?o.push(224|i>>12):(i=(1023&i)<<10,i|=1023&e.charCodeAt(++r),i+=65536,o.push(240|i>>18),o.push(128|i>>12&63)),o.push(128|i>>6&63)),o.push(128|63&i))}return d(3,o.length),p(o);default:var a;if(Array.isArray(e))for(d(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function k(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof p&&(p=function(t){return t}),"function"!=typeof d&&(d=function(){return E});var t=function t(){var e,r,n=_(),o=n>>5,i=31&n;if(7===o)switch(i){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,o=31744&r,i=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==i)return i*B;return e.setUint32(0,n<<16|o<<13|i<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(i))<0&&(o<2||6>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],18:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^o)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var o=(0,n(t("./define_crc")).default)("xmodem",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;o^=255&t[n],r=r<<8&65535,r^=o^=o>>>4,r^=o=o<<5&65535,r^=o=o<<7&65535}return r});r.default=o},{"./create_buffer":27,"./define_crc":28,buffer:3}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^o)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],27:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:3}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],29:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":5,"./crc16":6,"./crc16_ccitt":7,"./crc16_kermit":8,"./crc16_modbus":9,"./crc16_xmodem":10,"./crc24":11,"./crc32":12,"./crc8":13,"./crc8_1wire":14,"./crcjam":15}],30:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;0>=-c,c+=n;0>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+l?h/u:h*Math.pow(2,1-l))*u&&(a++,u/=2),c<=a+l?(s=0,a=c):1<=a+l?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));8<=o;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(l=function(t,e){return H(t,e,a)},h=function(t,e,r,n){var o,i;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=E(e),t){case"HEX":r=function(t){return w(t,f,o)};break;case"B64":r=function(t){return A(t,f,o)};break;case"BYTES":r=function(t){return x(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return k(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=h(v.slice(),g,y,p(s)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function A(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function x(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function k(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function E(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function B(t,h){var e;switch(h){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,a,s,u,f,c,l=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===h)for(c=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=o[a]<<8*(c+f%4*-1),l+=1}else if("UTF16BE"===h||"UTF16LE"===h)for(c=2,o="UTF16LE"===h||"UTF16LE"!==h&&!1,i=0;i>>8),u=(f=l+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),l+=2}return{value:e,binLen:8*l+r}};break;case"B64":e=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Fri, 16 Nov 2018 08:54:19 +0200 Subject: [PATCH 074/108] updated to v0.3.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fadb1529..767758e4 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "browser", "nodejs" ], - "version": "0.3.5", + "version": "0.3.6", "author": "Chris ", "homepage": "https://github.com/christsim/multicoin-address-validator", "license": "MIT", From ccda933fc0833f6f8db4d3063c4b75de62264245 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Wed, 19 Dec 2018 11:12:18 +0200 Subject: [PATCH 075/108] adds regtest address checking for bitcoin --- package.json | 2 +- src/currencies.js | 2 +- test/wallet_address_validator.js | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 767758e4..e2b34462 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "browser", "nodejs" ], - "version": "0.3.6", + "version": "0.3.7", "author": "Chris ", "homepage": "https://github.com/christsim/multicoin-address-validator", "license": "MIT", diff --git a/src/currencies.js b/src/currencies.js index 5367b218..a62e17b6 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -10,7 +10,7 @@ var SCValidator = require('./siacoin_validator') var CURRENCIES = [{ name: 'Bitcoin', symbol: 'btc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26']}, validator: BTCValidator }, { name: 'BitcoinCash', diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index e062312f..bc2b8f50 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -41,6 +41,9 @@ describe('WAValidator.validate()', function () { valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoin'); valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoin', 'testnet'); + // regtest + valid('GSa5espVLNseXEfKt46zEdS6jrPkmFghBU', 'bitcoin', 'testnet'); + // segwit addresses valid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'bitcoin'); valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 'bitcoin'); From 12d93169965b22c1b3f9d3d5f1ad4cf70c471ac8 Mon Sep 17 00:00:00 2001 From: Stephen Ephraim Date: Wed, 13 Feb 2019 22:37:11 +0200 Subject: [PATCH 076/108] Adds extra validators (#3) * Adds Address Validation For Tron (TRX) * Adds Wallet Address Validation For XEM * Adds New Validators To Readme * Adds Wallet Address Validation For LSK * Removes lisk library * Removes unnecessary libraries * Removes crypto-js library * Clean up --- README.md | 3 + dist/wallet-address-validator.js | 2685 ++++++++++++++++++++++++-- dist/wallet-address-validator.min.js | 2 +- package.json | 5 +- src/crypto/base32.js | 66 + src/crypto/utils.js | 94 +- src/currencies.js | 16 + src/lisk_validator.js | 19 + src/nem_validator.js | 23 + src/tron_validator.js | 61 + test/wallet_address_validator.js | 42 + yarn.lock | 23 +- 12 files changed, 2846 insertions(+), 193 deletions(-) create mode 100644 src/crypto/base32.js create mode 100644 src/lisk_validator.js create mode 100644 src/nem_validator.js create mode 100644 src/tron_validator.js diff --git a/README.md b/README.md index 44378201..44d06be9 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ npm install multicoin-address-validator * Komodo/kmd `'Komodo'` or `'kmd'` * lbry/lbc `'lbry'` or `'lbc'` * LiteCoin/ltc `'LiteCoin'` or `'ltc'` +* Lisk/lsk `'Lisk'` or `'lsk'` * loki/loki `'loki'` or `'loki'` * Matchpool/gup `'Matchpool'` or `'gup'` * MegaCoin/mec `'MegaCoin'` or `'mec'` @@ -75,6 +76,7 @@ npm install multicoin-address-validator * Monero/xmr `'Monero'` or `'xmr'` * NameCoin/nmc `'NameCoin'` or `'nmc'` * Nano/nano `'Nano'` or `'nano'` +* Nem/nem `'Nem'` or `'xem'` * Neo/neo `'Neo'` or `'neo'` * NeoGas/gas `'NeoGas'` or `'gas'` * Numeraire/nmr `'Numeraire'` or `'nmr'` @@ -99,6 +101,7 @@ npm install multicoin-address-validator * Swarm City/swt `'Swarm City'` or `'swt'` * TenX/pay `'TenX'` or `'pay'` * Tether/usdt `'Tether'` or `'usdt'` +* Tron/trono `'Tron'` or `'trx'` * TrueUSD/tusd `'TrueUSD'` or `'tusd'` * VertCoin/vtc `'VertCoin'` or `'vtc'` * Viberate/vib `'Viberate'` or `'vib'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index bb71d182..36d44146 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -92,7 +92,7 @@ module.exports = function base (ALPHABET) { } } -},{"safe-buffer":122}],2:[function(require,module,exports){ +},{"safe-buffer":123}],2:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -246,6 +246,2124 @@ function fromByteArray (uint8) { } },{}],3:[function(require,module,exports){ +(function (Buffer){ +/* bignumber.js v1.3.0 https://github.com/MikeMcl/bignumber.js/LICENCE */ + +/*jslint bitwise: true, eqeq: true, plusplus: true, sub: true, white: true, maxerr: 500 */ +/*global module */ + +/* + bignumber.js v1.3.0 + A JavaScript library for arbitrary-precision arithmetic. + https://github.com/MikeMcl/bignumber.js + Copyright (c) 2012 Michael Mclaughlin + MIT Expat Licence +*/ + +/*********************************** DEFAULTS ************************************/ + +/* + * The default values below must be integers within the stated ranges (inclusive). + * Most of these values can be changed during run-time using BigNumber.config(). + */ + +/* + * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, + * MAX_EXP, and the argument to toFixed, toPrecision and toExponential, beyond + * which an exception is thrown (if ERRORS is true). + */ +var MAX = 1E9, // 0 to 1e+9 + + // Limit of magnitude of exponent argument to toPower. + MAX_POWER = 1E6, // 1 to 1e+6 + + // The maximum number of decimal places for operations involving division. + DECIMAL_PLACES = 20, // 0 to MAX + + /* + * The rounding mode used when rounding to the above decimal places, and when + * using toFixed, toPrecision and toExponential, and round (default value). + * UP 0 Away from zero. + * DOWN 1 Towards zero. + * CEIL 2 Towards +Infinity. + * FLOOR 3 Towards -Infinity. + * HALF_UP 4 Towards nearest neighbour. If equidistant, up. + * HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. + * HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. + * HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. + * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. + */ + ROUNDING_MODE = 4, // 0 to 8 + + // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS] + + // The exponent value at and beneath which toString returns exponential notation. + // Number type: -7 + TO_EXP_NEG = -7, // 0 to -MAX + + // The exponent value at and above which toString returns exponential notation. + // Number type: 21 + TO_EXP_POS = 21, // 0 to MAX + + // RANGE : [MIN_EXP, MAX_EXP] + + // The minimum exponent value, beneath which underflow to zero occurs. + // Number type: -324 (5e-324) + MIN_EXP = -MAX, // -1 to -MAX + + // The maximum exponent value, above which overflow to Infinity occurs. + // Number type: 308 (1.7976931348623157e+308) + MAX_EXP = MAX, // 1 to MAX + + // Whether BigNumber Errors are ever thrown. + // CHANGE parseInt to parseFloat if changing ERRORS to false. + ERRORS = true, // true or false + parse = parseInt, // parseInt or parseFloat + +/***********************************************************************************/ + + P = BigNumber.prototype, + DIGITS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_', + outOfRange, + id = 0, + isValid = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, + trim = String.prototype.trim || function () {return this.replace(/^\s+|\s+$/g, '')}, + ONE = BigNumber(1); + + +// CONSTRUCTOR + + +/* + * The exported function. + * Create and return a new instance of a BigNumber object. + * + * n {number|string|BigNumber} A numeric value. + * [b] {number} The base of n. Integer, 2 to 64 inclusive. + */ +function BigNumber( n, b ) { + var e, i, isNum, digits, valid, orig, + x = this; + + // Enable constructor usage without new. + if ( !(x instanceof BigNumber) ) { + return new BigNumber( n, b ) + } + + // Duplicate. + if ( n instanceof BigNumber ) { + id = 0; + + // e is undefined. + if ( b !== e ) { + n += '' + } else { + x['s'] = n['s']; + x['e'] = n['e']; + x['c'] = ( n = n['c'] ) ? n.slice() : n; + return; + } + } + + // If number, check if minus zero. + if ( typeof n != 'string' ) { + n = ( isNum = typeof n == 'number' || + Object.prototype.toString.call(n) == '[object Number]' ) && + n === 0 && 1 / n < 0 ? '-0' : n + ''; + } + + orig = n; + + if ( b === e && isValid.test(n) ) { + + // Determine sign. + x['s'] = n.charAt(0) == '-' ? ( n = n.slice(1), -1 ) : 1; + + // Either n is not a valid BigNumber or a base has been specified. + } else { + + // Enable exponential notation to be used with base 10 argument. + // Ensure return value is rounded to DECIMAL_PLACES as with other bases. + if ( b == 10 ) { + + return setMode( n, DECIMAL_PLACES, ROUNDING_MODE ); + } + + n = trim.call(n).replace( /^\+(?!-)/, '' ); + + x['s'] = n.charAt(0) == '-' ? ( n = n.replace( /^-(?!-)/, '' ), -1 ) : 1; + + if ( b != null ) { + + if ( ( b == (b | 0) || !ERRORS ) && + !( outOfRange = !( b >= 2 && b < 65 ) ) ) { + + digits = '[' + DIGITS.slice( 0, b = b | 0 ) + ']+'; + + // Before non-decimal number validity test and base conversion + // remove the `.` from e.g. '1.', and replace e.g. '.1' with '0.1'. + n = n.replace( /\.$/, '' ).replace( /^\./, '0.' ); + + // Any number in exponential form will fail due to the e+/-. + if ( valid = new RegExp( + '^' + digits + '(?:\\.' + digits + ')?$', b < 37 ? 'i' : '' ).test(n) ) { + + if ( isNum ) { + + if ( n.replace( /^0\.0*|\./, '' ).length > 15 ) { + + // 'new BigNumber() number type has more than 15 significant digits: {n}' + ifExceptionsThrow( orig, 0 ); + } + + // Prevent later check for length on converted number. + isNum = !isNum; + } + n = convert( n, 10, b, x['s'] ); + + } else if ( n != 'Infinity' && n != 'NaN' ) { + + // 'new BigNumber() not a base {b} number: {n}' + ifExceptionsThrow( orig, 1, b ); + n = 'NaN'; + } + } else { + + // 'new BigNumber() base not an integer: {b}' + // 'new BigNumber() base out of range: {b}' + ifExceptionsThrow( b, 2 ); + + // Ignore base. + valid = isValid.test(n); + } + } else { + valid = isValid.test(n); + } + + if ( !valid ) { + + // Infinity/NaN + x['c'] = x['e'] = null; + + // NaN + if ( n != 'Infinity' ) { + + // No exception on NaN. + if ( n != 'NaN' ) { + + // 'new BigNumber() not a number: {n}' + ifExceptionsThrow( orig, 3 ); + } + x['s'] = null; + } + id = 0; + + return; + } + } + + // Decimal point? + if ( ( e = n.indexOf('.') ) > -1 ) { + n = n.replace( '.', '' ); + } + + // Exponential form? + if ( ( i = n.search( /e/i ) ) > 0 ) { + + // Determine exponent. + if ( e < 0 ) { + e = i; + } + e += +n.slice( i + 1 ); + n = n.substring( 0, i ); + + } else if ( e < 0 ) { + + // Integer. + e = n.length; + } + + // Determine leading zeros. + for ( i = 0; n.charAt(i) == '0'; i++ ) { + } + + b = n.length; + + // Disallow numbers with over 15 significant digits if number type. + if ( isNum && b > 15 && n.slice(i).length > 15 ) { + + // 'new BigNumber() number type has more than 15 significant digits: {n}' + ifExceptionsThrow( orig, 0 ); + } + id = 0; + + // Overflow? + if ( ( e -= i + 1 ) > MAX_EXP ) { + + // Infinity. + x['c'] = x['e'] = null; + + // Zero or underflow? + } else if ( i == b || e < MIN_EXP ) { + + // Zero. + x['c'] = [ x['e'] = 0 ]; + } else { + + // Determine trailing zeros. + for ( ; n.charAt(--b) == '0'; ) { + } + + x['e'] = e; + x['c'] = []; + + // Convert string to array of digits (without leading and trailing zeros). + for ( e = 0; i <= b; x['c'][e++] = +n.charAt(i++) ) { + } + } +} + + +// CONSTRUCTOR PROPERTIES/METHODS + + +BigNumber['ROUND_UP'] = 0; +BigNumber['ROUND_DOWN'] = 1; +BigNumber['ROUND_CEIL'] = 2; +BigNumber['ROUND_FLOOR'] = 3; +BigNumber['ROUND_HALF_UP'] = 4; +BigNumber['ROUND_HALF_DOWN'] = 5; +BigNumber['ROUND_HALF_EVEN'] = 6; +BigNumber['ROUND_HALF_CEIL'] = 7; +BigNumber['ROUND_HALF_FLOOR'] = 8; + +/* + * Create an instance from a Buffer + */ +BigNumber['fromBuffer'] = function (buf, opts) { + + if (!opts) opts = {}; + + var endian = { 1 : 'big', '-1' : 'little' }[opts.endian] + || opts.endian || 'big' + ; + + var size = opts.size === 'auto' ? Math.ceil(buf.length) : (opts.size || 1); + + if (buf.length % size !== 0) { + throw new RangeError('Buffer length (' + buf.length + ')' + + ' must be a multiple of size (' + size + ')' + ); + } + + var hex = []; + for (var i = 0; i < buf.length; i += size) { + var chunk = []; + for (var j = 0; j < size; j++) { + chunk.push(buf[ + i + (endian === 'big' ? j : (size - j - 1)) + ]); + } + + hex.push(chunk + .map(function (c) { + return (c < 16 ? '0' : '') + c.toString(16); + }) + .join('') + ); + } + + return BigNumber(hex.join(''), 16); + +}; + +/* + * Configure infrequently-changing library-wide settings. + * + * Accept an object or an argument list, with one or many of the following + * properties or parameters respectively: + * [ DECIMAL_PLACES [, ROUNDING_MODE [, EXPONENTIAL_AT [, RANGE [, ERRORS ]]]]] + * + * E.g. + * BigNumber.config(20, 4) is equivalent to + * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 }) + * Ignore properties/parameters set to null or undefined. + * + * Return an object with the properties current values. + */ +BigNumber['config'] = function () { + var v, p, + i = 0, + r = {}, + a = arguments, + o = a[0], + c = 'config', + inRange = function ( n, lo, hi ) { + return !( ( outOfRange = n < lo || n > hi ) || + parse(n) != n && n !== 0 ); + }, + has = o && typeof o == 'object' + ? function () {if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null} + : function () {if ( a.length > i ) return ( v = a[i++] ) != null}; + + // [DECIMAL_PLACES] {number} Integer, 0 to MAX inclusive. + if ( has( p = 'DECIMAL_PLACES' ) ) { + + if ( inRange( v, 0, MAX ) ) { + DECIMAL_PLACES = v | 0; + } else { + + // 'config() DECIMAL_PLACES not an integer: {v}' + // 'config() DECIMAL_PLACES out of range: {v}' + ifExceptionsThrow( v, p, c ); + } + } + r[p] = DECIMAL_PLACES; + + // [ROUNDING_MODE] {number} Integer, 0 to 8 inclusive. + if ( has( p = 'ROUNDING_MODE' ) ) { + + if ( inRange( v, 0, 8 ) ) { + ROUNDING_MODE = v | 0; + } else { + + // 'config() ROUNDING_MODE not an integer: {v}' + // 'config() ROUNDING_MODE out of range: {v}' + ifExceptionsThrow( v, p, c ); + } + } + r[p] = ROUNDING_MODE; + + /* + * [EXPONENTIAL_AT] {number|number[]} Integer, -MAX to MAX inclusive or + * [ integer -MAX to 0 inclusive, 0 to MAX inclusive ]. + */ + if ( has( p = 'EXPONENTIAL_AT' ) ) { + + if ( inRange( v, -MAX, MAX ) ) { + TO_EXP_NEG = -( TO_EXP_POS = ~~( v < 0 ? -v : +v ) ); + } else if ( !outOfRange && v && inRange( v[0], -MAX, 0 ) && + inRange( v[1], 0, MAX ) ) { + TO_EXP_NEG = ~~v[0]; + TO_EXP_POS = ~~v[1]; + } else { + + // 'config() EXPONENTIAL_AT not an integer or not [integer, integer]: {v}' + // 'config() EXPONENTIAL_AT out of range or not [negative, positive: {v}' + ifExceptionsThrow( v, p, c, 1 ); + } + } + r[p] = [ TO_EXP_NEG, TO_EXP_POS ]; + + /* + * [RANGE][ {number|number[]} Non-zero integer, -MAX to MAX inclusive or + * [ integer -MAX to -1 inclusive, integer 1 to MAX inclusive ]. + */ + if ( has( p = 'RANGE' ) ) { + + if ( inRange( v, -MAX, MAX ) && ~~v ) { + MIN_EXP = -( MAX_EXP = ~~( v < 0 ? -v : +v ) ); + } else if ( !outOfRange && v && inRange( v[0], -MAX, -1 ) && + inRange( v[1], 1, MAX ) ) { + MIN_EXP = ~~v[0], MAX_EXP = ~~v[1]; + } else { + + // 'config() RANGE not a non-zero integer or not [integer, integer]: {v}' + // 'config() RANGE out of range or not [negative, positive: {v}' + ifExceptionsThrow( v, p, c, 1, 1 ); + } + } + r[p] = [ MIN_EXP, MAX_EXP ]; + + // [ERRORS] {boolean|number} true, false, 1 or 0. + if ( has( p = 'ERRORS' ) ) { + + if ( v === !!v || v === 1 || v === 0 ) { + parse = ( outOfRange = id = 0, ERRORS = !!v ) + ? parseInt + : parseFloat; + } else { + + // 'config() ERRORS not a boolean or binary digit: {v}' + ifExceptionsThrow( v, p, c, 0, 0, 1 ); + } + } + r[p] = ERRORS; + + return r; +}; + + +// PRIVATE FUNCTIONS + + +// Assemble error messages. Throw BigNumber Errors. +function ifExceptionsThrow( arg, i, j, isArray, isRange, isErrors) { + + if ( ERRORS ) { + var error, + method = ['new BigNumber', 'cmp', 'div', 'eq', 'gt', 'gte', 'lt', + 'lte', 'minus', 'mod', 'plus', 'times', 'toFr' + ][ id ? id < 0 ? -id : id : 1 / id < 0 ? 1 : 0 ] + '()', + message = outOfRange ? ' out of range' : ' not a' + + ( isRange ? ' non-zero' : 'n' ) + ' integer'; + + message = ( [ + method + ' number type has more than 15 significant digits', + method + ' not a base ' + j + ' number', + method + ' base' + message, + method + ' not a number' ][i] || + j + '() ' + i + ( isErrors + ? ' not a boolean or binary digit' + : message + ( isArray + ? ' or not [' + ( outOfRange + ? ' negative, positive' + : ' integer, integer' ) + ' ]' + : '' ) ) ) + ': ' + arg; + + outOfRange = id = 0; + error = new Error(message); + error['name'] = 'BigNumber Error'; + + throw error; + } +} + + +/* + * Convert a numeric string of baseIn to a numeric string of baseOut. + */ +function convert( nStr, baseOut, baseIn, sign ) { + var e, dvs, dvd, nArr, fracArr, fracBN; + + // Convert string of base bIn to an array of numbers of baseOut. + // Eg. strToArr('255', 10) where baseOut is 16, returns [15, 15]. + // Eg. strToArr('ff', 16) where baseOut is 10, returns [2, 5, 5]. + function strToArr( str, bIn ) { + var j, + i = 0, + strL = str.length, + arrL, + arr = [0]; + + for ( bIn = bIn || baseIn; i < strL; i++ ) { + + for ( arrL = arr.length, j = 0; j < arrL; arr[j] *= bIn, j++ ) { + } + + for ( arr[0] += DIGITS.indexOf( str.charAt(i) ), j = 0; + j < arr.length; + j++ ) { + + if ( arr[j] > baseOut - 1 ) { + + if ( arr[j + 1] == null ) { + arr[j + 1] = 0; + } + arr[j + 1] += arr[j] / baseOut ^ 0; + arr[j] %= baseOut; + } + } + } + + return arr.reverse(); + } + + // Convert array to string. + // E.g. arrToStr( [9, 10, 11] ) becomes '9ab' (in bases above 11). + function arrToStr( arr ) { + var i = 0, + arrL = arr.length, + str = ''; + + for ( ; i < arrL; str += DIGITS.charAt( arr[i++] ) ) { + } + + return str; + } + + if ( baseIn < 37 ) { + nStr = nStr.toLowerCase(); + } + + /* + * If non-integer convert integer part and fraction part separately. + * Convert the fraction part as if it is an integer than use division to + * reduce it down again to a value less than one. + */ + if ( ( e = nStr.indexOf( '.' ) ) > -1 ) { + + /* + * Calculate the power to which to raise the base to get the number + * to divide the fraction part by after it has been converted as an + * integer to the required base. + */ + e = nStr.length - e - 1; + + // Use toFixed to avoid possible exponential notation. + dvs = strToArr( new BigNumber(baseIn)['pow'](e)['toF'](), 10 ); + + nArr = nStr.split('.'); + + // Convert the base of the fraction part (as integer). + dvd = strToArr( nArr[1] ); + + // Convert the base of the integer part. + nArr = strToArr( nArr[0] ); + + // Result will be a BigNumber with a value less than 1. + fracBN = divide( dvd, dvs, dvd.length - dvs.length, sign, baseOut, + // Is least significant digit of integer part an odd number? + nArr[nArr.length - 1] & 1 ); + + fracArr = fracBN['c']; + + // e can be <= 0 ( if e == 0, fracArr is [0] or [1] ). + if ( e = fracBN['e'] ) { + + // Append zeros according to the exponent of the result. + for ( ; ++e; fracArr.unshift(0) ) { + } + + // Append the fraction part to the converted integer part. + nStr = arrToStr(nArr) + '.' + arrToStr(fracArr); + + // fracArr is [1]. + // Fraction digits rounded up, so increment last digit of integer part. + } else if ( fracArr[0] ) { + + if ( nArr[ e = nArr.length - 1 ] < baseOut - 1 ) { + ++nArr[e]; + nStr = arrToStr(nArr); + } else { + nStr = new BigNumber( arrToStr(nArr), + baseOut )['plus'](ONE)['toS'](baseOut); + } + + // fracArr is [0]. No fraction digits. + } else { + nStr = arrToStr(nArr); + } + } else { + + // Simple integer. Convert base. + nStr = arrToStr( strToArr(nStr) ); + } + + return nStr; +} + + +// Perform division in the specified base. Called by div and convert. +function divide( dvd, dvs, exp, s, base, isOdd ) { + var dvsL, dvsT, next, cmp, remI, + dvsZ = dvs.slice(), + dvdI = dvsL = dvs.length, + dvdL = dvd.length, + rem = dvd.slice( 0, dvsL ), + remL = rem.length, + quo = new BigNumber(ONE), + qc = quo['c'] = [], + qi = 0, + dig = DECIMAL_PLACES + ( quo['e'] = exp ) + 1; + + quo['s'] = s; + s = dig < 0 ? 0 : dig; + + // Add zeros to make remainder as long as divisor. + for ( ; remL++ < dvsL; rem.push(0) ) { + } + + // Create version of divisor with leading zero. + dvsZ.unshift(0); + + do { + + // 'next' is how many times the divisor goes into the current remainder. + for ( next = 0; next < base; next++ ) { + + // Compare divisor and remainder. + if ( dvsL != ( remL = rem.length ) ) { + cmp = dvsL > remL ? 1 : -1; + } else { + for ( remI = -1, cmp = 0; ++remI < dvsL; ) { + + if ( dvs[remI] != rem[remI] ) { + cmp = dvs[remI] > rem[remI] ? 1 : -1; + break; + } + } + } + + // Subtract divisor from remainder (if divisor < remainder). + if ( cmp < 0 ) { + + // Remainder cannot be more than one digit longer than divisor. + // Equalise lengths using divisor with extra leading zero? + for ( dvsT = remL == dvsL ? dvs : dvsZ; remL; ) { + + if ( rem[--remL] < dvsT[remL] ) { + + for ( remI = remL; + remI && !rem[--remI]; + rem[remI] = base - 1 ) { + } + --rem[remI]; + rem[remL] += base; + } + rem[remL] -= dvsT[remL]; + } + for ( ; !rem[0]; rem.shift() ) { + } + } else { + break; + } + } + + // Add the 'next' digit to the result array. + qc[qi++] = cmp ? next : ++next; + + // Update the remainder. + rem[0] && cmp + ? ( rem[remL] = dvd[dvdI] || 0 ) + : ( rem = [ dvd[dvdI] ] ); + + } while ( ( dvdI++ < dvdL || rem[0] != null ) && s-- ); + + // Leading zero? Do not remove if result is simply zero (qi == 1). + if ( !qc[0] && qi != 1 ) { + + // There can't be more than one zero. + --quo['e']; + qc.shift(); + } + + // Round? + if ( qi > dig ) { + rnd( quo, DECIMAL_PLACES, base, isOdd, rem[0] != null ); + } + + // Overflow? + if ( quo['e'] > MAX_EXP ) { + + // Infinity. + quo['c'] = quo['e'] = null; + + // Underflow? + } else if ( quo['e'] < MIN_EXP ) { + + // Zero. + quo['c'] = [quo['e'] = 0]; + } + + return quo; +} + + +/* + * Return a string representing the value of BigNumber n in normal or + * exponential notation rounded to the specified decimal places or + * significant digits. + * Called by toString, toExponential (exp 1), toFixed, and toPrecision (exp 2). + * d is the index (with the value in normal notation) of the digit that may be + * rounded up. + */ +function format( n, d, exp ) { + + // Initially, i is the number of decimal places required. + var i = d - (n = new BigNumber(n))['e'], + c = n['c']; + + // +-Infinity or NaN? + if ( !c ) { + return n['toS'](); + } + + // Round? + if ( c.length > ++d ) { + rnd( n, i, 10 ); + } + + // Recalculate d if toFixed as n['e'] may have changed if value rounded up. + i = c[0] == 0 ? i + 1 : exp ? d : n['e'] + i + 1; + + // Append zeros? + for ( ; c.length < i; c.push(0) ) { + } + i = n['e']; + + /* + * toPrecision returns exponential notation if the number of significant + * digits specified is less than the number of digits necessary to + * represent the integer part of the value in normal notation. + */ + return exp == 1 || exp == 2 && ( --d < i || i <= TO_EXP_NEG ) + + // Exponential notation. + ? ( n['s'] < 0 && c[0] ? '-' : '' ) + ( c.length > 1 + ? ( c.splice( 1, 0, '.' ), c.join('') ) + : c[0] ) + ( i < 0 ? 'e' : 'e+' ) + i + + // Normal notation. + : n['toS'](); +} + + +// Round if necessary. +// Called by divide, format, setMode and sqrt. +function rnd( x, dp, base, isOdd, r ) { + var xc = x['c'], + isNeg = x['s'] < 0, + half = base / 2, + i = x['e'] + dp + 1, + + // 'next' is the digit after the digit that may be rounded up. + next = xc[i], + + /* + * 'more' is whether there are digits after 'next'. + * E.g. + * 0.005 (e = -3) to be rounded to 0 decimal places (dp = 0) gives i = -2 + * The 'next' digit is zero, and there ARE 'more' digits after it. + * 0.5 (e = -1) dp = 0 gives i = 0 + * The 'next' digit is 5 and there are no 'more' digits after it. + */ + more = r || i < 0 || xc[i + 1] != null; + + r = ROUNDING_MODE < 4 + ? ( next != null || more ) && + ( ROUNDING_MODE == 0 || + ROUNDING_MODE == 2 && !isNeg || + ROUNDING_MODE == 3 && isNeg ) + : next > half || next == half && + ( ROUNDING_MODE == 4 || more || + + /* + * isOdd is used in base conversion and refers to the least significant + * digit of the integer part of the value to be converted. The fraction + * part is rounded by this method separately from the integer part. + */ + ROUNDING_MODE == 6 && ( xc[i - 1] & 1 || !dp && isOdd ) || + ROUNDING_MODE == 7 && !isNeg || + ROUNDING_MODE == 8 && isNeg ); + + if ( i < 1 || !xc[0] ) { + xc.length = 0; + xc.push(0); + + if ( r ) { + + // 1, 0.1, 0.01, 0.001, 0.0001 etc. + xc[0] = 1; + x['e'] = -dp; + } else { + + // Zero. + x['e'] = 0; + } + + return x; + } + + // Remove any digits after the required decimal places. + xc.length = i--; + + // Round up? + if ( r ) { + + // Rounding up may mean the previous digit has to be rounded up and so on. + for ( --base; ++xc[i] > base; ) { + xc[i] = 0; + + if ( !i-- ) { + ++x['e']; + xc.unshift(1); + } + } + } + + // Remove trailing zeros. + for ( i = xc.length; !xc[--i]; xc.pop() ) { + } + + return x; +} + + +// Round after setting the appropriate rounding mode. +// Handles ceil, floor and round. +function setMode( x, dp, rm ) { + var r = ROUNDING_MODE; + + ROUNDING_MODE = rm; + x = new BigNumber(x); + x['c'] && rnd( x, dp, 10 ); + ROUNDING_MODE = r; + + return x; +} + + +// PROTOTYPE/INSTANCE METHODS + + +/* + * Return a new BigNumber whose value is the absolute value of this BigNumber. + */ +P['abs'] = P['absoluteValue'] = function () { + var x = new BigNumber(this); + + if ( x['s'] < 0 ) { + x['s'] = 1; + } + + return x; +}; + +/* + * Return the bit length of the number. + */ +P['bitLength'] = function () { + return this.toString(2).length; +}; + + +/* + * Return a new BigNumber whose value is the value of this BigNumber + * rounded to a whole number in the direction of Infinity. + */ +P['ceil'] = function () { + return setMode( this, 0, 2 ); +}; + + +/* + * Return + * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b), + * -1 if the value of this BigNumber is less than the value of BigNumber(y, b), + * 0 if they have the same value, + * or null if the value of either is NaN. + */ +P['comparedTo'] = P['cmp'] = function ( y, b ) { + var a, + x = this, + xc = x['c'], + yc = ( id = -id, y = new BigNumber( y, b ) )['c'], + i = x['s'], + j = y['s'], + k = x['e'], + l = y['e']; + + // Either NaN? + if ( !i || !j ) { + return null; + } + + a = xc && !xc[0], b = yc && !yc[0]; + + // Either zero? + if ( a || b ) { + return a ? b ? 0 : -j : i; + } + + // Signs differ? + if ( i != j ) { + return i; + } + + // Either Infinity? + if ( a = i < 0, b = k == l, !xc || !yc ) { + return b ? 0 : !xc ^ a ? 1 : -1; + } + + // Compare exponents. + if ( !b ) { + return k > l ^ a ? 1 : -1; + } + + // Compare digit by digit. + for ( i = -1, + j = ( k = xc.length ) < ( l = yc.length ) ? k : l; + ++i < j; ) { + + if ( xc[i] != yc[i] ) { + return xc[i] > yc[i] ^ a ? 1 : -1; + } + } + // Compare lengths. + return k == l ? 0 : k > l ^ a ? 1 : -1; +}; + + +/* + * n / 0 = I + * n / N = N + * n / I = 0 + * 0 / n = 0 + * 0 / 0 = N + * 0 / N = N + * 0 / I = 0 + * N / n = N + * N / 0 = N + * N / N = N + * N / I = N + * I / n = I + * I / 0 = I + * I / N = N + * I / I = N + * + * Return a new BigNumber whose value is the value of this BigNumber + * divided by the value of BigNumber(y, b), rounded according to + * DECIMAL_PLACES and ROUNDING_MODE. + */ +P['dividedBy'] = P['div'] = function ( y, b ) { + var xc = this['c'], + xe = this['e'], + xs = this['s'], + yc = ( id = 2, y = new BigNumber( y, b ) )['c'], + ye = y['e'], + ys = y['s'], + s = xs == ys ? 1 : -1; + + // Either NaN/Infinity/0? + return !xe && ( !xc || !xc[0] ) || !ye && ( !yc || !yc[0] ) + + // Either NaN? + ? new BigNumber( !xs || !ys || + + // Both 0 or both Infinity? + ( xc ? yc && xc[0] == yc[0] : !yc ) + + // Return NaN. + ? NaN + + // x is 0 or y is Infinity? + : xc && xc[0] == 0 || !yc + + // Return +-0. + ? s * 0 + + // y is 0. Return +-Infinity. + : s / 0 ) + + : divide( xc, yc, xe - ye, s, 10 ); +}; + + +/* + * Return true if the value of this BigNumber is equal to the value of + * BigNumber(n, b), otherwise returns false. + */ +P['equals'] = P['eq'] = function ( n, b ) { + id = 3; + return this['cmp']( n, b ) === 0; +}; + + +/* + * Return a new BigNumber whose value is the value of this BigNumber + * rounded to a whole number in the direction of -Infinity. + */ +P['floor'] = function () { + return setMode( this, 0, 3 ); +}; + + +/* + * Return true if the value of this BigNumber is greater than the value of + * BigNumber(n, b), otherwise returns false. + */ +P['greaterThan'] = P['gt'] = function ( n, b ) { + id = 4; + return this['cmp']( n, b ) > 0; +}; + + +/* + * Return true if the value of this BigNumber is greater than or equal to + * the value of BigNumber(n, b), otherwise returns false. + */ +P['greaterThanOrEqualTo'] = P['gte'] = P['gt'] = function ( n, b ) { + id = 5; + return ( b = this['cmp']( n, b ) ) == 1 || b === 0; +}; + + +/* + * Return true if the value of this BigNumber is a finite number, otherwise + * returns false. + */ +P['isFinite'] = P['isF'] = function () { + return !!this['c']; +}; + + +/* + * Return true if the value of this BigNumber is NaN, otherwise returns + * false. + */ +P['isNaN'] = function () { + return !this['s']; +}; + + +/* + * Return true if the value of this BigNumber is negative, otherwise + * returns false. + */ +P['isNegative'] = P['isNeg'] = function () { + return this['s'] < 0; +}; + + +/* + * Return true if the value of this BigNumber is 0 or -0, otherwise returns + * false. + */ +P['isZero'] = P['isZ'] = function () { + return !!this['c'] && this['c'][0] == 0; +}; + + +/* + * Return true if the value of this BigNumber is less than the value of + * BigNumber(n, b), otherwise returns false. + */ +P['lessThan'] = P['lt'] = function ( n, b ) { + id = 6; + return this['cmp']( n, b ) < 0; +}; + + +/* + * Return true if the value of this BigNumber is less than or equal to the + * value of BigNumber(n, b), otherwise returns false. + */ +P['lessThanOrEqualTo'] = P['lte'] = P['le'] = function ( n, b ) { + id = 7; + return ( b = this['cmp']( n, b ) ) == -1 || b === 0; +}; + + +/* + * n - 0 = n + * n - N = N + * n - I = -I + * 0 - n = -n + * 0 - 0 = 0 + * 0 - N = N + * 0 - I = -I + * N - n = N + * N - 0 = N + * N - N = N + * N - I = N + * I - n = I + * I - 0 = I + * I - N = N + * I - I = N + * + * Return a new BigNumber whose value is the value of this BigNumber minus + * the value of BigNumber(y, b). + */ +P['minus'] = P['sub'] = function ( y, b ) { + var d, i, j, xLTy, + x = this, + a = x['s']; + + b = ( id = 8, y = new BigNumber( y, b ) )['s']; + + // Either NaN? + if ( !a || !b ) { + return new BigNumber(NaN); + } + + // Signs differ? + if ( a != b ) { + return y['s'] = -b, x['plus'](y); + } + + var xc = x['c'], + xe = x['e'], + yc = y['c'], + ye = y['e']; + + if ( !xe || !ye ) { + + // Either Infinity? + if ( !xc || !yc ) { + return xc ? ( y['s'] = -b, y ) : new BigNumber( yc ? x : NaN ); + } + + // Either zero? + if ( !xc[0] || !yc[0] ) { + + // y is non-zero? + return yc[0] + ? ( y['s'] = -b, y ) + + // x is non-zero? + : new BigNumber( xc[0] + ? x + + // Both are zero. + // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity + : ROUNDING_MODE == 3 ? -0 : 0 ); + } + } + + // Determine which is the bigger number. + // Prepend zeros to equalise exponents. + if ( xc = xc.slice(), a = xe - ye ) { + d = ( xLTy = a < 0 ) ? ( a = -a, xc ) : ( ye = xe, yc ); + + for ( d.reverse(), b = a; b--; d.push(0) ) { + } + d.reverse(); + } else { + + // Exponents equal. Check digit by digit. + j = ( ( xLTy = xc.length < yc.length ) ? xc : yc ).length; + + for ( a = b = 0; b < j; b++ ) { + + if ( xc[b] != yc[b] ) { + xLTy = xc[b] < yc[b]; + break; + } + } + } + + // x < y? Point xc to the array of the bigger number. + if ( xLTy ) { + d = xc, xc = yc, yc = d; + y['s'] = -y['s']; + } + + /* + * Append zeros to xc if shorter. No need to add zeros to yc if shorter + * as subtraction only needs to start at yc.length. + */ + if ( ( b = -( ( j = xc.length ) - yc.length ) ) > 0 ) { + + for ( ; b--; xc[j++] = 0 ) { + } + } + + // Subtract yc from xc. + for ( b = yc.length; b > a; ){ + + if ( xc[--b] < yc[b] ) { + + for ( i = b; i && !xc[--i]; xc[i] = 9 ) { + } + --xc[i]; + xc[b] += 10; + } + xc[b] -= yc[b]; + } + + // Remove trailing zeros. + for ( ; xc[--j] == 0; xc.pop() ) { + } + + // Remove leading zeros and adjust exponent accordingly. + for ( ; xc[0] == 0; xc.shift(), --ye ) { + } + + /* + * No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity + * when neither x or y are Infinity. + */ + + // Underflow? + if ( ye < MIN_EXP || !xc[0] ) { + + /* + * Following IEEE 754 (2008) 6.3, + * n - n = +0 but n - n = -0 when rounding towards -Infinity. + */ + if ( !xc[0] ) { + y['s'] = ROUNDING_MODE == 3 ? -1 : 1; + } + + // Result is zero. + xc = [ye = 0]; + } + + return y['c'] = xc, y['e'] = ye, y; +}; + + +/* + * n % 0 = N + * n % N = N + * 0 % n = 0 + * -0 % n = -0 + * 0 % 0 = N + * 0 % N = N + * N % n = N + * N % 0 = N + * N % N = N + * + * Return a new BigNumber whose value is the value of this BigNumber modulo + * the value of BigNumber(y, b). + */ +P['modulo'] = P['mod'] = function ( y, b ) { + var x = this, + xc = x['c'], + yc = ( id = 9, y = new BigNumber( y, b ) )['c'], + i = x['s'], + j = y['s']; + + // Is x or y NaN, or y zero? + b = !i || !j || yc && !yc[0]; + + if ( b || xc && !xc[0] ) { + return new BigNumber( b ? NaN : x ); + } + + x['s'] = y['s'] = 1; + b = y['cmp'](x) == 1; + x['s'] = i, y['s'] = j; + + return b + ? new BigNumber(x) + : ( i = DECIMAL_PLACES, j = ROUNDING_MODE, + DECIMAL_PLACES = 0, ROUNDING_MODE = 1, + x = x['div'](y), + DECIMAL_PLACES = i, ROUNDING_MODE = j, + this['minus']( x['times'](y) ) ); +}; + + +/* + * Return a new BigNumber whose value is the value of this BigNumber + * negated, i.e. multiplied by -1. + */ +P['negated'] = P['neg'] = function () { + var x = new BigNumber(this); + + return x['s'] = -x['s'] || null, x; +}; + + +/* + * n + 0 = n + * n + N = N + * n + I = I + * 0 + n = n + * 0 + 0 = 0 + * 0 + N = N + * 0 + I = I + * N + n = N + * N + 0 = N + * N + N = N + * N + I = N + * I + n = I + * I + 0 = I + * I + N = N + * I + I = I + * + * Return a new BigNumber whose value is the value of this BigNumber plus + * the value of BigNumber(y, b). + */ +P['plus'] = P['add'] = function ( y, b ) { + var d, + x = this, + a = x['s']; + + b = ( id = 10, y = new BigNumber( y, b ) )['s']; + + // Either NaN? + if ( !a || !b ) { + return new BigNumber(NaN); + } + + // Signs differ? + if ( a != b ) { + return y['s'] = -b, x['minus'](y); + } + + var xe = x['e'], + xc = x['c'], + ye = y['e'], + yc = y['c']; + + if ( !xe || !ye ) { + + // Either Infinity? + if ( !xc || !yc ) { + + // Return +-Infinity. + return new BigNumber( a / 0 ); + } + + // Either zero? + if ( !xc[0] || !yc[0] ) { + + // y is non-zero? + return yc[0] + ? y + + // x is non-zero? + : new BigNumber( xc[0] + ? x + + // Both are zero. Return zero. + : a * 0 ); + } + } + + // Prepend zeros to equalise exponents. + // Note: Faster to use reverse then do unshifts. + if ( xc = xc.slice(), a = xe - ye ) { + d = a > 0 ? ( ye = xe, yc ) : ( a = -a, xc ); + + for ( d.reverse(); a--; d.push(0) ) { + } + d.reverse(); + } + + // Point xc to the longer array. + if ( xc.length - yc.length < 0 ) { + d = yc, yc = xc, xc = d; + } + + /* + * Only start adding at yc.length - 1 as the + * further digits of xc can be left as they are. + */ + for ( a = yc.length, b = 0; a; + b = ( xc[--a] = xc[a] + yc[a] + b ) / 10 ^ 0, xc[a] %= 10 ) { + } + + // No need to check for zero, as +x + +y != 0 && -x + -y != 0 + + if ( b ) { + xc.unshift(b); + + // Overflow? (MAX_EXP + 1 possible) + if ( ++ye > MAX_EXP ) { + + // Infinity. + xc = ye = null; + } + } + + // Remove trailing zeros. + for ( a = xc.length; xc[--a] == 0; xc.pop() ) { + } + + return y['c'] = xc, y['e'] = ye, y; +}; + + +/* + * Return a BigNumber whose value is the value of this BigNumber raised to + * the power e. If e is negative round according to DECIMAL_PLACES and + * ROUNDING_MODE. + * + * e {number} Integer, -MAX_POWER to MAX_POWER inclusive. + */ +P['toPower'] = P['pow'] = function ( e ) { + + // e to integer, avoiding NaN or Infinity becoming 0. + var i = e * 0 == 0 ? e | 0 : e, + x = new BigNumber(this), + y = new BigNumber(ONE); + + // Use Math.pow? + // Pass +-Infinity for out of range exponents. + if ( ( ( ( outOfRange = e < -MAX_POWER || e > MAX_POWER ) && + (i = e * 1 / 0) ) || + + /* + * Any exponent that fails the parse becomes NaN. + * + * Include 'e !== 0' because on Opera -0 == parseFloat(-0) is false, + * despite -0 === parseFloat(-0) && -0 == parseFloat('-0') is true. + */ + parse(e) != e && e !== 0 && !(i = NaN) ) && + + // 'pow() exponent not an integer: {e}' + // 'pow() exponent out of range: {e}' + !ifExceptionsThrow( e, 'exponent', 'pow' ) || + + // Pass zero to Math.pow, as any value to the power zero is 1. + !i ) { + + // i is +-Infinity, NaN or 0. + return new BigNumber( Math.pow( x['toS'](), i ) ); + } + + for ( i = i < 0 ? -i : i; ; ) { + + if ( i & 1 ) { + y = y['times'](x); + } + i >>= 1; + + if ( !i ) { + break; + } + x = x['times'](x); + } + + return e < 0 ? ONE['div'](y) : y; +}; + + +/* + * Return a BigNumber whose value is the value of this BigNumber raised to + * the power m modulo n. + * + * m {BigNumber} the value to take the power of + * n {BigNumber} the value to modulo by + */ +P['powm'] = function ( m, n ) { + return this.pow(m).mod(n); +}; + + +/* + * Return a new BigNumber whose value is the value of this BigNumber + * rounded to a maximum of dp decimal places using rounding mode rm, or to + * 0 and ROUNDING_MODE respectively if omitted. + * + * [dp] {number} Integer, 0 to MAX inclusive. + * [rm] {number} Integer, 0 to 8 inclusive. + */ +P['round'] = function ( dp, rm ) { + + dp = dp == null || ( ( ( outOfRange = dp < 0 || dp > MAX ) || + parse(dp) != dp ) && + + // 'round() decimal places out of range: {dp}' + // 'round() decimal places not an integer: {dp}' + !ifExceptionsThrow( dp, 'decimal places', 'round' ) ) + ? 0 + : dp | 0; + + rm = rm == null || ( ( ( outOfRange = rm < 0 || rm > 8 ) || + + // Include '&& rm !== 0' because with Opera -0 == parseFloat(-0) is false. + parse(rm) != rm && rm !== 0 ) && + + // 'round() mode not an integer: {rm}' + // 'round() mode out of range: {rm}' + !ifExceptionsThrow( rm, 'mode', 'round' ) ) + ? ROUNDING_MODE + : rm | 0; + + return setMode( this, dp, rm ); +}; + + +/* + * sqrt(-n) = N + * sqrt( N) = N + * sqrt(-I) = N + * sqrt( I) = I + * sqrt( 0) = 0 + * sqrt(-0) = -0 + * + * Return a new BigNumber whose value is the square root of the value of + * this BigNumber, rounded according to DECIMAL_PLACES and ROUNDING_MODE. + */ +P['squareRoot'] = P['sqrt'] = function () { + var n, r, re, t, + x = this, + c = x['c'], + s = x['s'], + e = x['e'], + dp = DECIMAL_PLACES, + rm = ROUNDING_MODE, + half = new BigNumber('0.5'); + + // Negative/NaN/Infinity/zero? + if ( s !== 1 || !c || !c[0] ) { + + return new BigNumber( !s || s < 0 && ( !c || c[0] ) + ? NaN + : c ? x : 1 / 0 ); + } + + // Initial estimate. + s = Math.sqrt( x['toS']() ); + ROUNDING_MODE = 1; + + /* + Math.sqrt underflow/overflow? + Pass x to Math.sqrt as integer, then adjust the exponent of the result. + */ + if ( s == 0 || s == 1 / 0 ) { + n = c.join(''); + + if ( !( n.length + e & 1 ) ) { + n += '0'; + } + r = new BigNumber( Math.sqrt(n) + '' ); + + // r may still not be finite. + if ( !r['c'] ) { + r['c'] = [1]; + } + r['e'] = ( ( ( e + 1 ) / 2 ) | 0 ) - ( e < 0 || e & 1 ); + } else { + r = new BigNumber( n = s.toString() ); + } + re = r['e']; + s = re + ( DECIMAL_PLACES += 4 ); + + if ( s < 3 ) { + s = 0; + } + e = s; + + // Newton-Raphson iteration. + for ( ; ; ) { + t = r; + r = half['times']( t['plus']( x['div'](t) ) ); + + if ( t['c'].slice( 0, s ).join('') === r['c'].slice( 0, s ).join('') ) { + c = r['c']; + + /* + The exponent of r may here be one less than the final result + exponent (re), e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust + s so the rounding digits are indexed correctly. + */ + s = s - ( n && r['e'] < re ); + + /* + The 4th rounding digit may be in error by -1 so if the 4 rounding + digits are 9999 or 4999 (i.e. approaching a rounding boundary) + continue the iteration. + */ + if ( c[s] == 9 && c[s - 1] == 9 && c[s - 2] == 9 && + ( c[s - 3] == 9 || n && c[s - 3] == 4 ) ) { + + /* + If 9999 on first run through, check to see if rounding up + gives the exact result as the nines may infinitely repeat. + */ + if ( n && c[s - 3] == 9 ) { + t = r['round']( dp, 0 ); + + if ( t['times'](t)['eq'](x) ) { + ROUNDING_MODE = rm; + DECIMAL_PLACES = dp; + + return t; + } + } + DECIMAL_PLACES += 4; + s += 4; + n = ''; + } else { + + /* + If the rounding digits are null, 0000 or 5000, check for an + exact result. If not, then there are further digits so + increment the 1st rounding digit to ensure correct rounding. + */ + if ( !c[e] && !c[e - 1] && !c[e - 2] && + ( !c[e - 3] || c[e - 3] == 5 ) ) { + + // Truncate to the first rounding digit. + if ( c.length > e - 2 ) { + c.length = e - 2; + } + + if ( !r['times'](r)['eq'](x) ) { + + while ( c.length < e - 3 ) { + c.push(0); + } + c[e - 3]++; + } + } + ROUNDING_MODE = rm; + rnd( r, DECIMAL_PLACES = dp, 10 ); + + return r; + } + } + } +}; + + +/* + * n * 0 = 0 + * n * N = N + * n * I = I + * 0 * n = 0 + * 0 * 0 = 0 + * 0 * N = N + * 0 * I = N + * N * n = N + * N * 0 = N + * N * N = N + * N * I = N + * I * n = I + * I * 0 = N + * I * N = N + * I * I = I + * + * Return a new BigNumber whose value is the value of this BigNumber times + * the value of BigNumber(y, b). + */ +P['times'] = P['mul'] = function ( y, b ) { + var c, + x = this, + xc = x['c'], + yc = ( id = 11, y = new BigNumber( y, b ) )['c'], + i = x['e'], + j = y['e'], + a = x['s']; + + y['s'] = a == ( b = y['s'] ) ? 1 : -1; + + // Either NaN/Infinity/0? + if ( !i && ( !xc || !xc[0] ) || !j && ( !yc || !yc[0] ) ) { + + // Either NaN? + return new BigNumber( !a || !b || + + // x is 0 and y is Infinity or y is 0 and x is Infinity? + xc && !xc[0] && !yc || yc && !yc[0] && !xc + + // Return NaN. + ? NaN + + // Either Infinity? + : !xc || !yc + + // Return +-Infinity. + ? y['s'] / 0 + + // x or y is 0. Return +-0. + : y['s'] * 0 ); + } + y['e'] = i + j; + + if ( ( a = xc.length ) < ( b = yc.length ) ) { + c = xc, xc = yc, yc = c, j = a, a = b, b = j; + } + + for ( j = a + b, c = []; j--; c.push(0) ) { + } + + // Multiply! + for ( i = b - 1; i > -1; i-- ) { + + for ( b = 0, j = a + i; + j > i; + b = c[j] + yc[i] * xc[j - i - 1] + b, + c[j--] = b % 10 | 0, + b = b / 10 | 0 ) { + } + + if ( b ) { + c[j] = ( c[j] + b ) % 10; + } + } + + b && ++y['e']; + + // Remove any leading zero. + !c[0] && c.shift(); + + // Remove trailing zeros. + for ( j = c.length; !c[--j]; c.pop() ) { + } + + // No zero check needed as only x * 0 == 0 etc. + + // Overflow? + y['c'] = y['e'] > MAX_EXP + + // Infinity. + ? ( y['e'] = null ) + + // Underflow? + : y['e'] < MIN_EXP + + // Zero. + ? [ y['e'] = 0 ] + + // Neither. + : c; + + return y; +}; + +/* + * Return a buffer containing the + */ +P['toBuffer'] = function ( opts ) { + + if (typeof opts === 'string') { + if (opts !== 'mpint') return 'Unsupported Buffer representation'; + + var abs = this.abs(); + var buf = abs.toBuffer({ size : 1, endian : 'big' }); + var len = buf.length === 1 && buf[0] === 0 ? 0 : buf.length; + if (buf[0] & 0x80) len ++; + + var ret = new Buffer(4 + len); + if (len > 0) buf.copy(ret, 4 + (buf[0] & 0x80 ? 1 : 0)); + if (buf[0] & 0x80) ret[4] = 0; + + ret[0] = len & (0xff << 24); + ret[1] = len & (0xff << 16); + ret[2] = len & (0xff << 8); + ret[3] = len & (0xff << 0); + + // two's compliment for negative integers: + var isNeg = this.lt(0); + if (isNeg) { + for (var i = 4; i < ret.length; i++) { + ret[i] = 0xff - ret[i]; + } + } + ret[4] = (ret[4] & 0x7f) | (isNeg ? 0x80 : 0); + if (isNeg) ret[ret.length - 1] ++; + + return ret; + } + + if (!opts) opts = {}; + + var endian = { 1 : 'big', '-1' : 'little' }[opts.endian] + || opts.endian || 'big' + ; + + var hex = this.toString(16); + if (hex.charAt(0) === '-') throw new Error( + 'converting negative numbers to Buffers not supported yet' + ); + + var size = opts.size === 'auto' ? Math.ceil(hex.length / 2) : (opts.size || 1); + + var len = Math.ceil(hex.length / (2 * size)) * size; + var buf = new Buffer(len); + + // zero-pad the hex string so the chunks are all `size` long + while (hex.length < 2 * len) hex = '0' + hex; + + var hx = hex + .split(new RegExp('(.{' + (2 * size) + '})')) + .filter(function (s) { return s.length > 0 }) + ; + + hx.forEach(function (chunk, i) { + for (var j = 0; j < size; j++) { + var ix = i * size + (endian === 'big' ? j : size - j - 1); + buf[ix] = parseInt(chunk.slice(j*2,j*2+2), 16); + } + }); + + return buf; +}; + +/* + * Return a string representing the value of this BigNumber in exponential + * notation to dp fixed decimal places and rounded using ROUNDING_MODE if + * necessary. + * + * [dp] {number} Integer, 0 to MAX inclusive. + */ +P['toExponential'] = P['toE'] = function ( dp ) { + + return format( this, + ( dp == null || ( ( outOfRange = dp < 0 || dp > MAX ) || + + /* + * Include '&& dp !== 0' because with Opera -0 == parseFloat(-0) is + * false, despite -0 == parseFloat('-0') && 0 == -0 being true. + */ + parse(dp) != dp && dp !== 0 ) && + + // 'toE() decimal places not an integer: {dp}' + // 'toE() decimal places out of range: {dp}' + !ifExceptionsThrow( dp, 'decimal places', 'toE' ) ) && this['c'] + ? this['c'].length - 1 + : dp | 0, 1 ); +}; + + +/* + * Return a string representing the value of this BigNumber in normal + * notation to dp fixed decimal places and rounded using ROUNDING_MODE if + * necessary. + * + * Note: as with JavaScript's number type, (-0).toFixed(0) is '0', + * but e.g. (-0.00001).toFixed(0) is '-0'. + * + * [dp] {number} Integer, 0 to MAX inclusive. + */ +P['toFixed'] = P['toF'] = function ( dp ) { + var n, str, d, + x = this; + + if ( !( dp == null || ( ( outOfRange = dp < 0 || dp > MAX ) || + parse(dp) != dp && dp !== 0 ) && + + // 'toF() decimal places not an integer: {dp}' + // 'toF() decimal places out of range: {dp}' + !ifExceptionsThrow( dp, 'decimal places', 'toF' ) ) ) { + d = x['e'] + ( dp | 0 ); + } + + n = TO_EXP_NEG, dp = TO_EXP_POS; + TO_EXP_NEG = -( TO_EXP_POS = 1 / 0 ); + + // Note: str is initially undefined. + if ( d == str ) { + str = x['toS'](); + } else { + str = format( x, d ); + + // (-0).toFixed() is '0', but (-0.1).toFixed() is '-0'. + // (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'. + if ( x['s'] < 0 && x['c'] ) { + + // As e.g. -0 toFixed(3), will wrongly be returned as -0.000 from toString. + if ( !x['c'][0] ) { + str = str.replace(/^-/, ''); + + // As e.g. -0.5 if rounded to -0 will cause toString to omit the minus sign. + } else if ( str.indexOf('-') < 0 ) { + str = '-' + str; + } + } + } + TO_EXP_NEG = n, TO_EXP_POS = dp; + + return str; +}; + + +/* + * Return a string array representing the value of this BigNumber as a + * simple fraction with an integer numerator and an integer denominator. + * The denominator will be a positive non-zero value less than or equal to + * the specified maximum denominator. If a maximum denominator is not + * specified, the denominator will be the lowest value necessary to + * represent the number exactly. + * + * [maxD] {number|string|BigNumber} Integer >= 1 and < Infinity. + */ +P['toFraction'] = P['toFr'] = function ( maxD ) { + var q, frac, n0, d0, d2, n, e, + n1 = d0 = new BigNumber(ONE), + d1 = n0 = new BigNumber('0'), + x = this, + xc = x['c'], + exp = MAX_EXP, + dp = DECIMAL_PLACES, + rm = ROUNDING_MODE, + d = new BigNumber(ONE); + + // NaN, Infinity. + if ( !xc ) { + return x['toS'](); + } + + e = d['e'] = xc.length - x['e'] - 1; + + // If max denominator is undefined or null... + if ( maxD == null || + + // or NaN... + ( !( id = 12, n = new BigNumber(maxD) )['s'] || + + // or less than 1, or Infinity... + ( outOfRange = n['cmp'](n1) < 0 || !n['c'] ) || + + // or not an integer... + ( ERRORS && n['e'] < n['c'].length - 1 ) ) && + + // 'toFr() max denominator not an integer: {maxD}' + // 'toFr() max denominator out of range: {maxD}' + !ifExceptionsThrow( maxD, 'max denominator', 'toFr' ) || + + // or greater than the maxD needed to specify the value exactly... + ( maxD = n )['cmp'](d) > 0 ) { + + // d is e.g. 10, 100, 1000, 10000... , n1 is 1. + maxD = e > 0 ? d : n1; + } + + MAX_EXP = 1 / 0; + n = new BigNumber( xc.join('') ); + + for ( DECIMAL_PLACES = 0, ROUNDING_MODE = 1; ; ) { + q = n['div'](d); + d2 = d0['plus']( q['times'](d1) ); + + if ( d2['cmp'](maxD) == 1 ) { + break; + } + + d0 = d1, d1 = d2; + + n1 = n0['plus']( q['times']( d2 = n1 ) ); + n0 = d2; + + d = n['minus']( q['times']( d2 = d ) ); + n = d2; + } + + d2 = maxD['minus'](d0)['div'](d1); + n0 = n0['plus']( d2['times'](n1) ); + d0 = d0['plus']( d2['times'](d1) ); + + n0['s'] = n1['s'] = x['s']; + + DECIMAL_PLACES = e * 2; + ROUNDING_MODE = rm; + + // Determine which fraction is closer to x, n0 / d0 or n1 / d1? + frac = n1['div'](d1)['minus'](x)['abs']()['cmp']( + n0['div'](d0)['minus'](x)['abs']() ) < 1 + ? [ n1['toS'](), d1['toS']() ] + : [ n0['toS'](), d0['toS']() ]; + + return MAX_EXP = exp, DECIMAL_PLACES = dp, frac; +}; + + +/* + * Return a string representing the value of this BigNumber to sd significant + * digits and rounded using ROUNDING_MODE if necessary. + * If sd is less than the number of digits necessary to represent the integer + * part of the value in normal notation, then use exponential notation. + * + * sd {number} Integer, 1 to MAX inclusive. + */ +P['toPrecision'] = P['toP'] = function ( sd ) { + + /* + * ERRORS true: Throw if sd not undefined, null or an integer in range. + * ERRORS false: Ignore sd if not a number or not in range. + * Truncate non-integers. + */ + return sd == null || ( ( ( outOfRange = sd < 1 || sd > MAX ) || + parse(sd) != sd ) && + + // 'toP() precision not an integer: {sd}' + // 'toP() precision out of range: {sd}' + !ifExceptionsThrow( sd, 'precision', 'toP' ) ) + ? this['toS']() + : format( this, --sd | 0, 2 ); +}; + + +/* + * Return a string representing the value of this BigNumber in base b, or + * base 10 if b is omitted. If a base is specified, including base 10, + * round according to DECIMAL_PLACES and ROUNDING_MODE. + * If a base is not specified, and this BigNumber has a positive exponent + * that is equal to or greater than TO_EXP_POS, or a negative exponent equal + * to or less than TO_EXP_NEG, return exponential notation. + * + * [b] {number} Integer, 2 to 64 inclusive. + */ +P['toString'] = P['toS'] = function ( b ) { + var u, str, strL, + x = this, + xe = x['e']; + + // Infinity or NaN? + if ( xe === null ) { + str = x['s'] ? 'Infinity' : 'NaN'; + + // Exponential format? + } else if ( b === u && ( xe <= TO_EXP_NEG || xe >= TO_EXP_POS ) ) { + return format( x, x['c'].length - 1, 1 ); + } else { + str = x['c'].join(''); + + // Negative exponent? + if ( xe < 0 ) { + + // Prepend zeros. + for ( ; ++xe; str = '0' + str ) { + } + str = '0.' + str; + + // Positive exponent? + } else if ( strL = str.length, xe > 0 ) { + + if ( ++xe > strL ) { + + // Append zeros. + for ( xe -= strL; xe-- ; str += '0' ) { + } + } else if ( xe < strL ) { + str = str.slice( 0, xe ) + '.' + str.slice(xe); + } + + // Exponent zero. + } else { + if ( u = str.charAt(0), strL > 1 ) { + str = u + '.' + str.slice(1); + + // Avoid '-0' + } else if ( u == '0' ) { + return u; + } + } + + if ( b != null ) { + + if ( !( outOfRange = !( b >= 2 && b < 65 ) ) && + ( b == (b | 0) || !ERRORS ) ) { + str = convert( str, b | 0, 10, x['s'] ); + + // Avoid '-0' + if ( str == '0' ) { + return str; + } + } else { + + // 'toS() base not an integer: {b}' + // 'toS() base out of range: {b}' + ifExceptionsThrow( b, 'base', 'toS' ); + } + } + + } + + return x['s'] < 0 ? '-' + str : str; +}; + + +/* + * Return as toString, but do not accept a base argument. + */ +P['valueOf'] = function () { + return this['toS'](); +}; + + +// Add aliases for BigDecimal methods. +//P['add'] = P['plus']; +//P['subtract'] = P['minus']; +//P['multiply'] = P['times']; +//P['divide'] = P['div']; +//P['remainder'] = P['mod']; +//P['compareTo'] = P['cmp']; +//P['negate'] = P['neg']; + + +// EXPORT +module.exports = BigNumber; + +}).call(this,require("buffer").Buffer) +},{"buffer":4}],4:[function(require,module,exports){ /*! * The buffer module from node.js, for the browser. * @@ -2024,7 +4142,7 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -},{"base64-js":2,"ieee754":30}],4:[function(require,module,exports){ +},{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ /* * The MIT License (MIT) * @@ -2432,62 +4550,62 @@ else if (!global.CBOR) })(this); -},{}],5:[function(require,module,exports){ +},{}],6:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc1').default; -},{"./es6/crc1":16}],6:[function(require,module,exports){ +},{"./es6/crc1":17}],7:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16').default; -},{"./es6/crc16":17}],7:[function(require,module,exports){ +},{"./es6/crc16":18}],8:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16ccitt').default; -},{"./es6/crc16ccitt":18}],8:[function(require,module,exports){ +},{"./es6/crc16ccitt":19}],9:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16kermit').default; -},{"./es6/crc16kermit":19}],9:[function(require,module,exports){ +},{"./es6/crc16kermit":20}],10:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16modbus').default; -},{"./es6/crc16modbus":20}],10:[function(require,module,exports){ +},{"./es6/crc16modbus":21}],11:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc16xmodem').default; -},{"./es6/crc16xmodem":21}],11:[function(require,module,exports){ +},{"./es6/crc16xmodem":22}],12:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc24').default; -},{"./es6/crc24":22}],12:[function(require,module,exports){ +},{"./es6/crc24":23}],13:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc32').default; -},{"./es6/crc32":23}],13:[function(require,module,exports){ +},{"./es6/crc32":24}],14:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc8').default; -},{"./es6/crc8":24}],14:[function(require,module,exports){ +},{"./es6/crc8":25}],15:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crc81wire').default; -},{"./es6/crc81wire":25}],15:[function(require,module,exports){ +},{"./es6/crc81wire":26}],16:[function(require,module,exports){ 'use strict'; module.exports = require('./es6/crcjam').default; -},{"./es6/crcjam":26}],16:[function(require,module,exports){ +},{"./es6/crcjam":27}],17:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2523,7 +4641,7 @@ var crc1 = (0, _define_crc2.default)('crc1', function (buf, previous) { exports.default = crc1; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],17:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],18:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2563,7 +4681,7 @@ var crc16 = (0, _define_crc2.default)('crc-16', function (buf, previous) { exports.default = crc16; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],18:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],19:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2603,7 +4721,7 @@ var crc16ccitt = (0, _define_crc2.default)('ccitt', function (buf, previous) { exports.default = crc16ccitt; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],19:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],20:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2643,7 +4761,7 @@ var crc16kermit = (0, _define_crc2.default)('kermit', function (buf, previous) { exports.default = crc16kermit; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],20:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],21:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2683,7 +4801,7 @@ var crc16modbus = (0, _define_crc2.default)('crc-16-modbus', function (buf, prev exports.default = crc16modbus; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],21:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],22:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2726,7 +4844,7 @@ var crc16xmodem = (0, _define_crc2.default)('xmodem', function (buf, previous) { exports.default = crc16xmodem; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],22:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],23:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2766,7 +4884,7 @@ var crc24 = (0, _define_crc2.default)('crc-24', function (buf, previous) { exports.default = crc24; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],23:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],24:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2806,7 +4924,7 @@ var crc32 = (0, _define_crc2.default)('crc-32', function (buf, previous) { exports.default = crc32; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],24:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],25:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2846,7 +4964,7 @@ var crc8 = (0, _define_crc2.default)('crc-8', function (buf, previous) { exports.default = crc8; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],25:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],26:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2886,7 +5004,7 @@ var crc81wire = (0, _define_crc2.default)('dallas-1-wire', function (buf, previo exports.default = crc81wire; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],26:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],27:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2928,7 +5046,7 @@ var crcjam = (0, _define_crc2.default)('jam', function (buf) { exports.default = crcjam; -},{"./create_buffer":27,"./define_crc":28,"buffer":3}],27:[function(require,module,exports){ +},{"./create_buffer":28,"./define_crc":29,"buffer":4}],28:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { @@ -2944,7 +5062,7 @@ function (val) { exports.default = createBuffer; -},{"buffer":3}],28:[function(require,module,exports){ +},{"buffer":4}],29:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -2962,7 +5080,7 @@ exports.default = function (model, calc) { return fn; }; -},{}],29:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ 'use strict'; module.exports = { @@ -2979,7 +5097,7 @@ module.exports = { crcjam: require('./crcjam') }; -},{"./crc1":5,"./crc16":6,"./crc16_ccitt":7,"./crc16_kermit":8,"./crc16_modbus":9,"./crc16_xmodem":10,"./crc24":11,"./crc32":12,"./crc8":13,"./crc8_1wire":14,"./crcjam":15}],30:[function(require,module,exports){ +},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -3065,7 +5183,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],31:[function(require,module,exports){ +},{}],32:[function(require,module,exports){ /* A JavaScript implementation of the SHA family of hashes, as defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding @@ -3096,7 +5214,7 @@ new m,new m,new m,new m,new m,new m];break;case "SHA-512":a=[new m,new m,new m,n 2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474, 2756734187,3204031479,3329325298];"function"===typeof define&&define.amd?define(function(){return w}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(module.exports=w),exports=w):I.jsSHA=w})(this); -},{}],32:[function(require,module,exports){ +},{}],33:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -3105,7 +5223,7 @@ var DataView = getNative(root, 'DataView'); module.exports = DataView; -},{"./_getNative":67,"./_root":97}],33:[function(require,module,exports){ +},{"./_getNative":68,"./_root":98}],34:[function(require,module,exports){ var hashClear = require('./_hashClear'), hashDelete = require('./_hashDelete'), hashGet = require('./_hashGet'), @@ -3139,7 +5257,7 @@ Hash.prototype.set = hashSet; module.exports = Hash; -},{"./_hashClear":72,"./_hashDelete":73,"./_hashGet":74,"./_hashHas":75,"./_hashSet":76}],34:[function(require,module,exports){ +},{"./_hashClear":73,"./_hashDelete":74,"./_hashGet":75,"./_hashHas":76,"./_hashSet":77}],35:[function(require,module,exports){ var listCacheClear = require('./_listCacheClear'), listCacheDelete = require('./_listCacheDelete'), listCacheGet = require('./_listCacheGet'), @@ -3173,7 +5291,7 @@ ListCache.prototype.set = listCacheSet; module.exports = ListCache; -},{"./_listCacheClear":81,"./_listCacheDelete":82,"./_listCacheGet":83,"./_listCacheHas":84,"./_listCacheSet":85}],35:[function(require,module,exports){ +},{"./_listCacheClear":82,"./_listCacheDelete":83,"./_listCacheGet":84,"./_listCacheHas":85,"./_listCacheSet":86}],36:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -3182,7 +5300,7 @@ var Map = getNative(root, 'Map'); module.exports = Map; -},{"./_getNative":67,"./_root":97}],36:[function(require,module,exports){ +},{"./_getNative":68,"./_root":98}],37:[function(require,module,exports){ var mapCacheClear = require('./_mapCacheClear'), mapCacheDelete = require('./_mapCacheDelete'), mapCacheGet = require('./_mapCacheGet'), @@ -3216,7 +5334,7 @@ MapCache.prototype.set = mapCacheSet; module.exports = MapCache; -},{"./_mapCacheClear":86,"./_mapCacheDelete":87,"./_mapCacheGet":88,"./_mapCacheHas":89,"./_mapCacheSet":90}],37:[function(require,module,exports){ +},{"./_mapCacheClear":87,"./_mapCacheDelete":88,"./_mapCacheGet":89,"./_mapCacheHas":90,"./_mapCacheSet":91}],38:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -3225,7 +5343,7 @@ var Promise = getNative(root, 'Promise'); module.exports = Promise; -},{"./_getNative":67,"./_root":97}],38:[function(require,module,exports){ +},{"./_getNative":68,"./_root":98}],39:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -3234,7 +5352,7 @@ var Set = getNative(root, 'Set'); module.exports = Set; -},{"./_getNative":67,"./_root":97}],39:[function(require,module,exports){ +},{"./_getNative":68,"./_root":98}],40:[function(require,module,exports){ var MapCache = require('./_MapCache'), setCacheAdd = require('./_setCacheAdd'), setCacheHas = require('./_setCacheHas'); @@ -3263,7 +5381,7 @@ SetCache.prototype.has = setCacheHas; module.exports = SetCache; -},{"./_MapCache":36,"./_setCacheAdd":98,"./_setCacheHas":99}],40:[function(require,module,exports){ +},{"./_MapCache":37,"./_setCacheAdd":99,"./_setCacheHas":100}],41:[function(require,module,exports){ var ListCache = require('./_ListCache'), stackClear = require('./_stackClear'), stackDelete = require('./_stackDelete'), @@ -3292,7 +5410,7 @@ Stack.prototype.set = stackSet; module.exports = Stack; -},{"./_ListCache":34,"./_stackClear":101,"./_stackDelete":102,"./_stackGet":103,"./_stackHas":104,"./_stackSet":105}],41:[function(require,module,exports){ +},{"./_ListCache":35,"./_stackClear":102,"./_stackDelete":103,"./_stackGet":104,"./_stackHas":105,"./_stackSet":106}],42:[function(require,module,exports){ var root = require('./_root'); /** Built-in value references. */ @@ -3300,7 +5418,7 @@ var Symbol = root.Symbol; module.exports = Symbol; -},{"./_root":97}],42:[function(require,module,exports){ +},{"./_root":98}],43:[function(require,module,exports){ var root = require('./_root'); /** Built-in value references. */ @@ -3308,7 +5426,7 @@ var Uint8Array = root.Uint8Array; module.exports = Uint8Array; -},{"./_root":97}],43:[function(require,module,exports){ +},{"./_root":98}],44:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -3317,7 +5435,7 @@ var WeakMap = getNative(root, 'WeakMap'); module.exports = WeakMap; -},{"./_getNative":67,"./_root":97}],44:[function(require,module,exports){ +},{"./_getNative":68,"./_root":98}],45:[function(require,module,exports){ /** * A specialized version of `_.filter` for arrays without support for * iteratee shorthands. @@ -3344,7 +5462,7 @@ function arrayFilter(array, predicate) { module.exports = arrayFilter; -},{}],45:[function(require,module,exports){ +},{}],46:[function(require,module,exports){ var baseTimes = require('./_baseTimes'), isArguments = require('./isArguments'), isArray = require('./isArray'), @@ -3395,7 +5513,7 @@ function arrayLikeKeys(value, inherited) { module.exports = arrayLikeKeys; -},{"./_baseTimes":57,"./_isIndex":77,"./isArguments":108,"./isArray":109,"./isBuffer":111,"./isTypedArray":117}],46:[function(require,module,exports){ +},{"./_baseTimes":58,"./_isIndex":78,"./isArguments":109,"./isArray":110,"./isBuffer":112,"./isTypedArray":118}],47:[function(require,module,exports){ /** * Appends the elements of `values` to `array`. * @@ -3417,7 +5535,7 @@ function arrayPush(array, values) { module.exports = arrayPush; -},{}],47:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ /** * A specialized version of `_.some` for arrays without support for iteratee * shorthands. @@ -3442,7 +5560,7 @@ function arraySome(array, predicate) { module.exports = arraySome; -},{}],48:[function(require,module,exports){ +},{}],49:[function(require,module,exports){ var eq = require('./eq'); /** @@ -3465,7 +5583,7 @@ function assocIndexOf(array, key) { module.exports = assocIndexOf; -},{"./eq":107}],49:[function(require,module,exports){ +},{"./eq":108}],50:[function(require,module,exports){ var arrayPush = require('./_arrayPush'), isArray = require('./isArray'); @@ -3487,7 +5605,7 @@ function baseGetAllKeys(object, keysFunc, symbolsFunc) { module.exports = baseGetAllKeys; -},{"./_arrayPush":46,"./isArray":109}],50:[function(require,module,exports){ +},{"./_arrayPush":47,"./isArray":110}],51:[function(require,module,exports){ var Symbol = require('./_Symbol'), getRawTag = require('./_getRawTag'), objectToString = require('./_objectToString'); @@ -3517,7 +5635,7 @@ function baseGetTag(value) { module.exports = baseGetTag; -},{"./_Symbol":41,"./_getRawTag":68,"./_objectToString":95}],51:[function(require,module,exports){ +},{"./_Symbol":42,"./_getRawTag":69,"./_objectToString":96}],52:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObjectLike = require('./isObjectLike'); @@ -3537,7 +5655,7 @@ function baseIsArguments(value) { module.exports = baseIsArguments; -},{"./_baseGetTag":50,"./isObjectLike":116}],52:[function(require,module,exports){ +},{"./_baseGetTag":51,"./isObjectLike":117}],53:[function(require,module,exports){ var baseIsEqualDeep = require('./_baseIsEqualDeep'), isObjectLike = require('./isObjectLike'); @@ -3567,7 +5685,7 @@ function baseIsEqual(value, other, bitmask, customizer, stack) { module.exports = baseIsEqual; -},{"./_baseIsEqualDeep":53,"./isObjectLike":116}],53:[function(require,module,exports){ +},{"./_baseIsEqualDeep":54,"./isObjectLike":117}],54:[function(require,module,exports){ var Stack = require('./_Stack'), equalArrays = require('./_equalArrays'), equalByTag = require('./_equalByTag'), @@ -3652,7 +5770,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { module.exports = baseIsEqualDeep; -},{"./_Stack":40,"./_equalArrays":61,"./_equalByTag":62,"./_equalObjects":63,"./_getTag":70,"./isArray":109,"./isBuffer":111,"./isTypedArray":117}],54:[function(require,module,exports){ +},{"./_Stack":41,"./_equalArrays":62,"./_equalByTag":63,"./_equalObjects":64,"./_getTag":71,"./isArray":110,"./isBuffer":112,"./isTypedArray":118}],55:[function(require,module,exports){ var isFunction = require('./isFunction'), isMasked = require('./_isMasked'), isObject = require('./isObject'), @@ -3701,7 +5819,7 @@ function baseIsNative(value) { module.exports = baseIsNative; -},{"./_isMasked":79,"./_toSource":106,"./isFunction":113,"./isObject":115}],55:[function(require,module,exports){ +},{"./_isMasked":80,"./_toSource":107,"./isFunction":114,"./isObject":116}],56:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isLength = require('./isLength'), isObjectLike = require('./isObjectLike'); @@ -3763,7 +5881,7 @@ function baseIsTypedArray(value) { module.exports = baseIsTypedArray; -},{"./_baseGetTag":50,"./isLength":114,"./isObjectLike":116}],56:[function(require,module,exports){ +},{"./_baseGetTag":51,"./isLength":115,"./isObjectLike":117}],57:[function(require,module,exports){ var isPrototype = require('./_isPrototype'), nativeKeys = require('./_nativeKeys'); @@ -3795,7 +5913,7 @@ function baseKeys(object) { module.exports = baseKeys; -},{"./_isPrototype":80,"./_nativeKeys":93}],57:[function(require,module,exports){ +},{"./_isPrototype":81,"./_nativeKeys":94}],58:[function(require,module,exports){ /** * The base implementation of `_.times` without support for iteratee shorthands * or max array length checks. @@ -3817,7 +5935,7 @@ function baseTimes(n, iteratee) { module.exports = baseTimes; -},{}],58:[function(require,module,exports){ +},{}],59:[function(require,module,exports){ /** * The base implementation of `_.unary` without support for storing metadata. * @@ -3833,7 +5951,7 @@ function baseUnary(func) { module.exports = baseUnary; -},{}],59:[function(require,module,exports){ +},{}],60:[function(require,module,exports){ /** * Checks if a `cache` value for `key` exists. * @@ -3848,7 +5966,7 @@ function cacheHas(cache, key) { module.exports = cacheHas; -},{}],60:[function(require,module,exports){ +},{}],61:[function(require,module,exports){ var root = require('./_root'); /** Used to detect overreaching core-js shims. */ @@ -3856,7 +5974,7 @@ var coreJsData = root['__core-js_shared__']; module.exports = coreJsData; -},{"./_root":97}],61:[function(require,module,exports){ +},{"./_root":98}],62:[function(require,module,exports){ var SetCache = require('./_SetCache'), arraySome = require('./_arraySome'), cacheHas = require('./_cacheHas'); @@ -3941,7 +6059,7 @@ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { module.exports = equalArrays; -},{"./_SetCache":39,"./_arraySome":47,"./_cacheHas":59}],62:[function(require,module,exports){ +},{"./_SetCache":40,"./_arraySome":48,"./_cacheHas":60}],63:[function(require,module,exports){ var Symbol = require('./_Symbol'), Uint8Array = require('./_Uint8Array'), eq = require('./eq'), @@ -4055,7 +6173,7 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { module.exports = equalByTag; -},{"./_Symbol":41,"./_Uint8Array":42,"./_equalArrays":61,"./_mapToArray":91,"./_setToArray":100,"./eq":107}],63:[function(require,module,exports){ +},{"./_Symbol":42,"./_Uint8Array":43,"./_equalArrays":62,"./_mapToArray":92,"./_setToArray":101,"./eq":108}],64:[function(require,module,exports){ var getAllKeys = require('./_getAllKeys'); /** Used to compose bitmasks for value comparisons. */ @@ -4146,7 +6264,7 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { module.exports = equalObjects; -},{"./_getAllKeys":65}],64:[function(require,module,exports){ +},{"./_getAllKeys":66}],65:[function(require,module,exports){ (function (global){ /** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; @@ -4154,7 +6272,7 @@ var freeGlobal = typeof global == 'object' && global && global.Object === Object module.exports = freeGlobal; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],65:[function(require,module,exports){ +},{}],66:[function(require,module,exports){ var baseGetAllKeys = require('./_baseGetAllKeys'), getSymbols = require('./_getSymbols'), keys = require('./keys'); @@ -4172,7 +6290,7 @@ function getAllKeys(object) { module.exports = getAllKeys; -},{"./_baseGetAllKeys":49,"./_getSymbols":69,"./keys":118}],66:[function(require,module,exports){ +},{"./_baseGetAllKeys":50,"./_getSymbols":70,"./keys":119}],67:[function(require,module,exports){ var isKeyable = require('./_isKeyable'); /** @@ -4192,7 +6310,7 @@ function getMapData(map, key) { module.exports = getMapData; -},{"./_isKeyable":78}],67:[function(require,module,exports){ +},{"./_isKeyable":79}],68:[function(require,module,exports){ var baseIsNative = require('./_baseIsNative'), getValue = require('./_getValue'); @@ -4211,7 +6329,7 @@ function getNative(object, key) { module.exports = getNative; -},{"./_baseIsNative":54,"./_getValue":71}],68:[function(require,module,exports){ +},{"./_baseIsNative":55,"./_getValue":72}],69:[function(require,module,exports){ var Symbol = require('./_Symbol'); /** Used for built-in method references. */ @@ -4259,7 +6377,7 @@ function getRawTag(value) { module.exports = getRawTag; -},{"./_Symbol":41}],69:[function(require,module,exports){ +},{"./_Symbol":42}],70:[function(require,module,exports){ var arrayFilter = require('./_arrayFilter'), stubArray = require('./stubArray'); @@ -4291,7 +6409,7 @@ var getSymbols = !nativeGetSymbols ? stubArray : function(object) { module.exports = getSymbols; -},{"./_arrayFilter":44,"./stubArray":119}],70:[function(require,module,exports){ +},{"./_arrayFilter":45,"./stubArray":120}],71:[function(require,module,exports){ var DataView = require('./_DataView'), Map = require('./_Map'), Promise = require('./_Promise'), @@ -4351,7 +6469,7 @@ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || module.exports = getTag; -},{"./_DataView":32,"./_Map":35,"./_Promise":37,"./_Set":38,"./_WeakMap":43,"./_baseGetTag":50,"./_toSource":106}],71:[function(require,module,exports){ +},{"./_DataView":33,"./_Map":36,"./_Promise":38,"./_Set":39,"./_WeakMap":44,"./_baseGetTag":51,"./_toSource":107}],72:[function(require,module,exports){ /** * Gets the value at `key` of `object`. * @@ -4366,7 +6484,7 @@ function getValue(object, key) { module.exports = getValue; -},{}],72:[function(require,module,exports){ +},{}],73:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** @@ -4383,7 +6501,7 @@ function hashClear() { module.exports = hashClear; -},{"./_nativeCreate":92}],73:[function(require,module,exports){ +},{"./_nativeCreate":93}],74:[function(require,module,exports){ /** * Removes `key` and its value from the hash. * @@ -4402,7 +6520,7 @@ function hashDelete(key) { module.exports = hashDelete; -},{}],74:[function(require,module,exports){ +},{}],75:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** Used to stand-in for `undefined` hash values. */ @@ -4434,7 +6552,7 @@ function hashGet(key) { module.exports = hashGet; -},{"./_nativeCreate":92}],75:[function(require,module,exports){ +},{"./_nativeCreate":93}],76:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** Used for built-in method references. */ @@ -4459,7 +6577,7 @@ function hashHas(key) { module.exports = hashHas; -},{"./_nativeCreate":92}],76:[function(require,module,exports){ +},{"./_nativeCreate":93}],77:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** Used to stand-in for `undefined` hash values. */ @@ -4484,7 +6602,7 @@ function hashSet(key, value) { module.exports = hashSet; -},{"./_nativeCreate":92}],77:[function(require,module,exports){ +},{"./_nativeCreate":93}],78:[function(require,module,exports){ /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; @@ -4511,7 +6629,7 @@ function isIndex(value, length) { module.exports = isIndex; -},{}],78:[function(require,module,exports){ +},{}],79:[function(require,module,exports){ /** * Checks if `value` is suitable for use as unique object key. * @@ -4528,7 +6646,7 @@ function isKeyable(value) { module.exports = isKeyable; -},{}],79:[function(require,module,exports){ +},{}],80:[function(require,module,exports){ var coreJsData = require('./_coreJsData'); /** Used to detect methods masquerading as native. */ @@ -4550,7 +6668,7 @@ function isMasked(func) { module.exports = isMasked; -},{"./_coreJsData":60}],80:[function(require,module,exports){ +},{"./_coreJsData":61}],81:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -4570,7 +6688,7 @@ function isPrototype(value) { module.exports = isPrototype; -},{}],81:[function(require,module,exports){ +},{}],82:[function(require,module,exports){ /** * Removes all key-value entries from the list cache. * @@ -4585,7 +6703,7 @@ function listCacheClear() { module.exports = listCacheClear; -},{}],82:[function(require,module,exports){ +},{}],83:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** Used for built-in method references. */ @@ -4622,7 +6740,7 @@ function listCacheDelete(key) { module.exports = listCacheDelete; -},{"./_assocIndexOf":48}],83:[function(require,module,exports){ +},{"./_assocIndexOf":49}],84:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** @@ -4643,7 +6761,7 @@ function listCacheGet(key) { module.exports = listCacheGet; -},{"./_assocIndexOf":48}],84:[function(require,module,exports){ +},{"./_assocIndexOf":49}],85:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** @@ -4661,7 +6779,7 @@ function listCacheHas(key) { module.exports = listCacheHas; -},{"./_assocIndexOf":48}],85:[function(require,module,exports){ +},{"./_assocIndexOf":49}],86:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** @@ -4689,7 +6807,7 @@ function listCacheSet(key, value) { module.exports = listCacheSet; -},{"./_assocIndexOf":48}],86:[function(require,module,exports){ +},{"./_assocIndexOf":49}],87:[function(require,module,exports){ var Hash = require('./_Hash'), ListCache = require('./_ListCache'), Map = require('./_Map'); @@ -4712,7 +6830,7 @@ function mapCacheClear() { module.exports = mapCacheClear; -},{"./_Hash":33,"./_ListCache":34,"./_Map":35}],87:[function(require,module,exports){ +},{"./_Hash":34,"./_ListCache":35,"./_Map":36}],88:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** @@ -4732,7 +6850,7 @@ function mapCacheDelete(key) { module.exports = mapCacheDelete; -},{"./_getMapData":66}],88:[function(require,module,exports){ +},{"./_getMapData":67}],89:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** @@ -4750,7 +6868,7 @@ function mapCacheGet(key) { module.exports = mapCacheGet; -},{"./_getMapData":66}],89:[function(require,module,exports){ +},{"./_getMapData":67}],90:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** @@ -4768,7 +6886,7 @@ function mapCacheHas(key) { module.exports = mapCacheHas; -},{"./_getMapData":66}],90:[function(require,module,exports){ +},{"./_getMapData":67}],91:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** @@ -4792,7 +6910,7 @@ function mapCacheSet(key, value) { module.exports = mapCacheSet; -},{"./_getMapData":66}],91:[function(require,module,exports){ +},{"./_getMapData":67}],92:[function(require,module,exports){ /** * Converts `map` to its key-value pairs. * @@ -4812,7 +6930,7 @@ function mapToArray(map) { module.exports = mapToArray; -},{}],92:[function(require,module,exports){ +},{}],93:[function(require,module,exports){ var getNative = require('./_getNative'); /* Built-in method references that are verified to be native. */ @@ -4820,7 +6938,7 @@ var nativeCreate = getNative(Object, 'create'); module.exports = nativeCreate; -},{"./_getNative":67}],93:[function(require,module,exports){ +},{"./_getNative":68}],94:[function(require,module,exports){ var overArg = require('./_overArg'); /* Built-in method references for those with the same name as other `lodash` methods. */ @@ -4828,7 +6946,7 @@ var nativeKeys = overArg(Object.keys, Object); module.exports = nativeKeys; -},{"./_overArg":96}],94:[function(require,module,exports){ +},{"./_overArg":97}],95:[function(require,module,exports){ var freeGlobal = require('./_freeGlobal'); /** Detect free variable `exports`. */ @@ -4860,7 +6978,7 @@ var nodeUtil = (function() { module.exports = nodeUtil; -},{"./_freeGlobal":64}],95:[function(require,module,exports){ +},{"./_freeGlobal":65}],96:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -4884,7 +7002,7 @@ function objectToString(value) { module.exports = objectToString; -},{}],96:[function(require,module,exports){ +},{}],97:[function(require,module,exports){ /** * Creates a unary function that invokes `func` with its argument transformed. * @@ -4901,7 +7019,7 @@ function overArg(func, transform) { module.exports = overArg; -},{}],97:[function(require,module,exports){ +},{}],98:[function(require,module,exports){ var freeGlobal = require('./_freeGlobal'); /** Detect free variable `self`. */ @@ -4912,7 +7030,7 @@ var root = freeGlobal || freeSelf || Function('return this')(); module.exports = root; -},{"./_freeGlobal":64}],98:[function(require,module,exports){ +},{"./_freeGlobal":65}],99:[function(require,module,exports){ /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; @@ -4933,7 +7051,7 @@ function setCacheAdd(value) { module.exports = setCacheAdd; -},{}],99:[function(require,module,exports){ +},{}],100:[function(require,module,exports){ /** * Checks if `value` is in the array cache. * @@ -4949,7 +7067,7 @@ function setCacheHas(value) { module.exports = setCacheHas; -},{}],100:[function(require,module,exports){ +},{}],101:[function(require,module,exports){ /** * Converts `set` to an array of its values. * @@ -4969,7 +7087,7 @@ function setToArray(set) { module.exports = setToArray; -},{}],101:[function(require,module,exports){ +},{}],102:[function(require,module,exports){ var ListCache = require('./_ListCache'); /** @@ -4986,7 +7104,7 @@ function stackClear() { module.exports = stackClear; -},{"./_ListCache":34}],102:[function(require,module,exports){ +},{"./_ListCache":35}],103:[function(require,module,exports){ /** * Removes `key` and its value from the stack. * @@ -5006,7 +7124,7 @@ function stackDelete(key) { module.exports = stackDelete; -},{}],103:[function(require,module,exports){ +},{}],104:[function(require,module,exports){ /** * Gets the stack value for `key`. * @@ -5022,7 +7140,7 @@ function stackGet(key) { module.exports = stackGet; -},{}],104:[function(require,module,exports){ +},{}],105:[function(require,module,exports){ /** * Checks if a stack value for `key` exists. * @@ -5038,7 +7156,7 @@ function stackHas(key) { module.exports = stackHas; -},{}],105:[function(require,module,exports){ +},{}],106:[function(require,module,exports){ var ListCache = require('./_ListCache'), Map = require('./_Map'), MapCache = require('./_MapCache'); @@ -5074,7 +7192,7 @@ function stackSet(key, value) { module.exports = stackSet; -},{"./_ListCache":34,"./_Map":35,"./_MapCache":36}],106:[function(require,module,exports){ +},{"./_ListCache":35,"./_Map":36,"./_MapCache":37}],107:[function(require,module,exports){ /** Used for built-in method references. */ var funcProto = Function.prototype; @@ -5102,7 +7220,7 @@ function toSource(func) { module.exports = toSource; -},{}],107:[function(require,module,exports){ +},{}],108:[function(require,module,exports){ /** * Performs a * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) @@ -5141,7 +7259,7 @@ function eq(value, other) { module.exports = eq; -},{}],108:[function(require,module,exports){ +},{}],109:[function(require,module,exports){ var baseIsArguments = require('./_baseIsArguments'), isObjectLike = require('./isObjectLike'); @@ -5179,7 +7297,7 @@ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsAr module.exports = isArguments; -},{"./_baseIsArguments":51,"./isObjectLike":116}],109:[function(require,module,exports){ +},{"./_baseIsArguments":52,"./isObjectLike":117}],110:[function(require,module,exports){ /** * Checks if `value` is classified as an `Array` object. * @@ -5207,7 +7325,7 @@ var isArray = Array.isArray; module.exports = isArray; -},{}],110:[function(require,module,exports){ +},{}],111:[function(require,module,exports){ var isFunction = require('./isFunction'), isLength = require('./isLength'); @@ -5242,7 +7360,7 @@ function isArrayLike(value) { module.exports = isArrayLike; -},{"./isFunction":113,"./isLength":114}],111:[function(require,module,exports){ +},{"./isFunction":114,"./isLength":115}],112:[function(require,module,exports){ var root = require('./_root'), stubFalse = require('./stubFalse'); @@ -5282,7 +7400,7 @@ var isBuffer = nativeIsBuffer || stubFalse; module.exports = isBuffer; -},{"./_root":97,"./stubFalse":120}],112:[function(require,module,exports){ +},{"./_root":98,"./stubFalse":121}],113:[function(require,module,exports){ var baseIsEqual = require('./_baseIsEqual'); /** @@ -5319,7 +7437,7 @@ function isEqual(value, other) { module.exports = isEqual; -},{"./_baseIsEqual":52}],113:[function(require,module,exports){ +},{"./_baseIsEqual":53}],114:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObject = require('./isObject'); @@ -5358,7 +7476,7 @@ function isFunction(value) { module.exports = isFunction; -},{"./_baseGetTag":50,"./isObject":115}],114:[function(require,module,exports){ +},{"./_baseGetTag":51,"./isObject":116}],115:[function(require,module,exports){ /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; @@ -5395,7 +7513,7 @@ function isLength(value) { module.exports = isLength; -},{}],115:[function(require,module,exports){ +},{}],116:[function(require,module,exports){ /** * Checks if `value` is the * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) @@ -5428,7 +7546,7 @@ function isObject(value) { module.exports = isObject; -},{}],116:[function(require,module,exports){ +},{}],117:[function(require,module,exports){ /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". @@ -5459,7 +7577,7 @@ function isObjectLike(value) { module.exports = isObjectLike; -},{}],117:[function(require,module,exports){ +},{}],118:[function(require,module,exports){ var baseIsTypedArray = require('./_baseIsTypedArray'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); @@ -5488,7 +7606,7 @@ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedA module.exports = isTypedArray; -},{"./_baseIsTypedArray":55,"./_baseUnary":58,"./_nodeUtil":94}],118:[function(require,module,exports){ +},{"./_baseIsTypedArray":56,"./_baseUnary":59,"./_nodeUtil":95}],119:[function(require,module,exports){ var arrayLikeKeys = require('./_arrayLikeKeys'), baseKeys = require('./_baseKeys'), isArrayLike = require('./isArrayLike'); @@ -5527,7 +7645,7 @@ function keys(object) { module.exports = keys; -},{"./_arrayLikeKeys":45,"./_baseKeys":56,"./isArrayLike":110}],119:[function(require,module,exports){ +},{"./_arrayLikeKeys":46,"./_baseKeys":57,"./isArrayLike":111}],120:[function(require,module,exports){ /** * This method returns a new empty array. * @@ -5552,7 +7670,7 @@ function stubArray() { module.exports = stubArray; -},{}],120:[function(require,module,exports){ +},{}],121:[function(require,module,exports){ /** * This method returns `false`. * @@ -5572,7 +7690,7 @@ function stubFalse() { module.exports = stubFalse; -},{}],121:[function(require,module,exports){ +},{}],122:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -5758,7 +7876,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],122:[function(require,module,exports){ +},{}],123:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -5822,7 +7940,7 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":3}],123:[function(require,module,exports){ +},{"buffer":4}],124:[function(require,module,exports){ var cbor = require('cbor-js'); var CRC = require('crc'); var base58 = require('./crypto/base58'); @@ -5859,7 +7977,7 @@ module.exports = { } }; -},{"./crypto/base58":125,"cbor-js":4,"crc":29}],124:[function(require,module,exports){ +},{"./crypto/base58":127,"cbor-js":5,"crc":30}],125:[function(require,module,exports){ (function (Buffer){ var base58 = require('./crypto/base58'); var segwit = require('./crypto/segwit_addr'); @@ -5949,7 +8067,74 @@ module.exports = { }; }).call(this,require("buffer").Buffer) -},{"./crypto/base58":125,"./crypto/segwit_addr":131,"./crypto/utils":133,"buffer":3}],125:[function(require,module,exports){ +},{"./crypto/base58":127,"./crypto/segwit_addr":133,"./crypto/utils":135,"buffer":4}],126:[function(require,module,exports){ +var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; + + /** +* Encode a string to base32 +*/ +var b32encode = function(s) { + var parts = []; + var quanta = Math.floor((s.length / 5)); + var leftover = s.length % 5; + + if (leftover != 0) { + for (var i = 0; i < (5 - leftover); i++) { + s += '\x00'; + } + quanta += 1; + } + + for (var i = 0; i < quanta; i++) { + parts.push(alphabet.charAt(s.charCodeAt(i * 5) >> 3)); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5) & 0x07) << 2) | (s.charCodeAt(i * 5 + 1) >> 6))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 1) & 0x3F) >> 1))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 1) & 0x01) << 4) | (s.charCodeAt(i * 5 + 2) >> 4))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 2) & 0x0F) << 1) | (s.charCodeAt(i * 5 + 3) >> 7))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 3) & 0x7F) >> 2))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 3) & 0x03) << 3) | (s.charCodeAt(i * 5 + 4) >> 5))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 4) & 0x1F)))); + } + + var replace = 0; + if (leftover == 1) replace = 6; + else if (leftover == 2) replace = 4; + else if (leftover == 3) replace = 3; + else if (leftover == 4) replace = 1; + + for (var i = 0; i < replace; i++) parts.pop(); + for (var i = 0; i < replace; i++) parts.push("="); + + return parts.join(""); +} + +/** +* Decode a base32 string. +* This is made specifically for our use, deals only with proper strings +*/ +var b32decode = function(s) { + var r = new ArrayBuffer(s.length * 5 / 8); + var b = new Uint8Array(r); + for (var j = 0; j < s.length / 8; j++) { + var v = [0, 0, 0, 0, 0, 0, 0, 0]; + for (var i = 0; i < 8; ++i) { + v[i] = alphabet.indexOf(s[j * 8 + i]); + } + var i = 0; + b[j * 5 + 0] = (v[i + 0] << 3) | (v[i + 1] >> 2); + b[j * 5 + 1] = ((v[i + 1] & 0x3) << 6) | (v[i + 2] << 1) | (v[i + 3] >> 4); + b[j * 5 + 2] = ((v[i + 3] & 0xf) << 4) | (v[i + 4] >> 1); + b[j * 5 + 3] = ((v[i + 4] & 0x1) << 7) | (v[i + 5] << 2) | (v[i + 6] >> 3); + b[j * 5 + 4] = ((v[i + 6] & 0x7) << 5) | (v[i + 7]); + } + return b; +} + +module.exports = { + b32decode: b32decode, + b32encode: b32encode +}; +},{}],127:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -5997,7 +8182,7 @@ module.exports = { } }; -},{}],126:[function(require,module,exports){ +},{}],128:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -6115,7 +8300,7 @@ function decode (bechString) { return {hrp: hrp, data: data.slice(0, data.length - 6)}; } -},{}],127:[function(require,module,exports){ +},{}],129:[function(require,module,exports){ /* JavaScript BigInteger library version 0.9.1 http://silentmatt.com/biginteger/ @@ -7566,7 +9751,7 @@ function decode (bechString) { exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt })(typeof exports !== 'undefined' ? exports : this); -},{}],128:[function(require,module,exports){ +},{}],130:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -7757,7 +9942,7 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":3}],129:[function(require,module,exports){ +},{"buffer":4}],131:[function(require,module,exports){ 'use strict'; /** @@ -8035,7 +10220,7 @@ function toHex (n) { module.exports = Blake2b; -},{}],130:[function(require,module,exports){ +},{}],132:[function(require,module,exports){ var JSBigInt = require('./biginteger')['JSBigInt']; /** @@ -8262,7 +10447,7 @@ var cnBase58 = (function () { return b58; })(); module.exports = cnBase58; -},{"./biginteger":127}],131:[function(require,module,exports){ +},{"./biginteger":129}],133:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -8358,7 +10543,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":126}],132:[function(require,module,exports){ +},{"./bech32":128}],134:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -9002,12 +11187,15 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":121}],133:[function(require,module,exports){ +},{"_process":122}],135:[function(require,module,exports){ (function (Buffer){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; var Blake2B = require('./blake2b'); +var base58 = require('./base58'); +var base32 = require('./base32'); +var BigNum = require('browserify-bignum'); function numberToHex(number) { var hex = Math.round(number).toString(16) @@ -9017,6 +11205,70 @@ function numberToHex(number) { return hex } +function isHexChar(c) { + if ((c >= 'A' && c <= 'F') || + (c >= 'a' && c <= 'f') || + (c >= '0' && c <= '9')) { + return 1; + } + return 0; +} + +/* Convert a hex char to value */ +function hexChar2byte(c) { + var d = 0; + if (c >= 'A' && c <= 'F') { + d = c.charCodeAt(0) - 'A'.charCodeAt(0) + 10; + } + else if (c >= 'a' && c <= 'f') { + d = c.charCodeAt(0) - 'a'.charCodeAt(0) + 10; + } + else if (c >= '0' && c <= '9') { + d = c.charCodeAt(0) - '0'.charCodeAt(0); + } + return d; +} + +/* Convert a byte to string */ +function byte2hexStr(byte) { + var hexByteMap = "0123456789ABCDEF"; + var str = ""; + str += hexByteMap.charAt(byte >> 4); + str += hexByteMap.charAt(byte & 0x0f); + return str; +} + +function byteArray2hexStr(byteArray) { + var str = ""; + for (var i = 0; i < (byteArray.length - 1); i++) { + str += byte2hexStr(byteArray[i]); + } + str += byte2hexStr(byteArray[i]); + return str; +} + +function hexStr2byteArray(str) { + var byteArray = Array(); + var d = 0; + var i = 0; + var j = 0; + var k = 0; + + for (i = 0; i < str.length; i++) { + var c = str.charAt(i); + if (isHexChar(c)) { + d <<= 4; + d += hexChar2byte(c); + j++; + if (0 === (j % 2)) { + byteArray[k++] = d; + d = 0; + } + } + } + return byteArray; +} + module.exports = { toHex: function (arrayOfBytes) { var hex = ''; @@ -9051,32 +11303,17 @@ module.exports = { blake2b256: function (hexString) { return new Blake2B(32).update(Buffer.from(hexString, 'hex'), 32).digest('hex'); }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX') - sha.update(hexString) - return sha.getHash('HEX') - }, - sha256Checksum: function (payload) { - return this.sha256(this.sha256(payload)).substr(0, 8) - }, - blake256: function (hexString) { - return new Blake256().update(hexString, 'hex').digest('hex') - }, - blake256Checksum: function (payload) { - return this.blake256(this.blake256(payload)).substr(0, 8) - }, - keccak256: function (hexString) { - return keccak256(hexString) + base58: base58.decode, + byteArray2hexStr: byteArray2hexStr, + hexStr2byteArray: hexStr2byteArray, + bigNumberToBuffer: function(bignumber, size){ + return new BigNum(bignumber).toBuffer({ size, endian: 'big' }); }, - keccak256Checksum: function (payload) { - return keccak256(payload) - .toString() - .substr(0, 8) - } + base32: base32 } }).call(this,require("buffer").Buffer) -},{"./blake256":128,"./blake2b":129,"./sha3":132,"buffer":3,"jssha/src/sha256":31}],134:[function(require,module,exports){ +},{"./base32":126,"./base58":127,"./blake256":130,"./blake2b":131,"./sha3":134,"browserify-bignum":3,"buffer":4,"jssha/src/sha256":32}],136:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); @@ -9084,12 +11321,15 @@ var ADAValidator = require('./ada_validator'); var XMRValidator = require('./monero_validator'); var NANOValidator = require('./nano_validator'); var SCValidator = require('./siacoin_validator') +var TRXValidator = require('./tron_validator'); +var NEMValidator = require('./nem_validator'); +var LSKValidator = require('./lisk_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ name: 'Bitcoin', symbol: 'btc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26']}, validator: BTCValidator }, { name: 'BitcoinCash', @@ -9453,6 +11693,19 @@ var CURRENCIES = [{ symbol: 'lbc', addressTypes: { prod: ['55'], testnet: [] }, validator: BTCValidator +}, { + name: 'tron', + symbol: 'trx', + addressTypes: {prod: [0x41], testnet: [0xa0]}, + validator: TRXValidator +}, { + name: 'nem', + symbol: 'xem', + validator: NEMValidator +}, { + name: 'lisk', + symbol: 'lsk', + validator: LSKValidator }]; @@ -9472,7 +11725,7 @@ module.exports = { -},{"./ada_validator":123,"./bitcoin_validator":124,"./ethereum_validator":135,"./monero_validator":136,"./nano_validator":137,"./ripple_validator":138,"./siacoin_validator":139}],135:[function(require,module,exports){ +},{"./ada_validator":124,"./bitcoin_validator":125,"./ethereum_validator":137,"./lisk_validator":138,"./monero_validator":139,"./nano_validator":140,"./nem_validator":141,"./ripple_validator":142,"./siacoin_validator":143,"./tron_validator":144}],137:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -9508,7 +11761,29 @@ module.exports = { } }; -},{"./crypto/utils":133}],136:[function(require,module,exports){ +},{"./crypto/utils":135}],138:[function(require,module,exports){ +(function (Buffer){ +var cryptoUtils = require('./crypto/utils'); + +var regexp = new RegExp('^[0-9]{1,20}L$'); + +module.exports = { + isValidAddress: function(address) { + if (!regexp.test(address)) { + return false; + } + return this.verifyAddress(address) + }, + + verifyAddress: function(address) { + var BUFFER_SIZE = 8; + var bigNumber = address.substring(0, address.length - 1); + var addressBuffer = cryptoUtils.bigNumberToBuffer(bigNumber); + return Buffer.from(addressBuffer).slice(0, BUFFER_SIZE).equals(addressBuffer); + } +}; +}).call(this,require("buffer").Buffer) +},{"./crypto/utils":135,"buffer":4}],139:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils') var cnBase58 = require('./crypto/cnBase58') @@ -9572,7 +11847,7 @@ module.exports = { } } -},{"./crypto/cnBase58":130,"./crypto/utils":133}],137:[function(require,module,exports){ +},{"./crypto/cnBase58":132,"./crypto/utils":135}],140:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -9601,7 +11876,33 @@ module.exports = { } }; -},{"./crypto/utils":133,"base-x":1}],138:[function(require,module,exports){ +},{"./crypto/utils":135,"base-x":1}],141:[function(require,module,exports){ +(function (Buffer){ +var cryptoUtils = require('./crypto/utils'); + + /** +* Check if an address is valid +* +* @param {string} _address - An address +* +* @return {boolean} - True if address is valid, false otherwise +*/ +var isValidAddress = function(_address) { + var address = _address.toString().toUpperCase().replace(/-/g, ''); + if (!address || address.length !== 40) { + return false; + } + var decoded = cryptoUtils.toHex(cryptoUtils.base32.b32decode(address)); + var stepThreeChecksum = cryptoUtils.keccak256Checksum(Buffer.from(decoded.slice(0, 42), 'hex')); + + return stepThreeChecksum === decoded.slice(42); +}; + +module.exports = { + isValidAddress: isValidAddress, +} +}).call(this,require("buffer").Buffer) +},{"./crypto/utils":135,"buffer":4}],142:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -9631,7 +11932,7 @@ module.exports = { } }; -},{"./crypto/utils":133,"base-x":1}],139:[function(require,module,exports){ +},{"./crypto/utils":135,"base-x":1}],143:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils') var isEqual = require('lodash/isEqual') @@ -9661,7 +11962,69 @@ module.exports = { } } -},{"./crypto/utils":133,"lodash/isEqual":112}],140:[function(require,module,exports){ +},{"./crypto/utils":135,"lodash/isEqual":113}],144:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); + +function decodeBase58Address(base58Sting) { + if (typeof (base58Sting) !== 'string') { + return false; + } + if (base58Sting.length <= 4) { + return false; + } + + try { + var address = cryptoUtils.base58(base58Sting); + } catch (e) { + return false + } + + /*if (base58Sting.length <= 4) { + return false; + }*/ + var len = address.length; + var offset = len - 4; + var checkSum = address.slice(offset); + address = address.slice(0, offset); + var hash0 = cryptoUtils.sha256(cryptoUtils.byteArray2hexStr(address)); + var hash1 = cryptoUtils.hexStr2byteArray(cryptoUtils.sha256(hash0)); + var checkSum1 = hash1.slice(0, 4); + if (checkSum[0] === checkSum1[0] && checkSum[1] === checkSum1[1] && checkSum[2] + === checkSum1[2] && checkSum[3] === checkSum1[3] + ) { + return address; + } + + return false; +} + +function getEnv(currency, networkType) { + var evn = networkType || 'prod'; + + if (evn !== 'prod' && evn !== 'testnet') evn = 'prod'; + + return currency.addressTypes[evn][0] +} + +module.exports = { + /** + * tron address validation + */ + isValidAddress: function (mainAddress, currency, networkType) { + var address = decodeBase58Address(mainAddress); + + if (!address) { + return false; + } + + if (address.length !== 21) { + return false; + } + + return getEnv(currency, networkType) === address[0]; + } +}; +},{"./crypto/utils":135}],145:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -9678,5 +12041,5 @@ module.exports = { }, }; -},{"./currencies":134}]},{},[140])(140) +},{"./currencies":136}]},{},[145])(145) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index e2611426..b55067ef 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function i(a,s,u){function f(e,t){if(!s[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var o=s[e]={exports:{}};a[e][0].call(o.exports,function(t){return f(a[e][1][t]||t)},o,o.exports,i,a,s,u)}return s[e].exports}for(var c="function"==typeof require&&require,t=0;t>=8;for(;0>=8}for(var a=0;t[a]===c&&a>16&255,i[a++]=e>>8&255,i[a++]=255&e;var f,c;2===o&&(e=l[t.charCodeAt(u)]<<2|l[t.charCodeAt(u+1)]>>4,i[a++]=255&e);1===o&&(e=l[t.charCodeAt(u)]<<10|l[t.charCodeAt(u+1)]<<4|l[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,a=r-n;i>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return o.join("")};for(var s=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=l,r.SlowBuffer=function(t){+t!=t&&(t=0);return l.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(o>>1;case"base64":return M(t).length;default:if(o)return n?-1:I(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=l.from(e,n)),l.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;i>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=w)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},l.prototype.equals=function(t){if(!l.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===l.compare(this,t)},l.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},l.prototype.compare=function(t,e,r,n,o){if(R(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),f=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i,a,s,u,f,c,l,h,p,d=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return h=e,p=r,L(I(t,(l=this).length-h),l,h,p);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(M(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,o,i=[],a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(t,(i=this).length-a),i,a,s);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;ot.length)throw new RangeError("Index out of range")}function S(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,o){return e=+e,r>>>=0,o||S(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,o){return e=+e,r>>>=0,o||S(t,0,r,8),i.write(t,e,r,n,52,8),r+8}l.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||B(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||B(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||B(t,1,this.length),this[t]},l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||B(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||B(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt16BE=function(t,e){t>>>=0,e||B(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!1,52,8)},l.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},l.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},l.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;0<=--i&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},l.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},l.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},l.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},l.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},l.prototype.copy=function(t,e,r,n){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function M(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function R(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:30}],4:[function(t,r,e){!function(t,E){"use strict";var B=Math.pow(2,-24),C=Math.pow(2,32),y=Math.pow(2,53);var e={encode:function(t){var a,s=new ArrayBuffer(256),u=new DataView(s),f=0;function c(t){for(var e=s.byteLength,r=f+t;e>2,i=0;i>6):(i<55296?o.push(224|i>>12):(i=(1023&i)<<10,i|=1023&e.charCodeAt(++r),i+=65536,o.push(240|i>>18),o.push(128|i>>12&63)),o.push(128|i>>6&63)),o.push(128|63&i))}return d(3,o.length),p(o);default:var a;if(Array.isArray(e))for(d(4,a=e.length),r=0;r>5!==t)throw"Invalid indefinite length element";return r}function k(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof p&&(p=function(t){return t}),"function"!=typeof d&&(d=function(){return E});var t=function t(){var e,r,n=_(),o=n>>5,i=31&n;if(7===o)switch(i){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=m(),n=32768&r,o=31744&r,i=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==i)return i*B;return e.setUint32(0,n<<16|o<<13|i<<13),e.getFloat32(0)}();case 26:return g(y.getFloat32(v),4);case 27:return g(y.getFloat64(v),8)}if((r=A(i))<0&&(o<2||6>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],18:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8^o)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("kermit",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16-modbus",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n>8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var o=(0,n(t("./define_crc")).default)("xmodem",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:0,n=0;n>>8&255;o^=255&t[n],r=r<<8&65535,r^=o^=o>>>4,r^=o=o<<5&65535,r^=o=o<<7&65535}return r});r.default=o},{"./create_buffer":27,"./define_crc":28,buffer:3}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-24",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:11994318,n=0;n>16^o)]^r<<8)}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-32",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=0===e?0:-1^~~e,n=0;n>>8}return-1^r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("buffer"),a=o(t("./create_buffer")),n=o(t("./define_crc"));function o(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-8",function(t,e){i.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n>>8}return r});r.default=u},{"./create_buffer":27,"./define_crc":28,buffer:3}],27:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:3}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,r){var e=function(t,e){return r(t,e)>>>0};return e.signed=r,(e.unsigned=e).model=t,e}},{}],29:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":5,"./crc16":6,"./crc16_ccitt":7,"./crc16_kermit":8,"./crc16_modbus":9,"./crc16_xmodem":10,"./crc24":11,"./crc32":12,"./crc8":13,"./crc8_1wire":14,"./crcjam":15}],30:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;0>=-c,c+=n;0>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(e+=1<=a+l?h/u:h*Math.pow(2,1-l))*u&&(a++,u/=2),c<=a+l?(s=0,a=c):1<=a+l?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));8<=o;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<= 1");if(0!==a.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(l=function(t,e){return H(t,e,a)},h=function(t,e,r,n){var o,i;if("SHA-224"!==a&&"SHA-256"!==a)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(e+65>>>9<<4),i=16;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,e+=r,t[o]=4294967295&e,t[o-1]=e/4294967296|0,r=t.length,e=0;e>>3)/4-1,n>>5;for(t=(e=u(t,v,g)).binLen,r=e.value,e=t>>>5,n=0;n>>5),g=t%c,m=!0},this.getHash=function(t,e){var r,n,o,i;if(!0===b)throw Error("Cannot call getHash after setting HMAC key");switch(o=E(e),t){case"HEX":r=function(t){return w(t,f,o)};break;case"B64":r=function(t){return A(t,f,o)};break;case"BYTES":r=function(t){return x(t,f)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}r=function(t){return k(t,f)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=h(v.slice(),g,y,p(s)),n=1;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function A(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;o<4;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function x(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function k(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function E(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function B(t,h){var e;switch(h){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":e=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":e=function(t,e,r){var n,o,i,a,s,u,f,c,l=0;if(e=e||[0],s=(r=r||0)>>>3,"UTF8"===h)for(c=3,i=0;i>>6),o.push(128|63&n)):n<55296||57344<=n?o.push(224|n>>>12,128|n>>>6&63,128|63&n):(i+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(i)),o.push(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)),a=0;a>>2;e.length<=u;)e.push(0);e[u]|=o[a]<<8*(c+f%4*-1),l+=1}else if("UTF16BE"===h||"UTF16LE"===h)for(c=2,o="UTF16LE"===h||"UTF16LE"!==h&&!1,i=0;i>>8),u=(f=l+s)>>>2;e.length<=u;)e.push(0);e[u]|=n<<8*(c+f%4*-1),l+=2}return{value:e,binLen:8*l+r}};break;case"B64":e=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]B&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return C(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function C(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function j(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||j(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||j(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);j(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);j(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!p();)B.push(t());else for(B=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],B=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],B[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,C=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o> 3)); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5) & 0x07) << 2) | (s.charCodeAt(i * 5 + 1) >> 6))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 1) & 0x3F) >> 1))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 1) & 0x01) << 4) | (s.charCodeAt(i * 5 + 2) >> 4))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 2) & 0x0F) << 1) | (s.charCodeAt(i * 5 + 3) >> 7))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 3) & 0x7F) >> 2))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 3) & 0x03) << 3) | (s.charCodeAt(i * 5 + 4) >> 5))); + parts.push(alphabet.charAt(((s.charCodeAt(i * 5 + 4) & 0x1F)))); + } + + var replace = 0; + if (leftover == 1) replace = 6; + else if (leftover == 2) replace = 4; + else if (leftover == 3) replace = 3; + else if (leftover == 4) replace = 1; + + for (var i = 0; i < replace; i++) parts.pop(); + for (var i = 0; i < replace; i++) parts.push("="); + + return parts.join(""); +} + +/** +* Decode a base32 string. +* This is made specifically for our use, deals only with proper strings +*/ +var b32decode = function(s) { + var r = new ArrayBuffer(s.length * 5 / 8); + var b = new Uint8Array(r); + for (var j = 0; j < s.length / 8; j++) { + var v = [0, 0, 0, 0, 0, 0, 0, 0]; + for (var i = 0; i < 8; ++i) { + v[i] = alphabet.indexOf(s[j * 8 + i]); + } + var i = 0; + b[j * 5 + 0] = (v[i + 0] << 3) | (v[i + 1] >> 2); + b[j * 5 + 1] = ((v[i + 1] & 0x3) << 6) | (v[i + 2] << 1) | (v[i + 3] >> 4); + b[j * 5 + 2] = ((v[i + 3] & 0xf) << 4) | (v[i + 4] >> 1); + b[j * 5 + 3] = ((v[i + 4] & 0x1) << 7) | (v[i + 5] << 2) | (v[i + 6] >> 3); + b[j * 5 + 4] = ((v[i + 6] & 0x7) << 5) | (v[i + 7]); + } + return b; +} + +module.exports = { + b32decode: b32decode, + b32encode: b32encode +}; \ No newline at end of file diff --git a/src/crypto/utils.js b/src/crypto/utils.js index 2af6b7f6..fb2f03b1 100644 --- a/src/crypto/utils.js +++ b/src/crypto/utils.js @@ -2,6 +2,9 @@ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; var Blake2B = require('./blake2b'); +var base58 = require('./base58'); +var base32 = require('./base32'); +var BigNum = require('browserify-bignum'); function numberToHex(number) { var hex = Math.round(number).toString(16) @@ -11,6 +14,70 @@ function numberToHex(number) { return hex } +function isHexChar(c) { + if ((c >= 'A' && c <= 'F') || + (c >= 'a' && c <= 'f') || + (c >= '0' && c <= '9')) { + return 1; + } + return 0; +} + +/* Convert a hex char to value */ +function hexChar2byte(c) { + var d = 0; + if (c >= 'A' && c <= 'F') { + d = c.charCodeAt(0) - 'A'.charCodeAt(0) + 10; + } + else if (c >= 'a' && c <= 'f') { + d = c.charCodeAt(0) - 'a'.charCodeAt(0) + 10; + } + else if (c >= '0' && c <= '9') { + d = c.charCodeAt(0) - '0'.charCodeAt(0); + } + return d; +} + +/* Convert a byte to string */ +function byte2hexStr(byte) { + var hexByteMap = "0123456789ABCDEF"; + var str = ""; + str += hexByteMap.charAt(byte >> 4); + str += hexByteMap.charAt(byte & 0x0f); + return str; +} + +function byteArray2hexStr(byteArray) { + var str = ""; + for (var i = 0; i < (byteArray.length - 1); i++) { + str += byte2hexStr(byteArray[i]); + } + str += byte2hexStr(byteArray[i]); + return str; +} + +function hexStr2byteArray(str) { + var byteArray = Array(); + var d = 0; + var i = 0; + var j = 0; + var k = 0; + + for (i = 0; i < str.length; i++) { + var c = str.charAt(i); + if (isHexChar(c)) { + d <<= 4; + d += hexChar2byte(c); + j++; + if (0 === (j % 2)) { + byteArray[k++] = d; + d = 0; + } + } + } + return byteArray; +} + module.exports = { toHex: function (arrayOfBytes) { var hex = ''; @@ -45,26 +112,11 @@ module.exports = { blake2b256: function (hexString) { return new Blake2B(32).update(Buffer.from(hexString, 'hex'), 32).digest('hex'); }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX') - sha.update(hexString) - return sha.getHash('HEX') - }, - sha256Checksum: function (payload) { - return this.sha256(this.sha256(payload)).substr(0, 8) - }, - blake256: function (hexString) { - return new Blake256().update(hexString, 'hex').digest('hex') - }, - blake256Checksum: function (payload) { - return this.blake256(this.blake256(payload)).substr(0, 8) + base58: base58.decode, + byteArray2hexStr: byteArray2hexStr, + hexStr2byteArray: hexStr2byteArray, + bigNumberToBuffer: function(bignumber, size){ + return new BigNum(bignumber).toBuffer({ size, endian: 'big' }); }, - keccak256: function (hexString) { - return keccak256(hexString) - }, - keccak256Checksum: function (payload) { - return keccak256(payload) - .toString() - .substr(0, 8) - } + base32: base32 } diff --git a/src/currencies.js b/src/currencies.js index a62e17b6..a669eeaf 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -5,6 +5,9 @@ var ADAValidator = require('./ada_validator'); var XMRValidator = require('./monero_validator'); var NANOValidator = require('./nano_validator'); var SCValidator = require('./siacoin_validator') +var TRXValidator = require('./tron_validator'); +var NEMValidator = require('./nem_validator'); +var LSKValidator = require('./lisk_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -374,6 +377,19 @@ var CURRENCIES = [{ symbol: 'lbc', addressTypes: { prod: ['55'], testnet: [] }, validator: BTCValidator +}, { + name: 'tron', + symbol: 'trx', + addressTypes: {prod: [0x41], testnet: [0xa0]}, + validator: TRXValidator +}, { + name: 'nem', + symbol: 'xem', + validator: NEMValidator +}, { + name: 'lisk', + symbol: 'lsk', + validator: LSKValidator }]; diff --git a/src/lisk_validator.js b/src/lisk_validator.js new file mode 100644 index 00000000..dba08f28 --- /dev/null +++ b/src/lisk_validator.js @@ -0,0 +1,19 @@ +var cryptoUtils = require('./crypto/utils'); + +var regexp = new RegExp('^[0-9]{1,20}L$'); + +module.exports = { + isValidAddress: function(address) { + if (!regexp.test(address)) { + return false; + } + return this.verifyAddress(address) + }, + + verifyAddress: function(address) { + var BUFFER_SIZE = 8; + var bigNumber = address.substring(0, address.length - 1); + var addressBuffer = cryptoUtils.bigNumberToBuffer(bigNumber); + return Buffer.from(addressBuffer).slice(0, BUFFER_SIZE).equals(addressBuffer); + } +}; \ No newline at end of file diff --git a/src/nem_validator.js b/src/nem_validator.js new file mode 100644 index 00000000..f996cd27 --- /dev/null +++ b/src/nem_validator.js @@ -0,0 +1,23 @@ +var cryptoUtils = require('./crypto/utils'); + + /** +* Check if an address is valid +* +* @param {string} _address - An address +* +* @return {boolean} - True if address is valid, false otherwise +*/ +var isValidAddress = function(_address) { + var address = _address.toString().toUpperCase().replace(/-/g, ''); + if (!address || address.length !== 40) { + return false; + } + var decoded = cryptoUtils.toHex(cryptoUtils.base32.b32decode(address)); + var stepThreeChecksum = cryptoUtils.keccak256Checksum(Buffer.from(decoded.slice(0, 42), 'hex')); + + return stepThreeChecksum === decoded.slice(42); +}; + +module.exports = { + isValidAddress: isValidAddress, +} \ No newline at end of file diff --git a/src/tron_validator.js b/src/tron_validator.js new file mode 100644 index 00000000..cfb4376f --- /dev/null +++ b/src/tron_validator.js @@ -0,0 +1,61 @@ +var cryptoUtils = require('./crypto/utils'); + +function decodeBase58Address(base58Sting) { + if (typeof (base58Sting) !== 'string') { + return false; + } + if (base58Sting.length <= 4) { + return false; + } + + try { + var address = cryptoUtils.base58(base58Sting); + } catch (e) { + return false + } + + /*if (base58Sting.length <= 4) { + return false; + }*/ + var len = address.length; + var offset = len - 4; + var checkSum = address.slice(offset); + address = address.slice(0, offset); + var hash0 = cryptoUtils.sha256(cryptoUtils.byteArray2hexStr(address)); + var hash1 = cryptoUtils.hexStr2byteArray(cryptoUtils.sha256(hash0)); + var checkSum1 = hash1.slice(0, 4); + if (checkSum[0] === checkSum1[0] && checkSum[1] === checkSum1[1] && checkSum[2] + === checkSum1[2] && checkSum[3] === checkSum1[3] + ) { + return address; + } + + return false; +} + +function getEnv(currency, networkType) { + var evn = networkType || 'prod'; + + if (evn !== 'prod' && evn !== 'testnet') evn = 'prod'; + + return currency.addressTypes[evn][0] +} + +module.exports = { + /** + * tron address validation + */ + isValidAddress: function (mainAddress, currency, networkType) { + var address = decodeBase58Address(mainAddress); + + if (!address) { + return false; + } + + if (address.length !== 21) { + return false; + } + + return getEnv(currency, networkType) === address[0]; + } +}; \ No newline at end of file diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index bc2b8f50..457d32e1 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -495,6 +495,25 @@ describe('WAValidator.validate()', function () { valid('bTFXPcV3a8iVDezogvHTHezWZ1mZGWpPDc', 'lbc') valid('bK2uEVn6UuwjCTUZ1Dfj5HhWYi9BtqZDDm', 'lbry') }) + + it('should return true for correct trx addresses', function () { + valid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r', 'trx'); + valid('27bLJCYjbH6MT8DBF9xcrK6yZnm43vx7MNQ', 'trx', 'testnet'); + }); + + it('should return true for correct nem addresses', function () { + valid('NBZMQO7ZPBYNBDUR7F75MAKA2S3DHDCIFG775N3D', 'xem'); + valid('TDWTRGT6GVWCV7GRWFNI45S53PGOJBKNUF3GE6PB', 'xem', 'testnet'); + }); + + it('should return true for correct lsk addresses', function () { + valid('469226551L', 'lsk'); + valid('15823701926930889868L', 'lsk'); + valid('1657699692452120239L', 'lsk'); + valid('555666666999992L', 'lsk'); + valid('6853061742992593192L', 'lsk'); + valid('530464791801L', 'lsk'); + }); }); describe('invalid results', function () { @@ -760,5 +779,28 @@ describe('WAValidator.validate()', function () { invalid('ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372') }) + it('should return false for incorrect tron addresses', function () { + commonTests('trx'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'trx'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'trx'); + }); + + it('should return false for incorrect nem addresses', function () { + commonTests('nem'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nem'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'nem'); + + invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'nem', 'testnet'); + invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'nem', 'testnet'); + }); + //15823701926930889868L + it('should return false for incorrect lsk addresses', function () { + commonTests('nem'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'lsk'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'lsk'); + + invalid('158237019269308898689L', 'lsk'); + invalid('158237A192B930C898689L', 'lsk'); + }); }); }); diff --git a/yarn.lock b/yarn.lock index bc1f14c4..f059e944 100644 --- a/yarn.lock +++ b/yarn.lock @@ -335,6 +335,11 @@ browserify-aes@^1.0.0, browserify-aes@^1.0.4: inherits "^2.0.1" safe-buffer "^5.0.1" +browserify-bignum@^1.3.0-2: + version "1.3.0-2" + resolved "https://registry.yarnpkg.com/browserify-bignum/-/browserify-bignum-1.3.0-2.tgz#ddc3b6ed607fd6c960966950e2b35a2b0c6fb9bf" + integrity sha1-3cO27WB/1slglmlQ4rNaKwxvub8= + browserify-cipher@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" @@ -617,10 +622,10 @@ commander@2.15.1: resolved "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" integrity sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag== -commander@~2.17.1: - version "2.17.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" - integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg== +commander@~2.13.0: + version "2.13.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" + integrity sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA== component-bind@1.0.0: version "1.0.0" @@ -2805,12 +2810,12 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -uglify-js@^3.4.9: - version "3.4.9" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3" - integrity sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q== +uglify-es@^3.3.9: + version "3.3.9" + resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677" + integrity sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ== dependencies: - commander "~2.17.1" + commander "~2.13.0" source-map "~0.6.1" ultron@~1.1.0: From 9b985a592ff3acbd3005a438bd02c60da3c4440d Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Wed, 13 Feb 2019 22:40:20 +0200 Subject: [PATCH 077/108] updated version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a23831d..0e6e4f9d 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "browser", "nodejs" ], - "version": "0.3.7", + "version": "0.3.8", "author": "Chris ", "homepage": "https://github.com/christsim/multicoin-address-validator", "license": "MIT", From b70a922ac3ee68cd16378df75e7df4be8cc88fa7 Mon Sep 17 00:00:00 2001 From: Stephen Ephraim Date: Fri, 15 Feb 2019 22:00:18 +0200 Subject: [PATCH 078/108] Adds BSV (#4) * Adds Address Validation For Tron (TRX) * Adds Wallet Address Validation For XEM * Adds New Validators To Readme * Adds Wallet Address Validation For LSK * Removes lisk library * Removes unnecessary libraries * Removes crypto-js library * Clean up * Adds BSV validator * Update bch to use bsv validator * Changes from bsv_validator to bch_validator * Adds bundle and minify versions * Adds check prefix for bch/bsv (bitcoincash) --- README.md | 85 ++++++++++++++++++++++ dist/wallet-address-validator.js | 103 +++++++++++++++++++++------ dist/wallet-address-validator.min.js | 2 +- src/bch_validator.js | 47 ++++++++++++ src/crypto/bech32.js | 1 + src/currencies.js | 10 ++- test/wallet_address_validator.js | 25 ++++++- 7 files changed, 247 insertions(+), 26 deletions(-) create mode 100644 src/bch_validator.js diff --git a/README.md b/README.md index 44d06be9..c4ace9b2 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,90 @@ npm install multicoin-address-validator ### Supported crypto currencies +<<<<<<< HEAD +* 0x/zrx `'0x'` or `'zrx'` +* Aragon/ant `'Aragon'` or `'ant'` +* Augur/rep `'Augur'` or `'rep'` +* AuroraCoin/aur `'AuroraCoin'` or `'aur'` +* Bancor/bnt `'Bancor'` or `'bnt'` +* Bankex/bkx `'Bankex'` or `'bkx'` +* Basic Attention Token/bat `'Basic Attention Token'` or `'bat'` +* BeaverCoin/bvc `'BeaverCoin'` or `'bvc'` +* BioCoin/bio `'BioCoin'` or `'bio'` +* Bitcoin/btc `'Bitcoin'` or `'btc'` +* Bitcoin SV/bsv `'Bitcoin SV'` or `'bsv'` +* BitcoinCash/bch `'BitcoinCash'` or `'bch'` +* BitcoinGold/btg `'BitcoinGold'` or `'btg'` +* BitcoinPrivate/btcp `'BitcoinPrivate'` or `'btcp'` +* BitcoinZ/btcz `'BitcoinZ'` or `'btcz'` +* Callisto/clo `'Callisto'` or `'clo'` +* Cardano/ada `'Cardano'` or `'ada'` +* Civic/cvc `'Civic'` or `'cvc'` +* Dash/dash `'Dash'` or `'dash'` +* Decred/dcr `'Decred'` or `'dcr'` +* DigiByte/dgb `'DigiByte'` or `'dgb'` +* District0x/dnt `'District0x'` or `'dnt'` +* DogeCoin/doge `'DogeCoin'` or `'doge'` +* Ethereum/eth `'Ethereum'` or `'eth'` +* EthereumClassic/etc `'EthereumClassic'` or `'etc'` +* EtherZero/etz `'EtherZero'` or `'etz'` +* Expanse/exp `'Expanse'` or `'exp'` +* FreiCoin/frc `'FreiCoin'` or `'frc'` +* GameCredits/game `'GameCredits'` or `'game'` +* GarliCoin/grlc `'GarliCoin'` or `'grlc'` +* Gnosis/gno `'Gnosis'` or `'gno'` +* Golem/gnt `'Golem'` or `'gnt'` +* Hush/hush `'Hush'` or `'hush'` +* hyperspace/xsc `'hyperspace'` or `'xsc'` +* iExec RLC/rlc `'iExec RLC'` or `'rlc'` +* Komodo/kmd `'Komodo'` or `'kmd'` +* lbry/lbc `'lbry'` or `'lbc'` +* lisk/lsk `'lisk'` or `'lsk'` +* LiteCoin/ltc `'LiteCoin'` or `'ltc'` +* loki/loki `'loki'` or `'loki'` +* Matchpool/gup `'Matchpool'` or `'gup'` +* MegaCoin/mec `'MegaCoin'` or `'mec'` +* Melon/mln `'Melon'` or `'mln'` +* MonaCoin/mona `'MonaCoin'` or `'mona'` +* Monero/xmr `'Monero'` or `'xmr'` +* NameCoin/nmc `'NameCoin'` or `'nmc'` +* Nano/nano `'Nano'` or `'nano'` +* nem/xem `'nem'` or `'xem'` +* Neo/neo `'Neo'` or `'neo'` +* NeoGas/gas `'NeoGas'` or `'gas'` +* Numeraire/nmr `'Numeraire'` or `'nmr'` +* Odyssey/ocn `'Odyssey'` or `'ocn'` +* OmiseGO/omg `'OmiseGO'` or `'omg'` +* PeerCoin/ppc `'PeerCoin'` or `'ppc'` +* PIVX/pivx `'PIVX'` or `'pivx'` +* Polymath/poly `'Polymath'` or `'poly'` +* PrimeCoin/xpm `'PrimeCoin'` or `'xpm'` +* ProtoShares/pts `'ProtoShares'` or `'pts'` +* Qtum/qtum `'Qtum'` or `'qtum'` +* RaiBlocks/xrb `'RaiBlocks'` or `'xrb'` +* Ripio Credit Network/rcn `'Ripio Credit Network'` or `'rcn'` +* Ripple/xrp `'Ripple'` or `'xrp'` +* Salt/salt `'Salt'` or `'salt'` +* siacoin/sc `'siacoin'` or `'sc'` +* SnowGem/sng `'SnowGem'` or `'sng'` +* SolarCoin/slr `'SolarCoin'` or `'slr'` +* Status/snt `'Status'` or `'snt'` +* Storj/storj `'Storj'` or `'storj'` +* Storm/storm `'Storm'` or `'storm'` +* Swarm City/swt `'Swarm City'` or `'swt'` +* TenX/pay `'TenX'` or `'pay'` +* Tether/usdt `'Tether'` or `'usdt'` +* tron/trx `'tron'` or `'trx'` +* TrueUSD/tusd `'TrueUSD'` or `'tusd'` +* VertCoin/vtc `'VertCoin'` or `'vtc'` +* Viberate/vib `'Viberate'` or `'vib'` +* VoteCoin/vot `'VoteCoin'` or `'vot'` +* Waves/waves `'Waves'` or `'waves'` +* Wings/wings `'Wings'` or `'wings'` +* ZCash/zec `'ZCash'` or `'zec'` +* ZClassic/zcl `'ZClassic'` or `'zcl'` +* ZenCash/zen `'ZenCash'` or `'zen'` +======= * 0x/zrx `'0x'` or `'zrx'` * Aragon/ant `'Aragon'` or `'ant'` * Augur/rep `'Augur'` or `'rep'` @@ -111,6 +195,7 @@ npm install multicoin-address-validator * ZCash/zec `'ZCash'` or `'zec'` * ZClassic/zcl `'ZClassic'` or `'zcl'` * ZenCash/zen `'ZenCash'` or `'zen'` +>>>>>>> upstream/master ### Usage example diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 36d44146..e23ba218 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -7977,7 +7977,55 @@ module.exports = { } }; -},{"./crypto/base58":127,"cbor-js":5,"crc":30}],125:[function(require,module,exports){ +},{"./crypto/base58":128,"cbor-js":5,"crc":30}],125:[function(require,module,exports){ +var cryptoUtils = require('./crypto/utils'); +var bech32 = require('./crypto/bech32'); +var BTCValidator = require('./bitcoin_validator'); + +function validateAddress(address, currency, networkType) { + var prefix = 'bitcoincash'; + var regexp = new RegExp(currency.regexp); + var raw_address; + + var res = address.split(':'); + if (res.length === 1) { + raw_address = address + } else { + if (res[0] !== 'bitcoincash') { + return false; + } + raw_address = res[1]; + } + + if (!regexp.test(raw_address)) { + return false; + } + + if (raw_address.toLowerCase() != raw_address && raw_address.toUpperCase() != raw_address) { + return false; + } + + var decoded = cryptoUtils.base32.b32decode(raw_address); + if (networkType === 'testnet') { + prefix = 'bchtest'; + } + + try { + if (bech32.verifyChecksum(prefix, decoded)) { + return false; + } + } catch(e) { + return false; + } + return true; +} + +module.exports = { + isValidAddress: function (address, currency, networkType) { + return validateAddress(address, currency, networkType) || BTCValidator.isValidAddress(address, currency, networkType); + } +} +},{"./bitcoin_validator":126,"./crypto/bech32":129,"./crypto/utils":136}],126:[function(require,module,exports){ (function (Buffer){ var base58 = require('./crypto/base58'); var segwit = require('./crypto/segwit_addr'); @@ -8067,7 +8115,7 @@ module.exports = { }; }).call(this,require("buffer").Buffer) -},{"./crypto/base58":127,"./crypto/segwit_addr":133,"./crypto/utils":135,"buffer":4}],126:[function(require,module,exports){ +},{"./crypto/base58":128,"./crypto/segwit_addr":134,"./crypto/utils":136,"buffer":4}],127:[function(require,module,exports){ var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; /** @@ -8134,7 +8182,7 @@ module.exports = { b32decode: b32decode, b32encode: b32encode }; -},{}],127:[function(require,module,exports){ +},{}],128:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -8182,7 +8230,7 @@ module.exports = { } }; -},{}],128:[function(require,module,exports){ +},{}],129:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -8209,6 +8257,7 @@ var GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]; module.exports = { decode: decode, encode: encode, + verifyChecksum: verifyChecksum }; @@ -8300,7 +8349,7 @@ function decode (bechString) { return {hrp: hrp, data: data.slice(0, data.length - 6)}; } -},{}],129:[function(require,module,exports){ +},{}],130:[function(require,module,exports){ /* JavaScript BigInteger library version 0.9.1 http://silentmatt.com/biginteger/ @@ -9751,7 +9800,7 @@ function decode (bechString) { exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt })(typeof exports !== 'undefined' ? exports : this); -},{}],130:[function(require,module,exports){ +},{}],131:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -9942,7 +9991,7 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":4}],131:[function(require,module,exports){ +},{"buffer":4}],132:[function(require,module,exports){ 'use strict'; /** @@ -10220,7 +10269,7 @@ function toHex (n) { module.exports = Blake2b; -},{}],132:[function(require,module,exports){ +},{}],133:[function(require,module,exports){ var JSBigInt = require('./biginteger')['JSBigInt']; /** @@ -10447,7 +10496,7 @@ var cnBase58 = (function () { return b58; })(); module.exports = cnBase58; -},{"./biginteger":129}],133:[function(require,module,exports){ +},{"./biginteger":130}],134:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -10543,7 +10592,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":128}],134:[function(require,module,exports){ +},{"./bech32":129}],135:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -11187,7 +11236,7 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":122}],135:[function(require,module,exports){ +},{"_process":122}],136:[function(require,module,exports){ (function (Buffer){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); @@ -11313,7 +11362,7 @@ module.exports = { } }).call(this,require("buffer").Buffer) -},{"./base32":126,"./base58":127,"./blake256":130,"./blake2b":131,"./sha3":134,"browserify-bignum":3,"buffer":4,"jssha/src/sha256":32}],136:[function(require,module,exports){ +},{"./base32":127,"./base58":128,"./blake256":131,"./blake2b":132,"./sha3":135,"browserify-bignum":3,"buffer":4,"jssha/src/sha256":32}],137:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); @@ -11324,6 +11373,7 @@ var SCValidator = require('./siacoin_validator') var TRXValidator = require('./tron_validator'); var NEMValidator = require('./nem_validator'); var LSKValidator = require('./lisk_validator'); +var BCHValidator = require('./bch_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -11334,8 +11384,15 @@ var CURRENCIES = [{ }, { name: 'BitcoinCash', symbol: 'bch', + regexp: '^[qQpP]{1}[0-9a-zA-Z]{41}$', addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator + validator: BCHValidator +}, { + name: 'Bitcoin SV', + symbol: 'bsv', + regexp: '^[qQ]{1}[0-9a-zA-Z]{41}$', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BCHValidator }, { name: 'LiteCoin', symbol: 'ltc', @@ -11725,7 +11782,7 @@ module.exports = { -},{"./ada_validator":124,"./bitcoin_validator":125,"./ethereum_validator":137,"./lisk_validator":138,"./monero_validator":139,"./nano_validator":140,"./nem_validator":141,"./ripple_validator":142,"./siacoin_validator":143,"./tron_validator":144}],137:[function(require,module,exports){ +},{"./ada_validator":124,"./bch_validator":125,"./bitcoin_validator":126,"./ethereum_validator":138,"./lisk_validator":139,"./monero_validator":140,"./nano_validator":141,"./nem_validator":142,"./ripple_validator":143,"./siacoin_validator":144,"./tron_validator":145}],138:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -11761,7 +11818,7 @@ module.exports = { } }; -},{"./crypto/utils":135}],138:[function(require,module,exports){ +},{"./crypto/utils":136}],139:[function(require,module,exports){ (function (Buffer){ var cryptoUtils = require('./crypto/utils'); @@ -11783,7 +11840,7 @@ module.exports = { } }; }).call(this,require("buffer").Buffer) -},{"./crypto/utils":135,"buffer":4}],139:[function(require,module,exports){ +},{"./crypto/utils":136,"buffer":4}],140:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils') var cnBase58 = require('./crypto/cnBase58') @@ -11847,7 +11904,7 @@ module.exports = { } } -},{"./crypto/cnBase58":132,"./crypto/utils":135}],140:[function(require,module,exports){ +},{"./crypto/cnBase58":133,"./crypto/utils":136}],141:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -11876,7 +11933,7 @@ module.exports = { } }; -},{"./crypto/utils":135,"base-x":1}],141:[function(require,module,exports){ +},{"./crypto/utils":136,"base-x":1}],142:[function(require,module,exports){ (function (Buffer){ var cryptoUtils = require('./crypto/utils'); @@ -11902,7 +11959,7 @@ module.exports = { isValidAddress: isValidAddress, } }).call(this,require("buffer").Buffer) -},{"./crypto/utils":135,"buffer":4}],142:[function(require,module,exports){ +},{"./crypto/utils":136,"buffer":4}],143:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -11932,7 +11989,7 @@ module.exports = { } }; -},{"./crypto/utils":135,"base-x":1}],143:[function(require,module,exports){ +},{"./crypto/utils":136,"base-x":1}],144:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils') var isEqual = require('lodash/isEqual') @@ -11962,7 +12019,7 @@ module.exports = { } } -},{"./crypto/utils":135,"lodash/isEqual":113}],144:[function(require,module,exports){ +},{"./crypto/utils":136,"lodash/isEqual":113}],145:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); function decodeBase58Address(base58Sting) { @@ -12024,7 +12081,7 @@ module.exports = { return getEnv(currency, networkType) === address[0]; } }; -},{"./crypto/utils":135}],145:[function(require,module,exports){ +},{"./crypto/utils":136}],146:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -12041,5 +12098,5 @@ module.exports = { }, }; -},{"./currencies":136}]},{},[145])(145) +},{"./currencies":137}]},{},[146])(146) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index b55067ef..8c038735 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]B&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return C(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function C(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function j(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||j(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||j(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);j(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);j(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!p();)B.push(t());else for(B=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],B=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],B[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,C=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]B&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return C(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function C(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!p();)B.push(t());else for(B=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],B=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],B[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,C=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Fri, 15 Feb 2019 22:21:26 +0200 Subject: [PATCH 079/108] Updates README to include BCH (#5) * Adds Address Validation For Tron (TRX) * Adds Wallet Address Validation For XEM * Adds New Validators To Readme * Adds Wallet Address Validation For LSK * Removes lisk library * Removes unnecessary libraries * Removes crypto-js library * Clean up * Adds BSV validator * Update bch to use bsv validator * Changes from bsv_validator to bch_validator * Adds bundle and minify versions * Adds check prefix for bch/bsv (bitcoincash) * Updates README --- README.md | 84 ------------------------------------------------------- 1 file changed, 84 deletions(-) diff --git a/README.md b/README.md index c4ace9b2..03d5d02c 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ npm install multicoin-address-validator ### Supported crypto currencies -<<<<<<< HEAD * 0x/zrx `'0x'` or `'zrx'` * Aragon/ant `'Aragon'` or `'ant'` * Augur/rep `'Augur'` or `'rep'` @@ -113,89 +112,6 @@ npm install multicoin-address-validator * ZCash/zec `'ZCash'` or `'zec'` * ZClassic/zcl `'ZClassic'` or `'zcl'` * ZenCash/zen `'ZenCash'` or `'zen'` -======= -* 0x/zrx `'0x'` or `'zrx'` -* Aragon/ant `'Aragon'` or `'ant'` -* Augur/rep `'Augur'` or `'rep'` -* AuroraCoin/aur `'AuroraCoin'` or `'aur'` -* Bancor/bnt `'Bancor'` or `'bnt'` -* Bankex/bkx `'Bankex'` or `'bkx'` -* Basic Attention Token/bat `'Basic Attention Token'` or `'bat'` -* BeaverCoin/bvc `'BeaverCoin'` or `'bvc'` -* BioCoin/bio `'BioCoin'` or `'bio'` -* Bitcoin/btc `'Bitcoin'` or `'btc'` -* BitcoinCash/bch `'BitcoinCash'` or `'bch'` -* BitcoinGold/btg `'BitcoinGold'` or `'btg'` -* BitcoinPrivate/btcp `'BitcoinPrivate'` or `'btcp'` -* BitcoinZ/btcz `'BitcoinZ'` or `'btcz'` -* Callisto/clo `'Callisto'` or `'clo'` -* Cardano/ada `'Cardano'` or `'ada'` -* Civic/cvc `'Civic'` or `'cvc'` -* Dash/dash `'Dash'` or `'dash'` -* Decred/dcr `'Decred'` or `'dcr'` -* DigiByte/dgb `'DigiByte'` or `'dgb'` -* District0x/dnt `'District0x'` or `'dnt'` -* DogeCoin/doge `'DogeCoin'` or `'doge'` -* Ethereum/eth `'Ethereum'` or `'eth'` -* EthereumClassic/etc `'EthereumClassic'` or `'etc'` -* EtherZero/etz `'EtherZero'` or `'etz'` -* Expanse/exp `'Expanse'` or `'exp'` -* FreiCoin/frc `'FreiCoin'` or `'frc'` -* GameCredits/game `'GameCredits'` or `'game'` -* GarliCoin/grlc `'GarliCoin'` or `'grlc'` -* Gnosis/gno `'Gnosis'` or `'gno'` -* Golem/gnt `'Golem'` or `'gnt'` -* Hush/hush `'Hush'` or `'hush'` -* hyperspace/xsc `'hyperspace'` or `'xsc'` -* iExec RLC/rlc `'iExec RLC'` or `'rlc'` -* Komodo/kmd `'Komodo'` or `'kmd'` -* lbry/lbc `'lbry'` or `'lbc'` -* LiteCoin/ltc `'LiteCoin'` or `'ltc'` -* Lisk/lsk `'Lisk'` or `'lsk'` -* loki/loki `'loki'` or `'loki'` -* Matchpool/gup `'Matchpool'` or `'gup'` -* MegaCoin/mec `'MegaCoin'` or `'mec'` -* Melon/mln `'Melon'` or `'mln'` -* MonaCoin/mona `'MonaCoin'` or `'mona'` -* Monero/xmr `'Monero'` or `'xmr'` -* NameCoin/nmc `'NameCoin'` or `'nmc'` -* Nano/nano `'Nano'` or `'nano'` -* Nem/nem `'Nem'` or `'xem'` -* Neo/neo `'Neo'` or `'neo'` -* NeoGas/gas `'NeoGas'` or `'gas'` -* Numeraire/nmr `'Numeraire'` or `'nmr'` -* Odyssey/ocn `'Odyssey'` or `'ocn'` -* OmiseGO/omg `'OmiseGO'` or `'omg'` -* PeerCoin/ppc `'PeerCoin'` or `'ppc'` -* PIVX/pivx `'PIVX'` or `'pivx'` -* Polymath/poly `'Polymath'` or `'poly'` -* PrimeCoin/xpm `'PrimeCoin'` or `'xpm'` -* ProtoShares/pts `'ProtoShares'` or `'pts'` -* Qtum/qtum `'Qtum'` or `'qtum'` -* RaiBlocks/xrb `'RaiBlocks'` or `'xrb'` -* Ripio Credit Network/rcn `'Ripio Credit Network'` or `'rcn'` -* Ripple/xrp `'Ripple'` or `'xrp'` -* Salt/salt `'Salt'` or `'salt'` -* siacoin/sc `'siacoin'` or `'sc'` -* SnowGem/sng `'SnowGem'` or `'sng'` -* SolarCoin/slr `'SolarCoin'` or `'slr'` -* Status/snt `'Status'` or `'snt'` -* Storj/storj `'Storj'` or `'storj'` -* Storm/storm `'Storm'` or `'storm'` -* Swarm City/swt `'Swarm City'` or `'swt'` -* TenX/pay `'TenX'` or `'pay'` -* Tether/usdt `'Tether'` or `'usdt'` -* Tron/trono `'Tron'` or `'trx'` -* TrueUSD/tusd `'TrueUSD'` or `'tusd'` -* VertCoin/vtc `'VertCoin'` or `'vtc'` -* Viberate/vib `'Viberate'` or `'vib'` -* VoteCoin/vot `'VoteCoin'` or `'vot'` -* Waves/waves `'Waves'` or `'waves'` -* Wings/wings `'Wings'` or `'wings'` -* ZCash/zec `'ZCash'` or `'zec'` -* ZClassic/zcl `'ZClassic'` or `'zcl'` -* ZenCash/zen `'ZenCash'` or `'zen'` ->>>>>>> upstream/master ### Usage example From d505bb43d31e0713413e685856e27fecea2bd883 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Fri, 15 Feb 2019 22:37:02 +0200 Subject: [PATCH 080/108] fixed vertcoin validator for '3' addresses --- dist/wallet-address-validator.js | 3 ++- dist/wallet-address-validator.min.js | 2 +- package.json | 2 +- src/currencies.js | 3 ++- test/wallet_address_validator.js | 9 +++++++++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index e23ba218..c14506e7 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -11456,8 +11456,9 @@ var CURRENCIES = [{ }, { name: 'VertCoin', symbol: 'vtc', - addressTypes: { prod: ['0x', '47'], testnet: ['6f', 'c4'] }, + addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, validator: BTCValidator + }, { name: 'BitcoinGold', symbol: 'btg', diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 8c038735..536d7cb3 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]B&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return C(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function C(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!p();)B.push(t());else for(B=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],B=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],B[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,C=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]B&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return C(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function C(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!p();)B.push(t());else for(B=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],B=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],B[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,C=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Fri, 8 Mar 2019 09:04:42 +0200 Subject: [PATCH 081/108] Adds XLM address validator (#6) * Adds Address Validation For Tron (TRX) * Adds Wallet Address Validation For XEM * Adds New Validators To Readme * Adds Wallet Address Validation For LSK * Removes lisk library * Removes unnecessary libraries * Removes crypto-js library * Clean up * Adds BSV validator * Update bch to use bsv validator * Changes from bsv_validator to bch_validator * Adds bundle and minify versions * Adds check prefix for bch/bsv (bitcoincash) * Updates README * Adds XLM address validator * Comment Out Currencies Generator --- README.md | 3 +- dist/wallet-address-validator.js | 66 +++++++++++++++++++++++++--- dist/wallet-address-validator.min.js | 2 +- src/currencies.js | 7 ++- src/stellar_validator.js | 46 +++++++++++++++++++ test/wallet_address_validator.js | 27 ++++++++++++ 6 files changed, 141 insertions(+), 10 deletions(-) create mode 100644 src/stellar_validator.js diff --git a/README.md b/README.md index 03d5d02c..3c221777 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ npm install multicoin-address-validator * SnowGem/sng `'SnowGem'` or `'sng'` * SolarCoin/slr `'SolarCoin'` or `'slr'` * Status/snt `'Status'` or `'snt'` +* stellar/xlm `'stellar'` or `'xlm'` * Storj/storj `'Storj'` or `'storj'` * Storm/storm `'Storm'` or `'storm'` * Swarm City/swt `'Swarm City'` or `'swt'` @@ -111,7 +112,7 @@ npm install multicoin-address-validator * Wings/wings `'Wings'` or `'wings'` * ZCash/zec `'ZCash'` or `'zec'` * ZClassic/zcl `'ZClassic'` or `'zcl'` -* ZenCash/zen `'ZenCash'` or `'zen'` +* ZenCash/zen `'ZenCash'` or `'zen'` ### Usage example diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index c14506e7..73c7904a 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -11374,6 +11374,7 @@ var TRXValidator = require('./tron_validator'); var NEMValidator = require('./nem_validator'); var LSKValidator = require('./lisk_validator'); var BCHValidator = require('./bch_validator'); +var XLMValidator = require('./stellar_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -11764,6 +11765,10 @@ var CURRENCIES = [{ name: 'lisk', symbol: 'lsk', validator: LSKValidator +}, { + name: 'stellar', + symbol: 'xlm', + validator: XLMValidator, }]; @@ -11776,14 +11781,14 @@ module.exports = { } }; -// spit out details for readme.md -// CURRENCIES -// .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) -// .forEach(c => console.log(`* ${c.name}/${c.symbol} \`'${c.name}'\` or \`'${c.symbol}'\` `)); +//spit out details for readme.md + CURRENCIES + .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) + .forEach(c => console.log(`* ${c.name}/${c.symbol} \`'${c.name}'\` or \`'${c.symbol}'\` `)); -},{"./ada_validator":124,"./bch_validator":125,"./bitcoin_validator":126,"./ethereum_validator":138,"./lisk_validator":139,"./monero_validator":140,"./nano_validator":141,"./nem_validator":142,"./ripple_validator":143,"./siacoin_validator":144,"./tron_validator":145}],138:[function(require,module,exports){ +},{"./ada_validator":124,"./bch_validator":125,"./bitcoin_validator":126,"./ethereum_validator":138,"./lisk_validator":139,"./monero_validator":140,"./nano_validator":141,"./nem_validator":142,"./ripple_validator":143,"./siacoin_validator":144,"./stellar_validator":145,"./tron_validator":146}],138:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -12021,6 +12026,53 @@ module.exports = { } },{"./crypto/utils":136,"lodash/isEqual":113}],145:[function(require,module,exports){ +var baseX = require('base-x'); +var crc = require('crc'); +var cryptoUtils = require('./crypto/utils'); + + var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; + + var base32 = baseX(ALPHABET); +var regexp = new RegExp('^[' + ALPHABET + ']{56}$'); +var ed25519PublicKeyVersionByte = (6 << 3); + + function swap16(number) { + var lower = number & 0xFF; + var upper = (number >> 8) & 0xFF; + return (lower << 8) | upper; +} + + function numberToHex(number) { + var hex = number.toString(16); + if(hex.length % 2 === 1) { + hex = '0' + hex; + } + return hex; +} + + module.exports = { + isValidAddress: function (address) { + if (regexp.test(address)) { + return this.verifyChecksum(address); + } + + return false; + }, + + verifyChecksum: function (address) { + // based on https://github.com/stellar/js-stellar-base/blob/master/src/strkey.js#L126 + var bytes = base32.decode(address); + if (bytes[0] !== ed25519PublicKeyVersionByte) { + return false; + } + + var computedChecksum = numberToHex(swap16(crc.crc16xmodem(bytes.slice(0, -2)))); + var checksum = cryptoUtils.toHex(bytes.slice(-2)); + + return computedChecksum === checksum + } +}; +},{"./crypto/utils":136,"base-x":1,"crc":30}],146:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); function decodeBase58Address(base58Sting) { @@ -12082,7 +12134,7 @@ module.exports = { return getEnv(currency, networkType) === address[0]; } }; -},{"./crypto/utils":136}],146:[function(require,module,exports){ +},{"./crypto/utils":136}],147:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -12099,5 +12151,5 @@ module.exports = { }, }; -},{"./currencies":137}]},{},[146])(146) +},{"./currencies":137}]},{},[147])(147) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 536d7cb3..8f0ab8b7 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]B&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return C(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function C(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!p();)B.push(t());else for(B=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],B=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],B[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,C=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o7&&t[r].toUpperCase()!==t[r]||parseInt(e[r],16)<=7&&t[r].toLowerCase()!==t[r])return!1;return!0}}},{"./crypto/utils":136}],139:[function(t,e,r){(function(r){var n=t("./crypto/utils"),o=new RegExp("^[0-9]{1,20}L$");e.exports={isValidAddress:function(t){return!!o.test(t)&&this.verifyAddress(t)},verifyAddress:function(t){var e=t.substring(0,t.length-1),o=n.bigNumberToBuffer(e);return r.from(o).slice(0,8).equals(o)}}}).call(this,t("buffer").Buffer)},{"./crypto/utils":136,buffer:4}],140:[function(t,e,r){var n=t("./crypto/utils"),o=t("./crypto/cnBase58"),i=new RegExp("^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$"),a=new RegExp("^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$");e.exports={isValidAddress:function(t,e,r){r=r||"prod";var s="standard";if(!i.test(t)){if(!a.test(t))return!1;s="integrated"}var u=o.decode(t);return!!u&&(!!function(t,e,r,n){var o=e.addressTypes;"integrated"==n&&(o=e.iAddressTypes);var i=parseInt(t.substr(0,2),16).toString();switch(r){case"prod":return o.prod.indexOf(i)>=0;case"testnet":return o.testnet.indexOf(i)>=0;case"both":return o.prod.indexOf(i)>=0||o.testnet.indexOf(i)>=0;default:return!1}}(u,e,r,s)&&u.slice(-8)===n.keccak256Checksum(function(t){if(t.length%2!=0)return null;for(var e=new Uint8Array(t.length/2),r=0;r>8&255)===i.toHex(r.slice(-2))}}},{"./crypto/utils":136,"base-x":1,crc:30}],146:[function(t,e,r){var n=t("./crypto/utils");e.exports={isValidAddress:function(t,e,r){var o=function(t){if("string"!=typeof t)return!1;if(t.length<=4)return!1;try{var e=n.base58(t)}catch(t){return!1}var r=e.length-4,o=e.slice(r);e=e.slice(0,r);var i=n.sha256(n.byteArray2hexStr(e)),a=n.hexStr2byteArray(n.sha256(i)).slice(0,4);return o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]&&o[3]===a[3]&&e}(t);return!!o&&(21===o.length&&function(t,e){var r=e||"prod";return"prod"!==r&&"testnet"!==r&&(r="prod"),t.addressTypes[r][0]}(e,r)===o[0])}}},{"./crypto/utils":136}],147:[function(t,e,r){var n=t("./currencies");e.exports={validate:function(t,e,r){var o=n.getByNameOrSymbol(e||"bitcoin");if(o&&o.validator)return o.validator.isValidAddress(t,o,r);throw new Error("Missing validator for currency: "+e)}}},{"./currencies":137}]},{},[147])(147)}); diff --git a/src/currencies.js b/src/currencies.js index 6438869f..993515e9 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -9,6 +9,7 @@ var TRXValidator = require('./tron_validator'); var NEMValidator = require('./nem_validator'); var LSKValidator = require('./lisk_validator'); var BCHValidator = require('./bch_validator'); +var XLMValidator = require('./stellar_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -399,6 +400,10 @@ var CURRENCIES = [{ name: 'lisk', symbol: 'lsk', validator: LSKValidator +}, { + name: 'stellar', + symbol: 'xlm', + validator: XLMValidator, }]; @@ -411,7 +416,7 @@ module.exports = { } }; -// spit out details for readme.md +//spit out details for readme.md // CURRENCIES // .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) // .forEach(c => console.log(`* ${c.name}/${c.symbol} \`'${c.name}'\` or \`'${c.symbol}'\` `)); diff --git a/src/stellar_validator.js b/src/stellar_validator.js new file mode 100644 index 00000000..dfac2faf --- /dev/null +++ b/src/stellar_validator.js @@ -0,0 +1,46 @@ +var baseX = require('base-x'); +var crc = require('crc'); +var cryptoUtils = require('./crypto/utils'); + + var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; + + var base32 = baseX(ALPHABET); +var regexp = new RegExp('^[' + ALPHABET + ']{56}$'); +var ed25519PublicKeyVersionByte = (6 << 3); + + function swap16(number) { + var lower = number & 0xFF; + var upper = (number >> 8) & 0xFF; + return (lower << 8) | upper; +} + + function numberToHex(number) { + var hex = number.toString(16); + if(hex.length % 2 === 1) { + hex = '0' + hex; + } + return hex; +} + + module.exports = { + isValidAddress: function (address) { + if (regexp.test(address)) { + return this.verifyChecksum(address); + } + + return false; + }, + + verifyChecksum: function (address) { + // based on https://github.com/stellar/js-stellar-base/blob/master/src/strkey.js#L126 + var bytes = base32.decode(address); + if (bytes[0] !== ed25519PublicKeyVersionByte) { + return false; + } + + var computedChecksum = numberToHex(swap16(crc.crc16xmodem(bytes.slice(0, -2)))); + var checksum = cryptoUtils.toHex(bytes.slice(-2)); + + return computedChecksum === checksum + } +}; \ No newline at end of file diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index efeaa203..c86f0b6f 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -533,6 +533,19 @@ describe('WAValidator.validate()', function () { valid('bitcoincash:qrwkk9a3es2wu7mdvzh0vekfvjuzysq8tv7r3hcwr5', 'bsv'); valid('1DrNXqCj2B8FKyx66RAWDkiEJhw2yrvhT3', 'bsv'); }); + + it('should return true for correct stellar addresses', function () { + valid('GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB', 'stellar'); + valid('GB7KKHHVYLDIZEKYJPAJUOTBE5E3NJAXPSDZK7O6O44WR3EBRO5HRPVT', 'stellar'); + valid('GD6WVYRVID442Y4JVWFWKWCZKB45UGHJAABBJRS22TUSTWGJYXIUR7N2', 'stellar'); + valid('GBCG42WTVWPO4Q6OZCYI3D6ZSTFSJIXIS6INCIUF23L6VN3ADE4337AP', 'stellar'); + valid('GDFX463YPLCO2EY7NGFMI7SXWWDQAMASGYZXCG2LATOF3PP5NQIUKBPT', 'stellar'); + valid('GBXEODUMM3SJ3QSX2VYUWFU3NRP7BQRC2ERWS7E2LZXDJXL2N66ZQ5PT', 'stellar'); + valid('GAJHORKJKDDEPYCD6URDFODV7CVLJ5AAOJKR6PG2VQOLWFQOF3X7XLOG', 'stellar'); + valid('GACXQEAXYBEZLBMQ2XETOBRO4P66FZAJENDHOQRYPUIXZIIXLKMZEXBJ', 'stellar'); + valid('GDD3XRXU3G4DXHVRUDH7LJM4CD4PDZTVP4QHOO4Q6DELKXUATR657OZV', 'stellar'); + valid('GDTYVCTAUQVPKEDZIBWEJGKBQHB4UGGXI2SXXUEW7LXMD4B7MK37CWLJ', 'stellar'); + }); }); describe('invalid results', function () { @@ -834,5 +847,19 @@ describe('WAValidator.validate()', function () { invalid('rlt2c2wuxr644encp3as0hygtj9djrsaumku3cex5', 'bsv'); invalid('qra607y4wnkmnpy3wcmrxmltzkrxywcq85c7watpdx09', 'bsv'); }); + + it('should return false for incorrect stellar addresses', function () { + commonTests('stellar'); + invalid('SBGWKM3CD4IL47QN6X54N6Y33T3JDNVI6AIJ6CD5IM47HG3IG4O36XCU', 'stellar'); + invalid('GBPXX0A5N4JYPESHAADMQKBPWZWQDQ64ZV6ZL2S3LAGW4SY7NTCMWIVL', 'stellar'); + invalid('GCFZB6L25D26RQFDWSSBDEYQ32JHLRMTT44ZYE3DZQUTYOL7WY43PLBG++', 'stellar'); + invalid('GADE5QJ2TY7S5ZB65Q43DFGWYWCPHIYDJ2326KZGAGBN7AE5UY6JVDRRA', 'stellar'); + invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2', 'stellar'); + invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2T', 'stellar'); + invalid('GDXIIZTKTLVYCBHURXL2UPMTYXOVNI7BRAEFQCP6EZCY4JLKY4VKFNLT', 'stellar'); + invalid('SAB5556L5AN5KSR5WF7UOEFDCIODEWEO7H2UR4S5R62DFTQOGLKOVZDY', 'stellar'); + invalid('gWRYUerEKuz53tstxEuR3NCkiQDcV4wzFHmvLnZmj7PUqxW2wt', 'stellar'); + invalid('g4VPBPrHZkfE8CsjuG2S4yBQNd455UWmk', 'stellar'); + }); }); }); From 89349a0dceddbc623b0bdfe603d42313270708fe Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Fri, 8 Mar 2019 09:21:23 +0200 Subject: [PATCH 082/108] updated dependencies --- .snyk | 4 ++++ package.json | 4 ++-- test/wallet_address_validator.js | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .snyk diff --git a/.snyk b/.snyk new file mode 100644 index 00000000..fad85078 --- /dev/null +++ b/.snyk @@ -0,0 +1,4 @@ +# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. +version: v1.13.3 +ignore: {} +patch: {} diff --git a/package.json b/package.json index 9fce698e..9e5181b1 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "start": "npm run bundle && npm run minify && npm test" }, "dependencies": { - "base-x": "^3.0.4", + "base-x": "^3.0.5", "browserify-bignum": "^1.3.0-2", "cbor-js": "^0.1.0", "crc": "^3.8.0", @@ -66,7 +66,7 @@ "karma-chai": "^0.1.0", "karma-chrome-launcher": "^2.2.0", "karma-mocha": "^1.3.0", - "mocha": "^5.2.0", + "mocha": "^6.0.2", "uglify-es": "^3.3.9" } } diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index efeaa203..7b16974a 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -527,6 +527,7 @@ describe('WAValidator.validate()', function () { valid('qzwryn9fxnpqkf7zt878tp2g9cg8kpl65qh2ml0w0r', 'bsv'); valid('qp65yngy5uds4wxtrkynptal4f76qzmrh52pa3mpaf', 'bsv'); valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); + valid('qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); valid('qz97s7ee0rvwlymtxrwafmvs87x6027jwuf3wepug7', 'bsv'); valid('bitcoincash:qpp32ssez340wfspnt79h6c4xds4fzf3m5j0cplx0l', 'bsv'); valid('qqg82u7tq2eahs3gkh9m6kjnmjehr69m5v37alepq4', 'bsv'); From 853da272ef5d2c7e730c0f5a939ba2ff9b9d8605 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Fri, 8 Mar 2019 09:21:35 +0200 Subject: [PATCH 083/108] added yarn.lock --- yarn.lock | 616 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 556 insertions(+), 60 deletions(-) diff --git a/yarn.lock b/yarn.lock index f059e944..38de34b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -53,6 +53,11 @@ after@0.8.2: resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" integrity sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8= +ansi-colors@3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" + integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw== + ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -63,6 +68,13 @@ ansi-regex@^3.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -84,6 +96,13 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + arr-diff@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" @@ -185,10 +204,10 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= -base-x@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.4.tgz#94c1788736da065edb1d68808869e357c977fa77" - integrity sha512-UYOadoSIkEI/VrRGSG6qp93rp2WdokiAiNYDfGW5qURAY8GiAQkvMbwNNSDYiVJopqv4gCna7xqf4rrNGp+5AA== +base-x@^3.0.5: + version "3.0.5" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.5.tgz#d3ada59afed05b921ab581ec3112e6444ba0795a" + integrity sha512-C3picSgzPSLE+jW3tcBzJoGwitOtazb5B+5YmAxZm2ybmTi9LNgAtDO/jjVEBZwHoXmDBZ9m/IELj3elJVRBcA== dependencies: safe-buffer "^5.0.1" @@ -512,6 +531,11 @@ callsite@1.0.0: resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" integrity sha1-KAOY5dZkvXQDi28JBRU+borxvCA= +camelcase@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.2.0.tgz#e7522abda5ed94cc0489e1b8466610e88404cf45" + integrity sha512-IXFsBS2pC+X0j0N/GE7Dm7j3bsEBp+oTpb7F50dwEVX7rf3IgwO9XatnegTsDtniKCUtEJH4fSU6Asw7uoVLfQ== + cbor-js@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/cbor-js/-/cbor-js-0.1.0.tgz#c80ce6120f387e8faa74370dfda21d965b8fc7f9" @@ -529,6 +553,15 @@ chai@^4.2.0: pathval "^1.1.0" type-detect "^4.0.5" +chalk@^2.0.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" @@ -582,6 +615,15 @@ class-utils@^0.3.5: isobject "^3.0.0" static-extend "^0.1.1" +cliui@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" + integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ== + dependencies: + string-width "^2.1.1" + strip-ansi "^4.0.0" + wrap-ansi "^2.0.0" + code-point-at@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" @@ -595,6 +637,18 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + colors@^1.1.0: version "1.3.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.2.tgz#2df8ff573dfbf255af562f8ce7181d6b971a359b" @@ -617,11 +671,6 @@ combine-source-map@^0.8.0, combine-source-map@~0.8.0: lodash.memoize "~3.0.3" source-map "~0.5.3" -commander@2.15.1: - version "2.15.1" - resolved "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" - integrity sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag== - commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" @@ -752,6 +801,17 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" +cross-spawn@^6.0.0: + version "6.0.5" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" + integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== + dependencies: + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" + crypto-browserify@^3.0.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -791,19 +851,24 @@ debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@3.1.0, debug@=3.1.0, debug@~3.1.0: +debug@3.2.6, debug@^3.1.0: + version "3.2.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" + integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== + dependencies: + ms "^2.1.1" + +debug@=3.1.0, debug@~3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== dependencies: ms "2.0.0" -debug@^3.1.0: - version "3.2.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== - dependencies: - ms "^2.1.1" +decamelize@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= decode-uri-component@^0.2.0: version "0.2.0" @@ -822,6 +887,13 @@ deep-extend@^0.6.0: resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== +define-properties@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" + integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== + dependencies: + object-keys "^1.0.12" + define-property@^0.2.5: version "0.2.5" resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" @@ -877,6 +949,11 @@ des.js@^1.0.0: inherits "^2.0.1" minimalistic-assert "^1.0.0" +detect-file@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" + integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= + detect-libc@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" @@ -955,6 +1032,13 @@ encodeurl@~1.0.1: resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= +end-of-stream@^1.1.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" + integrity sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q== + dependencies: + once "^1.4.0" + engine.io-client@~3.2.0: version "3.2.1" resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.2.1.tgz#6f54c0475de487158a1a7c77d10178708b6add36" @@ -1000,16 +1084,42 @@ ent@~2.2.0: resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" integrity sha1-6WQhkyWiHQX0RGai9obtbOX13R0= +es-abstract@^1.5.1: + version "1.13.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.13.0.tgz#ac86145fdd5099d8dd49558ccba2eaf9b88e24e9" + integrity sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg== + dependencies: + es-to-primitive "^1.2.0" + function-bind "^1.1.1" + has "^1.0.3" + is-callable "^1.1.4" + is-regex "^1.0.4" + object-keys "^1.0.12" + +es-to-primitive@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377" + integrity sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg== + dependencies: + is-callable "^1.1.4" + is-date-object "^1.0.1" + is-symbol "^1.0.2" + escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= -escape-string-regexp@1.0.5: +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + eventemitter3@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.0.tgz#090b4d6cdbd645ed10bf750d4b5407942d7ba163" @@ -1028,6 +1138,19 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: md5.js "^1.3.4" safe-buffer "^5.1.1" +execa@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" + integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== + dependencies: + cross-spawn "^6.0.0" + get-stream "^4.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + expand-braces@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/expand-braces/-/expand-braces-0.1.2.tgz#488b1d1d2451cb3d3a6b192cfc030f44c5855fea" @@ -1058,6 +1181,13 @@ expand-range@^0.1.0: is-number "^0.1.1" repeat-string "^0.2.2" +expand-tilde@^2.0.0, expand-tilde@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-2.0.2.tgz#97e801aa052df02454de46b02bf621642cdc8502" + integrity sha1-l+gBqgUt8CRU3kawK/YhZCzchQI= + dependencies: + homedir-polyfill "^1.0.1" + extend-shallow@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" @@ -1115,6 +1245,30 @@ finalhandler@1.1.0: statuses "~1.3.1" unpipe "~1.0.0" +find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + +findup-sync@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc" + integrity sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw= + dependencies: + detect-file "^1.0.0" + is-glob "^3.1.0" + micromatch "^3.0.4" + resolve-dir "^1.0.1" + +flat@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/flat/-/flat-4.1.0.tgz#090bec8b05e39cba309747f1d588f04dbaf98db2" + integrity sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw== + dependencies: + is-buffer "~2.0.3" + follow-redirects@^1.0.0: version "1.5.9" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.9.tgz#c9ed9d748b814a39535716e531b9196a845d89c6" @@ -1185,11 +1339,23 @@ get-assigned-identifiers@^1.2.0: resolved "https://registry.yarnpkg.com/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz#6dbf411de648cbaf8d9169ebb0d2d576191e2ff1" integrity sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ== +get-caller-file@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" + integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== + get-func-name@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= +get-stream@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" + integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== + dependencies: + pump "^3.0.0" + get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -1203,19 +1369,7 @@ glob-parent@^3.1.0: is-glob "^3.1.0" path-dirname "^1.0.0" -glob@7.1.2: - version "7.1.2" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" - integrity sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@^7.0.5, glob@^7.1.0, glob@^7.1.1: +glob@7.1.3, glob@^7.0.5, glob@^7.1.0, glob@^7.1.1: version "7.1.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== @@ -1227,6 +1381,26 @@ glob@^7.0.5, glob@^7.1.0, glob@^7.1.1: once "^1.3.0" path-is-absolute "^1.0.0" +global-modules@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-1.0.0.tgz#6d770f0eb523ac78164d72b5e71a8877265cc3ea" + integrity sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg== + dependencies: + global-prefix "^1.0.1" + is-windows "^1.0.1" + resolve-dir "^1.0.0" + +global-prefix@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-1.0.2.tgz#dbf743c6c14992593c655568cb66ed32c0122ebe" + integrity sha1-2/dDxsFJklk8ZVVoy2btMsASLr4= + dependencies: + expand-tilde "^2.0.2" + homedir-polyfill "^1.0.1" + ini "^1.3.4" + is-windows "^1.0.1" + which "^1.2.14" + graceful-fs@^4.1.11, graceful-fs@^4.1.2: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -1254,6 +1428,11 @@ has-flag@^3.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= +has-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" + integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= + has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" @@ -1290,7 +1469,7 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" -has@^1.0.0: +has@^1.0.0, has@^1.0.1, has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== @@ -1313,10 +1492,10 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.1" -he@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" - integrity sha1-k0EP0hsAlzUVH4howvJx80J+I/0= +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== hmac-drbg@^1.0.0: version "1.0.1" @@ -1327,6 +1506,13 @@ hmac-drbg@^1.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" +homedir-polyfill@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" + integrity sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA== + dependencies: + parse-passwd "^1.0.0" + htmlescape@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/htmlescape/-/htmlescape-1.1.1.tgz#3a03edc2214bca3b66424a3e7959349509cb0351" @@ -1405,7 +1591,7 @@ inherits@2.0.1: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" integrity sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE= -ini@~1.3.0: +ini@^1.3.4, ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== @@ -1433,6 +1619,11 @@ insert-module-globals@^7.0.0: undeclared-identifiers "^1.1.2" xtend "^4.0.0" +invert-kv@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" + integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA== + is-accessor-descriptor@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" @@ -1459,6 +1650,16 @@ is-buffer@^1.1.0, is-buffer@^1.1.5: resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== +is-buffer@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725" + integrity sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw== + +is-callable@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" + integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== + is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -1473,6 +1674,11 @@ is-data-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" +is-date-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" + integrity sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY= + is-descriptor@^0.1.0: version "0.1.6" resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" @@ -1553,7 +1759,26 @@ is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" -is-windows@^1.0.2: +is-regex@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" + integrity sha1-VRdIm1RwkbCTDglWVM7SXul+lJE= + dependencies: + has "^1.0.1" + +is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= + +is-symbol@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.2.tgz#a055f6ae57192caee329e7a860118b497a950f38" + integrity sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw== + dependencies: + has-symbols "^1.0.0" + +is-windows@^1.0.1, is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== @@ -1597,6 +1822,14 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= +js-yaml@3.12.0: + version "3.12.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" + integrity sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + json-stable-stringify@~0.0.0: version "0.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz#611c23e814db375527df851193db59dd2af27f45" @@ -1705,6 +1938,21 @@ labeled-stream-splicer@^2.0.0: isarray "^2.0.4" stream-splicer "^2.0.0" +lcid@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" + integrity sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA== + dependencies: + invert-kv "^2.0.0" + +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" @@ -1715,11 +1963,18 @@ lodash.memoize@~3.0.3: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" integrity sha1-LcvSwofLwKVcxCMovQxzYVDVPj8= -lodash@^4.17.4, lodash@^4.5.0: +lodash@^4.17.11, lodash@^4.17.4, lodash@^4.5.0: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== +log-symbols@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" + integrity sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== + dependencies: + chalk "^2.0.1" + log4js@^3.0.0: version "3.0.6" resolved "https://registry.yarnpkg.com/log4js/-/log4js-3.0.6.tgz#e6caced94967eeeb9ce399f9f8682a4b2b28c8ff" @@ -1736,6 +1991,13 @@ lru-cache@2.2.x: resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d" integrity sha1-bGWGGb7PFAMdDQtZSxYELOTcBj0= +map-age-cleaner@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" + integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== + dependencies: + p-defer "^1.0.0" + map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -1762,7 +2024,16 @@ media-typer@0.3.0: resolved "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -micromatch@^3.1.10, micromatch@^3.1.4: +mem@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-4.1.0.tgz#aeb9be2d21f47e78af29e4ac5978e8afa2ca5b8a" + integrity sha512-I5u6Q1x7wxO0kdOpYBB28xueHADYps5uty/zg936CiG8NTe5sJL8EjrCuLneuDW3PlMdZBGDIn8BirEVdovZvg== + dependencies: + map-age-cleaner "^0.1.1" + mimic-fn "^1.0.0" + p-is-promise "^2.0.0" + +micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== @@ -1806,6 +2077,11 @@ mime@^2.3.1: resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369" integrity sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg== +mimic-fn@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" + integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== + minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" @@ -1868,22 +2144,34 @@ mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1: dependencies: minimist "0.0.8" -mocha@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6" - integrity sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ== +mocha@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-6.0.2.tgz#cdc1a6fdf66472c079b5605bac59d29807702d2c" + integrity sha512-RtTJsmmToGyeTznSOMoM6TPEk1A84FQaHIciKrRqARZx+B5ccJ5tXlmJzEKGBxZdqk9UjpRsesZTUkZmR5YnuQ== dependencies: + ansi-colors "3.2.3" browser-stdout "1.3.1" - commander "2.15.1" - debug "3.1.0" + debug "3.2.6" diff "3.5.0" escape-string-regexp "1.0.5" - glob "7.1.2" + findup-sync "2.0.0" + glob "7.1.3" growl "1.10.5" - he "1.1.1" + he "1.2.0" + js-yaml "3.12.0" + log-symbols "2.2.0" minimatch "3.0.4" mkdirp "0.5.1" - supports-color "5.4.0" + ms "2.1.1" + node-environment-flags "1.0.4" + object.assign "4.1.0" + strip-json-comments "2.0.1" + supports-color "6.0.0" + which "1.3.1" + wide-align "1.1.3" + yargs "12.0.5" + yargs-parser "11.1.1" + yargs-unparser "1.5.0" module-deps@^6.0.0: version "6.1.0" @@ -1911,7 +2199,7 @@ ms@2.0.0: resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= -ms@^2.1.1: +ms@2.1.1, ms@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== @@ -1952,6 +2240,18 @@ negotiator@0.6.1: resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" integrity sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk= +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + +node-environment-flags@1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.4.tgz#0b784a6551426bfc16d3b2208424dcbc2b2ff038" + integrity sha512-M9rwCnWVLW7PX+NUWe3ejEdiLYinRpsEre9hMkU/6NS4h+EEulYaDH1gCEZ2gyXsmw+RXYDaV2JkkTNcsPDJ0Q== + dependencies: + object.getownpropertydescriptors "^2.0.3" + node-pre-gyp@^0.10.0: version "0.10.3" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc" @@ -1996,6 +2296,13 @@ npm-packlist@^1.1.6: ignore-walk "^3.0.1" npm-bundled "^1.0.1" +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= + dependencies: + path-key "^2.0.0" + npmlog@^4.0.2: version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" @@ -2035,6 +2342,11 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" +object-keys@^1.0.11, object-keys@^1.0.12: + version "1.1.0" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.0.tgz#11bd22348dd2e096a045ab06f6c85bcc340fa032" + integrity sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg== + object-visit@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" @@ -2042,6 +2354,24 @@ object-visit@^1.0.0: dependencies: isobject "^3.0.0" +object.assign@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" + integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== + dependencies: + define-properties "^1.1.2" + function-bind "^1.1.1" + has-symbols "^1.0.0" + object-keys "^1.0.11" + +object.getownpropertydescriptors@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" + integrity sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY= + dependencies: + define-properties "^1.1.2" + es-abstract "^1.5.1" + object.pick@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" @@ -2056,7 +2386,7 @@ on-finished@~2.3.0: dependencies: ee-first "1.1.1" -once@^1.3.0: +once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= @@ -2081,6 +2411,15 @@ os-homedir@^1.0.0: resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= +os-locale@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" + integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q== + dependencies: + execa "^1.0.0" + lcid "^2.0.0" + mem "^4.0.0" + os-tmpdir@^1.0.0, os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -2094,6 +2433,40 @@ osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" +p-defer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" + integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= + +p-is-promise@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.0.0.tgz#7554e3d572109a87e1f3f53f6a7d85d1b194f4c5" + integrity sha512-pzQPhYMCAgLAKPWD2jC3Se9fEfrD9npNos0y150EeqZll7akhEgGhTW/slB6lHku8AvYGiJ+YJ5hfHKePPgFWg== + +p-limit@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" + integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ== + dependencies: + p-try "^2.0.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-try@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1" + integrity sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ== + pako@~1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258" @@ -2117,6 +2490,11 @@ parse-asn1@^5.0.0: evp_bytestokey "^1.0.0" pbkdf2 "^3.0.3" +parse-passwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" + integrity sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= + parseqs@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" @@ -2151,11 +2529,21 @@ path-dirname@^1.0.0: resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= +path-key@^2.0.0, path-key@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= + path-parse@^1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" @@ -2209,6 +2597,14 @@ public-encrypt@^4.0.0: randombytes "^2.0.1" safe-buffer "^5.1.2" +pump@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" + integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + punycode@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" @@ -2336,11 +2732,29 @@ repeat-string@^1.6.1: resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-main-filename@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" + integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= + requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= +resolve-dir@^1.0.0, resolve-dir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-1.0.1.tgz#79a40644c362be82f26effe739c9bb5382046f43" + integrity sha1-eaQGRMNivoLybv/nOcm7U4IEb0M= + dependencies: + expand-tilde "^2.0.0" + global-modules "^1.0.0" + resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -2405,12 +2819,12 @@ sax@^1.2.4: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== -semver@^5.3.0: +semver@^5.3.0, semver@^5.5.0: version "5.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== -set-blocking@~2.0.0: +set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= @@ -2456,6 +2870,18 @@ shasum@^1.0.0: json-stable-stringify "~0.0.0" sha.js "~2.4.4" +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= + shell-quote@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767" @@ -2585,6 +3011,11 @@ split-string@^3.0.1, split-string@^3.0.2: dependencies: extend-shallow "^3.0.0" +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= + static-extend@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -2657,7 +3088,7 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -"string-width@^1.0.2 || 2": +"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== @@ -2686,7 +3117,12 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" -strip-json-comments@~2.0.1: +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= + +strip-json-comments@2.0.1, strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= @@ -2698,10 +3134,17 @@ subarg@^1.0.0: dependencies: minimist "^1.1.0" -supports-color@5.4.0: - version "5.4.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54" - integrity sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w== +supports-color@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a" + integrity sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg== + dependencies: + has-flag "^3.0.0" + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== dependencies: has-flag "^3.0.0" @@ -2926,14 +3369,19 @@ void-elements@^2.0.0: resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= -which@^1.2.1: +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= + +which@1.3.1, which@^1.2.1, which@^1.2.14, which@^1.2.9: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== dependencies: isexe "^2.0.0" -wide-align@^1.1.0: +wide-align@1.1.3, wide-align@^1.1.0: version "1.1.3" resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== @@ -2945,6 +3393,14 @@ wordwrap@~0.0.2: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc= +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -2969,11 +3425,51 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= +"y18n@^3.2.1 || ^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" + integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== + yallist@^3.0.0, yallist@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" integrity sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k= +yargs-parser@11.1.1, yargs-parser@^11.1.1: + version "11.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4" + integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs-unparser@1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.5.0.tgz#f2bb2a7e83cbc87bb95c8e572828a06c9add6e0d" + integrity sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw== + dependencies: + flat "^4.1.0" + lodash "^4.17.11" + yargs "^12.0.5" + +yargs@12.0.5, yargs@^12.0.5: + version "12.0.5" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13" + integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw== + dependencies: + cliui "^4.0.0" + decamelize "^1.2.0" + find-up "^3.0.0" + get-caller-file "^1.0.1" + os-locale "^3.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1 || ^4.0.0" + yargs-parser "^11.1.1" + yeast@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" From caa02fbbd8bb02b6e975d86a514201dbc7840c19 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Fri, 8 Mar 2019 09:30:07 +0200 Subject: [PATCH 084/108] updated to 0.3.10 --- dist/wallet-address-validator.js | 168 ++++++++++++++++++--------- dist/wallet-address-validator.min.js | 2 +- package.json | 2 +- 3 files changed, 115 insertions(+), 57 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 73c7904a..35a9cda1 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,85 +1,143 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i= 255) throw new TypeError('Alphabet too long') + + const BASE_MAP = new Uint8Array(256) + BASE_MAP.fill(255) - // pre-compute lookup table - for (var z = 0; z < ALPHABET.length; z++) { - var x = ALPHABET.charAt(z) + for (let i = 0; i < ALPHABET.length; i++) { + const x = ALPHABET.charAt(i) + const xc = x.charCodeAt(0) - if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous') - ALPHABET_MAP[x] = z + if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous') + BASE_MAP[xc] = i } + const BASE = ALPHABET.length + const LEADER = ALPHABET.charAt(0) + const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up + function encode (source) { + if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer') if (source.length === 0) return '' - var digits = [0] - for (var i = 0; i < source.length; ++i) { - for (var j = 0, carry = source[i]; j < digits.length; ++j) { - carry += digits[j] << 8 - digits[j] = carry % BASE - carry = (carry / BASE) | 0 - } + // Skip & count leading zeroes. + let zeroes = 0 + let length = 0 + let pbegin = 0 + const pend = source.length + + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++ + zeroes++ + } - while (carry > 0) { - digits.push(carry % BASE) - carry = (carry / BASE) | 0 + // Allocate enough space in big-endian base58 representation. + const size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + const b58 = new Uint8Array(size) + + // Process the bytes. + while (pbegin !== pend) { + let carry = source[pbegin] + + // Apply "b58 = b58 * 256 + ch". + let i = 0 + for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { + carry += (256 * b58[it]) >>> 0 + b58[it] = (carry % BASE) >>> 0 + carry = (carry / BASE) >>> 0 } + + if (carry !== 0) throw new Error('Non-zero carry') + length = i + pbegin++ } - var string = '' + // Skip leading zeroes in base58 result. + let it = size - length + while (it !== size && b58[it] === 0) { + it++ + } - // deal with leading zeros - for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER - // convert digits to a string - for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] + // Translate the result into a string. + let str = LEADER.repeat(zeroes) + for (; it < size; ++it) str += ALPHABET.charAt(b58[it]) - return string + return str } - function decodeUnsafe (string) { - if (typeof string !== 'string') throw new TypeError('Expected String') - if (string.length === 0) return Buffer.allocUnsafe(0) + function decodeUnsafe (source) { + if (typeof source !== 'string') throw new TypeError('Expected String') + if (source.length === 0) return Buffer.alloc(0) - var bytes = [0] - for (var i = 0; i < string.length; i++) { - var value = ALPHABET_MAP[string[i]] - if (value === undefined) return + let psz = 0 - for (var j = 0, carry = value; j < bytes.length; ++j) { - carry += bytes[j] * BASE - bytes[j] = carry & 0xff - carry >>= 8 - } + // Skip leading spaces. + if (source[psz] === ' ') return + + // Skip and count leading '1's. + let zeroes = 0 + let length = 0 + while (source[psz] === LEADER) { + zeroes++ + psz++ + } + + // Allocate enough space in big-endian base256 representation. + const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + const b256 = new Uint8Array(size) + + // Process the characters. + while (source[psz]) { + // Decode character + let carry = BASE_MAP[source.charCodeAt(psz)] - while (carry > 0) { - bytes.push(carry & 0xff) - carry >>= 8 + // Invalid character + if (carry === 255) return + + let i = 0 + for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { + carry += (BASE * b256[it]) >>> 0 + b256[it] = (carry % 256) >>> 0 + carry = (carry / 256) >>> 0 } + + if (carry !== 0) throw new Error('Non-zero carry') + length = i + psz++ + } + + // Skip trailing spaces. + if (source[psz] === ' ') return + + // Skip leading zeroes in b256. + let it = size - length + while (it !== size && b256[it] === 0) { + it++ } - // deal with leading zeros - for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { - bytes.push(0) + const vch = Buffer.allocUnsafe(zeroes + (size - it)) + vch.fill(0x00, 0, zeroes) + + let j = zeroes + while (it !== size) { + vch[j++] = b256[it++] } - return Buffer.from(bytes.reverse()) + return vch } function decode (string) { - var buffer = decodeUnsafe(string) + const buffer = decodeUnsafe(string) if (buffer) return buffer throw new Error('Non-base' + BASE + ' character') @@ -11782,9 +11840,9 @@ module.exports = { }; //spit out details for readme.md - CURRENCIES - .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) - .forEach(c => console.log(`* ${c.name}/${c.symbol} \`'${c.name}'\` or \`'${c.symbol}'\` `)); +// CURRENCIES +// .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) +// .forEach(c => console.log(`* ${c.name}/${c.symbol} \`'${c.name}'\` or \`'${c.symbol}'\` `)); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 8f0ab8b7..087c3725 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o7&&t[r].toUpperCase()!==t[r]||parseInt(e[r],16)<=7&&t[r].toLowerCase()!==t[r])return!1;return!0}}},{"./crypto/utils":136}],139:[function(t,e,r){(function(r){var n=t("./crypto/utils"),o=new RegExp("^[0-9]{1,20}L$");e.exports={isValidAddress:function(t){return!!o.test(t)&&this.verifyAddress(t)},verifyAddress:function(t){var e=t.substring(0,t.length-1),o=n.bigNumberToBuffer(e);return r.from(o).slice(0,8).equals(o)}}}).call(this,t("buffer").Buffer)},{"./crypto/utils":136,buffer:4}],140:[function(t,e,r){var n=t("./crypto/utils"),o=t("./crypto/cnBase58"),i=new RegExp("^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$"),a=new RegExp("^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$");e.exports={isValidAddress:function(t,e,r){r=r||"prod";var s="standard";if(!i.test(t)){if(!a.test(t))return!1;s="integrated"}var u=o.decode(t);return!!u&&(!!function(t,e,r,n){var o=e.addressTypes;"integrated"==n&&(o=e.iAddressTypes);var i=parseInt(t.substr(0,2),16).toString();switch(r){case"prod":return o.prod.indexOf(i)>=0;case"testnet":return o.testnet.indexOf(i)>=0;case"both":return o.prod.indexOf(i)>=0||o.testnet.indexOf(i)>=0;default:return!1}}(u,e,r,s)&&u.slice(-8)===n.keccak256Checksum(function(t){if(t.length%2!=0)return null;for(var e=new Uint8Array(t.length/2),r=0;r>8&255)===i.toHex(r.slice(-2))}}},{"./crypto/utils":136,"base-x":1,crc:30}],146:[function(t,e,r){var n=t("./crypto/utils");e.exports={isValidAddress:function(t,e,r){var o=function(t){if("string"!=typeof t)return!1;if(t.length<=4)return!1;try{var e=n.base58(t)}catch(t){return!1}var r=e.length-4,o=e.slice(r);e=e.slice(0,r);var i=n.sha256(n.byteArray2hexStr(e)),a=n.hexStr2byteArray(n.sha256(i)).slice(0,4);return o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]&&o[3]===a[3]&&e}(t);return!!o&&(21===o.length&&function(t,e){var r=e||"prod";return"prod"!==r&&"testnet"!==r&&(r="prod"),t.addressTypes[r][0]}(e,r)===o[0])}}},{"./crypto/utils":136}],147:[function(t,e,r){var n=t("./currencies");e.exports={validate:function(t,e,r){var o=n.getByNameOrSymbol(e||"bitcoin");if(o&&o.validator)return o.validator.isValidAddress(t,o,r);throw new Error("Missing validator for currency: "+e)}}},{"./currencies":137}]},{},[147])(147)}); +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);e.fill(255);for(let r=0;r>>0,c=new Uint8Array(f);for(;t[a];){let n=e[t.charCodeAt(a)];if(255===n)return;let o=0;for(let t=f-1;(0!==n||o>>0,c[t]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");u=o,a++}if(" "===t[a])return;let l=f-u;for(;l!==f&&0===c[l];)l++;const h=n.allocUnsafe(s+(f-l));h.fill(0,0,s);let p=s;for(;l!==f;)h[p++]=c[l++];return h}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";let i=0,s=0,u=0;const f=e.length;for(;u!==f&&0===e[u];)u++,i++;const c=(f-u)*a+1>>>0,l=new Uint8Array(c);for(;u!==f;){let t=e[u],n=0;for(let e=c-1;(0!==t||n>>0,l[e]=t%r>>>0,t=t/r>>>0;if(0!==t)throw new Error("Non-zero carry");s=n,u++}let h=c-s;for(;h!==c&&0===l[h];)h++;let p=o.repeat(i);for(;h0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Returns true if the address (string) is a valid wallet address for the crypto currency specified, see below for supported currencies. ### Supported crypto currencies -* 0x/zrx `'0x'` or `'zrx'` -* Aragon/ant `'Aragon'` or `'ant'` -* Augur/rep `'Augur'` or `'rep'` -* AuroraCoin/aur `'AuroraCoin'` or `'aur'` -* Bancor/bnt `'Bancor'` or `'bnt'` -* Bankex/bkx `'Bankex'` or `'bkx'` -* Basic Attention Token/bat `'Basic Attention Token'` or `'bat'` -* BeaverCoin/bvc `'BeaverCoin'` or `'bvc'` -* BioCoin/bio `'BioCoin'` or `'bio'` -* Bitcoin/btc `'Bitcoin'` or `'btc'` -* Bitcoin SV/bsv `'Bitcoin SV'` or `'bsv'` -* BitcoinCash/bch `'BitcoinCash'` or `'bch'` -* BitcoinGold/btg `'BitcoinGold'` or `'btg'` -* BitcoinPrivate/btcp `'BitcoinPrivate'` or `'btcp'` -* BitcoinZ/btcz `'BitcoinZ'` or `'btcz'` -* Callisto/clo `'Callisto'` or `'clo'` -* Cardano/ada `'Cardano'` or `'ada'` -* Civic/cvc `'Civic'` or `'cvc'` -* Dash/dash `'Dash'` or `'dash'` -* Decred/dcr `'Decred'` or `'dcr'` -* DigiByte/dgb `'DigiByte'` or `'dgb'` -* District0x/dnt `'District0x'` or `'dnt'` -* DogeCoin/doge `'DogeCoin'` or `'doge'` -* Ethereum/eth `'Ethereum'` or `'eth'` -* EthereumClassic/etc `'EthereumClassic'` or `'etc'` -* EtherZero/etz `'EtherZero'` or `'etz'` -* Expanse/exp `'Expanse'` or `'exp'` -* FreiCoin/frc `'FreiCoin'` or `'frc'` -* GameCredits/game `'GameCredits'` or `'game'` -* GarliCoin/grlc `'GarliCoin'` or `'grlc'` -* Gnosis/gno `'Gnosis'` or `'gno'` -* Golem/gnt `'Golem'` or `'gnt'` -* Hush/hush `'Hush'` or `'hush'` -* hyperspace/xsc `'hyperspace'` or `'xsc'` -* iExec RLC/rlc `'iExec RLC'` or `'rlc'` -* Komodo/kmd `'Komodo'` or `'kmd'` -* lbry/lbc `'lbry'` or `'lbc'` -* lisk/lsk `'lisk'` or `'lsk'` -* LiteCoin/ltc `'LiteCoin'` or `'ltc'` -* loki/loki `'loki'` or `'loki'` -* Matchpool/gup `'Matchpool'` or `'gup'` -* MegaCoin/mec `'MegaCoin'` or `'mec'` -* Melon/mln `'Melon'` or `'mln'` -* MonaCoin/mona `'MonaCoin'` or `'mona'` -* Monero/xmr `'Monero'` or `'xmr'` -* NameCoin/nmc `'NameCoin'` or `'nmc'` -* Nano/nano `'Nano'` or `'nano'` -* nem/xem `'nem'` or `'xem'` -* Neo/neo `'Neo'` or `'neo'` -* NeoGas/gas `'NeoGas'` or `'gas'` -* Numeraire/nmr `'Numeraire'` or `'nmr'` -* Odyssey/ocn `'Odyssey'` or `'ocn'` -* OmiseGO/omg `'OmiseGO'` or `'omg'` -* PeerCoin/ppc `'PeerCoin'` or `'ppc'` -* PIVX/pivx `'PIVX'` or `'pivx'` -* Polymath/poly `'Polymath'` or `'poly'` -* PrimeCoin/xpm `'PrimeCoin'` or `'xpm'` -* ProtoShares/pts `'ProtoShares'` or `'pts'` -* Qtum/qtum `'Qtum'` or `'qtum'` -* RaiBlocks/xrb `'RaiBlocks'` or `'xrb'` -* Ripio Credit Network/rcn `'Ripio Credit Network'` or `'rcn'` -* Ripple/xrp `'Ripple'` or `'xrp'` -* Salt/salt `'Salt'` or `'salt'` -* siacoin/sc `'siacoin'` or `'sc'` -* SnowGem/sng `'SnowGem'` or `'sng'` -* SolarCoin/slr `'SolarCoin'` or `'slr'` -* Status/snt `'Status'` or `'snt'` -* stellar/xlm `'stellar'` or `'xlm'` -* Storj/storj `'Storj'` or `'storj'` -* Storm/storm `'Storm'` or `'storm'` -* Swarm City/swt `'Swarm City'` or `'swt'` -* TenX/pay `'TenX'` or `'pay'` -* Tether/usdt `'Tether'` or `'usdt'` -* tron/trx `'tron'` or `'trx'` -* TrueUSD/tusd `'TrueUSD'` or `'tusd'` -* VertCoin/vtc `'VertCoin'` or `'vtc'` -* Viberate/vib `'Viberate'` or `'vib'` -* VoteCoin/vot `'VoteCoin'` or `'vot'` -* Waves/waves `'Waves'` or `'waves'` -* Wings/wings `'Wings'` or `'wings'` -* ZCash/zec `'ZCash'` or `'zec'` -* ZClassic/zcl `'ZClassic'` or `'zcl'` +* 0x/zrx `'0x'` or `'zrx'` +* Aragon/ant `'Aragon'` or `'ant'` +* Augur/rep `'Augur'` or `'rep'` +* AuroraCoin/aur `'AuroraCoin'` or `'aur'` +* Bancor/bnt `'Bancor'` or `'bnt'` +* Bankex/bkx `'Bankex'` or `'bkx'` +* Basic Attention Token/bat `'Basic Attention Token'` or `'bat'` +* BeaverCoin/bvc `'BeaverCoin'` or `'bvc'` +* BioCoin/bio `'BioCoin'` or `'bio'` +* Bitcoin/btc `'Bitcoin'` or `'btc'` +* Bitcoin SV/bsv `'Bitcoin SV'` or `'bsv'` +* BitcoinCash/bch `'BitcoinCash'` or `'bch'` +* BitcoinGold/btg `'BitcoinGold'` or `'btg'` +* BitcoinPrivate/btcp `'BitcoinPrivate'` or `'btcp'` +* BitcoinZ/btcz `'BitcoinZ'` or `'btcz'` +* BTU Protocol/btu `'BTU Protocol'` or `'btu'` +* Callisto/clo `'Callisto'` or `'clo'` +* Cardano/ada `'Cardano'` or `'ada'` +* Chainlink/link `'Chainlink'` or `'link'` +* Civic/cvc `'Civic'` or `'cvc'` +* Cred/lba `'Cred'` or `'lba'` +* Crypto.com Coin/cro `'Crypto.com Coin'` or `'cro'` +* Dash/dash `'Dash'` or `'dash'` +* Decred/dcr `'Decred'` or `'dcr'` +* DigiByte/dgb `'DigiByte'` or `'dgb'` +* District0x/dnt `'District0x'` or `'dnt'` +* DogeCoin/doge `'DogeCoin'` or `'doge'` +* Enjin Coin/enj `'Enjin Coin'` or `'enj'` +* Ethereum/eth `'Ethereum'` or `'eth'` +* EthereumClassic/etc `'EthereumClassic'` or `'etc'` +* EtherZero/etz `'EtherZero'` or `'etz'` +* Expanse/exp `'Expanse'` or `'exp'` +* FreiCoin/frc `'FreiCoin'` or `'frc'` +* GameCredits/game `'GameCredits'` or `'game'` +* GarliCoin/grlc `'GarliCoin'` or `'grlc'` +* Gnosis/gno `'Gnosis'` or `'gno'` +* Golem/gnt `'Golem'` or `'gnt'` +* HedgeTrade/hedg `'HedgeTrade'` or `'hedg'` +* Hush/hush `'Hush'` or `'hush'` +* iExec RLC/rlc `'iExec RLC'` or `'rlc'` +* Komodo/kmd `'Komodo'` or `'kmd'` +* LBRY Credits/lbc `'LBRY Credits'` or `'lbc'` +* Lisk/lsk `'Lisk'` or `'lsk'` +* LiteCoin/ltc `'LiteCoin'` or `'ltc'` +* Loki/loki `'Loki'` or `'loki'` +* Loom Network/loom `'Loom Network'` or `'loom'` +* Maker/mkr `'Maker'` or `'mkr'` +* Matchpool/gup `'Matchpool'` or `'gup'` +* MegaCoin/mec `'MegaCoin'` or `'mec'` +* Melon/mln `'Melon'` or `'mln'` +* Metal/mtl `'Metal'` or `'mtl'` +* MonaCoin/mona `'MonaCoin'` or `'mona'` +* Monero/xmr `'Monero'` or `'xmr'` +* Multi-collateral DAI/dai `'Multi-collateral DAI'` or `'dai'` +* NameCoin/nmc `'NameCoin'` or `'nmc'` +* Nano/nano `'Nano'` or `'nano'` +* Nem/xem `'Nem'` or `'xem'` +* Neo/neo `'Neo'` or `'neo'` +* NeoGas/gas `'NeoGas'` or `'gas'` +* Numeraire/nmr `'Numeraire'` or `'nmr'` +* Ocean Protocol/ocean `'Ocean Protocol'` or `'ocean'` +* Odyssey/ocn `'Odyssey'` or `'ocn'` +* OmiseGO/omg `'OmiseGO'` or `'omg'` +* PeerCoin/ppc `'PeerCoin'` or `'ppc'` +* PIVX/pivx `'PIVX'` or `'pivx'` +* Polymath/poly `'Polymath'` or `'poly'` +* PrimeCoin/xpm `'PrimeCoin'` or `'xpm'` +* ProtoShares/pts `'ProtoShares'` or `'pts'` +* Qtum/qtum `'Qtum'` or `'qtum'` +* Quant/qnt `'Quant'` or `'qnt'` +* RaiBlocks/xrb `'RaiBlocks'` or `'xrb'` +* Ripio Credit Network/rcn `'Ripio Credit Network'` or `'rcn'` +* Ripple/xrp `'Ripple'` or `'xrp'` +* Salt/salt `'Salt'` or `'salt'` +* Siacoin/sc `'Siacoin'` or `'sc'` +* SnowGem/sng `'SnowGem'` or `'sng'` +* SolarCoin/slr `'SolarCoin'` or `'slr'` +* SOLVE/solve `'SOLVE'` or `'solve'` +* Spendcoin/spnd `'Spendcoin'` or `'spnd'` +* Status/snt `'Status'` or `'snt'` +* Stellar/xlm `'Stellar'` or `'xlm'` +* Storj/storj `'Storj'` or `'storj'` +* Storm/storm `'Storm'` or `'storm'` +* Swarm City/swt `'Swarm City'` or `'swt'` +* Synthetix Network/snx `'Synthetix Network'` or `'snx'` +* TEMCO/temco `'TEMCO'` or `'temco'` +* TenX/pay `'TenX'` or `'pay'` +* Tether/usdt `'Tether'` or `'usdt'` +* Tron/trx `'Tron'` or `'trx'` +* TrueUSD/tusd `'TrueUSD'` or `'tusd'` +* VertCoin/vtc `'VertCoin'` or `'vtc'` +* Viberate/vib `'Viberate'` or `'vib'` +* VoteCoin/vot `'VoteCoin'` or `'vot'` +* Waves/waves `'Waves'` or `'waves'` +* Wings/wings `'Wings'` or `'wings'` +* ZCash/zec `'ZCash'` or `'zec'` +* ZClassic/zcl `'ZClassic'` or `'zcl'` * ZenCash/zen `'ZenCash'` or `'zen'` ### Usage example diff --git a/package.json b/package.json index c4b6420c..ff212d77 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "browser", "nodejs" ], - "version": "0.3.10", + "version": "0.3.11", "author": "Chris ", "homepage": "https://github.com/christsim/multicoin-address-validator", "license": "MIT", @@ -53,20 +53,20 @@ "start": "npm run bundle && npm run minify && npm test" }, "dependencies": { - "base-x": "^3.0.5", + "base-x": "^3.0.7", "browserify-bignum": "^1.3.0-2", "cbor-js": "^0.1.0", "crc": "^3.8.0", "jssha": "2.3.1" }, "devDependencies": { - "browserify": "^16.2.3", + "browserify": "^16.5.0", "chai": "^4.2.0", - "karma": "^3.1.1", + "karma": "^4.4.1", "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^2.2.0", + "karma-chrome-launcher": "^3.1.0", "karma-mocha": "^1.3.0", - "mocha": "^6.0.2", + "mocha": "^7.0.0", "uglify-es": "^3.3.9" } } diff --git a/src/currencies.js b/src/currencies.js index 993515e9..061aeaac 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -12,399 +12,467 @@ var BCHValidator = require('./bch_validator'); var XLMValidator = require('./stellar_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks -var CURRENCIES = [{ - name: 'Bitcoin', - symbol: 'btc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26']}, - validator: BTCValidator -}, { - name: 'BitcoinCash', - symbol: 'bch', - regexp: '^[qQpP]{1}[0-9a-zA-Z]{41}$', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BCHValidator -}, { - name: 'Bitcoin SV', - symbol: 'bsv', - regexp: '^[qQ]{1}[0-9a-zA-Z]{41}$', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BCHValidator -}, { - name: 'LiteCoin', - symbol: 'ltc', - addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, - validator: BTCValidator -}, { - name: 'PeerCoin', - symbol: 'ppc', - addressTypes: { prod: ['37', '75'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'DogeCoin', - symbol: 'doge', - addressTypes: { prod: ['1e', '16'], testnet: ['71', 'c4'] }, - validator: BTCValidator -}, { - name: 'BeaverCoin', - symbol: 'bvc', - addressTypes: { prod: ['19', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator, -}, { - name: 'FreiCoin', - symbol: 'frc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'ProtoShares', - symbol: 'pts', - addressTypes: { prod: ['38', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'MegaCoin', - symbol: 'mec', - addressTypes: { prod: ['32', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'PrimeCoin', - symbol: 'xpm', - addressTypes: { prod: ['17', '53'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'AuroraCoin', - symbol: 'aur', - addressTypes: { prod: ['17', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'NameCoin', - symbol: 'nmc', - addressTypes: { prod: ['34'], testnet: [] }, - validator: BTCValidator -}, { - name: 'BioCoin', - symbol: 'bio', - addressTypes: { prod: ['19', '14'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'GarliCoin', - symbol: 'grlc', - addressTypes: { prod: ['26', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'VertCoin', - symbol: 'vtc', - addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - -}, { - name: 'BitcoinGold', - symbol: 'btg', - addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'Komodo', - symbol: 'kmd', - addressTypes: { prod: ['3c', '55'], testnet: ['0', '5'] }, - validator: BTCValidator -}, { - name: 'BitcoinZ', - symbol: 'btcz', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'BitcoinPrivate', - symbol: 'btcp', - expectedLength: 26, - addressTypes: { prod: ['1325', '13af'], testnet: ['1957', '19e0'] }, - validator: BTCValidator -}, { - name: 'Hush', - symbol: 'hush', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'SnowGem', - symbol: 'sng', - expectedLength: 26, - addressTypes: { prod: ['1c28', '1c2d'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'ZCash', - symbol: 'zec', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'ZClassic', - symbol: 'zcl', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'ZenCash', - symbol: 'zen', - expectedLength: 26, - addressTypes: { prod: ['2089', '2096'], testnet: ['2092', '2098'] }, - validator: BTCValidator -}, { - name: 'VoteCoin', - symbol: 'vot', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'Decred', - symbol: 'dcr', - addressTypes: { prod: ['073f', '071a'], testnet: ['0f21', '0efc'] }, - hashFunction: 'blake256', - expectedLength: 26, - validator: BTCValidator -}, { - name: 'GameCredits', - symbol: 'game', - addressTypes: { prod: ['26', '05'], testnet: [] }, - validator: BTCValidator -}, { - name: 'PIVX', - symbol: 'pivx', - addressTypes: { prod: ['1e', '0d'], testnet: [] }, - validator: BTCValidator -}, { - name: 'SolarCoin', - symbol: 'slr', - addressTypes: { prod: ['12', '05'], testnet: [] }, - validator: BTCValidator -}, { - name: 'MonaCoin', - symbol: 'mona', - addressTypes: { prod: ['32', '37'], testnet: [] }, - validator: BTCValidator -}, { - name: 'DigiByte', - symbol: 'dgb', - addressTypes: { prod: ['1e'], testnet: [] }, - validator: BTCValidator -}, { - name: 'Tether', - symbol: 'usdt', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'Ripple', - symbol: 'xrp', - validator: XRPValidator, -}, { - name: 'Dash', - symbol: 'dash', - addressTypes: { prod: ['4c', '10'], testnet: ['8c', '13'] }, - validator: BTCValidator -}, { - name: 'Neo', - symbol: 'neo', - addressTypes: { prod: ['17'], testnet: [] }, - validator: BTCValidator -}, { - name: 'NeoGas', - symbol: 'gas', - addressTypes: { prod: ['17'], testnet: [] }, - validator: BTCValidator -}, { - name: 'Qtum', - symbol: 'qtum', - addressTypes: { prod: ['3a', '32'], testnet: ['78', '6e'] }, - validator: BTCValidator -}, { - name: 'Waves', - symbol: 'waves', - addressTypes: { prod: ['0157'], testnet: ['0154'] }, - expectedLength: 26, - hashFunction: 'blake256keccak256', - regex: /^[a-zA-Z0-9]{35}$/, - validator: BTCValidator -}, { - name: 'Ethereum', - symbol: 'eth', - validator: ETHValidator, -}, { - name: 'EtherZero', - symbol: 'etz', - validator: ETHValidator, -}, { - name: 'EthereumClassic', - symbol: 'etc', - validator: ETHValidator, -}, { - name: 'Callisto', - symbol: 'clo', - validator: ETHValidator, -}, { - name: 'Bankex', - symbol: 'bkx', - validator: ETHValidator -}, { - name: 'Cardano', - symbol: 'ada', - validator: ADAValidator -}, { - name: 'Monero', - symbol: 'xmr', - addressTypes: { prod: ['18'], testnet: ['53'] }, - iAddressTypes: { prod: ['19'], testnet: ['54'] }, - validator: XMRValidator -}, { - name: 'Aragon', - symbol: 'ant', - validator: ETHValidator -}, { - name: 'Basic Attention Token', - symbol: 'bat', - validator: ETHValidator -}, { - name: 'Bancor', - symbol: 'bnt', - validator: ETHValidator -}, { - name: 'Civic', - symbol: 'cvc', - validator: ETHValidator -}, { - name: 'District0x', - symbol: 'dnt', - validator: ETHValidator -}, { - name: 'Gnosis', - symbol: 'gno', - validator: ETHValidator -}, { - name: 'Golem', - symbol: 'gnt', - validator: ETHValidator -}, { - name: 'Matchpool', - symbol: 'gup', - validator: ETHValidator -}, { - name: 'Melon', - symbol: 'mln', - validator: ETHValidator -}, { - name: 'Numeraire', - symbol: 'nmr', - validator: ETHValidator -}, { - name: 'OmiseGO', - symbol: 'omg', - validator: ETHValidator -}, { - name: 'TenX', - symbol: 'pay', - validator: ETHValidator -}, { - name: 'Ripio Credit Network', - symbol: 'rcn', - validator: ETHValidator -}, { - name: 'Augur', - symbol: 'rep', - validator: ETHValidator -}, { - name: 'iExec RLC', - symbol: 'rlc', - validator: ETHValidator -}, { - name: 'Salt', - symbol: 'salt', - validator: ETHValidator -}, { - name: 'Status', - symbol: 'snt', - validator: ETHValidator -}, { - name: 'Storj', - symbol: 'storj', - validator: ETHValidator -}, { - name: 'Swarm City', - symbol: 'swt', - validator: ETHValidator -}, { - name: 'TrueUSD', - symbol: 'tusd', - validator: ETHValidator -}, { - name: 'Wings', - symbol: 'wings', - validator: ETHValidator -}, { - name: '0x', - symbol: 'zrx', - validator: ETHValidator -}, { - name: 'Expanse', - symbol: 'exp', - validator: ETHValidator -}, { - name: 'Viberate', - symbol: 'vib', - validator: ETHValidator -}, { - name: 'Odyssey', - symbol: 'ocn', - validator: ETHValidator -}, { - name: 'Polymath', - symbol: 'poly', - validator: ETHValidator -}, { - name: 'Storm', - symbol: 'storm', - validator: ETHValidator -}, { - name: 'Nano', - symbol: 'nano', - validator: NANOValidator, -}, { - name: 'RaiBlocks', - symbol: 'xrb', - validator: NANOValidator, -}, { - name: 'siacoin', - symbol: 'sc', - validator: SCValidator -}, { - name: 'hyperspace', - symbol: 'xsc', - validator: SCValidator -}, { - name: 'loki', - symbol: 'loki', - addressTypes: { prod: ['114', '116'], testnet: [] }, - iAddressTypes: { prod: ['115'], testnet: [] }, - validator: XMRValidator -}, { - name: 'lbry', - symbol: 'lbc', - addressTypes: { prod: ['55'], testnet: [] }, - validator: BTCValidator -}, { - name: 'tron', - symbol: 'trx', - addressTypes: {prod: [0x41], testnet: [0xa0]}, - validator: TRXValidator -}, { - name: 'nem', - symbol: 'xem', - validator: NEMValidator -}, { - name: 'lisk', - symbol: 'lsk', - validator: LSKValidator -}, { - name: 'stellar', - symbol: 'xlm', - validator: XLMValidator, -}]; +var CURRENCIES = [ + { + name: 'Bitcoin', + symbol: 'btc', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26'] }, + validator: BTCValidator + }, { + name: 'BitcoinCash', + symbol: 'bch', + regexp: '^[qQpP]{1}[0-9a-zA-Z]{41}$', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BCHValidator + }, { + name: 'Bitcoin SV', + symbol: 'bsv', + regexp: '^[qQ]{1}[0-9a-zA-Z]{41}$', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BCHValidator + }, { + name: 'LiteCoin', + symbol: 'ltc', + addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, + validator: BTCValidator + }, { + name: 'PeerCoin', + symbol: 'ppc', + addressTypes: { prod: ['37', '75'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'DogeCoin', + symbol: 'doge', + addressTypes: { prod: ['1e', '16'], testnet: ['71', 'c4'] }, + validator: BTCValidator + }, { + name: 'BeaverCoin', + symbol: 'bvc', + addressTypes: { prod: ['19', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator, + }, { + name: 'FreiCoin', + symbol: 'frc', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'ProtoShares', + symbol: 'pts', + addressTypes: { prod: ['38', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'MegaCoin', + symbol: 'mec', + addressTypes: { prod: ['32', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'PrimeCoin', + symbol: 'xpm', + addressTypes: { prod: ['17', '53'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'AuroraCoin', + symbol: 'aur', + addressTypes: { prod: ['17', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'NameCoin', + symbol: 'nmc', + addressTypes: { prod: ['34'], testnet: [] }, + validator: BTCValidator + }, { + name: 'BioCoin', + symbol: 'bio', + addressTypes: { prod: ['19', '14'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'GarliCoin', + symbol: 'grlc', + addressTypes: { prod: ['26', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'VertCoin', + symbol: 'vtc', + addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + + }, { + name: 'BitcoinGold', + symbol: 'btg', + addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'Komodo', + symbol: 'kmd', + addressTypes: { prod: ['3c', '55'], testnet: ['0', '5'] }, + validator: BTCValidator + }, { + name: 'BitcoinZ', + symbol: 'btcz', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'BitcoinPrivate', + symbol: 'btcp', + expectedLength: 26, + addressTypes: { prod: ['1325', '13af'], testnet: ['1957', '19e0'] }, + validator: BTCValidator + }, { + name: 'Hush', + symbol: 'hush', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'SnowGem', + symbol: 'sng', + expectedLength: 26, + addressTypes: { prod: ['1c28', '1c2d'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'ZCash', + symbol: 'zec', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'ZClassic', + symbol: 'zcl', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'ZenCash', + symbol: 'zen', + expectedLength: 26, + addressTypes: { prod: ['2089', '2096'], testnet: ['2092', '2098'] }, + validator: BTCValidator + }, { + name: 'VoteCoin', + symbol: 'vot', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'Decred', + symbol: 'dcr', + addressTypes: { prod: ['073f', '071a'], testnet: ['0f21', '0efc'] }, + hashFunction: 'blake256', + expectedLength: 26, + validator: BTCValidator + }, { + name: 'GameCredits', + symbol: 'game', + addressTypes: { prod: ['26', '05'], testnet: [] }, + validator: BTCValidator + }, { + name: 'PIVX', + symbol: 'pivx', + addressTypes: { prod: ['1e', '0d'], testnet: [] }, + validator: BTCValidator + }, { + name: 'SolarCoin', + symbol: 'slr', + addressTypes: { prod: ['12', '05'], testnet: [] }, + validator: BTCValidator + }, { + name: 'MonaCoin', + symbol: 'mona', + addressTypes: { prod: ['32', '37'], testnet: [] }, + validator: BTCValidator + }, { + name: 'DigiByte', + symbol: 'dgb', + addressTypes: { prod: ['1e'], testnet: [] }, + validator: BTCValidator + }, { + name: 'Tether', + symbol: 'usdt', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'Ripple', + symbol: 'xrp', + validator: XRPValidator, + }, { + name: 'Dash', + symbol: 'dash', + addressTypes: { prod: ['4c', '10'], testnet: ['8c', '13'] }, + validator: BTCValidator + }, { + name: 'Neo', + symbol: 'neo', + addressTypes: { prod: ['17'], testnet: [] }, + validator: BTCValidator + }, { + name: 'NeoGas', + symbol: 'gas', + addressTypes: { prod: ['17'], testnet: [] }, + validator: BTCValidator + }, { + name: 'Qtum', + symbol: 'qtum', + addressTypes: { prod: ['3a', '32'], testnet: ['78', '6e'] }, + validator: BTCValidator + }, { + name: 'Waves', + symbol: 'waves', + addressTypes: { prod: ['0157'], testnet: ['0154'] }, + expectedLength: 26, + hashFunction: 'blake256keccak256', + regex: /^[a-zA-Z0-9]{35}$/, + validator: BTCValidator + }, { + name: 'Ethereum', + symbol: 'eth', + validator: ETHValidator, + }, { + name: 'EtherZero', + symbol: 'etz', + validator: ETHValidator, + }, { + name: 'EthereumClassic', + symbol: 'etc', + validator: ETHValidator, + }, { + name: 'Callisto', + symbol: 'clo', + validator: ETHValidator, + }, { + name: 'Bankex', + symbol: 'bkx', + validator: ETHValidator + }, { + name: 'Cardano', + symbol: 'ada', + validator: ADAValidator + }, { + name: 'Monero', + symbol: 'xmr', + addressTypes: { prod: ['18'], testnet: ['53'] }, + iAddressTypes: { prod: ['19'], testnet: ['54'] }, + validator: XMRValidator + }, { + name: 'Aragon', + symbol: 'ant', + validator: ETHValidator + }, { + name: 'Basic Attention Token', + symbol: 'bat', + validator: ETHValidator + }, { + name: 'Bancor', + symbol: 'bnt', + validator: ETHValidator + }, { + name: 'Civic', + symbol: 'cvc', + validator: ETHValidator + }, { + name: 'District0x', + symbol: 'dnt', + validator: ETHValidator + }, { + name: 'Gnosis', + symbol: 'gno', + validator: ETHValidator + }, { + name: 'Golem', + symbol: 'gnt', + validator: ETHValidator + }, { + name: 'Matchpool', + symbol: 'gup', + validator: ETHValidator + }, { + name: 'Melon', + symbol: 'mln', + validator: ETHValidator + }, { + name: 'Numeraire', + symbol: 'nmr', + validator: ETHValidator + }, { + name: 'OmiseGO', + symbol: 'omg', + validator: ETHValidator + }, { + name: 'TenX', + symbol: 'pay', + validator: ETHValidator + }, { + name: 'Ripio Credit Network', + symbol: 'rcn', + validator: ETHValidator + }, { + name: 'Augur', + symbol: 'rep', + validator: ETHValidator + }, { + name: 'iExec RLC', + symbol: 'rlc', + validator: ETHValidator + }, { + name: 'Salt', + symbol: 'salt', + validator: ETHValidator + }, { + name: 'Status', + symbol: 'snt', + validator: ETHValidator + }, { + name: 'Storj', + symbol: 'storj', + validator: ETHValidator + }, { + name: 'Swarm City', + symbol: 'swt', + validator: ETHValidator + }, { + name: 'TrueUSD', + symbol: 'tusd', + validator: ETHValidator + }, { + name: 'Wings', + symbol: 'wings', + validator: ETHValidator + }, { + name: '0x', + symbol: 'zrx', + validator: ETHValidator + }, { + name: 'Expanse', + symbol: 'exp', + validator: ETHValidator + }, { + name: 'Viberate', + symbol: 'vib', + validator: ETHValidator + }, { + name: 'Odyssey', + symbol: 'ocn', + validator: ETHValidator + }, { + name: 'Polymath', + symbol: 'poly', + validator: ETHValidator + }, { + name: 'Storm', + symbol: 'storm', + validator: ETHValidator + }, { + name: 'Nano', + symbol: 'nano', + validator: NANOValidator, + }, { + name: 'RaiBlocks', + symbol: 'xrb', + validator: NANOValidator, + }, { + name: 'Siacoin', + symbol: 'sc', + validator: SCValidator + }, { + name: 'HyperSpace', + symbol: 'xsc', + validator: SCValidator + }, { + name: 'loki', + symbol: 'loki', + addressTypes: { prod: ['114', '116'], testnet: [] }, + iAddressTypes: { prod: ['115'], testnet: [] }, + validator: XMRValidator + }, { + name: 'LBRY Credits', + symbol: 'lbc', + addressTypes: { prod: ['55'], testnet: [] }, + validator: BTCValidator + }, { + name: 'Tron', + symbol: 'trx', + addressTypes: { prod: [0x41], testnet: [0xa0] }, + validator: TRXValidator + }, { + name: 'Nem', + symbol: 'xem', + validator: NEMValidator + }, { + name: 'Lisk', + symbol: 'lsk', + validator: LSKValidator + }, { + name: 'Stellar', + symbol: 'xlm', + validator: XLMValidator, + }, { + name: 'BTU Protocol', + symbol: 'btu', + validator: ETHValidator, + }, { + name: 'Crypto.com Coin', + symbol: 'cro', + validator: ETHValidator, + }, { + name: 'Multi-collateral DAI', + symbol: 'dai', + validator: ETHValidator, + }, { + name: 'Enjin Coin', + symbol: 'enj', + validator: ETHValidator, + }, { + name: 'HedgeTrade', + symbol: 'hedg', + validator: ETHValidator, + }, { + name: 'Cred', + symbol: 'lba', + validator: ETHValidator, + }, { + name: 'Chainlink', + symbol: 'link', + validator: ETHValidator, + }, { + name: 'Loom Network', + symbol: 'loom', + validator: ETHValidator, + }, { + name: 'Maker', + symbol: 'mkr', + validator: ETHValidator, + }, { + name: 'Metal', + symbol: 'mtl', + validator: ETHValidator, + }, { + name: 'Ocean Protocol', + symbol: 'ocean', + validator: ETHValidator, + }, { + name: 'Quant', + symbol: 'qnt', + validator: ETHValidator, + }, { + name: 'Synthetix Network', + symbol: 'snx', + validator: ETHValidator, + }, { + name: 'SOLVE', + symbol: 'solve', + validator: ETHValidator, + }, { + name: 'Spendcoin', + symbol: 'spnd', + validator: ETHValidator, + }, { + name: 'TEMCO', + symbol: 'temco', + validator: ETHValidator, + } + + +]; module.exports = { diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index ffcc00d3..e7e76060 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -1,866 +1,866 @@ var isNode = typeof module !== 'undefined' && typeof module.exports !== 'undefined' var chai = isNode ? require('chai') : window.chai, - expect = chai.expect + expect = chai.expect var WAValidator = isNode ? require('../src/wallet_address_validator') : window.WAValidator function valid(address, currency, networkType) { - var valid = WAValidator.validate(address, currency, networkType); - expect({ address, currency, valid }).to.deep.equal({ address, currency, valid: true }); + var valid = WAValidator.validate(address, currency, networkType); + expect({ address, currency, valid }).to.deep.equal({ address, currency, valid: true }); } function invalid(address, currency, networkType) { - var valid = WAValidator.validate(address, currency, networkType); - expect({ address, currency, valid }).to.deep.equal({ address, currency, valid: false }); + var valid = WAValidator.validate(address, currency, networkType); + expect({ address, currency, valid }).to.deep.equal({ address, currency, valid: false }); } describe('WAValidator.validate()', function () { - describe('valid results', function () { - it('should return true for correct bitcoin addresses', function () { - valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoin'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bitcoin'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BTC'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc', 'prod'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc', 'both'); - valid('15uwigGExiNQxTNr1QSZYPXJMp9Px2YnVU', 'btc', 'prod'); - valid('3FyVFsEyyBPzHjD3qUEgX7Jsn4tcHNZFkn', 'btc', 'prod'); - valid('38mKdURe1zcQyrFqRLzR8PRao3iLGEPVsU', 'btc', 'prod'); - valid('mptPo5AvLzJXi4T82vR6g82fT5uJ6HsQCu', 'btc', 'both'); - valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'bitcoin'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoin', 'testnet'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoin', 'both'); - - valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez'); - valid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd'); - - // p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt'); - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoin', 'testnet'); - - // regtest - valid('GSa5espVLNseXEfKt46zEdS6jrPkmFghBU', 'bitcoin', 'testnet'); - - // segwit addresses - valid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'bitcoin'); - valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 'bitcoin'); - valid('bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx', 'bitcoin'); - valid('BC1SW50QA3JX3S', 'bitcoin'); - valid('bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj', 'bitcoin'); - valid('tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy', 'bitcoin'); - - invalid("tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", 'bitcoin'), - invalid("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", 'bitcoin'), - invalid("BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", 'bitcoin'), - invalid("bc1rw5uspcuh", 'bitcoin'), - invalid("bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90", 'bitcoin'), - invalid("BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P", 'bitcoin'), - invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7", 'bitcoin'), - invalid("bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", 'bitcoin'), - invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv", 'bitcoin'), - invalid("bc1gmk9yu", 'bitcoin') + describe('valid results', function () { + it('should return true for correct bitcoin addresses', function () { + valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoin'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bitcoin'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BTC'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc', 'prod'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc', 'both'); + valid('15uwigGExiNQxTNr1QSZYPXJMp9Px2YnVU', 'btc', 'prod'); + valid('3FyVFsEyyBPzHjD3qUEgX7Jsn4tcHNZFkn', 'btc', 'prod'); + valid('38mKdURe1zcQyrFqRLzR8PRao3iLGEPVsU', 'btc', 'prod'); + valid('mptPo5AvLzJXi4T82vR6g82fT5uJ6HsQCu', 'btc', 'both'); + valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'bitcoin'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoin', 'testnet'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoin', 'both'); + + valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez'); + valid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd'); + + // p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt'); + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoin', 'testnet'); + + // regtest + valid('GSa5espVLNseXEfKt46zEdS6jrPkmFghBU', 'bitcoin', 'testnet'); + + // segwit addresses + valid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'bitcoin'); + valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 'bitcoin'); + valid('bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx', 'bitcoin'); + valid('BC1SW50QA3JX3S', 'bitcoin'); + valid('bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj', 'bitcoin'); + valid('tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy', 'bitcoin'); + + invalid("tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", 'bitcoin'), + invalid("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", 'bitcoin'), + invalid("BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", 'bitcoin'), + invalid("bc1rw5uspcuh", 'bitcoin'), + invalid("bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90", 'bitcoin'), + invalid("BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P", 'bitcoin'), + invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7", 'bitcoin'), + invalid("bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", 'bitcoin'), + invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv", 'bitcoin'), + invalid("bc1gmk9yu", 'bitcoin') + }); + + it('should return true for correct bitcoincash addresses', function () { + valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoincash'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bitcoincash'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BCH'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'prod'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'both'); + valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'bitcoincash'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'testnet'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'both'); + + // p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoincash'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoincash', 'testnet'); + + valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bch'); + + }); + + it('should return true for correct litecoin addresses', function () { + valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'litecoin'); + valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'LTC'); + valid('LTpYZG19YmfvY2bBDYtCKpunVRw7nVgRHW', 'litecoin'); + valid('Lb6wDP2kHGyWC7vrZuZAgV7V4ECyDdH7a6', 'litecoin'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'litecoin', 'testnet'); + + // p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'litecoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'litecoin', 'testnet'); + valid('QW2SvwjaJU8LD6GSmtm1PHnBG2xPuxwZFy', 'litecoin', 'testnet'); + valid('QjpzxpbLp5pCGsCczMbfh1uhC3P89QZavY', 'litecoin', 'testnet'); + }); + + it('should return true for correct peercoin addresses', function () { + valid('PHCEsP6od3WJ8K2WKWEDBYKhH95pc9kiZN', 'peercoin'); + valid('PSbM1pGoE9dnAuVWvpQqTTYVpKZU41dNAz', 'peercoin'); + valid('PUULeHrJL2WujJkorc2RsUAR3SardKUauu', 'peercoin'); + valid('PUULeHrJL2WujJkorc2RsUAR3SardKUauu', 'PPC'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'peercoin', 'testnet'); + + // p2sh addresses + valid('pNms4CaWqgZUxbNZaA1yP2gPr3BYnez9EM', 'peercoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'peercoin', 'testnet'); + }); + + it('should return true for correct dogecoin addresses', function () { + valid('DPpJVPpvPNP6i6tMj4rTycAGh8wReTqaSU', 'dogecoin'); + valid('DNzLUN6MyYVS5zf4Xc2yK69V3dXs6Mxia5', 'dogecoin'); + valid('DPS6iZj7roHquvwRYXNBua9QtKPzigUUhM', 'dogecoin'); + valid('DPS6iZj7roHquvwRYXNBua9QtKPzigUUhM', 'DOGE'); + //TODO: NEED A DOGECOIN TESTNET ADDRESS + + //p2sh addresses + valid('A7JjzK9k9x5b2MkkQzqt91WZsuu7wTu6iS', 'dogecoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'dogecoin', 'testnet'); + }); + + it('should return true for correct beavercoin addresses', function () { + valid('BPPtB4EpPi5wCaGXZuNyKQgng8ya579qUh', 'beavercoin'); + valid('BC1LLYoE4mTCHTJhVYvLGxhRTwAHyWTQ49', 'beavercoin'); + valid('BBuyeg2vjtyFdMNj3LTxuVra4wJMKVAY9C', 'beavercoin'); + valid('BBuyeg2vjtyFdMNj3LTxuVra4wJMKVAY9C', 'BVC'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'beavercoin', 'testnet'); + + // p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'beavercoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'beavercoin', 'testnet'); + }); + + it('should return true for correct freicoin addresses', function () { + valid('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', 'freicoin'); + valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'freicoin'); + valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'freicoin'); + valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'FRC'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'freicoin', 'testnet'); + + // p2sh addresse + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'freicoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'freicoin', 'testnet'); + }); + + it('should return true for correct protoshares addresses', function () { + valid('PaNGELmZgzRQCKeEKM6ifgTqNkC4ceiAWw', 'protoshares'); + valid('Piev8TMX2fT5mFtgxx2TXJaqXP37weMPuD', 'protoshares'); + valid('PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD', 'protoshares'); + valid('PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD', 'PTS'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'protoshares', 'testnet'); + + //p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'protoshares'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'protoshares', 'testnet'); + }); + + it('should return true for correct megacoin addresses', function () { + valid('MWUHaNxjXGZUYTh92i3zuDmsnH1rHSBk5M', 'megacoin'); + valid('MSAkrhRyte7bz999Ga5SqYjzypFFYa2oEb', 'megacoin'); + valid('MLUTAtDQFcfo1QACWocLuufFq5fBDTpCHE', 'megacoin'); + valid('MLUTAtDQFcfo1QACWocLuufFq5fBDTpCHE', 'MEC'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'megacoin', 'testnet'); + + //p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'megacoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'megacoin', 'testnet'); + }); + + it('should return true for correct primecoin addresses', function () { + valid('AVKeiZ5JadfWdH2EYVgVRfX4ufoyd4ehuM', 'primecoin'); + valid('AQXBRPyob4dywUJ21RUKrR1xetQCDVenKD', 'primecoin'); + valid('ANHfTZnskKqaBU7oZuSha9SpbHU3YBfeKf', 'primecoin'); + valid('AYdiYMKSGYxLcZNDmqB8jNcck7SQibrfiK', 'primecoin'); + valid('AYdiYMKSGYxLcZNDmqB8jNcck7SQibrfiK', 'XPM'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'primecoin', 'testnet'); + + //p2sh addresses + valid('af5CvTQq7agDh717Wszb5QDbWb7nT2mukP', 'primecoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'primecoin', 'testnet'); + }); + + it('should return true for correct auroracoin addresses', function () { + valid('ARM3GLZXF1PDTZ5vz3wh5MVahbK9BHTWAN', 'auroracoin'); + valid('AUtfc6ThCLb7FuEu7QPrWpJuaXaJRPciDF', 'auroracoin'); + valid('AUN1oaj5hjispGnczt8Aruw3TxgGyRqB3V', 'auroracoin'); + valid('AXGcBkGX6NiaDXj85C5dCrhTRUgwxSkKDK', 'auroracoin'); + valid('AXGcBkGX6NiaDXj85C5dCrhTRUgwxSkKDK', 'AUR'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'auroracoin', 'testnet'); + + //p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'auroracoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'auroracoin', 'testnet'); + }); + + it('should return true for correct namecoin addresses', function () { + valid('NEpeRmS775fnti8TDgJA28m8KLEfNNRZvT', 'namecoin'); + valid('MyJ691bGJ48RBK2LS8n1U57wcFLFScFXxi', 'namecoin'); + valid('NFY9aw1RXLGtWpeqgNQXprnUcZXyKNinTh', 'namecoin'); + valid('NCPPc7Pzb75CpRPJQPRRh6ouJTq7BCy1H4', 'namecoin'); + valid('NCPPc7Pzb75CpRPJQPRRh6ouJTq7BCy1H4', 'NMC'); + }); + + it('should return true for correct BioCoin addresses', function () { + valid('B7xseoLGk7hEpMDDeSvZDKmmiAMHWiccok', 'biocoin'); + valid('B8zjmYFGhWmiaQSJshfrnefE72xCapCkvo', 'biocoin'); + valid('muH8LL42DiMs8GEQ6Grfi8KUw2uFvuKr1J', 'biocoin', 'testnet'); + valid('muH8LL42DiMs8GEQ6Grfi8KUw2uFvuKr1J', 'BIO', 'testnet'); + valid('B8zjmYFGhWmiaQSJshfrnefE72xCapCkvo', 'BIO'); + }); + + it('should return true for correct Garlicoin addresses', function () { + valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'garlicoin'); + valid('GNWeWaoQ6rv21ZFjJWT9vb91hXUzFTLkru', 'garlicoin'); + valid('mjKbQTkgwzmsL3J86tdVzhyW9pc4NePqTb', 'garlicoin', 'testnet'); + valid('mnYp36NuyRavMKQ9Q9Q6oGqoorAs9p3zYn', 'GRLC', 'testnet'); + valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'GRLC'); + }); + + it('should return true for correct Vertcoin addresses', function () { + valid('3PgeyhEJEnS5CeBu3iFcu3JHVKemeHx1AW', 'VTC'); + valid('353nERPQKhGj4WGzoiWcareA76TPgRCVNA', 'VTC'); + valid('376g4TmL8uQKFYsRFrbv5iz9srmb5bocEt', 'VTC'); + valid('3AMtM4Zk5oNHu9i4jDiwKB6Kg5YEReBsav', 'VTC'); + + valid('VmoMjGf3zgZLy8sk3PMKd3xikZHXWvnYi7', 'vertcoin'); + valid('VmhHwXr3J8xMZpy62WuBGpu3xVvThWzcTQ', 'vertcoin'); + valid('mvww6DEJ18dbyQUukpVQXvLgrNDJazZn1Y', 'vertcoin', 'testnet'); + valid('mn3mdEE6cf1snxVsknNz4GRTdSrWXqYp7c', 'VTC', 'testnet'); + valid('Vri6Q4GgNFfdtcpxD961TotJwaSaYQCaL5', 'VTC'); + }); + + it('should return true for correct BitcoinGold addresses', function () { + valid('GW3JrQyHtoVfEFES3Y9JagiX3VSKQStLwj', 'bitcoingold'); + valid('GUDWdeMyAXQbrNFFivAhkJQ1GfBCFdc7JF', 'bitcoingold'); + valid('mvww6DEJ18dbyQUukpVQXvLgrNDJazZn1Y', 'bitcoingold', 'testnet'); + valid('mn3mdEE6cf1snxVsknNz4GRTdSrWXqYp7c', 'BTG', 'testnet'); + valid('GSNFPRsdaM3MXrU5HW1AxgFwmUQC8HXK9F', 'BTG'); + }); + + it('should return true for correct Decred addresses', function () { + valid('Dsesax2GJnMN4wwmWo5rJGq73dDK217Rh85', 'DCR'); + valid('DsYuxtvGRfN8rncXAndtLUpJm55F77K17RA', 'decred'); + valid('DsaXDG2NrJW8g4tFAb8n9MNx81Sn3Qc8AEV', 'decred'); + valid('TsijUgejaRnLKF5WAbpUxNtwKGUiKVeXLr7', 'decred', 'testnet'); + valid('TsZ9QmAoadF12hGvyALp6qvaF4be3BmLqG9', 'dcr', 'testnet'); + }); + + it('should return true for correct Digibyte addresses', function () { + valid('DG2rM2orU2JH5i4ACh3AKNpRTNESdv5xf8', 'DGB'); + valid('DBR2Lj1F17eHGHXgbpae2Wb4m39bDyA1qo', 'DGB'); + valid('D9TDZTR9Z9Mx2NoDJnhqhnYhDLKRAmsL9n', 'digibyte'); + valid('DHRzA1YHA1kFWpz2apRckZJy6KZRyGq4EV', 'digibyte'); + valid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'digibyte'); + }); + + it('should return true for correct Ethereum addresses', function () { + valid('0xE37c0D48d68da5c5b14E5c1a9f1CFE802776D9FF', 'ethereum'); + valid('0xa00354276d2fC74ee91e37D085d35748613f4748', 'ethereum'); + valid('0xAff4d6793F584a473348EbA058deb8caad77a288', 'ETH'); + valid('0xc6d9d2cd449a754c494264e1809c50e34d64562b', 'ETH'); + valid('0x52908400098527886E0F7030069857D2E4169EE7', 'ETH'); + valid('0x8617E340B3D01FA5F11F306F4090FD50E238070D', 'ETH'); + valid('0xde709f2102306220921060314715629080e2fb77', 'ETH'); + valid('0x27b1fdb04752bbc536007a920d24acb045561c26', 'ETH'); + valid('0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', 'ETH'); + valid('0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359', 'ETH'); + valid('0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB', 'ETH'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETH'); + + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ethereumclassic'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETC'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'etherzero'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETZ'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'callisto'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'CLO'); + }); + + it('should return true for correct Ripple addresses', function () { + valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'ripple'); + valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'XRP'); + valid('r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV', 'XRP'); + valid('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', 'XRP'); + valid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN', 'XRP'); + }); + + it('should return true for correct dash addresses', function () { + valid('Xx4dYKgz3Zcv6kheaqog3fynaKWjbahb6b', 'dash'); + valid('XcY4WJ6Z2Q8w7vcYER1JypC8s2oa3SQ1b1', 'DASH'); + valid('XqMkVUZnqe3w4xvgdZRtZoe7gMitDudGs4', 'dash'); + valid('yPv7h2i8v3dJjfSH4L3x91JSJszjdbsJJA', 'dash', 'testnet'); + valid('XoAAqv3oUYZ6xRjX3brfbf9PotrGanS6Th', 'dash'); + valid('yP5oXZQXBfBf9FyfZDpFiKDypxuNUKUV2E', 'dash', 'testnet'); + }); + + it('should return true for correct neo addresses', function () { + valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neo'); + valid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X', 'NEO'); + }); + + it('should return true for correct neo gas addresses', function () { + valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neogas'); + }); + + it('should return true for correct qtum addresses', function () { + valid('QNjUiD3bVVZwYTc5AhpeQbS1mfb2guyWhe', 'qtum'); + valid('QVZnSrMwKp6AL4FjUPPnfFgsma6j1DXQXu', 'QTUM'); + valid('MCgyroQse81wuv5RwPpY5DXDNxeafzLFJ8', 'QTUM'); + valid('QQYySVc5WEe3g6PnNFYmspqG5CfSG8rnma', 'QTUM'); + valid('MSvJQBJMZs1dhxz7UAWa2si4iyMD2FHQd5', 'QTUM'); + + valid('qcSLSxN1sngCWSrKFZ6UC7ri4hhVSdq9SU', 'qtum', 'testnet'); + valid('qJnbEdrm9ybjVqDCaX5SWNBHmZy2X7YbPT', 'qtum', 'testnet'); + valid('qchBPDUYswobzpDmY5DsTStt74sTYQtaQv', 'qtum', 'testnet'); + }); + + it('should return true for correct votecoin addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); + }); + + it('should return true for correct bitcoinz addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); + }); + + it('should return true for correct zclassic addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); + }); + + it('should return true for correct hush addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); + }); + + it('should return true for correct zcash addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); + }); + + it('should return true for correct bitcoinprivate addresses', function () { + valid('b1M4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); + //valid('bx....', 'BTCP'); + //valid('nx....', 'bitcoinprivate', 'testnet'); + }); + + it('should return true for correct snowgem addresses', function () { + valid('s1fx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); + valid('s3d27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); + }); + + it('should return true for correct zencash addresses', function () { + valid('znhiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); + valid('zssEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); + valid('ztmWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); + }); + + it('should return true for correct komodo addresses', function () { + valid('R9R5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); + valid('RAvj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); + //valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + }); + + it('should return true for correct Bankex addresses', function () { + valid('0xeac39e1bc802baae3d4b9cb518f3f60374bbad6c', 'bankex'); + valid('0x45245bc59219eeaaf6cd3f382e078a461ff9de7b', 'BKX'); + valid('0xf40d80FCfa5cdEa0bB1E570c2D52132ac9bC6aEC', 'bankex', 'testnet'); + valid('0x8A7395f281EeCf2B471B689E87Cf4C7fa8bb957d', 'BKX', 'testnet'); + }); + + + it('should return true for correct Cardano addresses', function () { + valid('Ae2tdPwUPEYxYNJw1He1esdZYvjmr4NtPzUsGTiqL9zd8ohjZYQcwu6kom7', 'cardano'); + valid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg', 'ada'); + valid('Ae2tdPwUPEZKmwoy3AU3cXb5Chnasj6mvVNxV1H11997q3VW5ihbSfQwGpm', 'ada'); + valid('4swhHtxKapQbj3TZEipgtp7NQzcRWDYqCxXYoPQWjGyHmhxS1w1TjUEszCQT1sQucGwmPQMYdv1FYs3d51KgoubviPBf', 'cardano'); + }); + + it('should return true for correct monero addresses', function () { + valid('47zQ5LAivg6hNCgijXSEFVLX7mke1bgM6YGLFaANDoJbgXDymcAAZvvMNt2PmMpqEe5qRy2zyfMYXdwpmdyitiFh84xnPG2', 'monero'); + valid('48bWuoDG75CXMDHbmPEvUF2hm1vLDic7ZJ7hqRkL65QR9p13AQAX4eEACXNk4YP115Q4KRVZnAvmMBHrcGfv9FvKPZnH6vH', 'XMR'); + valid('A2be3UvzMtkJtxRYgcCbQt2y7Rp2eLVGqNTWfZeankrWimSMM4y7uMP6B9oAZaHsXTj8KFSerkSkkVRuEuEca9QM8VhxCNU', 'monero', 'testnet'); + + //integrated addresses + valid('4Gd4DLiXzBmbVX2FZZ3Cvu6fUaWACup1qDowprUCje1kSP4FmbftiJMSfV8kWZXNqmVwj4m52xqtgFNUudVmsmGkGvkLcCibWfVUfUFVB7', 'monero'); + valid('4J5sF94AzXgFgx8LuWc9dcWkJkGkD3cL3L2AuhX6QA9jFvSxxj6QhHqHXqM2b2Go7G8RyDzEbHxYd9G26XUUbuJChipEyBz9fENMU2Ua9b', 'XMR'); + }); + + it('should return true for correct gamecredits addresses', function () { + valid('GU5BBtW9gxSKvAknvFi9yUaXKUNW9zUN2p', 'game'); + valid('GYxQMVzP6YpzX59QNRYqmJeHNtUMYSZPri', 'game'); + }); + + it('should return true for correct monacoin addresses', function () { + valid('MMN1Q1aRVUzanmg9DJjcRYzQSJQoBeQPui', 'mona'); + valid('PFMzNYnBm5X4c9qJkJPkfgdCyd9fuuy2vT', 'mona'); + valid('PCtN7VUYHW8w4g59BaphrfPs8g7pNgAzxn', 'mona'); + valid('MXCcYFGRmsd4d3CcQugFiqG8uarj5tVu76', 'mona'); + valid('MNK1pGsBf9WdoE54fZM9VFhkeYHW6VUf2u', 'mona'); + }); + + it('should return true for correct pivx addresses', function () { + valid('DJXFW9oJJBUX7QKrG6GKvmTs63MYKzwtpZ', 'pivx'); + valid('DEaYb8EHQgyKvX6VXDS3DZQautJrHBmK3T', 'pivx'); + valid('DDeCGR3QSgqsBxVR23bJvteiyYE34ZmxAc', 'pivx'); + valid('DSqQM8DPpBHHoZXHgRdwmaf6hZPEoZcFkh', 'pivx'); + }); + + it('should return true for correct solarcoin addresses', function () { + valid('8VxVLzwB26E2YZZ82o1NcQe96QSM2z6GwW', 'slr'); + valid('8YW5qcTjeyqX5kESsqu2BUdXiedgssegtQ', 'SolarCoin'); + }); + + it('should return true for correct tether addresses', function () { + valid('3MbYQMMmSkC3AgWkj9FMo5LsPTW1zBTwXL', 'usdt'); + valid('1KdXaqcBeoMAFVAPwTmYvDbEq6RnvNPF6J', 'tether'); + }); + + it('should return true for correct expanse addresses', function () { + valid('0xbab463743603a253bdf1f84975b1a9517505ae05', 'exp'); + valid('0x5d0777cb5d6977873904864c6ab531f4b3261f0b', 'expanse'); + }); + + it('should return true for correct waves addresses', function () { + valid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); + valid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHajj', 'waves'); + + valid('3Myrq5QDgRq3nBVRSSv9UYrP36xTtpJND5y', 'waves', 'testnet'); + valid('3My3KZgFQ3CrVHgz6vGRt8687sH4oAA1qp8', 'waves', 'testnet'); + }); + + it('should return true for correct nano addresses', function () { + valid('xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3', 'nano'); + valid('xrb_13ezf4od79h1tgj9aiu4djzcmmguendtjfuhwfukhuucboua8cpoihmh8byo', 'nano'); + valid('xrb_35jjmmmh81kydepzeuf9oec8hzkay7msr6yxagzxpcht7thwa5bus5tomgz9', 'nano'); + valid('xrb_1111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); + valid('xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est', 'nano'); + valid('xrb_3wm37qz19zhei7nzscjcopbrbnnachs4p1gnwo5oroi3qonw6inwgoeuufdp', 'nano'); + valid('xrb_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4', 'nano'); + valid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjmgu', 'nano'); + valid('xrb_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); + valid('nano_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); + }); + + it('should return true for correct siacoin addresses', function () { + valid( + 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', + 'siacoin' + ) + valid( + 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', + 'siacoin' + ) + valid( + 'ab0c327982abfcc6055a6c9551589167d8a73501aca8769f106371fbc937ad100c955c3b7ba9', + 'siacoin' + ) + valid( + 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530373', + 'siacoin' + ) + }) + + it('should return true for correct loki addresses', function () { + // public + valid( + 'L63ymg8cb5aRz1PhXrEQ22PWw9KBhBS8rMsgqbABhTGFfh53U3Rc2iWCJpCPsHZT5hfyt7fPQa612a5Z1tBnGYEA9h6YHnn', + 'loki' + ) + valid( + 'L5QKRGMNpQU3eCAdjMVTCR631bRKqnW1oEWWBEHAtFJLieA5VvuxyyubCd9FczEEatg8jfy39UJZ13npLJqZG6dtMtM99ha', + 'loki' + ) + // integrated + valid( + 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiD1xbPb6dpYo7toNRqk', + 'loki' + ) + valid( + 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiCtWq1AYo1oJTVqgUcQ', + 'loki' + ) + // subaddress + valid( + 'LW1VMYcvWPZZJ2h1pKGEku2y9WeDiAU2VhgrgVgvjybaRuCdcEkg6FhXjVNSd37Bp7fhYH8tVa5T9VmRaYiWyxYdCpEGBg8', + 'loki' + ) + }) + + it('should return true for correct lbry addresses', function () { + valid('bDb6NmobyDVeNGpizWQQBZkYjKCRQBdKdG', 'LBC') + valid('bTFXPcV3a8iVDezogvHTHezWZ1mZGWpPDc', 'lbc') + valid('bK2uEVn6UuwjCTUZ1Dfj5HhWYi9BtqZDDm', 'lbc') + valid('bNEMVqeUZUqTrYUxud5ehnUhtTAiWDXQ5e', 'lbc') + }) + + it('should return true for correct trx addresses', function () { + valid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r', 'trx'); + valid('27bLJCYjbH6MT8DBF9xcrK6yZnm43vx7MNQ', 'trx', 'testnet'); + }); + + it('should return true for correct nem addresses', function () { + valid('NBZMQO7ZPBYNBDUR7F75MAKA2S3DHDCIFG775N3D', 'xem'); + valid('TDWTRGT6GVWCV7GRWFNI45S53PGOJBKNUF3GE6PB', 'xem', 'testnet'); + }); + + it('should return true for correct lsk addresses', function () { + valid('469226551L', 'lsk'); + valid('15823701926930889868L', 'lsk'); + valid('1657699692452120239L', 'lsk'); + valid('555666666999992L', 'lsk'); + valid('6853061742992593192L', 'lsk'); + valid('530464791801L', 'lsk'); + }); + + it('should return true for correct bsv addresses', function () { + valid('qzwryn9fxnpqkf7zt878tp2g9cg8kpl65qh2ml0w0r', 'bsv'); + valid('qp65yngy5uds4wxtrkynptal4f76qzmrh52pa3mpaf', 'bsv'); + valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); + valid('qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); + valid('qz97s7ee0rvwlymtxrwafmvs87x6027jwuf3wepug7', 'bsv'); + valid('bitcoincash:qpp32ssez340wfspnt79h6c4xds4fzf3m5j0cplx0l', 'bsv'); + valid('qqg82u7tq2eahs3gkh9m6kjnmjehr69m5v37alepq4', 'bsv'); + valid('bitcoincash:qrwkk9a3es2wu7mdvzh0vekfvjuzysq8tv7r3hcwr5', 'bsv'); + valid('1DrNXqCj2B8FKyx66RAWDkiEJhw2yrvhT3', 'bsv'); + }); + + it('should return true for correct stellar addresses', function () { + valid('GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB', 'stellar'); + valid('GB7KKHHVYLDIZEKYJPAJUOTBE5E3NJAXPSDZK7O6O44WR3EBRO5HRPVT', 'stellar'); + valid('GD6WVYRVID442Y4JVWFWKWCZKB45UGHJAABBJRS22TUSTWGJYXIUR7N2', 'stellar'); + valid('GBCG42WTVWPO4Q6OZCYI3D6ZSTFSJIXIS6INCIUF23L6VN3ADE4337AP', 'stellar'); + valid('GDFX463YPLCO2EY7NGFMI7SXWWDQAMASGYZXCG2LATOF3PP5NQIUKBPT', 'stellar'); + valid('GBXEODUMM3SJ3QSX2VYUWFU3NRP7BQRC2ERWS7E2LZXDJXL2N66ZQ5PT', 'stellar'); + valid('GAJHORKJKDDEPYCD6URDFODV7CVLJ5AAOJKR6PG2VQOLWFQOF3X7XLOG', 'stellar'); + valid('GACXQEAXYBEZLBMQ2XETOBRO4P66FZAJENDHOQRYPUIXZIIXLKMZEXBJ', 'stellar'); + valid('GDD3XRXU3G4DXHVRUDH7LJM4CD4PDZTVP4QHOO4Q6DELKXUATR657OZV', 'stellar'); + valid('GDTYVCTAUQVPKEDZIBWEJGKBQHB4UGGXI2SXXUEW7LXMD4B7MK37CWLJ', 'stellar'); + }); + }); + + describe('invalid results', function () { + function commonTests(currency) { + invalid('', currency); //reject blank + invalid('%%@', currency); //reject invalid base58 string + invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency); //reject invalid address + invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency); //reject transaction id's + //testnet + invalid('', currency, 'testnet'); //reject blank + invalid('%%@', currency, 'testnet'); //reject invalid base58 string + invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency, 'testnet'); //reject invalid address + invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency, 'testnet'); //reject transaction id's + } + + it('should return false for incorrect bitcoin addresses', function () { + commonTests('bitcoin'); + }); + + it('should return false for incorrect bitcoincash addresses', function () { + commonTests('bitcoincash'); + }); + + it('should return false for incorrect litecoin addresses', function () { + commonTests('litecoin'); + }); + + it('should return false for incorrect peercoin addresses', function () { + commonTests('peercoin'); + }); + + it('should return false for incorrect dogecoin addresses', function () { + commonTests('dogecoin'); + }); + + it('should return false for incorrect beavercoin addresses', function () { + commonTests('beavercoin'); + }); + + it('should return false for incorrect freicoin addresses', function () { + commonTests('freicoin'); + }); + + it('should return false for incorrect protoshares addresses', function () { + commonTests('protoshares'); + }); + + it('should return false for incorrect megacoin addresses', function () { + commonTests('megacoin'); + }); + + it('should return false for incorrect primecoin addresses', function () { + commonTests('primecoin'); + }); + + it('should return false for incorrect auroracoin addresses', function () { + commonTests('auroracoin'); + }); + + it('should return false for incorrect namecoin addresses', function () { + commonTests('namecoin'); + }); + + it('should return false for incorrect biocoin addresses', function () { + commonTests('biocoin'); + }); + + it('should return false for incorrect garlicoin addresses', function () { + commonTests('garlicoin'); + }); + + it('should return false for incorrect vertcoin addresses', function () { + commonTests('vertcoin'); + }); + + it('should return false for incorrect bitcoingold addresses', function () { + commonTests('bitcoingold'); + }); + + it('should return false for incorrect decred addresses', function () { + commonTests('decred'); + }); + + it('should return false for incorrect gamecredits addresses', function () { + commonTests('game'); + }); + + it('should return false for incorrect monacoin addresses', function () { + commonTests('mona'); + }); + + it('should return false for incorrect solarcoin addresses', function () { + commonTests('slr'); + }); + + it('should return false for incorrect tether addresses', function () { + commonTests('usdt'); + }); + + it('should return false for incorrect expanse addresses', function () { + commonTests('exp'); + }); + + it('should return false for incorrect usdt addresses', function () { + commonTests('usdt'); + }); + + it('should return false for incorrect bankex addresses', function () { + invalid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'bankex'); + invalid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd', 'BKX'); + invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bankex', 'testnet'); + invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'BKX', 'testnet'); + }); + + it('should return false for incorrect digibyte addresses', function () { + commonTests('digibyte'); + }); + + it('should return false for incorrect eip55 addresses', function () { + invalid('6xAff4d6793F584a473348EbA058deb8caad77a288', 'ethereum'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereum'); + invalid('0XD1220A0CF47C7B9BE7A2E6BA89F429762E7B9ADB', 'ethereum'); + invalid('aFf4d6793f584a473348ebA058deb8caad77a2885', 'ethereum'); + invalid('0xff4d6793F584a473', 'ethereum'); + + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereumclassic'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'etherzero'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'callisto'); + }); + + it('should return false for incorrect ripple addresses', function () { + invalid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCN', 'ripple'); + invalid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhMN', 'XRP'); + invalid('6xAff4d6793F584a473348EbA058deb8ca', 'ripple'); + invalid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'ripple'); + }); + + it('should return false for incorrect dash addresses', function () { + commonTests('dash'); + }); + + it('should return false for incorrect neo addresses', function () { + commonTests('neo'); + invalid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTa', 'neo'); + invalid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ10', 'NEO'); + }); + + it('should return false for incorrect qtum addresses', function () { + commonTests('qtum'); + invalid('QNPhBbVhDghASxcUh2vHotQUgNeLRFTcfb', 'qtum'); + invalid('QOPhBbVhDghASxcUh2vHotQUgNeLRFTcfa', 'QTUM'); + }); + + it('should return false for incorrect votecoin addresses', function () { + commonTests('votecoin'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); + }); + + it('should return false for incorrect bitcoinz addresses', function () { + commonTests('bitcoinz'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); + }); + + it('should return false for incorrect zclassic addresses', function () { + commonTests('zclassic'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); + }); + + it('should return false for incorrect hush addresses', function () { + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); + }); + + it('should return false for incorrect zcash addresses', function () { + commonTests('zcash'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); + }); + + it('should return false for incorrect bitcoinprivate addresses', function () { + commonTests('bitcoinprivate'); + invalid('b1Y4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); + //invalid('bx....', 'BTCP'); + //invalid('nx....', 'bitcoinprivate', 'testnet'); + }); + + it('should return false for incorrect snowgem addresses', function () { + commonTests('snowgem'); + invalid('s1Yx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); + invalid('s3Y27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); + }); + + it('should return false for incorrect zencash addresses', function () { + commonTests('zencash'); + invalid('znYiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); + invalid('zsYEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); + invalid('ztYWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); + }); + + it('should return false for incorrect komodo addresses', function () { + commonTests('komodo'); + invalid('R9Y5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); + invalid('RAYj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); + //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + }); + + it('should return false for incorrect cardano addresses', function () { + commonTests('cardano'); + invalid('Ae2tdPwUPEYxYNJw1He1esdZYvjmr4NtPzUsGTiqL9zd8ohjZYQcwu6lom7', 'cardano'); + invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg1', 'cardano'); + invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRT', 'ada'); + //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + }); + + it('should return false for incorrect monero addresses', function () { + commonTests('monero'); + invalid('4AWygwA3hHNE4e4Yr9PtRWJiorXTjZkCi57g4ExYzfXDFFQ8DRFEFyui1dLqVknpqQjGUBdTMbgaFAZaDbrVHdk3GAKBZ3E', 'monero'); + invalid('44643dtxcxjgMWEQLo6mh1c4d9Zxx9GbgK9hEj9iGSiFEryCkbwHyJ3JqxZJRqeC3Hb7ZBLKq5NkaJwR1x95EYnR1bTgN6d', 'xmr'); + invalid('A17N9ztrxjQD3v3JJtHGvHVnq6BAbujDNEuensB6PFwBYFpkjAicih8hDtX76HBuEag5NeaCuMZmRMe6eE5NMRGxFTQn8nJ', 'monero', 'testnet'); + + //integrated + invalid('4LNSCKNSTPNbJYkyAEgL966eHJHLDHiq1PpwKoiFBybcSqNGYfLBJApC62uQEeGAFxfYEd29uXBBrJFo7DhKqFVNi3GhmN79EtD5dgycYz', 'monero'); + invalid('4JpzTwf3i1GeCV76beVr19179oa8j1L8xNSC1bXMtAxxdf4aTTLqubL8EvXfQmUGKt9MMigFtKy91VtoTTSfg1LU7LocPruT6KcGC9RKJV', 'xmr'); + }); + + it('should return false for incorrect waves addresses', function () { + commonTests('waves'); + invalid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs1', 'waves'); + invalid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHaj', 'waves'); + invalid('2P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); + + invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'waves', 'testnet'); + invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'waves', 'testnet'); + }); + + it('should return false for incorrect nano addresses', function () { + commonTests('nano'); + invalid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); + invalid('nano_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nano'); + invalid('nano_111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); + }); + + it('should return false for incorrect siacoin addresses', function () { + commonTests('siacoin') + invalid( + 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372', + 'siacoin' + ) + }) + + it('should return false for incorrect lbry addresses', function () { + commonTests('lbc') + invalid('ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372') + }) + + it('should return false for incorrect tron addresses', function () { + commonTests('trx'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'trx'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'trx'); + }); + + it('should return false for incorrect nem addresses', function () { + commonTests('nem'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nem'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'nem'); + + invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'nem', 'testnet'); + invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'nem', 'testnet'); + }); + //15823701926930889868L + it('should return false for incorrect lsk addresses', function () { + commonTests('lsk'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'lsk'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'lsk'); + + invalid('158237019269308898689L', 'lsk'); + invalid('158237A192B930C898689L', 'lsk'); + }); + + it('should return false for incorrect bsv addresses', function () { + commonTests('bsv'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'bsv'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'bsv'); + + invalid('158237019269308898689L', 'bsv'); + invalid('158237A192B930C898689L', 'bsv'); + invalid('bitcoin:qzpuefrpg3kl2ykQe52rxn96pd3Kp4qudywr5pyrsf', 'bsv'); + invalid('pzuefrpg3kl2ykqe52rxn96pd3kp4qudywr5py', 'bsv'); + invalid('rlt2c2wuxr644encp3as0hygtj9djrsaumku3cex5', 'bsv'); + invalid('qra607y4wnkmnpy3wcmrxmltzkrxywcq85c7watpdx09', 'bsv'); + }); + + it('should return false for incorrect stellar addresses', function () { + commonTests('stellar'); + invalid('SBGWKM3CD4IL47QN6X54N6Y33T3JDNVI6AIJ6CD5IM47HG3IG4O36XCU', 'stellar'); + invalid('GBPXX0A5N4JYPESHAADMQKBPWZWQDQ64ZV6ZL2S3LAGW4SY7NTCMWIVL', 'stellar'); + invalid('GCFZB6L25D26RQFDWSSBDEYQ32JHLRMTT44ZYE3DZQUTYOL7WY43PLBG++', 'stellar'); + invalid('GADE5QJ2TY7S5ZB65Q43DFGWYWCPHIYDJ2326KZGAGBN7AE5UY6JVDRRA', 'stellar'); + invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2', 'stellar'); + invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2T', 'stellar'); + invalid('GDXIIZTKTLVYCBHURXL2UPMTYXOVNI7BRAEFQCP6EZCY4JLKY4VKFNLT', 'stellar'); + invalid('SAB5556L5AN5KSR5WF7UOEFDCIODEWEO7H2UR4S5R62DFTQOGLKOVZDY', 'stellar'); + invalid('gWRYUerEKuz53tstxEuR3NCkiQDcV4wzFHmvLnZmj7PUqxW2wt', 'stellar'); + invalid('g4VPBPrHZkfE8CsjuG2S4yBQNd455UWmk', 'stellar'); + }); }); - - it('should return true for correct bitcoincash addresses', function () { - valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoincash'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bitcoincash'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BCH'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'prod'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'both'); - valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'bitcoincash'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'testnet'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'both'); - - // p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoincash'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoincash', 'testnet'); - - valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bch'); - - }); - - it('should return true for correct litecoin addresses', function () { - valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'litecoin'); - valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'LTC'); - valid('LTpYZG19YmfvY2bBDYtCKpunVRw7nVgRHW', 'litecoin'); - valid('Lb6wDP2kHGyWC7vrZuZAgV7V4ECyDdH7a6', 'litecoin'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'litecoin', 'testnet'); - - // p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'litecoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'litecoin', 'testnet'); - valid('QW2SvwjaJU8LD6GSmtm1PHnBG2xPuxwZFy', 'litecoin', 'testnet'); - valid('QjpzxpbLp5pCGsCczMbfh1uhC3P89QZavY', 'litecoin', 'testnet'); - }); - - it('should return true for correct peercoin addresses', function () { - valid('PHCEsP6od3WJ8K2WKWEDBYKhH95pc9kiZN', 'peercoin'); - valid('PSbM1pGoE9dnAuVWvpQqTTYVpKZU41dNAz', 'peercoin'); - valid('PUULeHrJL2WujJkorc2RsUAR3SardKUauu', 'peercoin'); - valid('PUULeHrJL2WujJkorc2RsUAR3SardKUauu', 'PPC'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'peercoin', 'testnet'); - - // p2sh addresses - valid('pNms4CaWqgZUxbNZaA1yP2gPr3BYnez9EM', 'peercoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'peercoin', 'testnet'); - }); - - it('should return true for correct dogecoin addresses', function () { - valid('DPpJVPpvPNP6i6tMj4rTycAGh8wReTqaSU', 'dogecoin'); - valid('DNzLUN6MyYVS5zf4Xc2yK69V3dXs6Mxia5', 'dogecoin'); - valid('DPS6iZj7roHquvwRYXNBua9QtKPzigUUhM', 'dogecoin'); - valid('DPS6iZj7roHquvwRYXNBua9QtKPzigUUhM', 'DOGE'); - //TODO: NEED A DOGECOIN TESTNET ADDRESS - - //p2sh addresses - valid('A7JjzK9k9x5b2MkkQzqt91WZsuu7wTu6iS', 'dogecoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'dogecoin', 'testnet'); - }); - - it('should return true for correct beavercoin addresses', function () { - valid('BPPtB4EpPi5wCaGXZuNyKQgng8ya579qUh', 'beavercoin'); - valid('BC1LLYoE4mTCHTJhVYvLGxhRTwAHyWTQ49', 'beavercoin'); - valid('BBuyeg2vjtyFdMNj3LTxuVra4wJMKVAY9C', 'beavercoin'); - valid('BBuyeg2vjtyFdMNj3LTxuVra4wJMKVAY9C', 'BVC'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'beavercoin', 'testnet'); - - // p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'beavercoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'beavercoin', 'testnet'); - }); - - it('should return true for correct freicoin addresses', function () { - valid('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', 'freicoin'); - valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'freicoin'); - valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'freicoin'); - valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'FRC'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'freicoin', 'testnet'); - - // p2sh addresse - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'freicoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'freicoin', 'testnet'); - }); - - it('should return true for correct protoshares addresses', function () { - valid('PaNGELmZgzRQCKeEKM6ifgTqNkC4ceiAWw', 'protoshares'); - valid('Piev8TMX2fT5mFtgxx2TXJaqXP37weMPuD', 'protoshares'); - valid('PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD', 'protoshares'); - valid('PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD', 'PTS'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'protoshares', 'testnet'); - - //p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'protoshares'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'protoshares', 'testnet'); - }); - - it('should return true for correct megacoin addresses', function () { - valid('MWUHaNxjXGZUYTh92i3zuDmsnH1rHSBk5M', 'megacoin'); - valid('MSAkrhRyte7bz999Ga5SqYjzypFFYa2oEb', 'megacoin'); - valid('MLUTAtDQFcfo1QACWocLuufFq5fBDTpCHE', 'megacoin'); - valid('MLUTAtDQFcfo1QACWocLuufFq5fBDTpCHE', 'MEC'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'megacoin', 'testnet'); - - //p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'megacoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'megacoin', 'testnet'); - }); - - it('should return true for correct primecoin addresses', function () { - valid('AVKeiZ5JadfWdH2EYVgVRfX4ufoyd4ehuM', 'primecoin'); - valid('AQXBRPyob4dywUJ21RUKrR1xetQCDVenKD', 'primecoin'); - valid('ANHfTZnskKqaBU7oZuSha9SpbHU3YBfeKf', 'primecoin'); - valid('AYdiYMKSGYxLcZNDmqB8jNcck7SQibrfiK', 'primecoin'); - valid('AYdiYMKSGYxLcZNDmqB8jNcck7SQibrfiK', 'XPM'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'primecoin', 'testnet'); - - //p2sh addresses - valid('af5CvTQq7agDh717Wszb5QDbWb7nT2mukP', 'primecoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'primecoin', 'testnet'); - }); - - it('should return true for correct auroracoin addresses', function () { - valid('ARM3GLZXF1PDTZ5vz3wh5MVahbK9BHTWAN', 'auroracoin'); - valid('AUtfc6ThCLb7FuEu7QPrWpJuaXaJRPciDF', 'auroracoin'); - valid('AUN1oaj5hjispGnczt8Aruw3TxgGyRqB3V', 'auroracoin'); - valid('AXGcBkGX6NiaDXj85C5dCrhTRUgwxSkKDK', 'auroracoin'); - valid('AXGcBkGX6NiaDXj85C5dCrhTRUgwxSkKDK', 'AUR'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'auroracoin', 'testnet'); - - //p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'auroracoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'auroracoin', 'testnet'); - }); - - it('should return true for correct namecoin addresses', function () { - valid('NEpeRmS775fnti8TDgJA28m8KLEfNNRZvT', 'namecoin'); - valid('MyJ691bGJ48RBK2LS8n1U57wcFLFScFXxi', 'namecoin'); - valid('NFY9aw1RXLGtWpeqgNQXprnUcZXyKNinTh', 'namecoin'); - valid('NCPPc7Pzb75CpRPJQPRRh6ouJTq7BCy1H4', 'namecoin'); - valid('NCPPc7Pzb75CpRPJQPRRh6ouJTq7BCy1H4', 'NMC'); - }); - - it('should return true for correct BioCoin addresses', function () { - valid('B7xseoLGk7hEpMDDeSvZDKmmiAMHWiccok', 'biocoin'); - valid('B8zjmYFGhWmiaQSJshfrnefE72xCapCkvo', 'biocoin'); - valid('muH8LL42DiMs8GEQ6Grfi8KUw2uFvuKr1J', 'biocoin', 'testnet'); - valid('muH8LL42DiMs8GEQ6Grfi8KUw2uFvuKr1J', 'BIO', 'testnet'); - valid('B8zjmYFGhWmiaQSJshfrnefE72xCapCkvo', 'BIO'); - }); - - it('should return true for correct Garlicoin addresses', function () { - valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'garlicoin'); - valid('GNWeWaoQ6rv21ZFjJWT9vb91hXUzFTLkru', 'garlicoin'); - valid('mjKbQTkgwzmsL3J86tdVzhyW9pc4NePqTb', 'garlicoin', 'testnet'); - valid('mnYp36NuyRavMKQ9Q9Q6oGqoorAs9p3zYn', 'GRLC', 'testnet'); - valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'GRLC'); - }); - - it('should return true for correct Vertcoin addresses', function () { - valid('3PgeyhEJEnS5CeBu3iFcu3JHVKemeHx1AW', 'VTC'); - valid('353nERPQKhGj4WGzoiWcareA76TPgRCVNA', 'VTC'); - valid('376g4TmL8uQKFYsRFrbv5iz9srmb5bocEt', 'VTC'); - valid('3AMtM4Zk5oNHu9i4jDiwKB6Kg5YEReBsav', 'VTC'); - - valid('VmoMjGf3zgZLy8sk3PMKd3xikZHXWvnYi7', 'vertcoin'); - valid('VmhHwXr3J8xMZpy62WuBGpu3xVvThWzcTQ', 'vertcoin'); - valid('mvww6DEJ18dbyQUukpVQXvLgrNDJazZn1Y', 'vertcoin', 'testnet'); - valid('mn3mdEE6cf1snxVsknNz4GRTdSrWXqYp7c', 'VTC', 'testnet'); - valid('Vri6Q4GgNFfdtcpxD961TotJwaSaYQCaL5', 'VTC'); - }); - - it('should return true for correct BitcoinGold addresses', function () { - valid('GW3JrQyHtoVfEFES3Y9JagiX3VSKQStLwj', 'bitcoingold'); - valid('GUDWdeMyAXQbrNFFivAhkJQ1GfBCFdc7JF', 'bitcoingold'); - valid('mvww6DEJ18dbyQUukpVQXvLgrNDJazZn1Y', 'bitcoingold', 'testnet'); - valid('mn3mdEE6cf1snxVsknNz4GRTdSrWXqYp7c', 'BTG', 'testnet'); - valid('GSNFPRsdaM3MXrU5HW1AxgFwmUQC8HXK9F', 'BTG'); - }); - - it('should return true for correct Decred addresses', function () { - valid('Dsesax2GJnMN4wwmWo5rJGq73dDK217Rh85', 'DCR'); - valid('DsYuxtvGRfN8rncXAndtLUpJm55F77K17RA', 'decred'); - valid('DsaXDG2NrJW8g4tFAb8n9MNx81Sn3Qc8AEV', 'decred'); - valid('TsijUgejaRnLKF5WAbpUxNtwKGUiKVeXLr7', 'decred', 'testnet'); - valid('TsZ9QmAoadF12hGvyALp6qvaF4be3BmLqG9', 'dcr', 'testnet'); - }); - - it('should return true for correct Digibyte addresses', function () { - valid('DG2rM2orU2JH5i4ACh3AKNpRTNESdv5xf8', 'DGB'); - valid('DBR2Lj1F17eHGHXgbpae2Wb4m39bDyA1qo', 'DGB'); - valid('D9TDZTR9Z9Mx2NoDJnhqhnYhDLKRAmsL9n', 'digibyte'); - valid('DHRzA1YHA1kFWpz2apRckZJy6KZRyGq4EV', 'digibyte'); - valid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'digibyte'); - }); - - it('should return true for correct Ethereum addresses', function () { - valid('0xE37c0D48d68da5c5b14E5c1a9f1CFE802776D9FF', 'ethereum'); - valid('0xa00354276d2fC74ee91e37D085d35748613f4748', 'ethereum'); - valid('0xAff4d6793F584a473348EbA058deb8caad77a288', 'ETH'); - valid('0xc6d9d2cd449a754c494264e1809c50e34d64562b', 'ETH'); - valid('0x52908400098527886E0F7030069857D2E4169EE7', 'ETH'); - valid('0x8617E340B3D01FA5F11F306F4090FD50E238070D', 'ETH'); - valid('0xde709f2102306220921060314715629080e2fb77', 'ETH'); - valid('0x27b1fdb04752bbc536007a920d24acb045561c26', 'ETH'); - valid('0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', 'ETH'); - valid('0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359', 'ETH'); - valid('0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB', 'ETH'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETH'); - - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ethereumclassic'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETC'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'etherzero'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETZ'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'callisto'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'CLO'); - }); - - it('should return true for correct Ripple addresses', function () { - valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'ripple'); - valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'XRP'); - valid('r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV', 'XRP'); - valid('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', 'XRP'); - valid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN', 'XRP'); - }); - - it('should return true for correct dash addresses', function () { - valid('Xx4dYKgz3Zcv6kheaqog3fynaKWjbahb6b', 'dash'); - valid('XcY4WJ6Z2Q8w7vcYER1JypC8s2oa3SQ1b1', 'DASH'); - valid('XqMkVUZnqe3w4xvgdZRtZoe7gMitDudGs4', 'dash'); - valid('yPv7h2i8v3dJjfSH4L3x91JSJszjdbsJJA', 'dash', 'testnet'); - valid('XoAAqv3oUYZ6xRjX3brfbf9PotrGanS6Th', 'dash'); - valid('yP5oXZQXBfBf9FyfZDpFiKDypxuNUKUV2E', 'dash', 'testnet'); - }); - - it('should return true for correct neo addresses', function () { - valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neo'); - valid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X', 'NEO'); - }); - - it('should return true for correct neo gas addresses', function () { - valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neogas'); - }); - - it('should return true for correct qtum addresses', function () { - valid('QNjUiD3bVVZwYTc5AhpeQbS1mfb2guyWhe', 'qtum'); - valid('QVZnSrMwKp6AL4FjUPPnfFgsma6j1DXQXu', 'QTUM'); - valid('MCgyroQse81wuv5RwPpY5DXDNxeafzLFJ8', 'QTUM'); - valid('QQYySVc5WEe3g6PnNFYmspqG5CfSG8rnma', 'QTUM'); - valid('MSvJQBJMZs1dhxz7UAWa2si4iyMD2FHQd5', 'QTUM'); - - valid('qcSLSxN1sngCWSrKFZ6UC7ri4hhVSdq9SU', 'qtum', 'testnet'); - valid('qJnbEdrm9ybjVqDCaX5SWNBHmZy2X7YbPT', 'qtum', 'testnet'); - valid('qchBPDUYswobzpDmY5DsTStt74sTYQtaQv', 'qtum', 'testnet'); - }); - - it('should return true for correct votecoin addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); - }); - - it('should return true for correct bitcoinz addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); - }); - - it('should return true for correct zclassic addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); - }); - - it('should return true for correct hush addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); - }); - - it('should return true for correct zcash addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); - }); - - it('should return true for correct bitcoinprivate addresses', function () { - valid('b1M4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); - //valid('bx....', 'BTCP'); - //valid('nx....', 'bitcoinprivate', 'testnet'); - }); - - it('should return true for correct snowgem addresses', function () { - valid('s1fx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); - valid('s3d27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); - }); - - it('should return true for correct zencash addresses', function () { - valid('znhiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); - valid('zssEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); - valid('ztmWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); - }); - - it('should return true for correct komodo addresses', function () { - valid('R9R5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); - valid('RAvj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); - //valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); - }); - - it('should return true for correct Bankex addresses', function () { - valid('0xeac39e1bc802baae3d4b9cb518f3f60374bbad6c', 'bankex'); - valid('0x45245bc59219eeaaf6cd3f382e078a461ff9de7b', 'BKX'); - valid('0xf40d80FCfa5cdEa0bB1E570c2D52132ac9bC6aEC', 'bankex', 'testnet'); - valid('0x8A7395f281EeCf2B471B689E87Cf4C7fa8bb957d', 'BKX', 'testnet'); - }); - - - it('should return true for correct Cardano addresses', function () { - valid('Ae2tdPwUPEYxYNJw1He1esdZYvjmr4NtPzUsGTiqL9zd8ohjZYQcwu6kom7', 'cardano'); - valid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg', 'ada'); - valid('Ae2tdPwUPEZKmwoy3AU3cXb5Chnasj6mvVNxV1H11997q3VW5ihbSfQwGpm', 'ada'); - valid('4swhHtxKapQbj3TZEipgtp7NQzcRWDYqCxXYoPQWjGyHmhxS1w1TjUEszCQT1sQucGwmPQMYdv1FYs3d51KgoubviPBf', 'cardano'); - }); - - it('should return true for correct monero addresses', function () { - valid('47zQ5LAivg6hNCgijXSEFVLX7mke1bgM6YGLFaANDoJbgXDymcAAZvvMNt2PmMpqEe5qRy2zyfMYXdwpmdyitiFh84xnPG2', 'monero'); - valid('48bWuoDG75CXMDHbmPEvUF2hm1vLDic7ZJ7hqRkL65QR9p13AQAX4eEACXNk4YP115Q4KRVZnAvmMBHrcGfv9FvKPZnH6vH', 'XMR'); - valid('A2be3UvzMtkJtxRYgcCbQt2y7Rp2eLVGqNTWfZeankrWimSMM4y7uMP6B9oAZaHsXTj8KFSerkSkkVRuEuEca9QM8VhxCNU', 'monero', 'testnet'); - - //integrated addresses - valid('4Gd4DLiXzBmbVX2FZZ3Cvu6fUaWACup1qDowprUCje1kSP4FmbftiJMSfV8kWZXNqmVwj4m52xqtgFNUudVmsmGkGvkLcCibWfVUfUFVB7', 'monero'); - valid('4J5sF94AzXgFgx8LuWc9dcWkJkGkD3cL3L2AuhX6QA9jFvSxxj6QhHqHXqM2b2Go7G8RyDzEbHxYd9G26XUUbuJChipEyBz9fENMU2Ua9b', 'XMR'); - }); - - it('should return true for correct gamecredits addresses', function () { - valid('GU5BBtW9gxSKvAknvFi9yUaXKUNW9zUN2p', 'game'); - valid('GYxQMVzP6YpzX59QNRYqmJeHNtUMYSZPri', 'game'); - }); - - it('should return true for correct monacoin addresses', function () { - valid('MMN1Q1aRVUzanmg9DJjcRYzQSJQoBeQPui', 'mona'); - valid('PFMzNYnBm5X4c9qJkJPkfgdCyd9fuuy2vT', 'mona'); - valid('PCtN7VUYHW8w4g59BaphrfPs8g7pNgAzxn', 'mona'); - valid('MXCcYFGRmsd4d3CcQugFiqG8uarj5tVu76', 'mona'); - valid('MNK1pGsBf9WdoE54fZM9VFhkeYHW6VUf2u', 'mona'); - }); - - it('should return true for correct pivx addresses', function () { - valid('DJXFW9oJJBUX7QKrG6GKvmTs63MYKzwtpZ', 'pivx'); - valid('DEaYb8EHQgyKvX6VXDS3DZQautJrHBmK3T', 'pivx'); - valid('DDeCGR3QSgqsBxVR23bJvteiyYE34ZmxAc', 'pivx'); - valid('DSqQM8DPpBHHoZXHgRdwmaf6hZPEoZcFkh', 'pivx'); - }); - - it('should return true for correct solarcoin addresses', function () { - valid('8VxVLzwB26E2YZZ82o1NcQe96QSM2z6GwW', 'slr'); - valid('8YW5qcTjeyqX5kESsqu2BUdXiedgssegtQ', 'SolarCoin'); - }); - - it('should return true for correct tether addresses', function () { - valid('3MbYQMMmSkC3AgWkj9FMo5LsPTW1zBTwXL', 'usdt'); - valid('1KdXaqcBeoMAFVAPwTmYvDbEq6RnvNPF6J', 'tether'); - }); - - it('should return true for correct expanse addresses', function () { - valid('0xbab463743603a253bdf1f84975b1a9517505ae05', 'exp'); - valid('0x5d0777cb5d6977873904864c6ab531f4b3261f0b', 'expanse'); - }); - - it('should return true for correct waves addresses', function () { - valid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); - valid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHajj', 'waves'); - - valid('3Myrq5QDgRq3nBVRSSv9UYrP36xTtpJND5y', 'waves', 'testnet'); - valid('3My3KZgFQ3CrVHgz6vGRt8687sH4oAA1qp8', 'waves', 'testnet'); - }); - - it('should return true for correct nano addresses', function () { - valid('xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3', 'nano'); - valid('xrb_13ezf4od79h1tgj9aiu4djzcmmguendtjfuhwfukhuucboua8cpoihmh8byo', 'nano'); - valid('xrb_35jjmmmh81kydepzeuf9oec8hzkay7msr6yxagzxpcht7thwa5bus5tomgz9', 'nano'); - valid('xrb_1111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); - valid('xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est', 'nano'); - valid('xrb_3wm37qz19zhei7nzscjcopbrbnnachs4p1gnwo5oroi3qonw6inwgoeuufdp', 'nano'); - valid('xrb_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4', 'nano'); - valid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjmgu', 'nano'); - valid('xrb_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); - valid('nano_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); - }); - - it('should return true for correct siacoin addresses', function () { - valid( - 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', - 'siacoin' - ) - valid( - 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', - 'siacoin' - ) - valid( - 'ab0c327982abfcc6055a6c9551589167d8a73501aca8769f106371fbc937ad100c955c3b7ba9', - 'siacoin' - ) - valid( - 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530373', - 'siacoin' - ) - }) - - it('should return true for correct loki addresses', function () { - // public - valid( - 'L63ymg8cb5aRz1PhXrEQ22PWw9KBhBS8rMsgqbABhTGFfh53U3Rc2iWCJpCPsHZT5hfyt7fPQa612a5Z1tBnGYEA9h6YHnn', - 'loki' - ) - valid( - 'L5QKRGMNpQU3eCAdjMVTCR631bRKqnW1oEWWBEHAtFJLieA5VvuxyyubCd9FczEEatg8jfy39UJZ13npLJqZG6dtMtM99ha', - 'loki' - ) - // integrated - valid( - 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiD1xbPb6dpYo7toNRqk', - 'loki' - ) - valid( - 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiCtWq1AYo1oJTVqgUcQ', - 'loki' - ) - // subaddress - valid( - 'LW1VMYcvWPZZJ2h1pKGEku2y9WeDiAU2VhgrgVgvjybaRuCdcEkg6FhXjVNSd37Bp7fhYH8tVa5T9VmRaYiWyxYdCpEGBg8', - 'loki' - ) - }) - - it('should return true for correct lbry addresses', function () { - valid('bNEMVqeUZUqTrYUxud5ehnUhtTAiWDXQ5e', 'lbry') - valid('bDb6NmobyDVeNGpizWQQBZkYjKCRQBdKdG', 'LBC') - valid('bTFXPcV3a8iVDezogvHTHezWZ1mZGWpPDc', 'lbc') - valid('bK2uEVn6UuwjCTUZ1Dfj5HhWYi9BtqZDDm', 'lbry') - }) - - it('should return true for correct trx addresses', function () { - valid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r', 'trx'); - valid('27bLJCYjbH6MT8DBF9xcrK6yZnm43vx7MNQ', 'trx', 'testnet'); - }); - - it('should return true for correct nem addresses', function () { - valid('NBZMQO7ZPBYNBDUR7F75MAKA2S3DHDCIFG775N3D', 'xem'); - valid('TDWTRGT6GVWCV7GRWFNI45S53PGOJBKNUF3GE6PB', 'xem', 'testnet'); - }); - - it('should return true for correct lsk addresses', function () { - valid('469226551L', 'lsk'); - valid('15823701926930889868L', 'lsk'); - valid('1657699692452120239L', 'lsk'); - valid('555666666999992L', 'lsk'); - valid('6853061742992593192L', 'lsk'); - valid('530464791801L', 'lsk'); - }); - - it('should return true for correct bsv addresses', function () { - valid('qzwryn9fxnpqkf7zt878tp2g9cg8kpl65qh2ml0w0r', 'bsv'); - valid('qp65yngy5uds4wxtrkynptal4f76qzmrh52pa3mpaf', 'bsv'); - valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); - valid('qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); - valid('qz97s7ee0rvwlymtxrwafmvs87x6027jwuf3wepug7', 'bsv'); - valid('bitcoincash:qpp32ssez340wfspnt79h6c4xds4fzf3m5j0cplx0l', 'bsv'); - valid('qqg82u7tq2eahs3gkh9m6kjnmjehr69m5v37alepq4', 'bsv'); - valid('bitcoincash:qrwkk9a3es2wu7mdvzh0vekfvjuzysq8tv7r3hcwr5', 'bsv'); - valid('1DrNXqCj2B8FKyx66RAWDkiEJhw2yrvhT3', 'bsv'); - }); - - it('should return true for correct stellar addresses', function () { - valid('GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB', 'stellar'); - valid('GB7KKHHVYLDIZEKYJPAJUOTBE5E3NJAXPSDZK7O6O44WR3EBRO5HRPVT', 'stellar'); - valid('GD6WVYRVID442Y4JVWFWKWCZKB45UGHJAABBJRS22TUSTWGJYXIUR7N2', 'stellar'); - valid('GBCG42WTVWPO4Q6OZCYI3D6ZSTFSJIXIS6INCIUF23L6VN3ADE4337AP', 'stellar'); - valid('GDFX463YPLCO2EY7NGFMI7SXWWDQAMASGYZXCG2LATOF3PP5NQIUKBPT', 'stellar'); - valid('GBXEODUMM3SJ3QSX2VYUWFU3NRP7BQRC2ERWS7E2LZXDJXL2N66ZQ5PT', 'stellar'); - valid('GAJHORKJKDDEPYCD6URDFODV7CVLJ5AAOJKR6PG2VQOLWFQOF3X7XLOG', 'stellar'); - valid('GACXQEAXYBEZLBMQ2XETOBRO4P66FZAJENDHOQRYPUIXZIIXLKMZEXBJ', 'stellar'); - valid('GDD3XRXU3G4DXHVRUDH7LJM4CD4PDZTVP4QHOO4Q6DELKXUATR657OZV', 'stellar'); - valid('GDTYVCTAUQVPKEDZIBWEJGKBQHB4UGGXI2SXXUEW7LXMD4B7MK37CWLJ', 'stellar'); - }); - }); - - describe('invalid results', function () { - function commonTests(currency) { - invalid('', currency); //reject blank - invalid('%%@', currency); //reject invalid base58 string - invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency); //reject invalid address - invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency); //reject transaction id's - //testnet - invalid('', currency, 'testnet'); //reject blank - invalid('%%@', currency, 'testnet'); //reject invalid base58 string - invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency, 'testnet'); //reject invalid address - invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency, 'testnet'); //reject transaction id's - } - - it('should return false for incorrect bitcoin addresses', function () { - commonTests('bitcoin'); - }); - - it('should return false for incorrect bitcoincash addresses', function () { - commonTests('bitcoincash'); - }); - - it('should return false for incorrect litecoin addresses', function () { - commonTests('litecoin'); - }); - - it('should return false for incorrect peercoin addresses', function () { - commonTests('peercoin'); - }); - - it('should return false for incorrect dogecoin addresses', function () { - commonTests('dogecoin'); - }); - - it('should return false for incorrect beavercoin addresses', function () { - commonTests('beavercoin'); - }); - - it('should return false for incorrect freicoin addresses', function () { - commonTests('freicoin'); - }); - - it('should return false for incorrect protoshares addresses', function () { - commonTests('protoshares'); - }); - - it('should return false for incorrect megacoin addresses', function () { - commonTests('megacoin'); - }); - - it('should return false for incorrect primecoin addresses', function () { - commonTests('primecoin'); - }); - - it('should return false for incorrect auroracoin addresses', function () { - commonTests('auroracoin'); - }); - - it('should return false for incorrect namecoin addresses', function () { - commonTests('namecoin'); - }); - - it('should return false for incorrect biocoin addresses', function () { - commonTests('biocoin'); - }); - - it('should return false for incorrect garlicoin addresses', function () { - commonTests('garlicoin'); - }); - - it('should return false for incorrect vertcoin addresses', function () { - commonTests('vertcoin'); - }); - - it('should return false for incorrect bitcoingold addresses', function () { - commonTests('bitcoingold'); - }); - - it('should return false for incorrect decred addresses', function () { - commonTests('decred'); - }); - - it('should return false for incorrect gamecredits addresses', function () { - commonTests('game'); - }); - - it('should return false for incorrect monacoin addresses', function () { - commonTests('mona'); - }); - - it('should return false for incorrect solarcoin addresses', function () { - commonTests('slr'); - }); - - it('should return false for incorrect tether addresses', function () { - commonTests('usdt'); - }); - - it('should return false for incorrect expanse addresses', function () { - commonTests('exp'); - }); - - it('should return false for incorrect usdt addresses', function () { - commonTests('usdt'); - }); - - it('should return false for incorrect bankex addresses', function () { - invalid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'bankex'); - invalid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd', 'BKX'); - invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bankex', 'testnet'); - invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'BKX', 'testnet'); - }); - - it('should return false for incorrect digibyte addresses', function () { - commonTests('digibyte'); - }); - - it('should return false for incorrect eip55 addresses', function () { - invalid('6xAff4d6793F584a473348EbA058deb8caad77a288', 'ethereum'); - invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereum'); - invalid('0XD1220A0CF47C7B9BE7A2E6BA89F429762E7B9ADB', 'ethereum'); - invalid('aFf4d6793f584a473348ebA058deb8caad77a2885', 'ethereum'); - invalid('0xff4d6793F584a473', 'ethereum'); - - invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereumclassic'); - invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'etherzero'); - invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'callisto'); - }); - - it('should return false for incorrect ripple addresses', function () { - invalid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCN', 'ripple'); - invalid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhMN', 'XRP'); - invalid('6xAff4d6793F584a473348EbA058deb8ca', 'ripple'); - invalid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'ripple'); - }); - - it('should return false for incorrect dash addresses', function () { - commonTests('dash'); - }); - - it('should return false for incorrect neo addresses', function () { - commonTests('neo'); - invalid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTa', 'neo'); - invalid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ10', 'NEO'); - }); - - it('should return false for incorrect qtum addresses', function () { - commonTests('qtum'); - invalid('QNPhBbVhDghASxcUh2vHotQUgNeLRFTcfb', 'qtum'); - invalid('QOPhBbVhDghASxcUh2vHotQUgNeLRFTcfa', 'QTUM'); - }); - - it('should return false for incorrect votecoin addresses', function () { - commonTests('votecoin'); - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); - }); - - it('should return false for incorrect bitcoinz addresses', function () { - commonTests('bitcoinz'); - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); - }); - - it('should return false for incorrect zclassic addresses', function () { - commonTests('zclassic'); - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); - }); - - it('should return false for incorrect hush addresses', function () { - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); - }); - - it('should return false for incorrect zcash addresses', function () { - commonTests('zcash'); - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); - }); - - it('should return false for incorrect bitcoinprivate addresses', function () { - commonTests('bitcoinprivate'); - invalid('b1Y4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); - //invalid('bx....', 'BTCP'); - //invalid('nx....', 'bitcoinprivate', 'testnet'); - }); - - it('should return false for incorrect snowgem addresses', function () { - commonTests('snowgem'); - invalid('s1Yx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); - invalid('s3Y27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); - }); - - it('should return false for incorrect zencash addresses', function () { - commonTests('zencash'); - invalid('znYiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); - invalid('zsYEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); - invalid('ztYWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); - }); - - it('should return false for incorrect komodo addresses', function () { - commonTests('komodo'); - invalid('R9Y5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); - invalid('RAYj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); - //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); - }); - - it('should return false for incorrect cardano addresses', function () { - commonTests('cardano'); - invalid('Ae2tdPwUPEYxYNJw1He1esdZYvjmr4NtPzUsGTiqL9zd8ohjZYQcwu6lom7', 'cardano'); - invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg1', 'cardano'); - invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRT', 'ada'); - //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); - }); - - it('should return false for incorrect monero addresses', function () { - commonTests('monero'); - invalid('4AWygwA3hHNE4e4Yr9PtRWJiorXTjZkCi57g4ExYzfXDFFQ8DRFEFyui1dLqVknpqQjGUBdTMbgaFAZaDbrVHdk3GAKBZ3E', 'monero'); - invalid('44643dtxcxjgMWEQLo6mh1c4d9Zxx9GbgK9hEj9iGSiFEryCkbwHyJ3JqxZJRqeC3Hb7ZBLKq5NkaJwR1x95EYnR1bTgN6d', 'xmr'); - invalid('A17N9ztrxjQD3v3JJtHGvHVnq6BAbujDNEuensB6PFwBYFpkjAicih8hDtX76HBuEag5NeaCuMZmRMe6eE5NMRGxFTQn8nJ', 'monero', 'testnet'); - - //integrated - invalid('4LNSCKNSTPNbJYkyAEgL966eHJHLDHiq1PpwKoiFBybcSqNGYfLBJApC62uQEeGAFxfYEd29uXBBrJFo7DhKqFVNi3GhmN79EtD5dgycYz', 'monero'); - invalid('4JpzTwf3i1GeCV76beVr19179oa8j1L8xNSC1bXMtAxxdf4aTTLqubL8EvXfQmUGKt9MMigFtKy91VtoTTSfg1LU7LocPruT6KcGC9RKJV', 'xmr'); - }); - - it('should return false for incorrect waves addresses', function () { - commonTests('waves'); - invalid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs1', 'waves'); - invalid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHaj', 'waves'); - invalid('2P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); - - invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'waves', 'testnet'); - invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'waves', 'testnet'); - }); - - it('should return false for incorrect nano addresses', function () { - commonTests('nano'); - invalid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); - invalid('nano_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nano'); - invalid('nano_111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); - }); - - it('should return false for incorrect siacoin addresses', function () { - commonTests('siacoin') - invalid( - 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372', - 'siacoin' - ) - }) - - it('should return false for incorrect lbry addresses', function () { - commonTests('lbry') - invalid('ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372') - }) - - it('should return false for incorrect tron addresses', function () { - commonTests('trx'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'trx'); - invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'trx'); - }); - - it('should return false for incorrect nem addresses', function () { - commonTests('nem'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nem'); - invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'nem'); - - invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'nem', 'testnet'); - invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'nem', 'testnet'); - }); - //15823701926930889868L - it('should return false for incorrect lsk addresses', function () { - commonTests('lsk'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'lsk'); - invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'lsk'); - - invalid('158237019269308898689L', 'lsk'); - invalid('158237A192B930C898689L', 'lsk'); - }); - - it('should return false for incorrect bsv addresses', function () { - commonTests('bsv'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'bsv'); - invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'bsv'); - - invalid('158237019269308898689L', 'bsv'); - invalid('158237A192B930C898689L', 'bsv'); - invalid('bitcoin:qzpuefrpg3kl2ykQe52rxn96pd3Kp4qudywr5pyrsf', 'bsv'); - invalid('pzuefrpg3kl2ykqe52rxn96pd3kp4qudywr5py', 'bsv'); - invalid('rlt2c2wuxr644encp3as0hygtj9djrsaumku3cex5', 'bsv'); - invalid('qra607y4wnkmnpy3wcmrxmltzkrxywcq85c7watpdx09', 'bsv'); - }); - - it('should return false for incorrect stellar addresses', function () { - commonTests('stellar'); - invalid('SBGWKM3CD4IL47QN6X54N6Y33T3JDNVI6AIJ6CD5IM47HG3IG4O36XCU', 'stellar'); - invalid('GBPXX0A5N4JYPESHAADMQKBPWZWQDQ64ZV6ZL2S3LAGW4SY7NTCMWIVL', 'stellar'); - invalid('GCFZB6L25D26RQFDWSSBDEYQ32JHLRMTT44ZYE3DZQUTYOL7WY43PLBG++', 'stellar'); - invalid('GADE5QJ2TY7S5ZB65Q43DFGWYWCPHIYDJ2326KZGAGBN7AE5UY6JVDRRA', 'stellar'); - invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2', 'stellar'); - invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2T', 'stellar'); - invalid('GDXIIZTKTLVYCBHURXL2UPMTYXOVNI7BRAEFQCP6EZCY4JLKY4VKFNLT', 'stellar'); - invalid('SAB5556L5AN5KSR5WF7UOEFDCIODEWEO7H2UR4S5R62DFTQOGLKOVZDY', 'stellar'); - invalid('gWRYUerEKuz53tstxEuR3NCkiQDcV4wzFHmvLnZmj7PUqxW2wt', 'stellar'); - invalid('g4VPBPrHZkfE8CsjuG2S4yBQNd455UWmk', 'stellar'); - }); - }); }); diff --git a/yarn.lock b/yarn.lock index 38de34b0..6b902891 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10,11 +10,6 @@ JSONStream@^1.0.3: jsonparse "^1.2.0" through ">=2.2.7 <3" -abbrev@1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" - integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== - accepts@~1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.5.tgz#eb777df6011723a3b14e8a72c0805c8e86746bd2" @@ -58,43 +53,30 @@ ansi-colors@3.2.3: resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw== -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= - ansi-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= -ansi-styles@^3.2.1: +ansi-regex@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" + integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== dependencies: color-convert "^1.9.0" -anymatch@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" - integrity sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw== - dependencies: - micromatch "^3.1.4" - normalize-path "^2.1.1" - -aproba@^1.0.3: - version "1.2.0" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" - integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== - -are-we-there-yet@~1.1.2: - version "1.1.5" - resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" - integrity sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w== +anymatch@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" + integrity sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg== dependencies: - delegates "^1.0.0" - readable-stream "^2.0.6" + normalize-path "^3.0.0" + picomatch "^2.0.4" argparse@^1.0.7: version "1.0.10" @@ -103,21 +85,6 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -arr-diff@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" - integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= - -arr-flatten@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" - integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== - -arr-union@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" - integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= - array-filter@~0.0.0: version "0.0.1" resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-0.0.1.tgz#7da8cf2e26628ed732803581fd21f67cacd2eeec" @@ -133,21 +100,6 @@ array-reduce@~0.0.0: resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b" integrity sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys= -array-slice@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-0.2.3.tgz#dd3cfb80ed7973a75117cdac69b0b99ec86186f5" - integrity sha1-3Tz7gO15c6dRF82sabC5nshhhvU= - -array-unique@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" - integrity sha1-odl8yvy8JiXMcPrc6zalDFiwGlM= - -array-unique@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" - integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= - arraybuffer.slice@~0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675" @@ -174,25 +126,17 @@ assertion-error@^1.1.0: resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== -assign-symbols@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" - integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= - -async-each@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" - integrity sha1-GdOGodntxufByF04iu28xW0zYC0= - async-limiter@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" integrity sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg== -atob@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" - integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== +async@^2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" + integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + dependencies: + lodash "^4.17.14" backo2@1.0.2: version "1.0.2" @@ -204,10 +148,10 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= -base-x@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.5.tgz#d3ada59afed05b921ab581ec3112e6444ba0795a" - integrity sha512-C3picSgzPSLE+jW3tcBzJoGwitOtazb5B+5YmAxZm2ybmTi9LNgAtDO/jjVEBZwHoXmDBZ9m/IELj3elJVRBcA== +base-x@^3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.7.tgz#1c5a7fafe8f66b4114063e8da102799d4e7c408f" + integrity sha512-zAKJGuQPihXW22fkrfOclUUZXM2g92z5GzlSMHxhO6r6Qj+Nm0ccaGNBzDZojzwOMkpjAv4J0fOv1U4go+a4iw== dependencies: safe-buffer "^5.0.1" @@ -226,19 +170,6 @@ base64id@1.0.0: resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6" integrity sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY= -base@^0.11.1: - version "0.11.2" - resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" - integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== - dependencies: - cache-base "^1.0.1" - class-utils "^0.3.5" - component-emitter "^1.2.1" - define-property "^1.0.0" - isobject "^3.0.1" - mixin-deep "^1.2.0" - pascalcase "^0.1.1" - better-assert@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" @@ -246,10 +177,10 @@ better-assert@~1.0.0: dependencies: callsite "1.0.0" -binary-extensions@^1.0.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.12.0.tgz#c2d780f53d45bba8317a8902d4ceeaf3a6385b14" - integrity sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg== +binary-extensions@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" + integrity sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow== blob@0.0.4: version "0.0.4" @@ -290,28 +221,12 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^0.1.2: - version "0.1.5" - resolved "https://registry.yarnpkg.com/braces/-/braces-0.1.5.tgz#c085711085291d8b75fdd74eab0f8597280711e6" - integrity sha1-wIVxEIUpHYt1/ddOqw+FlygHEeY= - dependencies: - expand-range "^0.1.0" - -braces@^2.3.0, braces@^2.3.1: - version "2.3.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" - integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== - dependencies: - arr-flatten "^1.1.0" - array-unique "^0.3.2" - extend-shallow "^2.0.1" - fill-range "^4.0.0" - isobject "^3.0.1" - repeat-element "^1.1.2" - snapdragon "^0.8.1" - snapdragon-node "^2.0.1" - split-string "^3.0.2" - to-regex "^3.0.1" +braces@^3.0.2, braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" brorand@^1.0.1: version "1.1.0" @@ -406,10 +321,10 @@ browserify-zlib@~0.2.0: dependencies: pako "~1.0.5" -browserify@^16.2.3: - version "16.2.3" - resolved "https://registry.yarnpkg.com/browserify/-/browserify-16.2.3.tgz#7ee6e654ba4f92bce6ab3599c3485b1cc7a0ad0b" - integrity sha512-zQt/Gd1+W+IY+h/xX2NYMW4orQWhqSwyV+xsblycTtpOuB27h1fZhhNQuipJ4t79ohw4P4mMem0jp/ZkISQtjQ== +browserify@^16.5.0: + version "16.5.0" + resolved "https://registry.yarnpkg.com/browserify/-/browserify-16.5.0.tgz#a1c2bc0431bec11fd29151941582e3f645ede881" + integrity sha512-6bfI3cl76YLAnCZ75AGu/XPOsqUhRyc0F/olGIJeCxtfxF2HvPKEcmjU9M8oAPxl4uBY1U7Nry33Q6koV3f2iw== dependencies: JSONStream "^1.0.3" assert "^1.4.0" @@ -448,7 +363,7 @@ browserify@^16.2.3: shasum "^1.0.0" shell-quote "^1.6.1" stream-browserify "^2.0.0" - stream-http "^2.0.0" + stream-http "^3.0.0" string_decoder "^1.1.1" subarg "^1.0.0" syntax-error "^1.1.1" @@ -506,21 +421,6 @@ bytes@3.0.0: resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" integrity sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg= -cache-base@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" - integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== - dependencies: - collection-visit "^1.0.0" - component-emitter "^1.2.1" - get-value "^2.0.6" - has-value "^1.0.0" - isobject "^3.0.1" - set-value "^2.0.0" - to-object-path "^0.3.0" - union-value "^1.0.0" - unset-value "^1.0.0" - cached-path-relative@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/cached-path-relative/-/cached-path-relative-1.0.1.tgz#d09c4b52800aa4c078e2dd81a869aac90d2e54e7" @@ -567,30 +467,35 @@ check-error@^1.0.2: resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= -chokidar@^2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.0.4.tgz#356ff4e2b0e8e43e322d18a372460bbcf3accd26" - integrity sha512-z9n7yt9rOvIJrMhvDtDictKrkFHeihkNl6uWMmZlmL6tJtX9Cs+87oK+teBx+JIgzvbX3yZHT3eF8vpbDxHJXQ== - dependencies: - anymatch "^2.0.0" - async-each "^1.0.0" - braces "^2.3.0" - glob-parent "^3.1.0" - inherits "^2.0.1" - is-binary-path "^1.0.0" - is-glob "^4.0.0" - lodash.debounce "^4.0.8" - normalize-path "^2.1.1" - path-is-absolute "^1.0.0" - readdirp "^2.0.0" - upath "^1.0.5" +chokidar@3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.0.tgz#12c0714668c55800f659e262d4962a97faf554a6" + integrity sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.2.0" optionalDependencies: - fsevents "^1.2.2" - -chownr@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" - integrity sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g== + fsevents "~2.1.1" + +chokidar@^3.0.0: + version "3.3.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.1.tgz#c84e5b3d18d9a4d77558fef466b1bf16bbeb3450" + integrity sha512-4QYCEWOcK3OJrxwvyyAOxFuhpvOVCYkr33LPfFNBjAD/w3sEzWsp2BUOkI4l9bHvWioAd0rc6NlHUOEaWkTeqg== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.3.0" + optionalDependencies: + fsevents "~2.1.2" cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: version "1.0.4" @@ -600,42 +505,14 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: inherits "^2.0.1" safe-buffer "^5.0.1" -circular-json@^0.5.5: - version "0.5.9" - resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.5.9.tgz#932763ae88f4f7dead7a0d09c8a51a4743a53b1d" - integrity sha512-4ivwqHpIFJZBuhN3g/pEcdbnGUywkBblloGbkglyloVjjR3uT6tieI89MVOfbP2tHX5sgb01FuLgAOzebNlJNQ== - -class-utils@^0.3.5: - version "0.3.6" - resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" - integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== - dependencies: - arr-union "^3.1.0" - define-property "^0.2.5" - isobject "^3.0.0" - static-extend "^0.1.1" - -cliui@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" - integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ== - dependencies: - string-width "^2.1.1" - strip-ansi "^4.0.0" - wrap-ansi "^2.0.0" - -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= - -collection-visit@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" - integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== dependencies: - map-visit "^1.0.0" - object-visit "^1.0.0" + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" color-convert@^1.9.0: version "1.9.3" @@ -654,13 +531,6 @@ colors@^1.1.0: resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.2.tgz#2df8ff573dfbf255af562f8ce7181d6b971a359b" integrity sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ== -combine-lists@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/combine-lists/-/combine-lists-1.0.1.tgz#458c07e09e0d900fc28b70a3fec2dacd1d2cb7f6" - integrity sha1-RYwH4J4NkA/Ci3Cj/sLazR0st/Y= - dependencies: - lodash "^4.5.0" - combine-source-map@^0.8.0, combine-source-map@~0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.8.0.tgz#a58d0df042c186fcf822a8e8015f5450d2d79a8b" @@ -681,7 +551,7 @@ component-bind@1.0.0: resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" integrity sha1-AMYIq33Nk4l8AAllGx06jh5zu9E= -component-emitter@1.2.1, component-emitter@^1.2.1: +component-emitter@1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" integrity sha1-E3kY1teCg/ffemt8WmPhQOaUJeY= @@ -723,11 +593,6 @@ console-browserify@^1.1.0: dependencies: date-now "^0.1.4" -console-control-strings@^1.0.0, console-control-strings@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" - integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= - constants-browserify@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" @@ -748,16 +613,6 @@ cookie@0.3.1: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s= -copy-descriptor@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" - integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= - -core-js@^2.2.0: - version "2.5.7" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" - integrity sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw== - core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -801,17 +656,6 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" -cross-spawn@^6.0.0: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" - crypto-browserify@^3.0.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -834,24 +678,24 @@ custom-event@~1.0.0: resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" integrity sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU= -date-format@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/date-format/-/date-format-1.2.0.tgz#615e828e233dd1ab9bb9ae0950e0ceccfa6ecad8" - integrity sha1-YV6CjiM90aubua4JUODOzPpuytg= +date-format@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/date-format/-/date-format-2.1.0.tgz#31d5b5ea211cf5fd764cd38baf9d033df7e125cf" + integrity sha512-bYQuGLeFxhkxNOF3rcMtiZxvCBAquGzZm6oWA1oZ0g2THUzivaRhv8uOhdr19LmoobSOLoIAxeUK2RdbM8IFTA== date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" integrity sha1-6vQ5/U1ISK105cx9vvIAZyueNFs= -debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3: +debug@2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== dependencies: ms "2.0.0" -debug@3.2.6, debug@^3.1.0: +debug@3.2.6, debug@^3.2.6: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== @@ -865,16 +709,18 @@ debug@=3.1.0, debug@~3.1.0: dependencies: ms "2.0.0" +debug@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== + dependencies: + ms "^2.1.1" + decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= -decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" - integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= - deep-eql@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" @@ -882,11 +728,6 @@ deep-eql@^3.0.1: dependencies: type-detect "^4.0.0" -deep-extend@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" - integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== - define-properties@^1.1.2: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -894,38 +735,11 @@ define-properties@^1.1.2: dependencies: object-keys "^1.0.12" -define-property@^0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" - integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= - dependencies: - is-descriptor "^0.1.0" - -define-property@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" - integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY= - dependencies: - is-descriptor "^1.0.0" - -define-property@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" - integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== - dependencies: - is-descriptor "^1.0.2" - isobject "^3.0.1" - defined@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" integrity sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM= -delegates@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" - integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= - depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -949,16 +763,6 @@ des.js@^1.0.0: inherits "^2.0.1" minimalistic-assert "^1.0.0" -detect-file@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" - integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= - -detect-libc@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - detective@^5.0.2: version "5.1.0" resolved "https://registry.yarnpkg.com/detective/-/detective-5.1.0.tgz#7a20d89236d7b331ccea65832e7123b5551bb7cb" @@ -1027,18 +831,16 @@ elliptic@^6.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.0" +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + encodeurl@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= -end-of-stream@^1.1.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" - integrity sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q== - dependencies: - once "^1.4.0" - engine.io-client@~3.2.0: version "3.2.1" resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.2.1.tgz#6f54c0475de487158a1a7c77d10178708b6add36" @@ -1138,99 +940,17 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: md5.js "^1.3.4" safe-buffer "^5.1.1" -execa@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" - integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== - dependencies: - cross-spawn "^6.0.0" - get-stream "^4.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -expand-braces@^0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/expand-braces/-/expand-braces-0.1.2.tgz#488b1d1d2451cb3d3a6b192cfc030f44c5855fea" - integrity sha1-SIsdHSRRyz06axks/AMPRMWFX+o= - dependencies: - array-slice "^0.2.3" - array-unique "^0.2.1" - braces "^0.1.2" - -expand-brackets@^2.1.4: - version "2.1.4" - resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" - integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= - dependencies: - debug "^2.3.3" - define-property "^0.2.5" - extend-shallow "^2.0.1" - posix-character-classes "^0.1.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - -expand-range@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-0.1.1.tgz#4cb8eda0993ca56fa4f41fc42f3cbb4ccadff044" - integrity sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ= - dependencies: - is-number "^0.1.1" - repeat-string "^0.2.2" - -expand-tilde@^2.0.0, expand-tilde@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-2.0.2.tgz#97e801aa052df02454de46b02bf621642cdc8502" - integrity sha1-l+gBqgUt8CRU3kawK/YhZCzchQI= - dependencies: - homedir-polyfill "^1.0.1" - -extend-shallow@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" - integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8= - dependencies: - is-extendable "^0.1.0" - -extend-shallow@^3.0.0, extend-shallow@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" - integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= - dependencies: - assign-symbols "^1.0.0" - is-extendable "^1.0.1" - extend@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== -extglob@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" - integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== - dependencies: - array-unique "^0.3.2" - define-property "^1.0.0" - expand-brackets "^2.1.4" - extend-shallow "^2.0.1" - fragment-cache "^0.2.1" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - -fill-range@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" - integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== dependencies: - extend-shallow "^2.0.1" - is-number "^3.0.0" - repeat-string "^1.6.1" - to-regex-range "^2.1.0" + to-regex-range "^5.0.1" finalhandler@1.1.0: version "1.1.0" @@ -1245,23 +965,13 @@ finalhandler@1.1.0: statuses "~1.3.1" unpipe "~1.0.0" -find-up@^3.0.0: +find-up@3.0.0, find-up@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== dependencies: locate-path "^3.0.0" -findup-sync@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc" - integrity sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw= - dependencies: - detect-file "^1.0.0" - is-glob "^3.1.0" - micromatch "^3.0.4" - resolve-dir "^1.0.1" - flat@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/flat/-/flat-4.1.0.tgz#090bec8b05e39cba309747f1d588f04dbaf98db2" @@ -1269,6 +979,11 @@ flat@^4.1.0: dependencies: is-buffer "~2.0.3" +flatted@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08" + integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg== + follow-redirects@^1.0.0: version "1.5.9" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.9.tgz#c9ed9d748b814a39535716e531b9196a845d89c6" @@ -1276,98 +991,51 @@ follow-redirects@^1.0.0: dependencies: debug "=3.1.0" -for-in@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" - integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= - -fragment-cache@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" - integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= - dependencies: - map-cache "^0.2.2" - -fs-access@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a" - integrity sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o= - dependencies: - null-check "^1.0.0" - -fs-minipass@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d" - integrity sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ== +fs-extra@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== dependencies: - minipass "^2.2.1" + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= -fsevents@^1.2.2: - version "1.2.4" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.4.tgz#f41dcb1af2582af3692da36fc55cbd8e1041c426" - integrity sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg== - dependencies: - nan "^2.9.2" - node-pre-gyp "^0.10.0" +fsevents@~2.1.1, fsevents@~2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805" + integrity sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA== function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== -gauge@~2.7.3: - version "2.7.4" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" - integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= - dependencies: - aproba "^1.0.3" - console-control-strings "^1.0.0" - has-unicode "^2.0.0" - object-assign "^4.1.0" - signal-exit "^3.0.0" - string-width "^1.0.1" - strip-ansi "^3.0.1" - wide-align "^1.1.0" - get-assigned-identifiers@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz#6dbf411de648cbaf8d9169ebb0d2d576191e2ff1" integrity sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ== -get-caller-file@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" - integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== +get-caller-file@^2.0.1: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== get-func-name@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= -get-stream@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" - integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== - dependencies: - pump "^3.0.0" - -get-value@^2.0.3, get-value@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" - integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= - -glob-parent@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" - integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= +glob-parent@~5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2" + integrity sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw== dependencies: - is-glob "^3.1.0" - path-dirname "^1.0.0" + is-glob "^4.0.1" glob@7.1.3, glob@^7.0.5, glob@^7.1.0, glob@^7.1.1: version "7.1.3" @@ -1381,31 +1049,16 @@ glob@7.1.3, glob@^7.0.5, glob@^7.1.0, glob@^7.1.1: once "^1.3.0" path-is-absolute "^1.0.0" -global-modules@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-1.0.0.tgz#6d770f0eb523ac78164d72b5e71a8877265cc3ea" - integrity sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg== - dependencies: - global-prefix "^1.0.1" - is-windows "^1.0.1" - resolve-dir "^1.0.0" - -global-prefix@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-1.0.2.tgz#dbf743c6c14992593c655568cb66ed32c0122ebe" - integrity sha1-2/dDxsFJklk8ZVVoy2btMsASLr4= - dependencies: - expand-tilde "^2.0.2" - homedir-polyfill "^1.0.1" - ini "^1.3.4" - is-windows "^1.0.1" - which "^1.2.14" - -graceful-fs@^4.1.11, graceful-fs@^4.1.2: +graceful-fs@^4.1.2: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" integrity sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg= +graceful-fs@^4.1.6: + version "4.2.3" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" + integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ== + growl@1.10.5: version "1.10.5" resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" @@ -1433,42 +1086,6 @@ has-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= -has-unicode@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" - integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= - -has-value@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" - integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= - dependencies: - get-value "^2.0.3" - has-values "^0.1.4" - isobject "^2.0.0" - -has-value@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" - integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= - dependencies: - get-value "^2.0.6" - has-values "^1.0.0" - isobject "^3.0.0" - -has-values@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" - integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E= - -has-values@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" - integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= - dependencies: - is-number "^3.0.0" - kind-of "^4.0.0" - has@^1.0.0, has@^1.0.1, has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" @@ -1506,13 +1123,6 @@ hmac-drbg@^1.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -homedir-polyfill@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" - integrity sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA== - dependencies: - parse-passwd "^1.0.0" - htmlescape@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/htmlescape/-/htmlescape-1.1.1.tgz#3a03edc2214bca3b66424a3e7959349509cb0351" @@ -1549,25 +1159,11 @@ iconv-lite@0.4.23: dependencies: safer-buffer ">= 2.1.2 < 3" -iconv-lite@^0.4.4: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - ieee754@^1.1.4: version "1.1.12" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.12.tgz#50bf24e5b9c8bb98af4964c941cdb0918da7b60b" integrity sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA== -ignore-walk@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8" - integrity sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ== - dependencies: - minimatch "^3.0.4" - indexof@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" @@ -1591,11 +1187,6 @@ inherits@2.0.1: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" integrity sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE= -ini@^1.3.4, ini@~1.3.0: - version "1.3.5" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" - integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== - inline-source-map@~0.6.0: version "0.6.2" resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.6.2.tgz#f9393471c18a79d1724f863fa38b586370ade2a5" @@ -1619,33 +1210,14 @@ insert-module-globals@^7.0.0: undeclared-identifiers "^1.1.2" xtend "^4.0.0" -invert-kv@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" - integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA== - -is-accessor-descriptor@^0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" - integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= - dependencies: - kind-of "^3.0.2" - -is-accessor-descriptor@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" - integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== - dependencies: - kind-of "^6.0.0" - -is-binary-path@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" - integrity sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg= +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== dependencies: - binary-extensions "^1.0.0" + binary-extensions "^2.0.0" -is-buffer@^1.1.0, is-buffer@^1.1.5: +is-buffer@^1.1.0: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== @@ -1660,104 +1232,32 @@ is-callable@^1.1.4: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== -is-data-descriptor@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" - integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= - dependencies: - kind-of "^3.0.2" - -is-data-descriptor@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" - integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== - dependencies: - kind-of "^6.0.0" - is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" integrity sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY= -is-descriptor@^0.1.0: - version "0.1.6" - resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" - integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== - dependencies: - is-accessor-descriptor "^0.1.6" - is-data-descriptor "^0.1.4" - kind-of "^5.0.0" - -is-descriptor@^1.0.0, is-descriptor@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" - integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== - dependencies: - is-accessor-descriptor "^1.0.0" - is-data-descriptor "^1.0.0" - kind-of "^6.0.2" - -is-extendable@^0.1.0, is-extendable@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" - integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= - -is-extendable@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" - integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== - dependencies: - is-plain-object "^2.0.4" - -is-extglob@^2.1.0, is-extglob@^2.1.1: +is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= - dependencies: - number-is-nan "^1.0.0" - is-fullwidth-code-point@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= -is-glob@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" - integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= - dependencies: - is-extglob "^2.1.0" - -is-glob@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0" - integrity sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A= +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== dependencies: is-extglob "^2.1.1" -is-number@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-0.1.1.tgz#69a7af116963d47206ec9bd9b48a14216f1e3806" - integrity sha1-aaevEWlj1HIG7JvZtIoUIW8eOAY= - -is-number@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" - integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= - dependencies: - kind-of "^3.0.2" - -is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" - integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== - dependencies: - isobject "^3.0.1" +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== is-regex@^1.0.4: version "1.0.4" @@ -1766,11 +1266,6 @@ is-regex@^1.0.4: dependencies: has "^1.0.1" -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= - is-symbol@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.2.tgz#a055f6ae57192caee329e7a860118b497a950f38" @@ -1778,16 +1273,6 @@ is-symbol@^1.0.2: dependencies: has-symbols "^1.0.0" -is-windows@^1.0.1, is-windows@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" - integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== - -isarray@1.0.0, isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= - isarray@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e" @@ -1798,6 +1283,11 @@ isarray@^2.0.4: resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.4.tgz#38e7bcbb0f3ba1b7933c86ba1894ddfc3781bbb7" integrity sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA== +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + isbinaryfile@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-3.0.3.tgz#5d6def3edebf6e8ca8cae9c30183a804b5f8be80" @@ -1810,22 +1300,10 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= -isobject@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" - integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= - dependencies: - isarray "1.0.0" - -isobject@^3.0.0, isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= - -js-yaml@3.12.0: - version "3.12.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" - integrity sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A== +js-yaml@3.13.1: + version "3.13.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" + integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== dependencies: argparse "^1.0.7" esprima "^4.0.0" @@ -1837,6 +1315,13 @@ json-stable-stringify@~0.0.0: dependencies: jsonify "~0.0.0" +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + optionalDependencies: + graceful-fs "^4.1.6" + jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" @@ -1857,12 +1342,11 @@ karma-chai@^0.1.0: resolved "https://registry.yarnpkg.com/karma-chai/-/karma-chai-0.1.0.tgz#bee5ad40400517811ae34bb945f762909108b79a" integrity sha1-vuWtQEAFF4Ea40u5RfdikJEIt5o= -karma-chrome-launcher@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz#cf1b9d07136cc18fe239327d24654c3dbc368acf" - integrity sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w== +karma-chrome-launcher@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.1.0.tgz#805a586799a4d05f4e54f72a204979f3f3066738" + integrity sha512-3dPs/n7vgz1rxxtynpzZTvb9y/GIaW8xjAwcIGttLbycqoFtI7yo1NGnQi6oFTherRE+GIhCAHZC4vEqWGhNvg== dependencies: - fs-access "^1.0.0" which "^1.2.1" karma-mocha@^1.3.0: @@ -1872,27 +1356,26 @@ karma-mocha@^1.3.0: dependencies: minimist "1.2.0" -karma@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/karma/-/karma-3.1.1.tgz#94c8edd20fb9597ccde343326da009737fb0423a" - integrity sha512-NetT3wPCQMNB36uiL9LLyhrOt8SQwrEKt0xD3+KpTCfm0VxVyUJdPL5oTq2Ic5ouemgL/Iz4wqXEbF3zea9kQQ== +karma@^4.4.1: + version "4.4.1" + resolved "https://registry.yarnpkg.com/karma/-/karma-4.4.1.tgz#6d9aaab037a31136dc074002620ee11e8c2e32ab" + integrity sha512-L5SIaXEYqzrh6b1wqYC42tNsFMx2PWuxky84pK9coK09MvmL7mxii3G3bZBh/0rvD27lqDd0le9jyhzvwif73A== dependencies: bluebird "^3.3.0" body-parser "^1.16.1" - chokidar "^2.0.3" + braces "^3.0.2" + chokidar "^3.0.0" colors "^1.1.0" - combine-lists "^1.0.0" connect "^3.6.0" - core-js "^2.2.0" di "^0.0.1" dom-serialize "^2.2.0" - expand-braces "^0.1.1" + flatted "^2.0.0" glob "^7.1.1" graceful-fs "^4.1.2" http-proxy "^1.13.0" isbinaryfile "^3.0.0" - lodash "^4.17.4" - log4js "^3.0.0" + lodash "^4.17.14" + log4js "^4.0.0" mime "^2.3.1" minimatch "^3.0.2" optimist "^0.6.1" @@ -1903,31 +1386,7 @@ karma@^3.1.1: socket.io "2.1.1" source-map "^0.6.1" tmp "0.0.33" - useragent "2.2.1" - -kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" - integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= - dependencies: - is-buffer "^1.1.5" - -kind-of@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" - integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc= - dependencies: - is-buffer "^1.1.5" - -kind-of@^5.0.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" - integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== - -kind-of@^6.0.0, kind-of@^6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" - integrity sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA== + useragent "2.3.0" labeled-stream-splicer@^2.0.0: version "2.0.1" @@ -1938,13 +1397,6 @@ labeled-stream-splicer@^2.0.0: isarray "^2.0.4" stream-splicer "^2.0.0" -lcid@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" - integrity sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA== - dependencies: - invert-kv "^2.0.0" - locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -1953,20 +1405,15 @@ locate-path@^3.0.0: p-locate "^3.0.0" path-exists "^3.0.0" -lodash.debounce@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" - integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= - lodash.memoize@~3.0.3: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" integrity sha1-LcvSwofLwKVcxCMovQxzYVDVPj8= -lodash@^4.17.11, lodash@^4.17.4, lodash@^4.5.0: - version "4.17.11" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" - integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== +lodash@^4.17.14, lodash@^4.17.15: + version "4.17.15" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" + integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== log-symbols@2.2.0: version "2.2.0" @@ -1975,40 +1422,24 @@ log-symbols@2.2.0: dependencies: chalk "^2.0.1" -log4js@^3.0.0: - version "3.0.6" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-3.0.6.tgz#e6caced94967eeeb9ce399f9f8682a4b2b28c8ff" - integrity sha512-ezXZk6oPJCWL483zj64pNkMuY/NcRX5MPiB0zE6tjZM137aeusrOnW1ecxgF9cmwMWkBMhjteQxBPoZBh9FDxQ== +log4js@^4.0.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/log4js/-/log4js-4.5.1.tgz#e543625e97d9e6f3e6e7c9fc196dd6ab2cae30b5" + integrity sha512-EEEgFcE9bLgaYUKuozyFfytQM2wDHtXn4tAN41pkaxpNjAykv11GVdeI4tHtmPWW4Xrgh9R/2d7XYghDVjbKKw== dependencies: - circular-json "^0.5.5" - date-format "^1.2.0" - debug "^3.1.0" - rfdc "^1.1.2" - streamroller "0.7.0" + date-format "^2.0.0" + debug "^4.1.1" + flatted "^2.0.0" + rfdc "^1.1.4" + streamroller "^1.0.6" -lru-cache@2.2.x: - version "2.2.4" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d" - integrity sha1-bGWGGb7PFAMdDQtZSxYELOTcBj0= - -map-age-cleaner@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" - integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== - dependencies: - p-defer "^1.0.0" - -map-cache@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" - integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= - -map-visit@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" - integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= +lru-cache@4.1.x: + version "4.1.5" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" + integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== dependencies: - object-visit "^1.0.0" + pseudomap "^1.0.2" + yallist "^2.1.2" md5.js@^1.3.4: version "1.3.5" @@ -2024,34 +1455,6 @@ media-typer@0.3.0: resolved "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -mem@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/mem/-/mem-4.1.0.tgz#aeb9be2d21f47e78af29e4ac5978e8afa2ca5b8a" - integrity sha512-I5u6Q1x7wxO0kdOpYBB28xueHADYps5uty/zg936CiG8NTe5sJL8EjrCuLneuDW3PlMdZBGDIn8BirEVdovZvg== - dependencies: - map-age-cleaner "^0.1.1" - mimic-fn "^1.0.0" - p-is-promise "^2.0.0" - -micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4: - version "3.1.10" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" - integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== - dependencies: - arr-diff "^4.0.0" - array-unique "^0.3.2" - braces "^2.3.1" - define-property "^2.0.2" - extend-shallow "^3.0.2" - extglob "^2.0.4" - fragment-cache "^0.2.1" - kind-of "^6.0.2" - nanomatch "^1.2.9" - object.pick "^1.3.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.2" - miller-rabin@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" @@ -2077,11 +1480,6 @@ mime@^2.3.1: resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369" integrity sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg== -mimic-fn@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" - integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== - minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" @@ -2104,7 +1502,7 @@ minimist@0.0.8: resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= -minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0: +minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1: version "1.2.0" resolved "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= @@ -2114,64 +1512,42 @@ minimist@~0.0.1: resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8= -minipass@^2.2.1, minipass@^2.3.3: - version "2.3.5" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848" - integrity sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - -minizlib@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.1.1.tgz#6734acc045a46e61d596a43bb9d9cd326e19cc42" - integrity sha512-TrfjCjk4jLhcJyGMYymBH6oTXcWjYbUAXTHDbtnWHjZC25h0cdajHuPE1zxb4DVmu8crfh+HwH/WMuyLG0nHBg== - dependencies: - minipass "^2.2.1" - -mixin-deep@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" - integrity sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ== - dependencies: - for-in "^1.0.2" - is-extendable "^1.0.1" - -mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1: +mkdirp@0.5.1, mkdirp@^0.5.0: version "0.5.1" resolved "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= dependencies: minimist "0.0.8" -mocha@^6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-6.0.2.tgz#cdc1a6fdf66472c079b5605bac59d29807702d2c" - integrity sha512-RtTJsmmToGyeTznSOMoM6TPEk1A84FQaHIciKrRqARZx+B5ccJ5tXlmJzEKGBxZdqk9UjpRsesZTUkZmR5YnuQ== +mocha@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.0.0.tgz#c60d14bf3de9601f549b3ff5be657eb8381c54bf" + integrity sha512-CirsOPbO3jU86YKjjMzFLcXIb5YiGLUrjrXFHoJ3e2z9vWiaZVCZQ2+gtRGMPWF+nFhN6AWwLM/juzAQ6KRkbA== dependencies: ansi-colors "3.2.3" browser-stdout "1.3.1" + chokidar "3.3.0" debug "3.2.6" diff "3.5.0" escape-string-regexp "1.0.5" - findup-sync "2.0.0" + find-up "3.0.0" glob "7.1.3" growl "1.10.5" he "1.2.0" - js-yaml "3.12.0" + js-yaml "3.13.1" log-symbols "2.2.0" minimatch "3.0.4" mkdirp "0.5.1" ms "2.1.1" - node-environment-flags "1.0.4" + node-environment-flags "1.0.6" object.assign "4.1.0" strip-json-comments "2.0.1" supports-color "6.0.0" which "1.3.1" wide-align "1.1.3" - yargs "12.0.5" - yargs-parser "11.1.1" - yargs-unparser "1.5.0" + yargs "13.3.0" + yargs-parser "13.1.1" + yargs-unparser "1.6.0" module-deps@^6.0.0: version "6.1.0" @@ -2204,156 +1580,34 @@ ms@2.1.1, ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -nan@^2.9.2: - version "2.11.1" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766" - integrity sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA== - -nanomatch@^1.2.9: - version "1.2.13" - resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" - integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== - dependencies: - arr-diff "^4.0.0" - array-unique "^0.3.2" - define-property "^2.0.2" - extend-shallow "^3.0.2" - fragment-cache "^0.2.1" - is-windows "^1.0.2" - kind-of "^6.0.2" - object.pick "^1.3.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - -needle@^2.2.1: - version "2.2.4" - resolved "https://registry.yarnpkg.com/needle/-/needle-2.2.4.tgz#51931bff82533b1928b7d1d69e01f1b00ffd2a4e" - integrity sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA== - dependencies: - debug "^2.1.2" - iconv-lite "^0.4.4" - sax "^1.2.4" - negotiator@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" integrity sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk= -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== - -node-environment-flags@1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.4.tgz#0b784a6551426bfc16d3b2208424dcbc2b2ff038" - integrity sha512-M9rwCnWVLW7PX+NUWe3ejEdiLYinRpsEre9hMkU/6NS4h+EEulYaDH1gCEZ2gyXsmw+RXYDaV2JkkTNcsPDJ0Q== +node-environment-flags@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.6.tgz#a30ac13621f6f7d674260a54dede048c3982c088" + integrity sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw== dependencies: object.getownpropertydescriptors "^2.0.3" + semver "^5.7.0" -node-pre-gyp@^0.10.0: - version "0.10.3" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc" - integrity sha512-d1xFs+C/IPS8Id0qPTZ4bUT8wWryfR/OzzAFxweG+uLN85oPzyo2Iw6bVlLQ/JOdgNonXLCoRyqDzDWq4iw72A== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.1" - needle "^2.2.1" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4" - -nopt@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" - integrity sha1-0NRoWv1UFRk8jHUFYC0NF81kR00= - dependencies: - abbrev "1" - osenv "^0.1.4" - -normalize-path@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" - integrity sha1-GrKLVW4Zg2Oowab35vogE3/mrtk= - dependencies: - remove-trailing-separator "^1.0.1" - -npm-bundled@^1.0.1: - version "1.0.5" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.5.tgz#3c1732b7ba936b3a10325aef616467c0ccbcc979" - integrity sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g== - -npm-packlist@^1.1.6: - version "1.1.12" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.1.12.tgz#22bde2ebc12e72ca482abd67afc51eb49377243a" - integrity sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g== - dependencies: - ignore-walk "^3.0.1" - npm-bundled "^1.0.1" - -npm-run-path@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= - dependencies: - path-key "^2.0.0" - -npmlog@^4.0.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" - integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== - dependencies: - are-we-there-yet "~1.1.2" - console-control-strings "~1.1.0" - gauge "~2.7.3" - set-blocking "~2.0.0" - -null-check@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd" - integrity sha1-l33/1xdgErnsMNKjnbXPcqBDnt0= - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= - -object-assign@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== object-component@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" integrity sha1-8MaapQ78lbhmwYb0AKM3acsvEpE= -object-copy@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" - integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw= - dependencies: - copy-descriptor "^0.1.0" - define-property "^0.2.5" - kind-of "^3.0.3" - object-keys@^1.0.11, object-keys@^1.0.12: version "1.1.0" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.0.tgz#11bd22348dd2e096a045ab06f6c85bcc340fa032" integrity sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg== -object-visit@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" - integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= - dependencies: - isobject "^3.0.0" - object.assign@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" @@ -2372,13 +1626,6 @@ object.getownpropertydescriptors@^2.0.3: define-properties "^1.1.2" es-abstract "^1.5.1" -object.pick@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" - integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= - dependencies: - isobject "^3.0.1" - on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -2386,7 +1633,7 @@ on-finished@~2.3.0: dependencies: ee-first "1.1.1" -once@^1.3.0, once@^1.3.1, once@^1.4.0: +once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= @@ -2406,48 +1653,11 @@ os-browserify@~0.3.0: resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= -os-homedir@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= - -os-locale@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" - integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q== - dependencies: - execa "^1.0.0" - lcid "^2.0.0" - mem "^4.0.0" - -os-tmpdir@^1.0.0, os-tmpdir@~1.0.2: +os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= -osenv@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" - integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.0" - -p-defer@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" - integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= - -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= - -p-is-promise@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.0.0.tgz#7554e3d572109a87e1f3f53f6a7d85d1b194f4c5" - integrity sha512-pzQPhYMCAgLAKPWD2jC3Se9fEfrD9npNos0y150EeqZll7akhEgGhTW/slB6lHku8AvYGiJ+YJ5hfHKePPgFWg== - p-limit@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" @@ -2490,11 +1700,6 @@ parse-asn1@^5.0.0: evp_bytestokey "^1.0.0" pbkdf2 "^3.0.3" -parse-passwd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" - integrity sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= - parseqs@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" @@ -2514,21 +1719,11 @@ parseurl@~1.3.2: resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" integrity sha1-/CidTtiZMRlGDBViUyYs3I3mW/M= -pascalcase@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" - integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= - path-browserify@~0.0.0: version "0.0.1" resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ== -path-dirname@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" - integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= - path-exists@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" @@ -2539,11 +1734,6 @@ path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= -path-key@^2.0.0, path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= - path-parse@^1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" @@ -2570,10 +1760,10 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" -posix-character-classes@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" - integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= +picomatch@^2.0.4, picomatch@^2.0.7: + version "2.2.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a" + integrity sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA== process-nextick-args@~2.0.0: version "2.0.0" @@ -2585,6 +1775,11 @@ process@~0.11.0: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= +pseudomap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= + public-encrypt@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" @@ -2597,14 +1792,6 @@ public-encrypt@^4.0.0: randombytes "^2.0.1" safe-buffer "^5.1.2" -pump@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - punycode@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" @@ -2665,16 +1852,6 @@ raw-body@2.3.3: iconv-lite "0.4.23" unpipe "1.0.0" -rc@^1.2.7: - version "1.2.8" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" - integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== - dependencies: - deep-extend "^0.6.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - read-only-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/read-only-stream/-/read-only-stream-2.0.0.tgz#2724fd6a8113d73764ac288d4386270c1dbf17f0" @@ -2682,7 +1859,7 @@ read-only-stream@^2.0.0: dependencies: readable-stream "^2.0.2" -readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.6: +readable-stream@^2.0.2, readable-stream@^2.1.5, readable-stream@^2.2.2: version "2.3.6" resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== @@ -2695,71 +1872,44 @@ readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable string_decoder "~1.1.1" util-deprecate "~1.0.1" -readdirp@^2.0.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525" - integrity sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ== +readable-stream@^3.0.6: + version "3.4.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.4.0.tgz#a51c26754658e0a3c21dbf59163bd45ba6f447fc" + integrity sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ== dependencies: - graceful-fs "^4.1.11" - micromatch "^3.1.10" - readable-stream "^2.0.2" + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" -regex-not@^1.0.0, regex-not@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" - integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== +readdirp@~3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.2.0.tgz#c30c33352b12c96dfb4b895421a49fd5a9593839" + integrity sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ== dependencies: - extend-shallow "^3.0.2" - safe-regex "^1.1.0" - -remove-trailing-separator@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" - integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8= - -repeat-element@^1.1.2: - version "1.1.3" - resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" - integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== - -repeat-string@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-0.2.2.tgz#c7a8d3236068362059a7e4651fc6884e8b1fb4ae" - integrity sha1-x6jTI2BoNiBZp+RlH8aITosftK4= + picomatch "^2.0.4" -repeat-string@^1.6.1: - version "1.6.1" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" - integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= +readdirp@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.3.0.tgz#984458d13a1e42e2e9f5841b129e162f369aff17" + integrity sha512-zz0pAkSPOXXm1viEwygWIPSPkcBYjW1xU5j/JBh5t9bGCJwa6f9+BJa6VaB2g+b55yVrmXzqkyLf4xaWYM0IkQ== + dependencies: + picomatch "^2.0.7" require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= -require-main-filename@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" - integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= -resolve-dir@^1.0.0, resolve-dir@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-1.0.1.tgz#79a40644c362be82f26effe739c9bb5382046f43" - integrity sha1-eaQGRMNivoLybv/nOcm7U4IEb0M= - dependencies: - expand-tilde "^2.0.0" - global-modules "^1.0.0" - -resolve-url@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" - integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= - resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" @@ -2772,17 +1922,12 @@ resolve@^1.1.4, resolve@^1.4.0: dependencies: path-parse "^1.0.5" -ret@~0.1.10: - version "0.1.15" - resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" - integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== - -rfdc@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.1.2.tgz#e6e72d74f5dc39de8f538f65e00c36c18018e349" - integrity sha512-92ktAgvZhBzYTIK0Mja9uen5q5J3NRVMoDkJL2VMwq6SXjVCgqvQeVP2XAaUY6HT+XpQYeLSjb3UoitBryKmdA== +rfdc@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.1.4.tgz#ba72cc1367a0ccd9cf81a870b3b58bd3ad07f8c2" + integrity sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug== -rimraf@^2.6.0, rimraf@^2.6.1: +rimraf@^2.6.0: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" integrity sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w== @@ -2802,53 +1947,21 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-regex@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" - integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= - dependencies: - ret "~0.1.10" - "safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -sax@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" - integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== +semver@^5.7.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@^5.3.0, semver@^5.5.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" - integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== - -set-blocking@^2.0.0, set-blocking@~2.0.0: +set-blocking@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= -set-value@^0.4.3: - version "0.4.3" - resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1" - integrity sha1-fbCPnT0i3H945Trzw79GZuzfzPE= - dependencies: - extend-shallow "^2.0.1" - is-extendable "^0.1.1" - is-plain-object "^2.0.1" - to-object-path "^0.3.0" - -set-value@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274" - integrity sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg== - dependencies: - extend-shallow "^2.0.1" - is-extendable "^0.1.1" - is-plain-object "^2.0.3" - split-string "^3.0.1" - setprototypeof@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" @@ -2870,18 +1983,6 @@ shasum@^1.0.0: json-stable-stringify "~0.0.0" sha.js "~2.4.4" -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= - dependencies: - shebang-regex "^1.0.0" - -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= - shell-quote@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767" @@ -2892,46 +1993,11 @@ shell-quote@^1.6.1: array-reduce "~0.0.0" jsonify "~0.0.0" -signal-exit@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= - simple-concat@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6" integrity sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY= -snapdragon-node@^2.0.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" - integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== - dependencies: - define-property "^1.0.0" - isobject "^3.0.0" - snapdragon-util "^3.0.1" - -snapdragon-util@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" - integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== - dependencies: - kind-of "^3.2.0" - -snapdragon@^0.8.1: - version "0.8.2" - resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" - integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== - dependencies: - base "^0.11.1" - debug "^2.2.0" - define-property "^0.2.5" - extend-shallow "^2.0.1" - map-cache "^0.2.2" - source-map "^0.5.6" - source-map-resolve "^0.5.0" - use "^3.1.0" - socket.io-adapter@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz#2a805e8a14d6372124dd9159ad4502f8cb07f06b" @@ -2978,52 +2044,21 @@ socket.io@2.1.1: socket.io-client "2.1.1" socket.io-parser "~3.2.0" -source-map-resolve@^0.5.0: - version "0.5.2" - resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259" - integrity sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA== - dependencies: - atob "^2.1.1" - decode-uri-component "^0.2.0" - resolve-url "^0.2.1" - source-map-url "^0.4.0" - urix "^0.1.0" - -source-map-url@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" - integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= - -source-map@^0.5.6, source-map@~0.5.3: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -split-string@^3.0.1, split-string@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" - integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== - dependencies: - extend-shallow "^3.0.0" +source-map@~0.5.3: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= -static-extend@^0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" - integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= - dependencies: - define-property "^0.2.5" - object-copy "^0.1.0" - "statuses@>= 1.4.0 < 2": version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" @@ -3050,15 +2085,14 @@ stream-combiner2@^1.1.1: duplexer2 "~0.1.0" readable-stream "^2.0.2" -stream-http@^2.0.0: - version "2.8.3" - resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.8.3.tgz#b2d242469288a5a27ec4fe8933acf623de6514fc" - integrity sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw== +stream-http@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-3.1.0.tgz#22fb33fe9b4056b4eccf58bd8f400c4b993ffe57" + integrity sha512-cuB6RgO7BqC4FBYzmnvhob5Do3wIdIsXAgGycHJnW+981gHqoYcYz9lqjJrk8WXRddbwPuqPYRl+bag6mYv4lw== dependencies: builtin-status-codes "^3.0.0" inherits "^2.0.1" - readable-stream "^2.3.6" - to-arraybuffer "^1.0.0" + readable-stream "^3.0.6" xtend "^4.0.0" stream-splicer@^2.0.0: @@ -3069,26 +2103,18 @@ stream-splicer@^2.0.0: inherits "^2.0.1" readable-stream "^2.0.2" -streamroller@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-0.7.0.tgz#a1d1b7cf83d39afb0d63049a5acbf93493bdf64b" - integrity sha512-WREzfy0r0zUqp3lGO096wRuUp7ho1X6uo/7DJfTlEi0Iv/4gT7YHqXDjKC2ioVGBZtE8QzsQD9nx1nIuoZ57jQ== - dependencies: - date-format "^1.2.0" - debug "^3.1.0" - mkdirp "^0.5.1" - readable-stream "^2.3.0" - -string-width@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= +streamroller@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-1.0.6.tgz#8167d8496ed9f19f05ee4b158d9611321b8cacd9" + integrity sha512-3QC47Mhv3/aZNFpDDVO44qQb9gwB9QggMEE0sQmkTAwBVYdBRWISdsywlkfm5II1Q5y/pmrHflti/IgmIzdDBg== dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" + async "^2.6.2" + date-format "^2.0.0" + debug "^3.2.6" + fs-extra "^7.0.1" + lodash "^4.17.14" -"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.1: +"string-width@^1.0.2 || 2": version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== @@ -3096,6 +2122,15 @@ string-width@^1.0.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" +string-width@^3.0.0, string-width@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + string_decoder@^1.1.1, string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -3103,13 +2138,6 @@ string_decoder@^1.1.1, string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= - dependencies: - ansi-regex "^2.0.0" - strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" @@ -3117,12 +2145,14 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" -strip-eof@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" -strip-json-comments@2.0.1, strip-json-comments@~2.0.1: +strip-json-comments@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= @@ -3155,19 +2185,6 @@ syntax-error@^1.1.1: dependencies: acorn-node "^1.2.0" -tar@^4: - version "4.4.6" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.6.tgz#63110f09c00b4e60ac8bcfe1bf3c8660235fbc9b" - integrity sha512-tMkTnh9EdzxyfW+6GK6fCahagXsnYk6kE6S9Gr9pjVdys769+laCTbodXDhPAjzVtEBazRgP0gYqOjnk9dQzLg== - dependencies: - chownr "^1.0.1" - fs-minipass "^1.2.5" - minipass "^2.3.3" - minizlib "^1.1.0" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.2" - through2@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" @@ -3200,35 +2217,12 @@ to-array@0.1.4: resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" integrity sha1-F+bBH3PdTz10zaek/zI46a2b+JA= -to-arraybuffer@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" - integrity sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M= - -to-object-path@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" - integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= - dependencies: - kind-of "^3.0.2" - -to-regex-range@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" - integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= - dependencies: - is-number "^3.0.0" - repeat-string "^1.6.1" - -to-regex@^3.0.1, to-regex@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" - integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== dependencies: - define-property "^2.0.2" - extend-shallow "^3.0.2" - regex-not "^1.0.2" - safe-regex "^1.1.0" + is-number "^7.0.0" tty-browserify@0.0.1: version "0.0.1" @@ -3281,39 +2275,16 @@ undeclared-identifiers@^1.1.2: simple-concat "^1.0.0" xtend "^4.0.1" -union-value@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" - integrity sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ= - dependencies: - arr-union "^3.1.0" - get-value "^2.0.6" - is-extendable "^0.1.1" - set-value "^0.4.3" +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= -unset-value@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" - integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= - dependencies: - has-value "^0.3.1" - isobject "^3.0.0" - -upath@^1.0.5: - version "1.1.0" - resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.0.tgz#35256597e46a581db4793d0ce47fa9aebfc9fabd" - integrity sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw== - -urix@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" - integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= - url@~0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" @@ -3322,20 +2293,15 @@ url@~0.11.0: punycode "1.3.2" querystring "0.2.0" -use@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" - integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== - -useragent@2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.2.1.tgz#cf593ef4f2d175875e8bb658ea92e18a4fd06d8e" - integrity sha1-z1k+9PLRdYdei7ZY6pLhik/QbY4= +useragent@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.3.0.tgz#217f943ad540cb2128658ab23fc960f6a88c9972" + integrity sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw== dependencies: - lru-cache "2.2.x" + lru-cache "4.1.x" tmp "0.0.x" -util-deprecate@~1.0.1: +util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= @@ -3374,14 +2340,14 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= -which@1.3.1, which@^1.2.1, which@^1.2.14, which@^1.2.9: +which@1.3.1, which@^1.2.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== dependencies: isexe "^2.0.0" -wide-align@1.1.3, wide-align@^1.1.0: +wide-align@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== @@ -3393,13 +2359,14 @@ wordwrap@~0.0.2: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc= -wrap-ansi@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" - integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" wrappy@1: version "1.0.2" @@ -3425,50 +2392,48 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= -"y18n@^3.2.1 || ^4.0.0": +y18n@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== -yallist@^3.0.0, yallist@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" - integrity sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k= +yallist@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= -yargs-parser@11.1.1, yargs-parser@^11.1.1: - version "11.1.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4" - integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ== +yargs-parser@13.1.1, yargs-parser@^13.1.1: + version "13.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.1.tgz#d26058532aa06d365fe091f6a1fc06b2f7e5eca0" + integrity sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ== dependencies: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-unparser@1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.5.0.tgz#f2bb2a7e83cbc87bb95c8e572828a06c9add6e0d" - integrity sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw== +yargs-unparser@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.6.0.tgz#ef25c2c769ff6bd09e4b0f9d7c605fb27846ea9f" + integrity sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw== dependencies: flat "^4.1.0" - lodash "^4.17.11" - yargs "^12.0.5" + lodash "^4.17.15" + yargs "^13.3.0" -yargs@12.0.5, yargs@^12.0.5: - version "12.0.5" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13" - integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw== +yargs@13.3.0, yargs@^13.3.0: + version "13.3.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.0.tgz#4c657a55e07e5f2cf947f8a366567c04a0dedc83" + integrity sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA== dependencies: - cliui "^4.0.0" - decamelize "^1.2.0" + cliui "^5.0.0" find-up "^3.0.0" - get-caller-file "^1.0.1" - os-locale "^3.0.0" + get-caller-file "^2.0.1" require-directory "^2.1.1" - require-main-filename "^1.0.1" + require-main-filename "^2.0.0" set-blocking "^2.0.0" - string-width "^2.0.0" + string-width "^3.0.0" which-module "^2.0.0" - y18n "^3.2.1 || ^4.0.0" - yargs-parser "^11.1.1" + y18n "^4.0.0" + yargs-parser "^13.1.1" yeast@0.1.2: version "0.1.2" From 671b3770d9c5949b9c2d2c2b6dcdb1b253f30508 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Wed, 15 Jan 2020 21:04:53 +0200 Subject: [PATCH 086/108] added get currencies and find currencies --- dist/wallet-address-validator.js | 1049 +++++++++++++------------ dist/wallet-address-validator.min.js | 2 +- index.html | 2 +- package-lock.json | 0 package.json | 4 +- src/currencies.js | 3 + src/wallet_address_validator.js | 6 + test/wallet_address_get_currencies.js | 33 + 8 files changed, 599 insertions(+), 500 deletions(-) delete mode 100644 package-lock.json create mode 100644 test/wallet_address_get_currencies.js diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 35a9cda1..7901fada 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,154 +1,124 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i= 255) throw new TypeError('Alphabet too long') - - const BASE_MAP = new Uint8Array(256) +// @ts-ignore +var _Buffer = require('safe-buffer').Buffer +function base (ALPHABET) { + if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } + var BASE_MAP = new Uint8Array(256) BASE_MAP.fill(255) - - for (let i = 0; i < ALPHABET.length; i++) { - const x = ALPHABET.charAt(i) - const xc = x.charCodeAt(0) - - if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous') + for (var i = 0; i < ALPHABET.length; i++) { + var x = ALPHABET.charAt(i) + var xc = x.charCodeAt(0) + if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } BASE_MAP[xc] = i } - - const BASE = ALPHABET.length - const LEADER = ALPHABET.charAt(0) - const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up - const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up - + var BASE = ALPHABET.length + var LEADER = ALPHABET.charAt(0) + var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up function encode (source) { - if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer') - if (source.length === 0) return '' - - // Skip & count leading zeroes. - let zeroes = 0 - let length = 0 - let pbegin = 0 - const pend = source.length - + if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } + if (source.length === 0) { return '' } + // Skip & count leading zeroes. + var zeroes = 0 + var length = 0 + var pbegin = 0 + var pend = source.length while (pbegin !== pend && source[pbegin] === 0) { pbegin++ zeroes++ } - - // Allocate enough space in big-endian base58 representation. - const size = ((pend - pbegin) * iFACTOR + 1) >>> 0 - const b58 = new Uint8Array(size) - - // Process the bytes. + // Allocate enough space in big-endian base58 representation. + var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + var b58 = new Uint8Array(size) + // Process the bytes. while (pbegin !== pend) { - let carry = source[pbegin] - - // Apply "b58 = b58 * 256 + ch". - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (256 * b58[it]) >>> 0 - b58[it] = (carry % BASE) >>> 0 + var carry = source[pbegin] + // Apply "b58 = b58 * 256 + ch". + var i = 0 + for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { + carry += (256 * b58[it1]) >>> 0 + b58[it1] = (carry % BASE) >>> 0 carry = (carry / BASE) >>> 0 } - - if (carry !== 0) throw new Error('Non-zero carry') + if (carry !== 0) { throw new Error('Non-zero carry') } length = i pbegin++ } - - // Skip leading zeroes in base58 result. - let it = size - length - while (it !== size && b58[it] === 0) { - it++ + // Skip leading zeroes in base58 result. + var it2 = size - length + while (it2 !== size && b58[it2] === 0) { + it2++ } - - // Translate the result into a string. - let str = LEADER.repeat(zeroes) - for (; it < size; ++it) str += ALPHABET.charAt(b58[it]) - + // Translate the result into a string. + var str = LEADER.repeat(zeroes) + for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } return str } - function decodeUnsafe (source) { - if (typeof source !== 'string') throw new TypeError('Expected String') - if (source.length === 0) return Buffer.alloc(0) - - let psz = 0 - - // Skip leading spaces. - if (source[psz] === ' ') return - - // Skip and count leading '1's. - let zeroes = 0 - let length = 0 + 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 while (source[psz] === LEADER) { zeroes++ psz++ } - - // Allocate enough space in big-endian base256 representation. - const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. - const b256 = new Uint8Array(size) - - // Process the characters. + // Allocate enough space in big-endian base256 representation. + var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + var b256 = new Uint8Array(size) + // Process the characters. while (source[psz]) { - // Decode character - let carry = BASE_MAP[source.charCodeAt(psz)] - - // Invalid character - if (carry === 255) return - - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (BASE * b256[it]) >>> 0 - b256[it] = (carry % 256) >>> 0 + // Decode character + var carry = BASE_MAP[source.charCodeAt(psz)] + // Invalid character + if (carry === 255) { return } + var i = 0 + for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { + carry += (BASE * b256[it3]) >>> 0 + b256[it3] = (carry % 256) >>> 0 carry = (carry / 256) >>> 0 } - - if (carry !== 0) throw new Error('Non-zero carry') + if (carry !== 0) { throw new Error('Non-zero carry') } length = i psz++ } - - // Skip trailing spaces. - if (source[psz] === ' ') return - - // Skip leading zeroes in b256. - let it = size - length - while (it !== size && b256[it] === 0) { - it++ + // Skip trailing spaces. + if (source[psz] === ' ') { return } + // Skip leading zeroes in b256. + var it4 = size - length + while (it4 !== size && b256[it4] === 0) { + it4++ } - - const vch = Buffer.allocUnsafe(zeroes + (size - it)) + var vch = _Buffer.allocUnsafe(zeroes + (size - it4)) vch.fill(0x00, 0, zeroes) - - let j = zeroes - while (it !== size) { - vch[j++] = b256[it++] + var j = zeroes + while (it4 !== size) { + vch[j++] = b256[it4++] } - return vch } - function decode (string) { - const buffer = decodeUnsafe(string) - if (buffer) return buffer - + var buffer = decodeUnsafe(string) + if (buffer) { return buffer } throw new Error('Non-base' + BASE + ' character') } - return { encode: encode, decodeUnsafe: decodeUnsafe, decode: decode } } +module.exports = base },{"safe-buffer":123}],2:[function(require,module,exports){ 'use strict' @@ -11435,399 +11405,467 @@ var BCHValidator = require('./bch_validator'); var XLMValidator = require('./stellar_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks -var CURRENCIES = [{ - name: 'Bitcoin', - symbol: 'btc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26']}, - validator: BTCValidator -}, { - name: 'BitcoinCash', - symbol: 'bch', - regexp: '^[qQpP]{1}[0-9a-zA-Z]{41}$', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BCHValidator -}, { - name: 'Bitcoin SV', - symbol: 'bsv', - regexp: '^[qQ]{1}[0-9a-zA-Z]{41}$', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BCHValidator -}, { - name: 'LiteCoin', - symbol: 'ltc', - addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, - validator: BTCValidator -}, { - name: 'PeerCoin', - symbol: 'ppc', - addressTypes: { prod: ['37', '75'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'DogeCoin', - symbol: 'doge', - addressTypes: { prod: ['1e', '16'], testnet: ['71', 'c4'] }, - validator: BTCValidator -}, { - name: 'BeaverCoin', - symbol: 'bvc', - addressTypes: { prod: ['19', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator, -}, { - name: 'FreiCoin', - symbol: 'frc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'ProtoShares', - symbol: 'pts', - addressTypes: { prod: ['38', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'MegaCoin', - symbol: 'mec', - addressTypes: { prod: ['32', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'PrimeCoin', - symbol: 'xpm', - addressTypes: { prod: ['17', '53'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'AuroraCoin', - symbol: 'aur', - addressTypes: { prod: ['17', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'NameCoin', - symbol: 'nmc', - addressTypes: { prod: ['34'], testnet: [] }, - validator: BTCValidator -}, { - name: 'BioCoin', - symbol: 'bio', - addressTypes: { prod: ['19', '14'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'GarliCoin', - symbol: 'grlc', - addressTypes: { prod: ['26', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'VertCoin', - symbol: 'vtc', - addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - -}, { - name: 'BitcoinGold', - symbol: 'btg', - addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'Komodo', - symbol: 'kmd', - addressTypes: { prod: ['3c', '55'], testnet: ['0', '5'] }, - validator: BTCValidator -}, { - name: 'BitcoinZ', - symbol: 'btcz', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'BitcoinPrivate', - symbol: 'btcp', - expectedLength: 26, - addressTypes: { prod: ['1325', '13af'], testnet: ['1957', '19e0'] }, - validator: BTCValidator -}, { - name: 'Hush', - symbol: 'hush', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'SnowGem', - symbol: 'sng', - expectedLength: 26, - addressTypes: { prod: ['1c28', '1c2d'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'ZCash', - symbol: 'zec', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'ZClassic', - symbol: 'zcl', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'ZenCash', - symbol: 'zen', - expectedLength: 26, - addressTypes: { prod: ['2089', '2096'], testnet: ['2092', '2098'] }, - validator: BTCValidator -}, { - name: 'VoteCoin', - symbol: 'vot', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'Decred', - symbol: 'dcr', - addressTypes: { prod: ['073f', '071a'], testnet: ['0f21', '0efc'] }, - hashFunction: 'blake256', - expectedLength: 26, - validator: BTCValidator -}, { - name: 'GameCredits', - symbol: 'game', - addressTypes: { prod: ['26', '05'], testnet: [] }, - validator: BTCValidator -}, { - name: 'PIVX', - symbol: 'pivx', - addressTypes: { prod: ['1e', '0d'], testnet: [] }, - validator: BTCValidator -}, { - name: 'SolarCoin', - symbol: 'slr', - addressTypes: { prod: ['12', '05'], testnet: [] }, - validator: BTCValidator -}, { - name: 'MonaCoin', - symbol: 'mona', - addressTypes: { prod: ['32', '37'], testnet: [] }, - validator: BTCValidator -}, { - name: 'DigiByte', - symbol: 'dgb', - addressTypes: { prod: ['1e'], testnet: [] }, - validator: BTCValidator -}, { - name: 'Tether', - symbol: 'usdt', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'Ripple', - symbol: 'xrp', - validator: XRPValidator, -}, { - name: 'Dash', - symbol: 'dash', - addressTypes: { prod: ['4c', '10'], testnet: ['8c', '13'] }, - validator: BTCValidator -}, { - name: 'Neo', - symbol: 'neo', - addressTypes: { prod: ['17'], testnet: [] }, - validator: BTCValidator -}, { - name: 'NeoGas', - symbol: 'gas', - addressTypes: { prod: ['17'], testnet: [] }, - validator: BTCValidator -}, { - name: 'Qtum', - symbol: 'qtum', - addressTypes: { prod: ['3a', '32'], testnet: ['78', '6e'] }, - validator: BTCValidator -}, { - name: 'Waves', - symbol: 'waves', - addressTypes: { prod: ['0157'], testnet: ['0154'] }, - expectedLength: 26, - hashFunction: 'blake256keccak256', - regex: /^[a-zA-Z0-9]{35}$/, - validator: BTCValidator -}, { - name: 'Ethereum', - symbol: 'eth', - validator: ETHValidator, -}, { - name: 'EtherZero', - symbol: 'etz', - validator: ETHValidator, -}, { - name: 'EthereumClassic', - symbol: 'etc', - validator: ETHValidator, -}, { - name: 'Callisto', - symbol: 'clo', - validator: ETHValidator, -}, { - name: 'Bankex', - symbol: 'bkx', - validator: ETHValidator -}, { - name: 'Cardano', - symbol: 'ada', - validator: ADAValidator -}, { - name: 'Monero', - symbol: 'xmr', - addressTypes: { prod: ['18'], testnet: ['53'] }, - iAddressTypes: { prod: ['19'], testnet: ['54'] }, - validator: XMRValidator -}, { - name: 'Aragon', - symbol: 'ant', - validator: ETHValidator -}, { - name: 'Basic Attention Token', - symbol: 'bat', - validator: ETHValidator -}, { - name: 'Bancor', - symbol: 'bnt', - validator: ETHValidator -}, { - name: 'Civic', - symbol: 'cvc', - validator: ETHValidator -}, { - name: 'District0x', - symbol: 'dnt', - validator: ETHValidator -}, { - name: 'Gnosis', - symbol: 'gno', - validator: ETHValidator -}, { - name: 'Golem', - symbol: 'gnt', - validator: ETHValidator -}, { - name: 'Matchpool', - symbol: 'gup', - validator: ETHValidator -}, { - name: 'Melon', - symbol: 'mln', - validator: ETHValidator -}, { - name: 'Numeraire', - symbol: 'nmr', - validator: ETHValidator -}, { - name: 'OmiseGO', - symbol: 'omg', - validator: ETHValidator -}, { - name: 'TenX', - symbol: 'pay', - validator: ETHValidator -}, { - name: 'Ripio Credit Network', - symbol: 'rcn', - validator: ETHValidator -}, { - name: 'Augur', - symbol: 'rep', - validator: ETHValidator -}, { - name: 'iExec RLC', - symbol: 'rlc', - validator: ETHValidator -}, { - name: 'Salt', - symbol: 'salt', - validator: ETHValidator -}, { - name: 'Status', - symbol: 'snt', - validator: ETHValidator -}, { - name: 'Storj', - symbol: 'storj', - validator: ETHValidator -}, { - name: 'Swarm City', - symbol: 'swt', - validator: ETHValidator -}, { - name: 'TrueUSD', - symbol: 'tusd', - validator: ETHValidator -}, { - name: 'Wings', - symbol: 'wings', - validator: ETHValidator -}, { - name: '0x', - symbol: 'zrx', - validator: ETHValidator -}, { - name: 'Expanse', - symbol: 'exp', - validator: ETHValidator -}, { - name: 'Viberate', - symbol: 'vib', - validator: ETHValidator -}, { - name: 'Odyssey', - symbol: 'ocn', - validator: ETHValidator -}, { - name: 'Polymath', - symbol: 'poly', - validator: ETHValidator -}, { - name: 'Storm', - symbol: 'storm', - validator: ETHValidator -}, { - name: 'Nano', - symbol: 'nano', - validator: NANOValidator, -}, { - name: 'RaiBlocks', - symbol: 'xrb', - validator: NANOValidator, -}, { - name: 'siacoin', - symbol: 'sc', - validator: SCValidator -}, { - name: 'hyperspace', - symbol: 'xsc', - validator: SCValidator -}, { - name: 'loki', - symbol: 'loki', - addressTypes: { prod: ['114', '116'], testnet: [] }, - iAddressTypes: { prod: ['115'], testnet: [] }, - validator: XMRValidator -}, { - name: 'lbry', - symbol: 'lbc', - addressTypes: { prod: ['55'], testnet: [] }, - validator: BTCValidator -}, { - name: 'tron', - symbol: 'trx', - addressTypes: {prod: [0x41], testnet: [0xa0]}, - validator: TRXValidator -}, { - name: 'nem', - symbol: 'xem', - validator: NEMValidator -}, { - name: 'lisk', - symbol: 'lsk', - validator: LSKValidator -}, { - name: 'stellar', - symbol: 'xlm', - validator: XLMValidator, -}]; +var CURRENCIES = [ + { + name: 'Bitcoin', + symbol: 'btc', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26'] }, + validator: BTCValidator + }, { + name: 'BitcoinCash', + symbol: 'bch', + regexp: '^[qQpP]{1}[0-9a-zA-Z]{41}$', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BCHValidator + }, { + name: 'Bitcoin SV', + symbol: 'bsv', + regexp: '^[qQ]{1}[0-9a-zA-Z]{41}$', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BCHValidator + }, { + name: 'LiteCoin', + symbol: 'ltc', + addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, + validator: BTCValidator + }, { + name: 'PeerCoin', + symbol: 'ppc', + addressTypes: { prod: ['37', '75'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'DogeCoin', + symbol: 'doge', + addressTypes: { prod: ['1e', '16'], testnet: ['71', 'c4'] }, + validator: BTCValidator + }, { + name: 'BeaverCoin', + symbol: 'bvc', + addressTypes: { prod: ['19', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator, + }, { + name: 'FreiCoin', + symbol: 'frc', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'ProtoShares', + symbol: 'pts', + addressTypes: { prod: ['38', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'MegaCoin', + symbol: 'mec', + addressTypes: { prod: ['32', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'PrimeCoin', + symbol: 'xpm', + addressTypes: { prod: ['17', '53'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'AuroraCoin', + symbol: 'aur', + addressTypes: { prod: ['17', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'NameCoin', + symbol: 'nmc', + addressTypes: { prod: ['34'], testnet: [] }, + validator: BTCValidator + }, { + name: 'BioCoin', + symbol: 'bio', + addressTypes: { prod: ['19', '14'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'GarliCoin', + symbol: 'grlc', + addressTypes: { prod: ['26', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'VertCoin', + symbol: 'vtc', + addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + + }, { + name: 'BitcoinGold', + symbol: 'btg', + addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'Komodo', + symbol: 'kmd', + addressTypes: { prod: ['3c', '55'], testnet: ['0', '5'] }, + validator: BTCValidator + }, { + name: 'BitcoinZ', + symbol: 'btcz', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'BitcoinPrivate', + symbol: 'btcp', + expectedLength: 26, + addressTypes: { prod: ['1325', '13af'], testnet: ['1957', '19e0'] }, + validator: BTCValidator + }, { + name: 'Hush', + symbol: 'hush', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'SnowGem', + symbol: 'sng', + expectedLength: 26, + addressTypes: { prod: ['1c28', '1c2d'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'ZCash', + symbol: 'zec', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'ZClassic', + symbol: 'zcl', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'ZenCash', + symbol: 'zen', + expectedLength: 26, + addressTypes: { prod: ['2089', '2096'], testnet: ['2092', '2098'] }, + validator: BTCValidator + }, { + name: 'VoteCoin', + symbol: 'vot', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'Decred', + symbol: 'dcr', + addressTypes: { prod: ['073f', '071a'], testnet: ['0f21', '0efc'] }, + hashFunction: 'blake256', + expectedLength: 26, + validator: BTCValidator + }, { + name: 'GameCredits', + symbol: 'game', + addressTypes: { prod: ['26', '05'], testnet: [] }, + validator: BTCValidator + }, { + name: 'PIVX', + symbol: 'pivx', + addressTypes: { prod: ['1e', '0d'], testnet: [] }, + validator: BTCValidator + }, { + name: 'SolarCoin', + symbol: 'slr', + addressTypes: { prod: ['12', '05'], testnet: [] }, + validator: BTCValidator + }, { + name: 'MonaCoin', + symbol: 'mona', + addressTypes: { prod: ['32', '37'], testnet: [] }, + validator: BTCValidator + }, { + name: 'DigiByte', + symbol: 'dgb', + addressTypes: { prod: ['1e'], testnet: [] }, + validator: BTCValidator + }, { + name: 'Tether', + symbol: 'usdt', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'Ripple', + symbol: 'xrp', + validator: XRPValidator, + }, { + name: 'Dash', + symbol: 'dash', + addressTypes: { prod: ['4c', '10'], testnet: ['8c', '13'] }, + validator: BTCValidator + }, { + name: 'Neo', + symbol: 'neo', + addressTypes: { prod: ['17'], testnet: [] }, + validator: BTCValidator + }, { + name: 'NeoGas', + symbol: 'gas', + addressTypes: { prod: ['17'], testnet: [] }, + validator: BTCValidator + }, { + name: 'Qtum', + symbol: 'qtum', + addressTypes: { prod: ['3a', '32'], testnet: ['78', '6e'] }, + validator: BTCValidator + }, { + name: 'Waves', + symbol: 'waves', + addressTypes: { prod: ['0157'], testnet: ['0154'] }, + expectedLength: 26, + hashFunction: 'blake256keccak256', + regex: /^[a-zA-Z0-9]{35}$/, + validator: BTCValidator + }, { + name: 'Ethereum', + symbol: 'eth', + validator: ETHValidator, + }, { + name: 'EtherZero', + symbol: 'etz', + validator: ETHValidator, + }, { + name: 'EthereumClassic', + symbol: 'etc', + validator: ETHValidator, + }, { + name: 'Callisto', + symbol: 'clo', + validator: ETHValidator, + }, { + name: 'Bankex', + symbol: 'bkx', + validator: ETHValidator + }, { + name: 'Cardano', + symbol: 'ada', + validator: ADAValidator + }, { + name: 'Monero', + symbol: 'xmr', + addressTypes: { prod: ['18'], testnet: ['53'] }, + iAddressTypes: { prod: ['19'], testnet: ['54'] }, + validator: XMRValidator + }, { + name: 'Aragon', + symbol: 'ant', + validator: ETHValidator + }, { + name: 'Basic Attention Token', + symbol: 'bat', + validator: ETHValidator + }, { + name: 'Bancor', + symbol: 'bnt', + validator: ETHValidator + }, { + name: 'Civic', + symbol: 'cvc', + validator: ETHValidator + }, { + name: 'District0x', + symbol: 'dnt', + validator: ETHValidator + }, { + name: 'Gnosis', + symbol: 'gno', + validator: ETHValidator + }, { + name: 'Golem', + symbol: 'gnt', + validator: ETHValidator + }, { + name: 'Matchpool', + symbol: 'gup', + validator: ETHValidator + }, { + name: 'Melon', + symbol: 'mln', + validator: ETHValidator + }, { + name: 'Numeraire', + symbol: 'nmr', + validator: ETHValidator + }, { + name: 'OmiseGO', + symbol: 'omg', + validator: ETHValidator + }, { + name: 'TenX', + symbol: 'pay', + validator: ETHValidator + }, { + name: 'Ripio Credit Network', + symbol: 'rcn', + validator: ETHValidator + }, { + name: 'Augur', + symbol: 'rep', + validator: ETHValidator + }, { + name: 'iExec RLC', + symbol: 'rlc', + validator: ETHValidator + }, { + name: 'Salt', + symbol: 'salt', + validator: ETHValidator + }, { + name: 'Status', + symbol: 'snt', + validator: ETHValidator + }, { + name: 'Storj', + symbol: 'storj', + validator: ETHValidator + }, { + name: 'Swarm City', + symbol: 'swt', + validator: ETHValidator + }, { + name: 'TrueUSD', + symbol: 'tusd', + validator: ETHValidator + }, { + name: 'Wings', + symbol: 'wings', + validator: ETHValidator + }, { + name: '0x', + symbol: 'zrx', + validator: ETHValidator + }, { + name: 'Expanse', + symbol: 'exp', + validator: ETHValidator + }, { + name: 'Viberate', + symbol: 'vib', + validator: ETHValidator + }, { + name: 'Odyssey', + symbol: 'ocn', + validator: ETHValidator + }, { + name: 'Polymath', + symbol: 'poly', + validator: ETHValidator + }, { + name: 'Storm', + symbol: 'storm', + validator: ETHValidator + }, { + name: 'Nano', + symbol: 'nano', + validator: NANOValidator, + }, { + name: 'RaiBlocks', + symbol: 'xrb', + validator: NANOValidator, + }, { + name: 'Siacoin', + symbol: 'sc', + validator: SCValidator + }, { + name: 'HyperSpace', + symbol: 'xsc', + validator: SCValidator + }, { + name: 'loki', + symbol: 'loki', + addressTypes: { prod: ['114', '116'], testnet: [] }, + iAddressTypes: { prod: ['115'], testnet: [] }, + validator: XMRValidator + }, { + name: 'LBRY Credits', + symbol: 'lbc', + addressTypes: { prod: ['55'], testnet: [] }, + validator: BTCValidator + }, { + name: 'Tron', + symbol: 'trx', + addressTypes: { prod: [0x41], testnet: [0xa0] }, + validator: TRXValidator + }, { + name: 'Nem', + symbol: 'xem', + validator: NEMValidator + }, { + name: 'Lisk', + symbol: 'lsk', + validator: LSKValidator + }, { + name: 'Stellar', + symbol: 'xlm', + validator: XLMValidator, + }, { + name: 'BTU Protocol', + symbol: 'btu', + validator: ETHValidator, + }, { + name: 'Crypto.com Coin', + symbol: 'cro', + validator: ETHValidator, + }, { + name: 'Multi-collateral DAI', + symbol: 'dai', + validator: ETHValidator, + }, { + name: 'Enjin Coin', + symbol: 'enj', + validator: ETHValidator, + }, { + name: 'HedgeTrade', + symbol: 'hedg', + validator: ETHValidator, + }, { + name: 'Cred', + symbol: 'lba', + validator: ETHValidator, + }, { + name: 'Chainlink', + symbol: 'link', + validator: ETHValidator, + }, { + name: 'Loom Network', + symbol: 'loom', + validator: ETHValidator, + }, { + name: 'Maker', + symbol: 'mkr', + validator: ETHValidator, + }, { + name: 'Metal', + symbol: 'mtl', + validator: ETHValidator, + }, { + name: 'Ocean Protocol', + symbol: 'ocean', + validator: ETHValidator, + }, { + name: 'Quant', + symbol: 'qnt', + validator: ETHValidator, + }, { + name: 'Synthetix Network', + symbol: 'snx', + validator: ETHValidator, + }, { + name: 'SOLVE', + symbol: 'solve', + validator: ETHValidator, + }, { + name: 'Spendcoin', + symbol: 'spnd', + validator: ETHValidator, + }, { + name: 'TEMCO', + symbol: 'temco', + validator: ETHValidator, + } + + +]; module.exports = { @@ -11836,6 +11874,9 @@ module.exports = { return CURRENCIES.find(function (currency) { return currency.name.toLowerCase() === nameOrSymbol || currency.symbol.toLowerCase() === nameOrSymbol }); + }, + getAll: function () { + return CURRENCIES; } }; @@ -12197,6 +12238,16 @@ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; +function validate(address, currencyNameOrSymbol, networkType) { + var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); + + if (currency && currency.validator) { + return currency.validator.isValidAddress(address, currency, networkType); + } + + throw new Error('Missing validator for currency: ' + currencyNameOrSymbol); +} + module.exports = { validate: function (address, currencyNameOrSymbol, networkType) { var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); @@ -12207,6 +12258,12 @@ module.exports = { throw new Error('Missing validator for currency: ' + currencyNameOrSymbol); }, + getCurrencies: function () { + return currencies.getAll(); + }, + findCurrency: function(symbol) { + return currencies.getByNameOrSymbol(symbol) || null ; + } }; },{"./currencies":137}]},{},[147])(147) diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 087c3725..bc202ec7 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);e.fill(255);for(let r=0;r>>0,c=new Uint8Array(f);for(;t[a];){let n=e[t.charCodeAt(a)];if(255===n)return;let o=0;for(let t=f-1;(0!==n||o>>0,c[t]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");u=o,a++}if(" "===t[a])return;let l=f-u;for(;l!==f&&0===c[l];)l++;const h=n.allocUnsafe(s+(f-l));h.fill(0,0,s);let p=s;for(;l!==f;)h[p++]=c[l++];return h}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";let i=0,s=0,u=0;const f=e.length;for(;u!==f&&0===e[u];)u++,i++;const c=(f-u)*a+1>>>0,l=new Uint8Array(c);for(;u!==f;){let t=e[u],n=0;for(let e=c-1;(0!==t||n>>0,l[e]=t%r>>>0,t=t/r>>>0;if(0!==t)throw new Error("Non-zero carry");s=n,u++}let h=c-s;for(;h!==c&&0===l[h];)h++;let p=o.repeat(i);for(;h0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o=255)throw new TypeError("Alphabet too long");var e=new Uint8Array(256);e.fill(255);for(var r=0;r>>0,c=new Uint8Array(f);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=f-1;(0!==l||h>>0,c[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}if(" "!==t[r]){for(var d=f-i;d!==f&&0===c[d];)d++;var v=n.allocUnsafe(o+(f-d));v.fill(0,0,o);for(var y=o;d!==f;)v[y++]=c[d++];return v}}}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,o=0,i=0,u=e.length;i!==u&&0===e[i];)i++,r++;for(var c=(u-i)*f+1>>>0,l=new Uint8Array(c);i!==u;){for(var h=e[i],p=0,d=c-1;(0!==h||p>>0,l[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,i++}for(var v=c-o;v!==c&&0===l[v];)v++;for(var y=s.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Wed, 15 Jan 2020 21:10:41 +0200 Subject: [PATCH 087/108] updated travis to include latest node and remove old node versions --- .travis.yml | 5 ++--- README.md | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b4451656..34ed7e4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ addons: chrome: stable language: node_js node_js: - - "4" - - "6" - "8" - - "9" + - "10" + - "stable" diff --git a/README.md b/README.md index b120af26..9e7bc5bf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # wallet-address-validator Simple wallet address validator for validating Bitcoin and other altcoins addresses in **Node.js and browser**. +[![Build Status](https://travis-ci.org/christsim/multicoin-address-validator.svg?branch=master)](https://travis-ci.org/christsim/multicoin-address-validator) + Forked from [ryanralph/altcoin-address](https://github.com/ryanralph/altcoin-address). **File size is ~17 kB (minifed and gzipped)**. From 48372c40024fc3a6b446efe0aa7bc8a63aecc1e5 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Wed, 15 Jan 2020 21:16:02 +0200 Subject: [PATCH 088/108] updated README.md --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 9e7bc5bf..4a01fab7 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,29 @@ else // As this is a invalid litecoin address 'Address INVALID' will be logged to console. ``` +```javascript +var WAValidator = require('multicoin-address-validator'); + +var currency = WAValidator.findCurrency('xrp'); +if(currency) + console.log('This currency exists'); +else + console.log('Currency INVALID'); + +// As this is a valid currency symbol 'This currency exists' will be logged to console. +``` + +```javascript +var WAValidator = require('multicoin-address-validator'); + +var currency = WAValidator.findCurrency('random'); +if(currency) + console.log('This currency exists'); +else + console.log('Currency INVALID'); + +// As this is not a valid currency symbol 'Currency INVALID' will be logged to console. +``` #### Browser ```html From 38692782d56f194c407cf8d838851805fd9f1a6d Mon Sep 17 00:00:00 2001 From: GusGold Date: Tue, 28 May 2019 22:31:47 +1000 Subject: [PATCH 089/108] cherry-picked eos validator --- src/eos_validator.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/eos_validator.js diff --git a/src/eos_validator.js b/src/eos_validator.js new file mode 100644 index 00000000..934e497b --- /dev/null +++ b/src/eos_validator.js @@ -0,0 +1,14 @@ +function isValidEOSAddress (address, currency, networkType) { + var regex = /^[a-z0-9]+$/g // Must be numbers and lowercase letters only + if (address.search(regex) !== -1 && address.length === 12) { + return true + } else { + return false + } +} + +module.exports = { + isValidAddress: function (address, currency, networkType) { + return isValidEOSAddress(address, currency, networkType) + } +} From 20640801113c6cfc6408f2edf247470ee51e95f5 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Fri, 24 Jan 2020 12:06:46 +0200 Subject: [PATCH 090/108] Cherry picked and added EOS --- README.md | 5 +- dist/wallet-address-validator.js | 55 ++++--- dist/wallet-address-validator.min.js | 2 +- package.json | 224 ++++++++++++++++++--------- src/currencies.js | 12 +- test/wallet_address_validator.js | 14 ++ 6 files changed, 215 insertions(+), 97 deletions(-) diff --git a/README.md b/README.md index 4a01fab7..65c7a26e 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ npm install multicoin-address-validator * District0x/dnt `'District0x'` or `'dnt'` * DogeCoin/doge `'DogeCoin'` or `'doge'` * Enjin Coin/enj `'Enjin Coin'` or `'enj'` +* EOS/eos `'EOS'` or `'eos'` * Ethereum/eth `'Ethereum'` or `'eth'` * EthereumClassic/etc `'EthereumClassic'` or `'etc'` * EtherZero/etz `'EtherZero'` or `'etz'` @@ -71,12 +72,13 @@ npm install multicoin-address-validator * Golem/gnt `'Golem'` or `'gnt'` * HedgeTrade/hedg `'HedgeTrade'` or `'hedg'` * Hush/hush `'Hush'` or `'hush'` +* HyperSpace/xsc `'HyperSpace'` or `'xsc'` * iExec RLC/rlc `'iExec RLC'` or `'rlc'` * Komodo/kmd `'Komodo'` or `'kmd'` * LBRY Credits/lbc `'LBRY Credits'` or `'lbc'` * Lisk/lsk `'Lisk'` or `'lsk'` * LiteCoin/ltc `'LiteCoin'` or `'ltc'` -* Loki/loki `'Loki'` or `'loki'` +* loki/loki `'loki'` or `'loki'` * Loom Network/loom `'Loom Network'` or `'loom'` * Maker/mkr `'Maker'` or `'mkr'` * Matchpool/gup `'Matchpool'` or `'gup'` @@ -131,6 +133,7 @@ npm install multicoin-address-validator * ZClassic/zcl `'ZClassic'` or `'zcl'` * ZenCash/zen `'ZenCash'` or `'zen'` + ### Usage example #### Node diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 7901fada..384ea12f 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -11403,6 +11403,7 @@ var NEMValidator = require('./nem_validator'); var LSKValidator = require('./lisk_validator'); var BCHValidator = require('./bch_validator'); var XLMValidator = require('./stellar_validator'); +var EOSValidator = require('./eos_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [ @@ -11862,9 +11863,11 @@ var CURRENCIES = [ name: 'TEMCO', symbol: 'temco', validator: ETHValidator, + }, { + name: 'EOS', + symbol: 'eos', + validator: EOSValidator } - - ]; @@ -11887,7 +11890,23 @@ module.exports = { -},{"./ada_validator":124,"./bch_validator":125,"./bitcoin_validator":126,"./ethereum_validator":138,"./lisk_validator":139,"./monero_validator":140,"./nano_validator":141,"./nem_validator":142,"./ripple_validator":143,"./siacoin_validator":144,"./stellar_validator":145,"./tron_validator":146}],138:[function(require,module,exports){ +},{"./ada_validator":124,"./bch_validator":125,"./bitcoin_validator":126,"./eos_validator":138,"./ethereum_validator":139,"./lisk_validator":140,"./monero_validator":141,"./nano_validator":142,"./nem_validator":143,"./ripple_validator":144,"./siacoin_validator":145,"./stellar_validator":146,"./tron_validator":147}],138:[function(require,module,exports){ +function isValidEOSAddress (address, currency, networkType) { + var regex = /^[a-z0-9]+$/g // Must be numbers and lowercase letters only + if (address.search(regex) !== -1 && address.length === 12) { + return true + } else { + return false + } +} + +module.exports = { + isValidAddress: function (address, currency, networkType) { + return isValidEOSAddress(address, currency, networkType) + } +} + +},{}],139:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -11923,7 +11942,7 @@ module.exports = { } }; -},{"./crypto/utils":136}],139:[function(require,module,exports){ +},{"./crypto/utils":136}],140:[function(require,module,exports){ (function (Buffer){ var cryptoUtils = require('./crypto/utils'); @@ -11945,7 +11964,7 @@ module.exports = { } }; }).call(this,require("buffer").Buffer) -},{"./crypto/utils":136,"buffer":4}],140:[function(require,module,exports){ +},{"./crypto/utils":136,"buffer":4}],141:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils') var cnBase58 = require('./crypto/cnBase58') @@ -12009,7 +12028,7 @@ module.exports = { } } -},{"./crypto/cnBase58":133,"./crypto/utils":136}],141:[function(require,module,exports){ +},{"./crypto/cnBase58":133,"./crypto/utils":136}],142:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -12038,7 +12057,7 @@ module.exports = { } }; -},{"./crypto/utils":136,"base-x":1}],142:[function(require,module,exports){ +},{"./crypto/utils":136,"base-x":1}],143:[function(require,module,exports){ (function (Buffer){ var cryptoUtils = require('./crypto/utils'); @@ -12064,7 +12083,7 @@ module.exports = { isValidAddress: isValidAddress, } }).call(this,require("buffer").Buffer) -},{"./crypto/utils":136,"buffer":4}],143:[function(require,module,exports){ +},{"./crypto/utils":136,"buffer":4}],144:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -12094,7 +12113,7 @@ module.exports = { } }; -},{"./crypto/utils":136,"base-x":1}],144:[function(require,module,exports){ +},{"./crypto/utils":136,"base-x":1}],145:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils') var isEqual = require('lodash/isEqual') @@ -12124,7 +12143,7 @@ module.exports = { } } -},{"./crypto/utils":136,"lodash/isEqual":113}],145:[function(require,module,exports){ +},{"./crypto/utils":136,"lodash/isEqual":113}],146:[function(require,module,exports){ var baseX = require('base-x'); var crc = require('crc'); var cryptoUtils = require('./crypto/utils'); @@ -12171,7 +12190,7 @@ var ed25519PublicKeyVersionByte = (6 << 3); return computedChecksum === checksum } }; -},{"./crypto/utils":136,"base-x":1,"crc":30}],146:[function(require,module,exports){ +},{"./crypto/utils":136,"base-x":1,"crc":30}],147:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); function decodeBase58Address(base58Sting) { @@ -12233,21 +12252,11 @@ module.exports = { return getEnv(currency, networkType) === address[0]; } }; -},{"./crypto/utils":136}],147:[function(require,module,exports){ +},{"./crypto/utils":136}],148:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; -function validate(address, currencyNameOrSymbol, networkType) { - var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); - - if (currency && currency.validator) { - return currency.validator.isValidAddress(address, currency, networkType); - } - - throw new Error('Missing validator for currency: ' + currencyNameOrSymbol); -} - module.exports = { validate: function (address, currencyNameOrSymbol, networkType) { var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); @@ -12266,5 +12275,5 @@ module.exports = { } }; -},{"./currencies":137}]},{},[147])(147) +},{"./currencies":137}]},{},[148])(148) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index bc202ec7..1a23c031 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");var e=new Uint8Array(256);e.fill(255);for(var r=0;r>>0,c=new Uint8Array(f);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=f-1;(0!==l||h>>0,c[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}if(" "!==t[r]){for(var d=f-i;d!==f&&0===c[d];)d++;var v=n.allocUnsafe(o+(f-d));v.fill(0,0,o);for(var y=o;d!==f;)v[y++]=c[d++];return v}}}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,o=0,i=0,u=e.length;i!==u&&0===e[i];)i++,r++;for(var c=(u-i)*f+1>>>0,l=new Uint8Array(c);i!==u;){for(var h=e[i],p=0,d=c-1;(0!==h||p>>0,l[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,i++}for(var v=c-o;v!==c&&0===l[v];)v++;for(var y=s.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o=255)throw new TypeError("Alphabet too long");var e=new Uint8Array(256);e.fill(255);for(var r=0;r>>0,c=new Uint8Array(f);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=f-1;(0!==l||h>>0,c[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}if(" "!==t[r]){for(var d=f-i;d!==f&&0===c[d];)d++;var v=n.allocUnsafe(o+(f-d));v.fill(0,0,o);for(var y=o;d!==f;)v[y++]=c[d++];return v}}}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,o=0,i=0,u=e.length;i!==u&&0===e[i];)i++,r++;for(var c=(u-i)*f+1>>>0,l=new Uint8Array(c);i!==u;){for(var h=e[i],p=0,d=c-1;(0!==h||p>>0,l[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,i++}for(var v=c-o;v!==c&&0===l[v];)v++;for(var y=s.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) // .forEach(c => console.log(`* ${c.name}/${c.symbol} \`'${c.name}'\` or \`'${c.symbol}'\` `)); +//spit out keywords for package.json +// CURRENCIES +// .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) +// .forEach(c => console.log(`"${c.name}","${c.symbol}",`)); + diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index e7e76060..5c8c06a5 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -547,6 +547,12 @@ describe('WAValidator.validate()', function () { valid('GDD3XRXU3G4DXHVRUDH7LJM4CD4PDZTVP4QHOO4Q6DELKXUATR657OZV', 'stellar'); valid('GDTYVCTAUQVPKEDZIBWEJGKBQHB4UGGXI2SXXUEW7LXMD4B7MK37CWLJ', 'stellar'); }); + + it('should return true for correct eos addresses', function () { + valid('bittrexacct1', 'eos'); + valid('binancecleos', 'eos'); + valid('123456789012', 'eos'); + }); }); describe('invalid results', function () { @@ -862,5 +868,13 @@ describe('WAValidator.validate()', function () { invalid('gWRYUerEKuz53tstxEuR3NCkiQDcV4wzFHmvLnZmj7PUqxW2wt', 'stellar'); invalid('g4VPBPrHZkfE8CsjuG2S4yBQNd455UWmk', 'stellar'); }); + + it('should return false for incorrect eos addresses', function () { + commonTests('eos'); + invalid('1234567890123', 'eos'); + invalid('12345678901', 'eos'); + invalid('12345678901@', 'eos'); + }); + }); }); From 86abdfae70e5aa227380ca4d2ead868000954cb7 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Fri, 24 Jan 2020 12:16:27 +0200 Subject: [PATCH 091/108] updated version --- dist/wallet-address-validator.js | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 384ea12f..97ad2d5f 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -11888,6 +11888,11 @@ module.exports = { // .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) // .forEach(c => console.log(`* ${c.name}/${c.symbol} \`'${c.name}'\` or \`'${c.symbol}'\` `)); +//spit out keywords for package.json +// CURRENCIES +// .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) +// .forEach(c => console.log(`"${c.name}","${c.symbol}",`)); + },{"./ada_validator":124,"./bch_validator":125,"./bitcoin_validator":126,"./eos_validator":138,"./ethereum_validator":139,"./lisk_validator":140,"./monero_validator":141,"./nano_validator":142,"./nem_validator":143,"./ripple_validator":144,"./siacoin_validator":145,"./stellar_validator":146,"./tron_validator":147}],138:[function(require,module,exports){ diff --git a/package.json b/package.json index 5350b715..88de2d19 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "ZClassic","zcl", "ZenCash","zen" ], - "version": "0.3.4", + "version": "0.4.0", "author": "Chris ", "homepage": "https://github.com/christsim/multicoin-address-validator", "license": "MIT", From 663fd376580ee3826cf8d8b6610683a0076bdb29 Mon Sep 17 00:00:00 2001 From: Stephen Ephraim Date: Fri, 24 Jan 2020 15:39:50 +0200 Subject: [PATCH 092/108] Adds XTZ address validator (#13) --- README.md | 1 + dist/wallet-address-validator.js | 1046 +++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- package.json | 9 +- src/crypto/utils.js | 11 +- src/currencies.js | 7 +- src/tezos_validator.js | 36 + test/wallet_address_validator.js | 20 + 8 files changed, 604 insertions(+), 528 deletions(-) create mode 100644 src/tezos_validator.js diff --git a/README.md b/README.md index 65c7a26e..abf269b7 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ npm install multicoin-address-validator * TEMCO/temco `'TEMCO'` or `'temco'` * TenX/pay `'TenX'` or `'pay'` * Tether/usdt `'Tether'` or `'usdt'` +* Tezos/xtz `'Tezos'` or `'xtz'` * Tron/trx `'Tron'` or `'trx'` * TrueUSD/tusd `'TrueUSD'` or `'tusd'` * VertCoin/vtc `'VertCoin'` or `'vtc'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 97ad2d5f..f3b66424 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,124 +1,96 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i= 255) { throw new TypeError('Alphabet too long') } - var BASE_MAP = new Uint8Array(256) - BASE_MAP.fill(255) - for (var i = 0; i < ALPHABET.length; i++) { - var x = ALPHABET.charAt(i) - var xc = x.charCodeAt(0) - if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } - BASE_MAP[xc] = i - } +// base-x encoding +// Forked from https://github.com/cryptocoinjs/bs58 +// Originally written by Mike Hearn for BitcoinJ +// Copyright (c) 2011 Google Inc +// Ported to JavaScript by Stefan Thomas +// Merged Buffer refactorings from base58-native by Stephen Pair +// Copyright (c) 2013 BitPay Inc + +var Buffer = require('safe-buffer').Buffer + +module.exports = function base (ALPHABET) { + var ALPHABET_MAP = {} var BASE = ALPHABET.length var LEADER = ALPHABET.charAt(0) - var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up - var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up + + // pre-compute lookup table + for (var z = 0; z < ALPHABET.length; z++) { + var x = ALPHABET.charAt(z) + + if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous') + ALPHABET_MAP[x] = z + } + function encode (source) { - if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } - if (source.length === 0) { return '' } - // Skip & count leading zeroes. - var zeroes = 0 - var length = 0 - var pbegin = 0 - var pend = source.length - while (pbegin !== pend && source[pbegin] === 0) { - pbegin++ - zeroes++ - } - // Allocate enough space in big-endian base58 representation. - var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 - var b58 = new Uint8Array(size) - // Process the bytes. - while (pbegin !== pend) { - var carry = source[pbegin] - // Apply "b58 = b58 * 256 + ch". - var i = 0 - for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { - carry += (256 * b58[it1]) >>> 0 - b58[it1] = (carry % BASE) >>> 0 - carry = (carry / BASE) >>> 0 + if (source.length === 0) return '' + + var digits = [0] + for (var i = 0; i < source.length; ++i) { + for (var j = 0, carry = source[i]; j < digits.length; ++j) { + carry += digits[j] << 8 + digits[j] = carry % BASE + carry = (carry / BASE) | 0 } - if (carry !== 0) { throw new Error('Non-zero carry') } - length = i - pbegin++ - } - // Skip leading zeroes in base58 result. - var it2 = size - length - while (it2 !== size && b58[it2] === 0) { - it2++ - } - // Translate the result into a string. - var str = LEADER.repeat(zeroes) - for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } - return str - } - function decodeUnsafe (source) { - 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 - while (source[psz] === LEADER) { - zeroes++ - psz++ - } - // Allocate enough space in big-endian base256 representation. - var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. - var b256 = new Uint8Array(size) - // Process the characters. - while (source[psz]) { - // Decode character - var carry = BASE_MAP[source.charCodeAt(psz)] - // Invalid character - if (carry === 255) { return } - var i = 0 - for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { - carry += (BASE * b256[it3]) >>> 0 - b256[it3] = (carry % 256) >>> 0 - carry = (carry / 256) >>> 0 + + while (carry > 0) { + digits.push(carry % BASE) + carry = (carry / BASE) | 0 } - if (carry !== 0) { throw new Error('Non-zero carry') } - 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) { - it4++ + + var string = '' + + // deal with leading zeros + for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER + // convert digits to a string + for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] + + return string + } + + function decodeUnsafe (string) { + if (typeof string !== 'string') throw new TypeError('Expected String') + if (string.length === 0) return Buffer.allocUnsafe(0) + + var bytes = [0] + for (var i = 0; i < string.length; i++) { + var value = ALPHABET_MAP[string[i]] + if (value === undefined) return + + for (var j = 0, carry = value; j < bytes.length; ++j) { + carry += bytes[j] * BASE + bytes[j] = carry & 0xff + carry >>= 8 + } + + while (carry > 0) { + bytes.push(carry & 0xff) + carry >>= 8 + } } - var vch = _Buffer.allocUnsafe(zeroes + (size - it4)) - vch.fill(0x00, 0, zeroes) - var j = zeroes - while (it4 !== size) { - vch[j++] = b256[it4++] + + // deal with leading zeros + for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { + bytes.push(0) } - return vch + + return Buffer.from(bytes.reverse()) } + function decode (string) { var buffer = decodeUnsafe(string) - if (buffer) { return buffer } + if (buffer) return buffer + throw new Error('Non-base' + BASE + ' character') } + return { encode: encode, decodeUnsafe: decodeUnsafe, decode: decode } } -module.exports = base },{"safe-buffer":123}],2:[function(require,module,exports){ 'use strict' @@ -4171,412 +4143,412 @@ function numberIsNaN (obj) { } },{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014 Patrick Gansterer - * - * 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. - */ - -(function(global, undefined) { "use strict"; -var POW_2_24 = Math.pow(2, -24), - POW_2_32 = Math.pow(2, 32), - POW_2_53 = Math.pow(2, 53); - -function encode(value) { - var data = new ArrayBuffer(256); - var dataView = new DataView(data); - var lastLength; - var offset = 0; - - function ensureSpace(length) { - var newByteLength = data.byteLength; - var requiredLength = offset + length; - while (newByteLength < requiredLength) - newByteLength *= 2; - if (newByteLength !== data.byteLength) { - var oldDataView = dataView; - data = new ArrayBuffer(newByteLength); - dataView = new DataView(data); - var uint32count = (offset + 3) >> 2; - for (var i = 0; i < uint32count; ++i) - dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); - } - - lastLength = length; - return dataView; - } - function write() { - offset += lastLength; - } - function writeFloat64(value) { - write(ensureSpace(8).setFloat64(offset, value)); - } - function writeUint8(value) { - write(ensureSpace(1).setUint8(offset, value)); - } - function writeUint8Array(value) { - var dataView = ensureSpace(value.length); - for (var i = 0; i < value.length; ++i) - dataView.setUint8(offset + i, value[i]); - write(); - } - function writeUint16(value) { - write(ensureSpace(2).setUint16(offset, value)); - } - function writeUint32(value) { - write(ensureSpace(4).setUint32(offset, value)); - } - function writeUint64(value) { - var low = value % POW_2_32; - var high = (value - low) / POW_2_32; - var dataView = ensureSpace(8); - dataView.setUint32(offset, high); - dataView.setUint32(offset + 4, low); - write(); - } - function writeTypeAndLength(type, length) { - if (length < 24) { - writeUint8(type << 5 | length); - } else if (length < 0x100) { - writeUint8(type << 5 | 24); - writeUint8(length); - } else if (length < 0x10000) { - writeUint8(type << 5 | 25); - writeUint16(length); - } else if (length < 0x100000000) { - writeUint8(type << 5 | 26); - writeUint32(length); - } else { - writeUint8(type << 5 | 27); - writeUint64(length); - } - } - - function encodeItem(value) { - var i; - - if (value === false) - return writeUint8(0xf4); - if (value === true) - return writeUint8(0xf5); - if (value === null) - return writeUint8(0xf6); - if (value === undefined) - return writeUint8(0xf7); - - switch (typeof value) { - case "number": - if (Math.floor(value) === value) { - if (0 <= value && value <= POW_2_53) - return writeTypeAndLength(0, value); - if (-POW_2_53 <= value && value < 0) - return writeTypeAndLength(1, -(value + 1)); - } - writeUint8(0xfb); - return writeFloat64(value); - - case "string": - var utf8data = []; - for (i = 0; i < value.length; ++i) { - var charCode = value.charCodeAt(i); - if (charCode < 0x80) { - utf8data.push(charCode); - } else if (charCode < 0x800) { - utf8data.push(0xc0 | charCode >> 6); - utf8data.push(0x80 | charCode & 0x3f); - } else if (charCode < 0xd800) { - utf8data.push(0xe0 | charCode >> 12); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } else { - charCode = (charCode & 0x3ff) << 10; - charCode |= value.charCodeAt(++i) & 0x3ff; - charCode += 0x10000; - - utf8data.push(0xf0 | charCode >> 18); - utf8data.push(0x80 | (charCode >> 12) & 0x3f); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } - } - - writeTypeAndLength(3, utf8data.length); - return writeUint8Array(utf8data); - - default: - var length; - if (Array.isArray(value)) { - length = value.length; - writeTypeAndLength(4, length); - for (i = 0; i < length; ++i) - encodeItem(value[i]); - } else if (value instanceof Uint8Array) { - writeTypeAndLength(2, value.length); - writeUint8Array(value); - } else { - var keys = Object.keys(value); - length = keys.length; - writeTypeAndLength(5, length); - for (i = 0; i < length; ++i) { - var key = keys[i]; - encodeItem(key); - encodeItem(value[key]); - } - } - } - } - - encodeItem(value); - - if ("slice" in data) - return data.slice(0, offset); - - var ret = new ArrayBuffer(offset); - var retView = new DataView(ret); - for (var i = 0; i < offset; ++i) - retView.setUint8(i, dataView.getUint8(i)); - return ret; -} - -function decode(data, tagger, simpleValue) { - var dataView = new DataView(data); - var offset = 0; - - if (typeof tagger !== "function") - tagger = function(value) { return value; }; - if (typeof simpleValue !== "function") - simpleValue = function() { return undefined; }; - - function read(value, length) { - offset += length; - return value; - } - function readArrayBuffer(length) { - return read(new Uint8Array(data, offset, length), length); - } - function readFloat16() { - var tempArrayBuffer = new ArrayBuffer(4); - var tempDataView = new DataView(tempArrayBuffer); - var value = readUint16(); - - var sign = value & 0x8000; - var exponent = value & 0x7c00; - var fraction = value & 0x03ff; - - if (exponent === 0x7c00) - exponent = 0xff << 10; - else if (exponent !== 0) - exponent += (127 - 15) << 10; - else if (fraction !== 0) - return fraction * POW_2_24; - - tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); - return tempDataView.getFloat32(0); - } - function readFloat32() { - return read(dataView.getFloat32(offset), 4); - } - function readFloat64() { - return read(dataView.getFloat64(offset), 8); - } - function readUint8() { - return read(dataView.getUint8(offset), 1); - } - function readUint16() { - return read(dataView.getUint16(offset), 2); - } - function readUint32() { - return read(dataView.getUint32(offset), 4); - } - function readUint64() { - return readUint32() * POW_2_32 + readUint32(); - } - function readBreak() { - if (dataView.getUint8(offset) !== 0xff) - return false; - offset += 1; - return true; - } - function readLength(additionalInformation) { - if (additionalInformation < 24) - return additionalInformation; - if (additionalInformation === 24) - return readUint8(); - if (additionalInformation === 25) - return readUint16(); - if (additionalInformation === 26) - return readUint32(); - if (additionalInformation === 27) - return readUint64(); - if (additionalInformation === 31) - return -1; - throw "Invalid length encoding"; - } - function readIndefiniteStringLength(majorType) { - var initialByte = readUint8(); - if (initialByte === 0xff) - return -1; - var length = readLength(initialByte & 0x1f); - if (length < 0 || (initialByte >> 5) !== majorType) - throw "Invalid indefinite length element"; - return length; - } - - function appendUtf16data(utf16data, length) { - for (var i = 0; i < length; ++i) { - var value = readUint8(); - if (value & 0x80) { - if (value < 0xe0) { - value = (value & 0x1f) << 6 - | (readUint8() & 0x3f); - length -= 1; - } else if (value < 0xf0) { - value = (value & 0x0f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 2; - } else { - value = (value & 0x0f) << 18 - | (readUint8() & 0x3f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 3; - } - } - - if (value < 0x10000) { - utf16data.push(value); - } else { - value -= 0x10000; - utf16data.push(0xd800 | (value >> 10)); - utf16data.push(0xdc00 | (value & 0x3ff)); - } - } - } - - function decodeItem() { - var initialByte = readUint8(); - var majorType = initialByte >> 5; - var additionalInformation = initialByte & 0x1f; - var i; - var length; - - if (majorType === 7) { - switch (additionalInformation) { - case 25: - return readFloat16(); - case 26: - return readFloat32(); - case 27: - return readFloat64(); - } - } - - length = readLength(additionalInformation); - if (length < 0 && (majorType < 2 || 6 < majorType)) - throw "Invalid length"; - - switch (majorType) { - case 0: - return length; - case 1: - return -1 - length; - case 2: - if (length < 0) { - var elements = []; - var fullArrayLength = 0; - while ((length = readIndefiniteStringLength(majorType)) >= 0) { - fullArrayLength += length; - elements.push(readArrayBuffer(length)); - } - var fullArray = new Uint8Array(fullArrayLength); - var fullArrayOffset = 0; - for (i = 0; i < elements.length; ++i) { - fullArray.set(elements[i], fullArrayOffset); - fullArrayOffset += elements[i].length; - } - return fullArray; - } - return readArrayBuffer(length); - case 3: - var utf16data = []; - if (length < 0) { - while ((length = readIndefiniteStringLength(majorType)) >= 0) - appendUtf16data(utf16data, length); - } else - appendUtf16data(utf16data, length); - return String.fromCharCode.apply(null, utf16data); - case 4: - var retArray; - if (length < 0) { - retArray = []; - while (!readBreak()) - retArray.push(decodeItem()); - } else { - retArray = new Array(length); - for (i = 0; i < length; ++i) - retArray[i] = decodeItem(); - } - return retArray; - case 5: - var retObject = {}; - for (i = 0; i < length || length < 0 && !readBreak(); ++i) { - var key = decodeItem(); - retObject[key] = decodeItem(); - } - return retObject; - case 6: - return tagger(decodeItem(), length); - case 7: - switch (length) { - case 20: - return false; - case 21: - return true; - case 22: - return null; - case 23: - return undefined; - default: - return simpleValue(length); - } - } - } - - var ret = decodeItem(); - if (offset !== data.byteLength) - throw "Remaining bytes"; - return ret; -} - -var obj = { encode: encode, decode: decode }; - -if (typeof define === "function" && define.amd) - define("cbor/cbor", obj); -else if (typeof module !== 'undefined' && module.exports) - module.exports = obj; -else if (!global.CBOR) - global.CBOR = obj; - -})(this); +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 Patrick Gansterer + * + * 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. + */ + +(function(global, undefined) { "use strict"; +var POW_2_24 = Math.pow(2, -24), + POW_2_32 = Math.pow(2, 32), + POW_2_53 = Math.pow(2, 53); + +function encode(value) { + var data = new ArrayBuffer(256); + var dataView = new DataView(data); + var lastLength; + var offset = 0; + + function ensureSpace(length) { + var newByteLength = data.byteLength; + var requiredLength = offset + length; + while (newByteLength < requiredLength) + newByteLength *= 2; + if (newByteLength !== data.byteLength) { + var oldDataView = dataView; + data = new ArrayBuffer(newByteLength); + dataView = new DataView(data); + var uint32count = (offset + 3) >> 2; + for (var i = 0; i < uint32count; ++i) + dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); + } + + lastLength = length; + return dataView; + } + function write() { + offset += lastLength; + } + function writeFloat64(value) { + write(ensureSpace(8).setFloat64(offset, value)); + } + function writeUint8(value) { + write(ensureSpace(1).setUint8(offset, value)); + } + function writeUint8Array(value) { + var dataView = ensureSpace(value.length); + for (var i = 0; i < value.length; ++i) + dataView.setUint8(offset + i, value[i]); + write(); + } + function writeUint16(value) { + write(ensureSpace(2).setUint16(offset, value)); + } + function writeUint32(value) { + write(ensureSpace(4).setUint32(offset, value)); + } + function writeUint64(value) { + var low = value % POW_2_32; + var high = (value - low) / POW_2_32; + var dataView = ensureSpace(8); + dataView.setUint32(offset, high); + dataView.setUint32(offset + 4, low); + write(); + } + function writeTypeAndLength(type, length) { + if (length < 24) { + writeUint8(type << 5 | length); + } else if (length < 0x100) { + writeUint8(type << 5 | 24); + writeUint8(length); + } else if (length < 0x10000) { + writeUint8(type << 5 | 25); + writeUint16(length); + } else if (length < 0x100000000) { + writeUint8(type << 5 | 26); + writeUint32(length); + } else { + writeUint8(type << 5 | 27); + writeUint64(length); + } + } + + function encodeItem(value) { + var i; + + if (value === false) + return writeUint8(0xf4); + if (value === true) + return writeUint8(0xf5); + if (value === null) + return writeUint8(0xf6); + if (value === undefined) + return writeUint8(0xf7); + + switch (typeof value) { + case "number": + if (Math.floor(value) === value) { + if (0 <= value && value <= POW_2_53) + return writeTypeAndLength(0, value); + if (-POW_2_53 <= value && value < 0) + return writeTypeAndLength(1, -(value + 1)); + } + writeUint8(0xfb); + return writeFloat64(value); + + case "string": + var utf8data = []; + for (i = 0; i < value.length; ++i) { + var charCode = value.charCodeAt(i); + if (charCode < 0x80) { + utf8data.push(charCode); + } else if (charCode < 0x800) { + utf8data.push(0xc0 | charCode >> 6); + utf8data.push(0x80 | charCode & 0x3f); + } else if (charCode < 0xd800) { + utf8data.push(0xe0 | charCode >> 12); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } else { + charCode = (charCode & 0x3ff) << 10; + charCode |= value.charCodeAt(++i) & 0x3ff; + charCode += 0x10000; + + utf8data.push(0xf0 | charCode >> 18); + utf8data.push(0x80 | (charCode >> 12) & 0x3f); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } + } + + writeTypeAndLength(3, utf8data.length); + return writeUint8Array(utf8data); + + default: + var length; + if (Array.isArray(value)) { + length = value.length; + writeTypeAndLength(4, length); + for (i = 0; i < length; ++i) + encodeItem(value[i]); + } else if (value instanceof Uint8Array) { + writeTypeAndLength(2, value.length); + writeUint8Array(value); + } else { + var keys = Object.keys(value); + length = keys.length; + writeTypeAndLength(5, length); + for (i = 0; i < length; ++i) { + var key = keys[i]; + encodeItem(key); + encodeItem(value[key]); + } + } + } + } + + encodeItem(value); + + if ("slice" in data) + return data.slice(0, offset); + + var ret = new ArrayBuffer(offset); + var retView = new DataView(ret); + for (var i = 0; i < offset; ++i) + retView.setUint8(i, dataView.getUint8(i)); + return ret; +} + +function decode(data, tagger, simpleValue) { + var dataView = new DataView(data); + var offset = 0; + + if (typeof tagger !== "function") + tagger = function(value) { return value; }; + if (typeof simpleValue !== "function") + simpleValue = function() { return undefined; }; + + function read(value, length) { + offset += length; + return value; + } + function readArrayBuffer(length) { + return read(new Uint8Array(data, offset, length), length); + } + function readFloat16() { + var tempArrayBuffer = new ArrayBuffer(4); + var tempDataView = new DataView(tempArrayBuffer); + var value = readUint16(); + + var sign = value & 0x8000; + var exponent = value & 0x7c00; + var fraction = value & 0x03ff; + + if (exponent === 0x7c00) + exponent = 0xff << 10; + else if (exponent !== 0) + exponent += (127 - 15) << 10; + else if (fraction !== 0) + return fraction * POW_2_24; + + tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); + return tempDataView.getFloat32(0); + } + function readFloat32() { + return read(dataView.getFloat32(offset), 4); + } + function readFloat64() { + return read(dataView.getFloat64(offset), 8); + } + function readUint8() { + return read(dataView.getUint8(offset), 1); + } + function readUint16() { + return read(dataView.getUint16(offset), 2); + } + function readUint32() { + return read(dataView.getUint32(offset), 4); + } + function readUint64() { + return readUint32() * POW_2_32 + readUint32(); + } + function readBreak() { + if (dataView.getUint8(offset) !== 0xff) + return false; + offset += 1; + return true; + } + function readLength(additionalInformation) { + if (additionalInformation < 24) + return additionalInformation; + if (additionalInformation === 24) + return readUint8(); + if (additionalInformation === 25) + return readUint16(); + if (additionalInformation === 26) + return readUint32(); + if (additionalInformation === 27) + return readUint64(); + if (additionalInformation === 31) + return -1; + throw "Invalid length encoding"; + } + function readIndefiniteStringLength(majorType) { + var initialByte = readUint8(); + if (initialByte === 0xff) + return -1; + var length = readLength(initialByte & 0x1f); + if (length < 0 || (initialByte >> 5) !== majorType) + throw "Invalid indefinite length element"; + return length; + } + + function appendUtf16data(utf16data, length) { + for (var i = 0; i < length; ++i) { + var value = readUint8(); + if (value & 0x80) { + if (value < 0xe0) { + value = (value & 0x1f) << 6 + | (readUint8() & 0x3f); + length -= 1; + } else if (value < 0xf0) { + value = (value & 0x0f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 2; + } else { + value = (value & 0x0f) << 18 + | (readUint8() & 0x3f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 3; + } + } + + if (value < 0x10000) { + utf16data.push(value); + } else { + value -= 0x10000; + utf16data.push(0xd800 | (value >> 10)); + utf16data.push(0xdc00 | (value & 0x3ff)); + } + } + } + + function decodeItem() { + var initialByte = readUint8(); + var majorType = initialByte >> 5; + var additionalInformation = initialByte & 0x1f; + var i; + var length; + + if (majorType === 7) { + switch (additionalInformation) { + case 25: + return readFloat16(); + case 26: + return readFloat32(); + case 27: + return readFloat64(); + } + } + + length = readLength(additionalInformation); + if (length < 0 && (majorType < 2 || 6 < majorType)) + throw "Invalid length"; + + switch (majorType) { + case 0: + return length; + case 1: + return -1 - length; + case 2: + if (length < 0) { + var elements = []; + var fullArrayLength = 0; + while ((length = readIndefiniteStringLength(majorType)) >= 0) { + fullArrayLength += length; + elements.push(readArrayBuffer(length)); + } + var fullArray = new Uint8Array(fullArrayLength); + var fullArrayOffset = 0; + for (i = 0; i < elements.length; ++i) { + fullArray.set(elements[i], fullArrayOffset); + fullArrayOffset += elements[i].length; + } + return fullArray; + } + return readArrayBuffer(length); + case 3: + var utf16data = []; + if (length < 0) { + while ((length = readIndefiniteStringLength(majorType)) >= 0) + appendUtf16data(utf16data, length); + } else + appendUtf16data(utf16data, length); + return String.fromCharCode.apply(null, utf16data); + case 4: + var retArray; + if (length < 0) { + retArray = []; + while (!readBreak()) + retArray.push(decodeItem()); + } else { + retArray = new Array(length); + for (i = 0; i < length; ++i) + retArray[i] = decodeItem(); + } + return retArray; + case 5: + var retObject = {}; + for (i = 0; i < length || length < 0 && !readBreak(); ++i) { + var key = decodeItem(); + retObject[key] = decodeItem(); + } + return retObject; + case 6: + return tagger(decodeItem(), length); + case 7: + switch (length) { + case 20: + return false; + case 21: + return true; + case 22: + return null; + case 23: + return undefined; + default: + return simpleValue(length); + } + } + } + + var ret = decodeItem(); + if (offset !== data.byteLength) + throw "Remaining bytes"; + return ret; +} + +var obj = { encode: encode, decode: decode }; + +if (typeof define === "function" && define.amd) + define("cbor/cbor", obj); +else if (typeof module !== 'undefined' && module.exports) + module.exports = obj; +else if (!global.CBOR) + global.CBOR = obj; + +})(this); },{}],6:[function(require,module,exports){ 'use strict'; @@ -11354,10 +11326,13 @@ module.exports = { } return hex; }, - sha256: function (hexString) { - var sha = new jsSHA('SHA-256', 'HEX'); - sha.update(hexString); - return sha.getHash('HEX'); + sha256: function (payload, format = 'HEX') { + var sha = new jsSHA('SHA-256', format); + sha.update(payload); + return sha.getHash(format); + }, + sha256x2: function (buffer, format = 'HEX') { + return this.sha256(this.sha256(buffer, format), format); }, sha256Checksum: function (payload) { return this.sha256(this.sha256(payload)).substr(0, 8); @@ -11404,6 +11379,7 @@ var LSKValidator = require('./lisk_validator'); var BCHValidator = require('./bch_validator'); var XLMValidator = require('./stellar_validator'); var EOSValidator = require('./eos_validator'); +var XTZValidator = require('./tezos_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [ @@ -11867,6 +11843,10 @@ var CURRENCIES = [ name: 'EOS', symbol: 'eos', validator: EOSValidator + }, { + name: 'Tezos', + symbol: 'xtz', + validator: XTZValidator } ]; @@ -11895,7 +11875,7 @@ module.exports = { -},{"./ada_validator":124,"./bch_validator":125,"./bitcoin_validator":126,"./eos_validator":138,"./ethereum_validator":139,"./lisk_validator":140,"./monero_validator":141,"./nano_validator":142,"./nem_validator":143,"./ripple_validator":144,"./siacoin_validator":145,"./stellar_validator":146,"./tron_validator":147}],138:[function(require,module,exports){ +},{"./ada_validator":124,"./bch_validator":125,"./bitcoin_validator":126,"./eos_validator":138,"./ethereum_validator":139,"./lisk_validator":140,"./monero_validator":141,"./nano_validator":142,"./nem_validator":143,"./ripple_validator":144,"./siacoin_validator":145,"./stellar_validator":146,"./tezos_validator":147,"./tron_validator":148}],138:[function(require,module,exports){ function isValidEOSAddress (address, currency, networkType) { var regex = /^[a-z0-9]+$/g // Must be numbers and lowercase letters only if (address.search(regex) !== -1 && address.length === 12) { @@ -12196,6 +12176,44 @@ var ed25519PublicKeyVersionByte = (6 << 3); } }; },{"./crypto/utils":136,"base-x":1,"crc":30}],147:[function(require,module,exports){ +const base58 = require('./crypto/base58'); +const cryptoUtils = require('./crypto/utils'); + +const prefix = new Uint8Array([6, 161, 159]); + +function decodeRaw(buffer) { + let payload = buffer.slice(0, -4); + let checksum = buffer.slice(-4); + let newChecksum = cryptoUtils.hexStr2byteArray( + cryptoUtils.sha256x2(cryptoUtils.byteArray2hexStr(payload)) + ); + + if (checksum[0] ^ newChecksum[0] | + checksum[1] ^ newChecksum[1] | + checksum[2] ^ newChecksum[2] | + checksum[3] ^ newChecksum[3]) + return; + return payload; +} + +const isValidAddress = function(address) { + try { + let buffer = base58.decode(address); + let payload = decodeRaw(buffer); + if (!payload) + return false; + payload.slice(prefix.length); + return true; + } catch (e) { + return false; + } +}; + +module.exports = { + isValidAddress +}; + +},{"./crypto/base58":128,"./crypto/utils":136}],148:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); function decodeBase58Address(base58Sting) { @@ -12257,7 +12275,7 @@ module.exports = { return getEnv(currency, networkType) === address[0]; } }; -},{"./crypto/utils":136}],148:[function(require,module,exports){ +},{"./crypto/utils":136}],149:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -12280,5 +12298,5 @@ module.exports = { } }; -},{"./currencies":137}]},{},[148])(148) +},{"./currencies":137}]},{},[149])(149) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 1a23c031..ecb49e5c 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");var e=new Uint8Array(256);e.fill(255);for(var r=0;r>>0,c=new Uint8Array(f);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=f-1;(0!==l||h>>0,c[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}if(" "!==t[r]){for(var d=f-i;d!==f&&0===c[d];)d++;var v=n.allocUnsafe(o+(f-d));v.fill(0,0,o);for(var y=o;d!==f;)v[y++]=c[d++];return v}}}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,o=0,i=0,u=e.length;i!==u&&0===e[i];)i++,r++;for(var c=(u-i)*f+1>>>0,l=new Uint8Array(c);i!==u;){for(var h=e[i],p=0,d=c-1;(0!==h||p>>0,l[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,i++}for(var v=c-o;v!==c&&0===l[v];)v++;for(var y=s.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Fri, 24 Jan 2020 15:45:10 +0200 Subject: [PATCH 093/108] updated version after merging tezos --- dist/wallet-address-validator.js | 988 ++++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- package.json | 11 +- test/wallet_address_validator.js | 2 + 4 files changed, 521 insertions(+), 482 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index f3b66424..ee80d948 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -1,96 +1,124 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WAValidator = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i= 255) { throw new TypeError('Alphabet too long') } + var BASE_MAP = new Uint8Array(256) + BASE_MAP.fill(255) + for (var i = 0; i < ALPHABET.length; i++) { + var x = ALPHABET.charAt(i) + var xc = x.charCodeAt(0) + if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } + BASE_MAP[xc] = i + } var BASE = ALPHABET.length var LEADER = ALPHABET.charAt(0) - - // pre-compute lookup table - for (var z = 0; z < ALPHABET.length; z++) { - var x = ALPHABET.charAt(z) - - if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous') - ALPHABET_MAP[x] = z - } - + var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up function encode (source) { - if (source.length === 0) return '' - - var digits = [0] - for (var i = 0; i < source.length; ++i) { - for (var j = 0, carry = source[i]; j < digits.length; ++j) { - carry += digits[j] << 8 - digits[j] = carry % BASE - carry = (carry / BASE) | 0 + if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } + if (source.length === 0) { return '' } + // Skip & count leading zeroes. + var zeroes = 0 + var length = 0 + var pbegin = 0 + var pend = source.length + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++ + zeroes++ + } + // Allocate enough space in big-endian base58 representation. + var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + var b58 = new Uint8Array(size) + // Process the bytes. + while (pbegin !== pend) { + var carry = source[pbegin] + // Apply "b58 = b58 * 256 + ch". + var i = 0 + for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { + carry += (256 * b58[it1]) >>> 0 + b58[it1] = (carry % BASE) >>> 0 + carry = (carry / BASE) >>> 0 } - - while (carry > 0) { - digits.push(carry % BASE) - carry = (carry / BASE) | 0 + if (carry !== 0) { throw new Error('Non-zero carry') } + length = i + pbegin++ + } + // Skip leading zeroes in base58 result. + var it2 = size - length + while (it2 !== size && b58[it2] === 0) { + it2++ + } + // Translate the result into a string. + var str = LEADER.repeat(zeroes) + for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } + return str + } + function decodeUnsafe (source) { + 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 + while (source[psz] === LEADER) { + zeroes++ + psz++ + } + // Allocate enough space in big-endian base256 representation. + var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + var b256 = new Uint8Array(size) + // Process the characters. + while (source[psz]) { + // Decode character + var carry = BASE_MAP[source.charCodeAt(psz)] + // Invalid character + if (carry === 255) { return } + var i = 0 + for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { + carry += (BASE * b256[it3]) >>> 0 + b256[it3] = (carry % 256) >>> 0 + carry = (carry / 256) >>> 0 } + if (carry !== 0) { throw new Error('Non-zero carry') } + length = i + psz++ } - - var string = '' - - // deal with leading zeros - for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER - // convert digits to a string - for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] - - return string - } - - function decodeUnsafe (string) { - if (typeof string !== 'string') throw new TypeError('Expected String') - if (string.length === 0) return Buffer.allocUnsafe(0) - - var bytes = [0] - for (var i = 0; i < string.length; i++) { - var value = ALPHABET_MAP[string[i]] - if (value === undefined) return - - for (var j = 0, carry = value; j < bytes.length; ++j) { - carry += bytes[j] * BASE - bytes[j] = carry & 0xff - carry >>= 8 - } - - while (carry > 0) { - bytes.push(carry & 0xff) - carry >>= 8 - } + // Skip trailing spaces. + if (source[psz] === ' ') { return } + // Skip leading zeroes in b256. + var it4 = size - length + while (it4 !== size && b256[it4] === 0) { + it4++ } - - // deal with leading zeros - for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) { - bytes.push(0) + var vch = _Buffer.allocUnsafe(zeroes + (size - it4)) + vch.fill(0x00, 0, zeroes) + var j = zeroes + while (it4 !== size) { + vch[j++] = b256[it4++] } - - return Buffer.from(bytes.reverse()) + return vch } - function decode (string) { var buffer = decodeUnsafe(string) - if (buffer) return buffer - + if (buffer) { return buffer } throw new Error('Non-base' + BASE + ' character') } - return { encode: encode, decodeUnsafe: decodeUnsafe, decode: decode } } +module.exports = base },{"safe-buffer":123}],2:[function(require,module,exports){ 'use strict' @@ -4143,412 +4171,412 @@ function numberIsNaN (obj) { } },{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014 Patrick Gansterer - * - * 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. - */ - -(function(global, undefined) { "use strict"; -var POW_2_24 = Math.pow(2, -24), - POW_2_32 = Math.pow(2, 32), - POW_2_53 = Math.pow(2, 53); - -function encode(value) { - var data = new ArrayBuffer(256); - var dataView = new DataView(data); - var lastLength; - var offset = 0; - - function ensureSpace(length) { - var newByteLength = data.byteLength; - var requiredLength = offset + length; - while (newByteLength < requiredLength) - newByteLength *= 2; - if (newByteLength !== data.byteLength) { - var oldDataView = dataView; - data = new ArrayBuffer(newByteLength); - dataView = new DataView(data); - var uint32count = (offset + 3) >> 2; - for (var i = 0; i < uint32count; ++i) - dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); - } - - lastLength = length; - return dataView; - } - function write() { - offset += lastLength; - } - function writeFloat64(value) { - write(ensureSpace(8).setFloat64(offset, value)); - } - function writeUint8(value) { - write(ensureSpace(1).setUint8(offset, value)); - } - function writeUint8Array(value) { - var dataView = ensureSpace(value.length); - for (var i = 0; i < value.length; ++i) - dataView.setUint8(offset + i, value[i]); - write(); - } - function writeUint16(value) { - write(ensureSpace(2).setUint16(offset, value)); - } - function writeUint32(value) { - write(ensureSpace(4).setUint32(offset, value)); - } - function writeUint64(value) { - var low = value % POW_2_32; - var high = (value - low) / POW_2_32; - var dataView = ensureSpace(8); - dataView.setUint32(offset, high); - dataView.setUint32(offset + 4, low); - write(); - } - function writeTypeAndLength(type, length) { - if (length < 24) { - writeUint8(type << 5 | length); - } else if (length < 0x100) { - writeUint8(type << 5 | 24); - writeUint8(length); - } else if (length < 0x10000) { - writeUint8(type << 5 | 25); - writeUint16(length); - } else if (length < 0x100000000) { - writeUint8(type << 5 | 26); - writeUint32(length); - } else { - writeUint8(type << 5 | 27); - writeUint64(length); - } - } - - function encodeItem(value) { - var i; - - if (value === false) - return writeUint8(0xf4); - if (value === true) - return writeUint8(0xf5); - if (value === null) - return writeUint8(0xf6); - if (value === undefined) - return writeUint8(0xf7); - - switch (typeof value) { - case "number": - if (Math.floor(value) === value) { - if (0 <= value && value <= POW_2_53) - return writeTypeAndLength(0, value); - if (-POW_2_53 <= value && value < 0) - return writeTypeAndLength(1, -(value + 1)); - } - writeUint8(0xfb); - return writeFloat64(value); - - case "string": - var utf8data = []; - for (i = 0; i < value.length; ++i) { - var charCode = value.charCodeAt(i); - if (charCode < 0x80) { - utf8data.push(charCode); - } else if (charCode < 0x800) { - utf8data.push(0xc0 | charCode >> 6); - utf8data.push(0x80 | charCode & 0x3f); - } else if (charCode < 0xd800) { - utf8data.push(0xe0 | charCode >> 12); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } else { - charCode = (charCode & 0x3ff) << 10; - charCode |= value.charCodeAt(++i) & 0x3ff; - charCode += 0x10000; - - utf8data.push(0xf0 | charCode >> 18); - utf8data.push(0x80 | (charCode >> 12) & 0x3f); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } - } - - writeTypeAndLength(3, utf8data.length); - return writeUint8Array(utf8data); - - default: - var length; - if (Array.isArray(value)) { - length = value.length; - writeTypeAndLength(4, length); - for (i = 0; i < length; ++i) - encodeItem(value[i]); - } else if (value instanceof Uint8Array) { - writeTypeAndLength(2, value.length); - writeUint8Array(value); - } else { - var keys = Object.keys(value); - length = keys.length; - writeTypeAndLength(5, length); - for (i = 0; i < length; ++i) { - var key = keys[i]; - encodeItem(key); - encodeItem(value[key]); - } - } - } - } - - encodeItem(value); - - if ("slice" in data) - return data.slice(0, offset); - - var ret = new ArrayBuffer(offset); - var retView = new DataView(ret); - for (var i = 0; i < offset; ++i) - retView.setUint8(i, dataView.getUint8(i)); - return ret; -} - -function decode(data, tagger, simpleValue) { - var dataView = new DataView(data); - var offset = 0; - - if (typeof tagger !== "function") - tagger = function(value) { return value; }; - if (typeof simpleValue !== "function") - simpleValue = function() { return undefined; }; - - function read(value, length) { - offset += length; - return value; - } - function readArrayBuffer(length) { - return read(new Uint8Array(data, offset, length), length); - } - function readFloat16() { - var tempArrayBuffer = new ArrayBuffer(4); - var tempDataView = new DataView(tempArrayBuffer); - var value = readUint16(); - - var sign = value & 0x8000; - var exponent = value & 0x7c00; - var fraction = value & 0x03ff; - - if (exponent === 0x7c00) - exponent = 0xff << 10; - else if (exponent !== 0) - exponent += (127 - 15) << 10; - else if (fraction !== 0) - return fraction * POW_2_24; - - tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); - return tempDataView.getFloat32(0); - } - function readFloat32() { - return read(dataView.getFloat32(offset), 4); - } - function readFloat64() { - return read(dataView.getFloat64(offset), 8); - } - function readUint8() { - return read(dataView.getUint8(offset), 1); - } - function readUint16() { - return read(dataView.getUint16(offset), 2); - } - function readUint32() { - return read(dataView.getUint32(offset), 4); - } - function readUint64() { - return readUint32() * POW_2_32 + readUint32(); - } - function readBreak() { - if (dataView.getUint8(offset) !== 0xff) - return false; - offset += 1; - return true; - } - function readLength(additionalInformation) { - if (additionalInformation < 24) - return additionalInformation; - if (additionalInformation === 24) - return readUint8(); - if (additionalInformation === 25) - return readUint16(); - if (additionalInformation === 26) - return readUint32(); - if (additionalInformation === 27) - return readUint64(); - if (additionalInformation === 31) - return -1; - throw "Invalid length encoding"; - } - function readIndefiniteStringLength(majorType) { - var initialByte = readUint8(); - if (initialByte === 0xff) - return -1; - var length = readLength(initialByte & 0x1f); - if (length < 0 || (initialByte >> 5) !== majorType) - throw "Invalid indefinite length element"; - return length; - } - - function appendUtf16data(utf16data, length) { - for (var i = 0; i < length; ++i) { - var value = readUint8(); - if (value & 0x80) { - if (value < 0xe0) { - value = (value & 0x1f) << 6 - | (readUint8() & 0x3f); - length -= 1; - } else if (value < 0xf0) { - value = (value & 0x0f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 2; - } else { - value = (value & 0x0f) << 18 - | (readUint8() & 0x3f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 3; - } - } - - if (value < 0x10000) { - utf16data.push(value); - } else { - value -= 0x10000; - utf16data.push(0xd800 | (value >> 10)); - utf16data.push(0xdc00 | (value & 0x3ff)); - } - } - } - - function decodeItem() { - var initialByte = readUint8(); - var majorType = initialByte >> 5; - var additionalInformation = initialByte & 0x1f; - var i; - var length; - - if (majorType === 7) { - switch (additionalInformation) { - case 25: - return readFloat16(); - case 26: - return readFloat32(); - case 27: - return readFloat64(); - } - } - - length = readLength(additionalInformation); - if (length < 0 && (majorType < 2 || 6 < majorType)) - throw "Invalid length"; - - switch (majorType) { - case 0: - return length; - case 1: - return -1 - length; - case 2: - if (length < 0) { - var elements = []; - var fullArrayLength = 0; - while ((length = readIndefiniteStringLength(majorType)) >= 0) { - fullArrayLength += length; - elements.push(readArrayBuffer(length)); - } - var fullArray = new Uint8Array(fullArrayLength); - var fullArrayOffset = 0; - for (i = 0; i < elements.length; ++i) { - fullArray.set(elements[i], fullArrayOffset); - fullArrayOffset += elements[i].length; - } - return fullArray; - } - return readArrayBuffer(length); - case 3: - var utf16data = []; - if (length < 0) { - while ((length = readIndefiniteStringLength(majorType)) >= 0) - appendUtf16data(utf16data, length); - } else - appendUtf16data(utf16data, length); - return String.fromCharCode.apply(null, utf16data); - case 4: - var retArray; - if (length < 0) { - retArray = []; - while (!readBreak()) - retArray.push(decodeItem()); - } else { - retArray = new Array(length); - for (i = 0; i < length; ++i) - retArray[i] = decodeItem(); - } - return retArray; - case 5: - var retObject = {}; - for (i = 0; i < length || length < 0 && !readBreak(); ++i) { - var key = decodeItem(); - retObject[key] = decodeItem(); - } - return retObject; - case 6: - return tagger(decodeItem(), length); - case 7: - switch (length) { - case 20: - return false; - case 21: - return true; - case 22: - return null; - case 23: - return undefined; - default: - return simpleValue(length); - } - } - } - - var ret = decodeItem(); - if (offset !== data.byteLength) - throw "Remaining bytes"; - return ret; -} - -var obj = { encode: encode, decode: decode }; - -if (typeof define === "function" && define.amd) - define("cbor/cbor", obj); -else if (typeof module !== 'undefined' && module.exports) - module.exports = obj; -else if (!global.CBOR) - global.CBOR = obj; - -})(this); +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 Patrick Gansterer + * + * 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. + */ + +(function(global, undefined) { "use strict"; +var POW_2_24 = Math.pow(2, -24), + POW_2_32 = Math.pow(2, 32), + POW_2_53 = Math.pow(2, 53); + +function encode(value) { + var data = new ArrayBuffer(256); + var dataView = new DataView(data); + var lastLength; + var offset = 0; + + function ensureSpace(length) { + var newByteLength = data.byteLength; + var requiredLength = offset + length; + while (newByteLength < requiredLength) + newByteLength *= 2; + if (newByteLength !== data.byteLength) { + var oldDataView = dataView; + data = new ArrayBuffer(newByteLength); + dataView = new DataView(data); + var uint32count = (offset + 3) >> 2; + for (var i = 0; i < uint32count; ++i) + dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); + } + + lastLength = length; + return dataView; + } + function write() { + offset += lastLength; + } + function writeFloat64(value) { + write(ensureSpace(8).setFloat64(offset, value)); + } + function writeUint8(value) { + write(ensureSpace(1).setUint8(offset, value)); + } + function writeUint8Array(value) { + var dataView = ensureSpace(value.length); + for (var i = 0; i < value.length; ++i) + dataView.setUint8(offset + i, value[i]); + write(); + } + function writeUint16(value) { + write(ensureSpace(2).setUint16(offset, value)); + } + function writeUint32(value) { + write(ensureSpace(4).setUint32(offset, value)); + } + function writeUint64(value) { + var low = value % POW_2_32; + var high = (value - low) / POW_2_32; + var dataView = ensureSpace(8); + dataView.setUint32(offset, high); + dataView.setUint32(offset + 4, low); + write(); + } + function writeTypeAndLength(type, length) { + if (length < 24) { + writeUint8(type << 5 | length); + } else if (length < 0x100) { + writeUint8(type << 5 | 24); + writeUint8(length); + } else if (length < 0x10000) { + writeUint8(type << 5 | 25); + writeUint16(length); + } else if (length < 0x100000000) { + writeUint8(type << 5 | 26); + writeUint32(length); + } else { + writeUint8(type << 5 | 27); + writeUint64(length); + } + } + + function encodeItem(value) { + var i; + + if (value === false) + return writeUint8(0xf4); + if (value === true) + return writeUint8(0xf5); + if (value === null) + return writeUint8(0xf6); + if (value === undefined) + return writeUint8(0xf7); + + switch (typeof value) { + case "number": + if (Math.floor(value) === value) { + if (0 <= value && value <= POW_2_53) + return writeTypeAndLength(0, value); + if (-POW_2_53 <= value && value < 0) + return writeTypeAndLength(1, -(value + 1)); + } + writeUint8(0xfb); + return writeFloat64(value); + + case "string": + var utf8data = []; + for (i = 0; i < value.length; ++i) { + var charCode = value.charCodeAt(i); + if (charCode < 0x80) { + utf8data.push(charCode); + } else if (charCode < 0x800) { + utf8data.push(0xc0 | charCode >> 6); + utf8data.push(0x80 | charCode & 0x3f); + } else if (charCode < 0xd800) { + utf8data.push(0xe0 | charCode >> 12); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } else { + charCode = (charCode & 0x3ff) << 10; + charCode |= value.charCodeAt(++i) & 0x3ff; + charCode += 0x10000; + + utf8data.push(0xf0 | charCode >> 18); + utf8data.push(0x80 | (charCode >> 12) & 0x3f); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } + } + + writeTypeAndLength(3, utf8data.length); + return writeUint8Array(utf8data); + + default: + var length; + if (Array.isArray(value)) { + length = value.length; + writeTypeAndLength(4, length); + for (i = 0; i < length; ++i) + encodeItem(value[i]); + } else if (value instanceof Uint8Array) { + writeTypeAndLength(2, value.length); + writeUint8Array(value); + } else { + var keys = Object.keys(value); + length = keys.length; + writeTypeAndLength(5, length); + for (i = 0; i < length; ++i) { + var key = keys[i]; + encodeItem(key); + encodeItem(value[key]); + } + } + } + } + + encodeItem(value); + + if ("slice" in data) + return data.slice(0, offset); + + var ret = new ArrayBuffer(offset); + var retView = new DataView(ret); + for (var i = 0; i < offset; ++i) + retView.setUint8(i, dataView.getUint8(i)); + return ret; +} + +function decode(data, tagger, simpleValue) { + var dataView = new DataView(data); + var offset = 0; + + if (typeof tagger !== "function") + tagger = function(value) { return value; }; + if (typeof simpleValue !== "function") + simpleValue = function() { return undefined; }; + + function read(value, length) { + offset += length; + return value; + } + function readArrayBuffer(length) { + return read(new Uint8Array(data, offset, length), length); + } + function readFloat16() { + var tempArrayBuffer = new ArrayBuffer(4); + var tempDataView = new DataView(tempArrayBuffer); + var value = readUint16(); + + var sign = value & 0x8000; + var exponent = value & 0x7c00; + var fraction = value & 0x03ff; + + if (exponent === 0x7c00) + exponent = 0xff << 10; + else if (exponent !== 0) + exponent += (127 - 15) << 10; + else if (fraction !== 0) + return fraction * POW_2_24; + + tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); + return tempDataView.getFloat32(0); + } + function readFloat32() { + return read(dataView.getFloat32(offset), 4); + } + function readFloat64() { + return read(dataView.getFloat64(offset), 8); + } + function readUint8() { + return read(dataView.getUint8(offset), 1); + } + function readUint16() { + return read(dataView.getUint16(offset), 2); + } + function readUint32() { + return read(dataView.getUint32(offset), 4); + } + function readUint64() { + return readUint32() * POW_2_32 + readUint32(); + } + function readBreak() { + if (dataView.getUint8(offset) !== 0xff) + return false; + offset += 1; + return true; + } + function readLength(additionalInformation) { + if (additionalInformation < 24) + return additionalInformation; + if (additionalInformation === 24) + return readUint8(); + if (additionalInformation === 25) + return readUint16(); + if (additionalInformation === 26) + return readUint32(); + if (additionalInformation === 27) + return readUint64(); + if (additionalInformation === 31) + return -1; + throw "Invalid length encoding"; + } + function readIndefiniteStringLength(majorType) { + var initialByte = readUint8(); + if (initialByte === 0xff) + return -1; + var length = readLength(initialByte & 0x1f); + if (length < 0 || (initialByte >> 5) !== majorType) + throw "Invalid indefinite length element"; + return length; + } + + function appendUtf16data(utf16data, length) { + for (var i = 0; i < length; ++i) { + var value = readUint8(); + if (value & 0x80) { + if (value < 0xe0) { + value = (value & 0x1f) << 6 + | (readUint8() & 0x3f); + length -= 1; + } else if (value < 0xf0) { + value = (value & 0x0f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 2; + } else { + value = (value & 0x0f) << 18 + | (readUint8() & 0x3f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 3; + } + } + + if (value < 0x10000) { + utf16data.push(value); + } else { + value -= 0x10000; + utf16data.push(0xd800 | (value >> 10)); + utf16data.push(0xdc00 | (value & 0x3ff)); + } + } + } + + function decodeItem() { + var initialByte = readUint8(); + var majorType = initialByte >> 5; + var additionalInformation = initialByte & 0x1f; + var i; + var length; + + if (majorType === 7) { + switch (additionalInformation) { + case 25: + return readFloat16(); + case 26: + return readFloat32(); + case 27: + return readFloat64(); + } + } + + length = readLength(additionalInformation); + if (length < 0 && (majorType < 2 || 6 < majorType)) + throw "Invalid length"; + + switch (majorType) { + case 0: + return length; + case 1: + return -1 - length; + case 2: + if (length < 0) { + var elements = []; + var fullArrayLength = 0; + while ((length = readIndefiniteStringLength(majorType)) >= 0) { + fullArrayLength += length; + elements.push(readArrayBuffer(length)); + } + var fullArray = new Uint8Array(fullArrayLength); + var fullArrayOffset = 0; + for (i = 0; i < elements.length; ++i) { + fullArray.set(elements[i], fullArrayOffset); + fullArrayOffset += elements[i].length; + } + return fullArray; + } + return readArrayBuffer(length); + case 3: + var utf16data = []; + if (length < 0) { + while ((length = readIndefiniteStringLength(majorType)) >= 0) + appendUtf16data(utf16data, length); + } else + appendUtf16data(utf16data, length); + return String.fromCharCode.apply(null, utf16data); + case 4: + var retArray; + if (length < 0) { + retArray = []; + while (!readBreak()) + retArray.push(decodeItem()); + } else { + retArray = new Array(length); + for (i = 0; i < length; ++i) + retArray[i] = decodeItem(); + } + return retArray; + case 5: + var retObject = {}; + for (i = 0; i < length || length < 0 && !readBreak(); ++i) { + var key = decodeItem(); + retObject[key] = decodeItem(); + } + return retObject; + case 6: + return tagger(decodeItem(), length); + case 7: + switch (length) { + case 20: + return false; + case 21: + return true; + case 22: + return null; + case 23: + return undefined; + default: + return simpleValue(length); + } + } + } + + var ret = decodeItem(); + if (offset !== data.byteLength) + throw "Remaining bytes"; + return ret; +} + +var obj = { encode: encode, decode: decode }; + +if (typeof define === "function" && define.amd) + define("cbor/cbor", obj); +else if (typeof module !== 'undefined' && module.exports) + module.exports = obj; +else if (!global.CBOR) + global.CBOR = obj; + +})(this); },{}],6:[function(require,module,exports){ 'use strict'; @@ -11372,7 +11400,7 @@ var BTCValidator = require('./bitcoin_validator'); var ADAValidator = require('./ada_validator'); var XMRValidator = require('./monero_validator'); var NANOValidator = require('./nano_validator'); -var SCValidator = require('./siacoin_validator') +var SCValidator = require('./siacoin_validator'); var TRXValidator = require('./tron_validator'); var NEMValidator = require('./nem_validator'); var LSKValidator = require('./lisk_validator'); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index ecb49e5c..f79b3a74 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a>=8;for(;f>0;)i.push(255&f),f>>=8}for(var c=0;t[c]===o&&c0;)n.push(s%r),s=s/r|0}for(var u="",f=0;0===e[f]&&f=0;--c)u+=t[n[c]];return u},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{"safe-buffer":123}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=f(t),n=r[0],a=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,c=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),D(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o=255)throw new TypeError("Alphabet too long");var e=new Uint8Array(256);e.fill(255);for(var r=0;r>>0,c=new Uint8Array(f);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=f-1;(0!==l||h>>0,c[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}if(" "!==t[r]){for(var d=f-i;d!==f&&0===c[d];)d++;var v=n.allocUnsafe(o+(f-d));v.fill(0,0,o);for(var y=o;d!==f;)v[y++]=c[d++];return v}}}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,o=0,i=0,u=e.length;i!==u&&0===e[i];)i++,r++;for(var c=(u-i)*f+1>>>0,l=new Uint8Array(c);i!==u;){for(var h=e[i],p=0,d=c-1;(0!==h||p>>0,l[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,i++}for(var v=c-o;v!==c&&0===l[v];)v++;for(var y=s.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),z(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function z(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Sat, 25 Apr 2020 10:56:57 +0200 Subject: [PATCH 094/108] added support for monero sub addresses, updated depencies. --- dist/wallet-address-validator.js | 43 ++-- dist/wallet-address-validator.min.js | 2 +- package.json | 12 +- src/currencies.js | 4 +- test/wallet_address_validator.js | 5 + yarn.lock | 344 +++++++++++++++++---------- 6 files changed, 255 insertions(+), 155 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index ee80d948..813e7726 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -5217,30 +5217,29 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding HMAC implementation as defined in FIPS PUB 198a - Copyright Brian Turek 2008-2017 + Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors Distributed under the BSD License See http://caligatio.github.com/jsSHA/ for more information - - Several functions taken from Paul Johnston */ -'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; -b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> -5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); -}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> -6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); -if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, -"");if(-1!==k&&ku)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(a,b){return A(a,b,c)},y=function(a,b,g,h){var d,e;if("SHA-224"===c||"SHA-256"===c)d=(b+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;a.length<=d;)a.push(0);a[b>>>5]|=128<<24-b%32;b=b+g;a[d]=b&4294967295; +a[d-1]=b/4294967296|0;g=a.length;for(b=0;b>>3;h=d/4-1;for(d>>5;c=n(a,b,h);a=c.binLen;d=c.value;c=a>>>5;for(e=0;e>>5);h=a%l;z=!0};this.getHash=function(a,d){var e,l,n,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key"); +n=C(d);switch(a){case "HEX":e=function(a){return D(a,f,n)};break;case "B64":e=function(a){return E(a,f,n)};break;case "BYTES":e=function(a){return F(a,f)};break;case "ARRAYBUFFER":try{l=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}e=function(a){return G(a,f)};break;case "UINT8ARRAY":try{l=new Uint8Array(0)}catch(v){throw Error("UINT8ARRAY not supported by this environment");}e=function(a){return H(a,f)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY"); +}q=y(b.slice(),h,g,p(k));for(l=1;l>>3;for(g=0;g>>2,a.length<=h&&a.push(0),a[h]|=c[g]<<8*(3+e%4*-1);return{value:a,binLen:8*c.length+d}}function D(c,a,d){var g="";a/=8;var b, +h;for(b=0;b>>2]>>>8*(3+b%4*-1),g+="0123456789abcdef".charAt(h>>>4&15)+"0123456789abcdef".charAt(h&15);return d.outputUpper?g.toUpperCase():g}function E(c,a,d){var g="",b=a/8,h,e,k;for(h=0;h>>2]:0,k=h+2>>2]:0,k=(c[h>>>2]>>>8*(3+h%4*-1)&255)<<16|(e>>>8*(3+(h+1)%4*-1)&255)<<8|k>>>8*(3+(h+2)%4*-1)&255,e=0;4>e;e+=1)8*h+6*e<=a?g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(k>>>6*(3-e)&63):g+=d.b64Pad;return g}function F(c,a){var d= +"",g=a/8,b,h;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(h);return d}function G(c,a){var d=a/8,g,b=new ArrayBuffer(d),h;h=new Uint8Array(b);for(g=0;g>>2]>>>8*(3+g%4*-1)&255;return b}function H(c,a){var d=a/8,g,b=new Uint8Array(d);for(g=0;g>>2]>>>8*(3+g%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var d=a.length,k,n,f,l,q;if(0!==d%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(k=0;k>>1)+q;for(f=l>>>2;b.length<=f;)b.push(0);b[f]|=n<<8*(3+l%4*-1)}return{value:b,binLen:4*d+c}};break;case "TEXT":d=function(c,b,d){var e,k,n=0,f,l,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,f=0;fe?k.push(e):2048>e?(k.push(192|e>>>6),k.push(128|e&63)):55296>e||57344<=e?k.push(224|e>>>12,128|e>>>6&63,128|e&63):(f+=1,e=65536+((e&1023)<<10|c.charCodeAt(f)&1023),k.push(240|e>>>18,128|e>>>12&63,128|e>>>6&63,128|e&63)),l=0;l>>2;b.length<=m;)b.push(0);b[m]|=k[l]<<8*(r+p%4*-1);n+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,k="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,f=0;f>>8);p=n+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=e<<8*(r+p%4*-1);n+=2}return{value:b,binLen:8*n+d}};break;case "B64":d=function(a,b,c){var d=0,k,n,f,l,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");n=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==n&&n=255)throw new TypeError("Alphabet too long");var e=new Uint8Array(256);e.fill(255);for(var r=0;r>>0,c=new Uint8Array(f);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=f-1;(0!==l||h>>0,c[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}if(" "!==t[r]){for(var d=f-i;d!==f&&0===c[d];)d++;var v=n.allocUnsafe(o+(f-d));v.fill(0,0,o);for(var y=o;d!==f;)v[y++]=c[d++];return v}}}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,o=0,i=0,u=e.length;i!==u&&0===e[i];)i++,r++;for(var c=(u-i)*f+1>>>0,l=new Uint8Array(c);i!==u;){for(var h=e[i],p=0,d=c-1;(0!==h||p>>0,l[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,i++}for(var v=c-o;v!==c&&0===l[v];)v++;for(var y=s.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:N(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),z(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function z(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,l,h,p,d,v,y,g,b=0,_=[],m=0,x=!1,E=[],C=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(d=function(e,r){return A(e,r,t)},v=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,ae/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(e=0;e<=i;e+=1)E[e]=909522486^r[e],C[e]=1549556828^r[e];o=d(E,o),b=p,x=!0},this.update=function(t){var e,r,n,i=0,a=p>>>5;for(t=(e=l(t,_,m)).binLen,r=e.value,e=t>>>5,n=0;n>>5),m=t%p,B=!0},this.getHash=function(e,r){var n,c,l,p;if(!0===x)throw Error("Cannot call getHash after setting HMAC key");switch(l=f(r),e){case"HEX":n=function(t){return i(t,h,l)};break;case"B64":n=function(t){return a(t,h,l)};break;case"BYTES":n=function(t){return s(t,h)};break;case"ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return u(t,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(p=v(_.slice(),m,b,y(o)),c=1;c>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function a(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function s(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function u(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function f(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function c(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o=255)throw new TypeError("Alphabet too long");var e=new Uint8Array(256);e.fill(255);for(var r=0;r>>0,c=new Uint8Array(f);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=f-1;(0!==l||h>>0,c[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}if(" "!==t[r]){for(var d=f-i;d!==f&&0===c[d];)d++;var v=n.allocUnsafe(o+(f-d));v.fill(0,0,o);for(var y=o;d!==f;)v[y++]=c[d++];return v}}}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,o=0,i=0,u=e.length;i!==u&&0===e[i];)i++,r++;for(var c=(u-i)*f+1>>>0,l=new Uint8Array(c);i!==u;){for(var h=e[i],p=0,d=c-1;(0!==h||p>>0,l[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,i++}for(var v=c-o;v!==c&&0===l[v];)v++;for(var y=s.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:L(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),z(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||U(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||U(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||U(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||U(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||U(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||U(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);O(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);O(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function z(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,i,p,d,v,y,g,b,_=0,m=[],w=0,A=!1,C=[],k=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return E(e,r,t)},y=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=i(t,m,w)).binLen,r=e.value,e=t>>>5,n=0;n>>5),w=t%d,B=!0},this.getHash=function(e,r){var n,i,h,d;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,p,h)};break;case"B64":n=function(t){return s(t,p,h)};break;case"BYTES":n=function(t){return u(t,p)};break;case"ARRAYBUFFER":try{i=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,p)};break;case"UINT8ARRAY":try{i=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,p)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(d=y(m.slice(),w,_,g(o)),i=1;i>>3,n=0;n>>2,e.length<=i&&e.push(0),e[i]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,o,i="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function s(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function u(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function f(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function c(t,e){var r,n=e/8,o=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o Date: Sat, 25 Apr 2020 11:09:44 +0200 Subject: [PATCH 095/108] merged lodash.isequal fix --- dist/wallet-address-validator.js | 2679 ++++++++++---------------- dist/wallet-address-validator.min.js | 2 +- package.json | 311 ++- src/siacoin_validator.js | 2 +- yarn.lock | 13 +- 5 files changed, 1246 insertions(+), 1761 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 813e7726..1af045f4 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -10,7 +10,9 @@ var _Buffer = require('safe-buffer').Buffer function base (ALPHABET) { if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } var BASE_MAP = new Uint8Array(256) - BASE_MAP.fill(255) + for (var j = 0; j < BASE_MAP.length; j++) { + BASE_MAP[j] = 255 + } for (var i = 0; i < ALPHABET.length; i++) { var x = ALPHABET.charAt(i) var xc = x.charCodeAt(0) @@ -22,6 +24,7 @@ function base (ALPHABET) { var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up function encode (source) { + if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) } if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } if (source.length === 0) { return '' } // Skip & count leading zeroes. @@ -120,7 +123,7 @@ function base (ALPHABET) { } module.exports = base -},{"safe-buffer":123}],2:[function(require,module,exports){ +},{"safe-buffer":35}],2:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -5242,227 +5245,122 @@ new m,new m,new m,new m,new m,new m];break;case "SHA-512":a=[new m,new m,new m,n 2756734187,3204031479,3329325298];"function"===typeof define&&define.amd?define(function(){return w}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(module.exports=w),exports=w):K.jsSHA=w})(this); },{}],33:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); - -/* Built-in method references that are verified to be native. */ -var DataView = getNative(root, 'DataView'); - -module.exports = DataView; - -},{"./_getNative":68,"./_root":98}],34:[function(require,module,exports){ -var hashClear = require('./_hashClear'), - hashDelete = require('./_hashDelete'), - hashGet = require('./_hashGet'), - hashHas = require('./_hashHas'), - hashSet = require('./_hashSet'); - -/** - * Creates a hash object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Hash(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -// Add methods to `Hash`. -Hash.prototype.clear = hashClear; -Hash.prototype['delete'] = hashDelete; -Hash.prototype.get = hashGet; -Hash.prototype.has = hashHas; -Hash.prototype.set = hashSet; - -module.exports = Hash; - -},{"./_hashClear":73,"./_hashDelete":74,"./_hashGet":75,"./_hashHas":76,"./_hashSet":77}],35:[function(require,module,exports){ -var listCacheClear = require('./_listCacheClear'), - listCacheDelete = require('./_listCacheDelete'), - listCacheGet = require('./_listCacheGet'), - listCacheHas = require('./_listCacheHas'), - listCacheSet = require('./_listCacheSet'); - -/** - * Creates an list cache object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function ListCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -// Add methods to `ListCache`. -ListCache.prototype.clear = listCacheClear; -ListCache.prototype['delete'] = listCacheDelete; -ListCache.prototype.get = listCacheGet; -ListCache.prototype.has = listCacheHas; -ListCache.prototype.set = listCacheSet; - -module.exports = ListCache; - -},{"./_listCacheClear":82,"./_listCacheDelete":83,"./_listCacheGet":84,"./_listCacheHas":85,"./_listCacheSet":86}],36:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); - -/* Built-in method references that are verified to be native. */ -var Map = getNative(root, 'Map'); - -module.exports = Map; - -},{"./_getNative":68,"./_root":98}],37:[function(require,module,exports){ -var mapCacheClear = require('./_mapCacheClear'), - mapCacheDelete = require('./_mapCacheDelete'), - mapCacheGet = require('./_mapCacheGet'), - mapCacheHas = require('./_mapCacheHas'), - mapCacheSet = require('./_mapCacheSet'); - +(function (global){ /** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. + * Lodash (Custom Build) + * Build: `lodash modularize exports="npm" -o ./` + * Copyright JS Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ -function MapCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} -// Add methods to `MapCache`. -MapCache.prototype.clear = mapCacheClear; -MapCache.prototype['delete'] = mapCacheDelete; -MapCache.prototype.get = mapCacheGet; -MapCache.prototype.has = mapCacheHas; -MapCache.prototype.set = mapCacheSet; - -module.exports = MapCache; - -},{"./_mapCacheClear":87,"./_mapCacheDelete":88,"./_mapCacheGet":89,"./_mapCacheHas":90,"./_mapCacheSet":91}],38:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); - -/* Built-in method references that are verified to be native. */ -var Promise = getNative(root, 'Promise'); +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; -module.exports = Promise; +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; -},{"./_getNative":68,"./_root":98}],39:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; -/* Built-in method references that are verified to be native. */ -var Set = getNative(root, 'Set'); +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; -module.exports = Set; +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + asyncTag = '[object AsyncFunction]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag = '[object Map]', + numberTag = '[object Number]', + nullTag = '[object Null]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + proxyTag = '[object Proxy]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]', + undefinedTag = '[object Undefined]', + weakMapTag = '[object WeakMap]'; -},{"./_getNative":68,"./_root":98}],40:[function(require,module,exports){ -var MapCache = require('./_MapCache'), - setCacheAdd = require('./_setCacheAdd'), - setCacheHas = require('./_setCacheHas'); +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; /** - * - * Creates an array cache object to store unique values. - * - * @private - * @constructor - * @param {Array} [values] The values to cache. + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ -function SetCache(values) { - var index = -1, - length = values == null ? 0 : values.length; - - this.__data__ = new MapCache; - while (++index < length) { - this.add(values[index]); - } -} - -// Add methods to `SetCache`. -SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; -SetCache.prototype.has = setCacheHas; - -module.exports = SetCache; - -},{"./_MapCache":37,"./_setCacheAdd":99,"./_setCacheHas":100}],41:[function(require,module,exports){ -var ListCache = require('./_ListCache'), - stackClear = require('./_stackClear'), - stackDelete = require('./_stackDelete'), - stackGet = require('./_stackGet'), - stackHas = require('./_stackHas'), - stackSet = require('./_stackSet'); +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; -/** - * Creates a stack cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Stack(entries) { - var data = this.__data__ = new ListCache(entries); - this.size = data.size; -} +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; -// Add methods to `Stack`. -Stack.prototype.clear = stackClear; -Stack.prototype['delete'] = stackDelete; -Stack.prototype.get = stackGet; -Stack.prototype.has = stackHas; -Stack.prototype.set = stackSet; +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; -module.exports = Stack; +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = +typedArrayTags[errorTag] = typedArrayTags[funcTag] = +typedArrayTags[mapTag] = typedArrayTags[numberTag] = +typedArrayTags[objectTag] = typedArrayTags[regexpTag] = +typedArrayTags[setTag] = typedArrayTags[stringTag] = +typedArrayTags[weakMapTag] = false; -},{"./_ListCache":35,"./_stackClear":102,"./_stackDelete":103,"./_stackGet":104,"./_stackHas":105,"./_stackSet":106}],42:[function(require,module,exports){ -var root = require('./_root'); +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; -/** Built-in value references. */ -var Symbol = root.Symbol; +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; -module.exports = Symbol; +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); -},{"./_root":98}],43:[function(require,module,exports){ -var root = require('./_root'); +/** Detect free variable `exports`. */ +var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; -/** Built-in value references. */ -var Uint8Array = root.Uint8Array; +/** Detect free variable `module`. */ +var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; -module.exports = Uint8Array; +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; -},{"./_root":98}],44:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports && freeGlobal.process; -/* Built-in method references that are verified to be native. */ -var WeakMap = getNative(root, 'WeakMap'); +/** Used to access faster Node.js helpers. */ +var nodeUtil = (function() { + try { + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} +}()); -module.exports = WeakMap; +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; -},{"./_getNative":68,"./_root":98}],45:[function(require,module,exports){ /** * A specialized version of `_.filter` for arrays without support for * iteratee shorthands. @@ -5487,60 +5385,6 @@ function arrayFilter(array, predicate) { return result; } -module.exports = arrayFilter; - -},{}],46:[function(require,module,exports){ -var baseTimes = require('./_baseTimes'), - isArguments = require('./isArguments'), - isArray = require('./isArray'), - isBuffer = require('./isBuffer'), - isIndex = require('./_isIndex'), - isTypedArray = require('./isTypedArray'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Creates an array of the enumerable property names of the array-like `value`. - * - * @private - * @param {*} value The value to query. - * @param {boolean} inherited Specify returning inherited property names. - * @returns {Array} Returns the array of property names. - */ -function arrayLikeKeys(value, inherited) { - var isArr = isArray(value), - isArg = !isArr && isArguments(value), - isBuff = !isArr && !isArg && isBuffer(value), - isType = !isArr && !isArg && !isBuff && isTypedArray(value), - skipIndexes = isArr || isArg || isBuff || isType, - result = skipIndexes ? baseTimes(value.length, String) : [], - length = result.length; - - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && - !(skipIndexes && ( - // Safari 9 has enumerable `arguments.length` in strict mode. - key == 'length' || - // Node.js 0.10 has enumerable non-index properties on buffers. - (isBuff && (key == 'offset' || key == 'parent')) || - // PhantomJS 2 has enumerable non-index properties on typed arrays. - (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || - // Skip index properties. - isIndex(key, length) - ))) { - result.push(key); - } - } - return result; -} - -module.exports = arrayLikeKeys; - -},{"./_baseTimes":58,"./_isIndex":78,"./isArguments":109,"./isArray":110,"./isBuffer":112,"./isTypedArray":118}],47:[function(require,module,exports){ /** * Appends the elements of `values` to `array`. * @@ -5560,9 +5404,6 @@ function arrayPush(array, values) { return array; } -module.exports = arrayPush; - -},{}],48:[function(require,module,exports){ /** * A specialized version of `_.some` for arrays without support for iteratee * shorthands. @@ -5585,1647 +5426,1284 @@ function arraySome(array, predicate) { return false; } -module.exports = arraySome; - -},{}],49:[function(require,module,exports){ -var eq = require('./eq'); - /** - * Gets the index at which the `key` is found in `array` of key-value pairs. + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. * * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); } - return -1; + return result; } -module.exports = assocIndexOf; - -},{"./eq":108}],50:[function(require,module,exports){ -var arrayPush = require('./_arrayPush'), - isArray = require('./isArray'); - /** - * The base implementation of `getAllKeys` and `getAllKeysIn` which uses - * `keysFunc` and `symbolsFunc` to get the enumerable property names and - * symbols of `object`. + * The base implementation of `_.unary` without support for storing metadata. * * @private - * @param {Object} object The object to query. - * @param {Function} keysFunc The function to get the keys of `object`. - * @param {Function} symbolsFunc The function to get the symbols of `object`. - * @returns {Array} Returns the array of property names and symbols. + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. */ -function baseGetAllKeys(object, keysFunc, symbolsFunc) { - var result = keysFunc(object); - return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); +function baseUnary(func) { + return function(value) { + return func(value); + }; } -module.exports = baseGetAllKeys; - -},{"./_arrayPush":47,"./isArray":110}],51:[function(require,module,exports){ -var Symbol = require('./_Symbol'), - getRawTag = require('./_getRawTag'), - objectToString = require('./_objectToString'); - -/** `Object#toString` result references. */ -var nullTag = '[object Null]', - undefinedTag = '[object Undefined]'; - -/** Built-in value references. */ -var symToStringTag = Symbol ? Symbol.toStringTag : undefined; - /** - * The base implementation of `getTag` without fallbacks for buggy environments. + * Checks if a `cache` value for `key` exists. * * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function baseGetTag(value) { - if (value == null) { - return value === undefined ? undefinedTag : nullTag; - } - return (symToStringTag && symToStringTag in Object(value)) - ? getRawTag(value) - : objectToString(value); +function cacheHas(cache, key) { + return cache.has(key); } -module.exports = baseGetTag; - -},{"./_Symbol":42,"./_getRawTag":69,"./_objectToString":96}],52:[function(require,module,exports){ -var baseGetTag = require('./_baseGetTag'), - isObjectLike = require('./isObjectLike'); - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]'; - /** - * The base implementation of `_.isArguments`. + * Gets the value at `key` of `object`. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. */ -function baseIsArguments(value) { - return isObjectLike(value) && baseGetTag(value) == argsTag; +function getValue(object, key) { + return object == null ? undefined : object[key]; } -module.exports = baseIsArguments; - -},{"./_baseGetTag":51,"./isObjectLike":117}],53:[function(require,module,exports){ -var baseIsEqualDeep = require('./_baseIsEqualDeep'), - isObjectLike = require('./isObjectLike'); - /** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. + * Converts `map` to its key-value pairs. * * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {boolean} bitmask The bitmask flags. - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Function} [customizer] The function to customize comparisons. - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. */ -function baseIsEqual(value, other, bitmask, customizer, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); -} - -module.exports = baseIsEqual; - -},{"./_baseIsEqualDeep":54,"./isObjectLike":117}],54:[function(require,module,exports){ -var Stack = require('./_Stack'), - equalArrays = require('./_equalArrays'), - equalByTag = require('./_equalByTag'), - equalObjects = require('./_equalObjects'), - getTag = require('./_getTag'), - isArray = require('./isArray'), - isBuffer = require('./isBuffer'), - isTypedArray = require('./isTypedArray'); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1; - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - objectTag = '[object Object]'; - -/** Used for built-in method references. */ -var objectProto = Object.prototype; +function mapToArray(map) { + var index = -1, + result = Array(map.size); -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; +} /** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. + * Creates a unary function that invokes `func` with its argument transformed. * * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} [stack] Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. */ -function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = objIsArr ? arrayTag : getTag(object), - othTag = othIsArr ? arrayTag : getTag(other); - - objTag = objTag == argsTag ? objectTag : objTag; - othTag = othTag == argsTag ? objectTag : othTag; - - var objIsObj = objTag == objectTag, - othIsObj = othTag == objectTag, - isSameTag = objTag == othTag; - - if (isSameTag && isBuffer(object)) { - if (!isBuffer(other)) { - return false; - } - objIsArr = true; - objIsObj = false; - } - if (isSameTag && !objIsObj) { - stack || (stack = new Stack); - return (objIsArr || isTypedArray(object)) - ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) - : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); - } - if (!(bitmask & COMPARE_PARTIAL_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, - othUnwrapped = othIsWrapped ? other.value() : other; - - stack || (stack = new Stack); - return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack); - return equalObjects(object, other, bitmask, customizer, equalFunc, stack); +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; } -module.exports = baseIsEqualDeep; - -},{"./_Stack":41,"./_equalArrays":62,"./_equalByTag":63,"./_equalObjects":64,"./_getTag":71,"./isArray":110,"./isBuffer":112,"./isTypedArray":118}],55:[function(require,module,exports){ -var isFunction = require('./isFunction'), - isMasked = require('./_isMasked'), - isObject = require('./isObject'), - toSource = require('./_toSource'); - /** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; +function setToArray(set) { + var index = -1, + result = Array(set.size); -/** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; + set.forEach(function(value) { + result[++index] = value; + }); + return result; +} /** Used for built-in method references. */ -var funcProto = Function.prototype, +var arrayProto = Array.prototype, + funcProto = Function.prototype, objectProto = Object.prototype; +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; + /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + /** Used to detect if a method is native. */ var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); +/** Built-in value references. */ +var Buffer = moduleExports ? root.Buffer : undefined, + Symbol = root.Symbol, + Uint8Array = root.Uint8Array, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + splice = arrayProto.splice, + symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols = Object.getOwnPropertySymbols, + nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, + nativeKeys = overArg(Object.keys, Object); + +/* Built-in method references that are verified to be native. */ +var DataView = getNative(root, 'DataView'), + Map = getNative(root, 'Map'), + Promise = getNative(root, 'Promise'), + Set = getNative(root, 'Set'), + WeakMap = getNative(root, 'WeakMap'), + nativeCreate = getNative(Object, 'create'); + +/** Used to detect maps, sets, and weakmaps. */ +var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map), + promiseCtorString = toSource(Promise), + setCtorString = toSource(Set), + weakMapCtorString = toSource(WeakMap); + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; + /** - * The base implementation of `_.isNative` without bad shim checks. + * Creates a hash object. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; - } - var pattern = isFunction(value) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); -} +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; -module.exports = baseIsNative; - -},{"./_isMasked":80,"./_toSource":107,"./isFunction":114,"./isObject":116}],56:[function(require,module,exports){ -var baseGetTag = require('./_baseGetTag'), - isLength = require('./isLength'), - isObjectLike = require('./isObjectLike'); - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - weakMapTag = '[object WeakMap]'; - -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - -/** Used to identify `toStringTag` values of typed arrays. */ -var typedArrayTags = {}; -typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = -typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = -typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = -typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = -typedArrayTags[uint32Tag] = true; -typedArrayTags[argsTag] = typedArrayTags[arrayTag] = -typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = -typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = -typedArrayTags[errorTag] = typedArrayTags[funcTag] = -typedArrayTags[mapTag] = typedArrayTags[numberTag] = -typedArrayTags[objectTag] = typedArrayTags[regexpTag] = -typedArrayTags[setTag] = typedArrayTags[stringTag] = -typedArrayTags[weakMapTag] = false; + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} /** - * The base implementation of `_.isTypedArray` without Node.js optimizations. + * Removes all key-value entries from the hash. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @name clear + * @memberOf Hash */ -function baseIsTypedArray(value) { - return isObjectLike(value) && - isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; } -module.exports = baseIsTypedArray; - -},{"./_baseGetTag":51,"./isLength":115,"./isObjectLike":117}],57:[function(require,module,exports){ -var isPrototype = require('./_isPrototype'), - nativeKeys = require('./_nativeKeys'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - /** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * Removes `key` and its value from the hash. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != 'constructor') { - result.push(key); - } - } +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; return result; } -module.exports = baseKeys; - -},{"./_isPrototype":81,"./_nativeKeys":94}],58:[function(require,module,exports){ /** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. + * Gets the hash value for `key`. * * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); +function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; } - return result; + return hasOwnProperty.call(data, key) ? data[key] : undefined; } -module.exports = baseTimes; - -},{}],59:[function(require,module,exports){ /** - * The base implementation of `_.unary` without support for storing metadata. + * Checks if a hash value for `key` exists. * * @private - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function baseUnary(func) { - return function(value) { - return func(value); - }; +function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); } -module.exports = baseUnary; - -},{}],60:[function(require,module,exports){ /** - * Checks if a `cache` value for `key` exists. + * Sets the hash `key` to `value`. * * @private - * @param {Object} cache The cache to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. */ -function cacheHas(cache, key) { - return cache.has(key); +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; } -module.exports = cacheHas; - -},{}],61:[function(require,module,exports){ -var root = require('./_root'); - -/** Used to detect overreaching core-js shims. */ -var coreJsData = root['__core-js_shared__']; +// Add methods to `Hash`. +Hash.prototype.clear = hashClear; +Hash.prototype['delete'] = hashDelete; +Hash.prototype.get = hashGet; +Hash.prototype.has = hashHas; +Hash.prototype.set = hashSet; -module.exports = coreJsData; +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; -},{"./_root":98}],62:[function(require,module,exports){ -var SetCache = require('./_SetCache'), - arraySome = require('./_arraySome'), - cacheHas = require('./_cacheHas'); + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1, - COMPARE_UNORDERED_FLAG = 2; +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} /** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. + * Removes `key` and its value from the list cache. * * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - arrLength = array.length, - othLength = other.length; +function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + if (index < 0) { return false; } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); } - var index = -1, - result = true, - seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; + --this.size; + return true; +} - stack.set(array, other); - stack.set(other, array); +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index]; + return index < 0 ? undefined : data[index][1]; +} - if (customizer) { - var compared = isPartial - ? customizer(othValue, arrValue, index, other, array, stack) - : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (seen) { - if (!arraySome(other, function(othValue, othIndex) { - if (!cacheHas(seen, othIndex) && - (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!( - arrValue === othValue || - equalFunc(arrValue, othValue, bitmask, customizer, stack) - )) { - result = false; - break; - } - } - stack['delete'](array); - stack['delete'](other); - return result; +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; } -module.exports = equalArrays; - -},{"./_SetCache":40,"./_arraySome":48,"./_cacheHas":60}],63:[function(require,module,exports){ -var Symbol = require('./_Symbol'), - Uint8Array = require('./_Uint8Array'), - eq = require('./eq'), - equalArrays = require('./_equalArrays'), - mapToArray = require('./_mapToArray'), - setToArray = require('./_setToArray'); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1, - COMPARE_UNORDERED_FLAG = 2; - -/** `Object#toString` result references. */ -var boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - mapTag = '[object Map]', - numberTag = '[object Number]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]'; - -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]'; - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; - /** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * Sets the list cache `key` to `value`. * * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. */ -function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { - case dataViewTag: - if ((object.byteLength != other.byteLength) || - (object.byteOffset != other.byteOffset)) { - return false; - } - object = object.buffer; - other = other.buffer; - - case arrayBufferTag: - if ((object.byteLength != other.byteLength) || - !equalFunc(new Uint8Array(object), new Uint8Array(other))) { - return false; - } - return true; - - case boolTag: - case dateTag: - case numberTag: - // Coerce booleans to `1` or `0` and dates to milliseconds. - // Invalid dates are coerced to `NaN`. - return eq(+object, +other); - - case errorTag: - return object.name == other.name && object.message == other.message; - - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring - // for more details. - return object == (other + ''); - - case mapTag: - var convert = mapToArray; - - case setTag: - var isPartial = bitmask & COMPARE_PARTIAL_FLAG; - convert || (convert = setToArray); - - if (object.size != other.size && !isPartial) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= COMPARE_UNORDERED_FLAG; - - // Recursively compare objects (susceptible to call stack limits). - stack.set(object, other); - var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); - stack['delete'](object); - return result; +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; } - return false; + return this; } -module.exports = equalByTag; - -},{"./_Symbol":42,"./_Uint8Array":43,"./_equalArrays":62,"./_mapToArray":92,"./_setToArray":101,"./eq":108}],64:[function(require,module,exports){ -var getAllKeys = require('./_getAllKeys'); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1; - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; /** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. + * Creates a map cache object to store key-value pairs. * * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - objProps = getAllKeys(object), - objLength = objProps.length, - othProps = getAllKeys(other), - othLength = othProps.length; - - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; - } - var result = true; - stack.set(object, other); - stack.set(other, object); - - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, objValue, key, other, object, stack) - : customizer(objValue, othValue, key, object, other, stack); - } - // Recursively compare objects (susceptible to call stack limits). - if (!(compared === undefined - ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) - : compared - )) { - result = false; - break; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (result && !skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor == 'function' && objCtor instanceof objCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - result = false; - } + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); } - stack['delete'](object); - stack['delete'](other); - return result; } -module.exports = equalObjects; - -},{"./_getAllKeys":66}],65:[function(require,module,exports){ -(function (global){ -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -module.exports = freeGlobal; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],66:[function(require,module,exports){ -var baseGetAllKeys = require('./_baseGetAllKeys'), - getSymbols = require('./_getSymbols'), - keys = require('./keys'); - /** - * Creates an array of own enumerable property names and symbols of `object`. + * Removes all key-value entries from the map. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. + * @name clear + * @memberOf MapCache */ -function getAllKeys(object) { - return baseGetAllKeys(object, keys, getSymbols); +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; } -module.exports = getAllKeys; - -},{"./_baseGetAllKeys":50,"./_getSymbols":70,"./keys":119}],67:[function(require,module,exports){ -var isKeyable = require('./_isKeyable'); - /** - * Gets the data for `map`. + * Removes `key` and its value from the map. * * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) - ? data[typeof key == 'string' ? 'string' : 'hash'] - : data.map; +function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; } -module.exports = getMapData; - -},{"./_isKeyable":79}],68:[function(require,module,exports){ -var baseIsNative = require('./_baseIsNative'), - getValue = require('./_getValue'); - /** - * Gets the native function at `key` of `object`. + * Gets the map value for `key`. * * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : undefined; +function mapCacheGet(key) { + return getMapData(this, key).get(key); } -module.exports = getNative; - -},{"./_baseIsNative":55,"./_getValue":72}],69:[function(require,module,exports){ -var Symbol = require('./_Symbol'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var nativeObjectToString = objectProto.toString; - -/** Built-in value references. */ -var symToStringTag = Symbol ? Symbol.toStringTag : undefined; - /** - * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * Checks if a map value for `key` exists. * * @private - * @param {*} value The value to query. - * @returns {string} Returns the raw `toStringTag`. + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag), - tag = value[symToStringTag]; - - try { - value[symToStringTag] = undefined; - var unmasked = true; - } catch (e) {} - - var result = nativeObjectToString.call(value); - if (unmasked) { - if (isOwn) { - value[symToStringTag] = tag; - } else { - delete value[symToStringTag]; - } - } - return result; +function mapCacheHas(key) { + return getMapData(this, key).has(key); } -module.exports = getRawTag; - -},{"./_Symbol":42}],70:[function(require,module,exports){ -var arrayFilter = require('./_arrayFilter'), - stubArray = require('./stubArray'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Built-in value references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeGetSymbols = Object.getOwnPropertySymbols; - /** - * Creates an array of the own enumerable symbols of `object`. + * Sets the map `key` to `value`. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. */ -var getSymbols = !nativeGetSymbols ? stubArray : function(object) { - if (object == null) { - return []; - } - object = Object(object); - return arrayFilter(nativeGetSymbols(object), function(symbol) { - return propertyIsEnumerable.call(object, symbol); - }); -}; - -module.exports = getSymbols; - -},{"./_arrayFilter":45,"./stubArray":120}],71:[function(require,module,exports){ -var DataView = require('./_DataView'), - Map = require('./_Map'), - Promise = require('./_Promise'), - Set = require('./_Set'), - WeakMap = require('./_WeakMap'), - baseGetTag = require('./_baseGetTag'), - toSource = require('./_toSource'); - -/** `Object#toString` result references. */ -var mapTag = '[object Map]', - objectTag = '[object Object]', - promiseTag = '[object Promise]', - setTag = '[object Set]', - weakMapTag = '[object WeakMap]'; +function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; -var dataViewTag = '[object DataView]'; + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} -/** Used to detect maps, sets, and weakmaps. */ -var dataViewCtorString = toSource(DataView), - mapCtorString = toSource(Map), - promiseCtorString = toSource(Promise), - setCtorString = toSource(Set), - weakMapCtorString = toSource(WeakMap); +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; /** - * Gets the `toStringTag` of `value`. + * + * Creates an array cache object to store unique values. * * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. + * @constructor + * @param {Array} [values] The values to cache. */ -var getTag = baseGetTag; - -// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. -if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || - (Map && getTag(new Map) != mapTag) || - (Promise && getTag(Promise.resolve()) != promiseTag) || - (Set && getTag(new Set) != setTag) || - (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function(value) { - var result = baseGetTag(value), - Ctor = result == objectTag ? value.constructor : undefined, - ctorString = Ctor ? toSource(Ctor) : ''; - - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: return dataViewTag; - case mapCtorString: return mapTag; - case promiseCtorString: return promiseTag; - case setCtorString: return setTag; - case weakMapCtorString: return weakMapTag; - } - } - return result; - }; +function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); + } } -module.exports = getTag; +/** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ +function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; +} -},{"./_DataView":33,"./_Map":36,"./_Promise":38,"./_Set":39,"./_WeakMap":44,"./_baseGetTag":51,"./_toSource":107}],72:[function(require,module,exports){ /** - * Gets the value at `key` of `object`. + * Checks if `value` is in the array cache. * * @private - * @param {Object} [object] The object to query. - * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. */ -function getValue(object, key) { - return object == null ? undefined : object[key]; +function setCacheHas(value) { + return this.__data__.has(value); } -module.exports = getValue; +// Add methods to `SetCache`. +SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; +SetCache.prototype.has = setCacheHas; -},{}],73:[function(require,module,exports){ -var nativeCreate = require('./_nativeCreate'); +/** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; +} /** - * Removes all key-value entries from the hash. + * Removes all key-value entries from the stack. * * @private * @name clear - * @memberOf Hash + * @memberOf Stack */ -function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; +function stackClear() { + this.__data__ = new ListCache; this.size = 0; } -module.exports = hashClear; - -},{"./_nativeCreate":93}],74:[function(require,module,exports){ /** - * Removes `key` and its value from the hash. + * Removes `key` and its value from the stack. * * @private * @name delete - * @memberOf Hash - * @param {Object} hash The hash to modify. + * @memberOf Stack * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function hashDelete(key) { - var result = this.has(key) && delete this.__data__[key]; - this.size -= result ? 1 : 0; +function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; return result; } -module.exports = hashDelete; - -},{}],75:[function(require,module,exports){ -var nativeCreate = require('./_nativeCreate'); - -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - /** - * Gets the hash value for `key`. + * Gets the stack value for `key`. * * @private * @name get - * @memberOf Hash + * @memberOf Stack * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ -function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty.call(data, key) ? data[key] : undefined; +function stackGet(key) { + return this.__data__.get(key); } -module.exports = hashGet; - -},{"./_nativeCreate":93}],76:[function(require,module,exports){ -var nativeCreate = require('./_nativeCreate'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - /** - * Checks if a hash value for `key` exists. + * Checks if a stack value for `key` exists. * * @private * @name has - * @memberOf Hash + * @memberOf Stack * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function hashHas(key) { - var data = this.__data__; - return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); +function stackHas(key) { + return this.__data__.has(key); } -module.exports = hashHas; - -},{"./_nativeCreate":93}],77:[function(require,module,exports){ -var nativeCreate = require('./_nativeCreate'); - -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - /** - * Sets the hash `key` to `value`. + * Sets the stack `key` to `value`. * * @private * @name set - * @memberOf Hash + * @memberOf Stack * @param {string} key The key of the value to set. * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. + * @returns {Object} Returns the stack cache instance. */ -function hashSet(key, value) { +function stackSet(key, value) { var data = this.__data__; - this.size += this.has(key) ? 0 : 1; - data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; return this; } -module.exports = hashSet; - -},{"./_nativeCreate":93}],78:[function(require,module,exports){ -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - var type = typeof value; - length = length == null ? MAX_SAFE_INTEGER : length; - - return !!length && - (type == 'number' || - (type != 'symbol' && reIsUint.test(value))) && - (value > -1 && value % 1 == 0 && value < length); -} - -module.exports = isIndex; +// Add methods to `Stack`. +Stack.prototype.clear = stackClear; +Stack.prototype['delete'] = stackDelete; +Stack.prototype.get = stackGet; +Stack.prototype.has = stackHas; +Stack.prototype.set = stackSet; -},{}],79:[function(require,module,exports){ /** - * Checks if `value` is suitable for use as unique object key. + * Creates an array of the enumerable property names of the array-like `value`. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. */ -function isKeyable(value) { - var type = typeof value; - return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') - ? (value !== '__proto__') - : (value === null); -} - -module.exports = isKeyable; - -},{}],80:[function(require,module,exports){ -var coreJsData = require('./_coreJsData'); - -/** Used to detect methods masquerading as native. */ -var maskSrcKey = (function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); - return uid ? ('Symbol(src)_1.' + uid) : ''; -}()); +function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; -/** - * Checks if `func` has its source masked. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is masked, else `false`. - */ -function isMasked(func) { - return !!maskSrcKey && (maskSrcKey in func); + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; } -module.exports = isMasked; - -},{"./_coreJsData":61}],81:[function(require,module,exports){ -/** Used for built-in method references. */ -var objectProto = Object.prototype; - /** - * Checks if `value` is likely a prototype object. + * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - - return value === proto; +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; } -module.exports = isPrototype; - -},{}],82:[function(require,module,exports){ /** - * Removes all key-value entries from the list cache. + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. * * @private - * @name clear - * @memberOf ListCache + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. */ -function listCacheClear() { - this.__data__ = []; - this.size = 0; +function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); } -module.exports = listCacheClear; - -},{}],83:[function(require,module,exports){ -var assocIndexOf = require('./_assocIndexOf'); - -/** Used for built-in method references. */ -var arrayProto = Array.prototype; - -/** Built-in value references. */ -var splice = arrayProto.splice; - /** - * Removes `key` and its value from the list cache. + * The base implementation of `getTag` without fallbacks for buggy environments. * * @private - * @name delete - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. */ -function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; } - --this.size; - return true; + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); } -module.exports = listCacheDelete; - -},{"./_assocIndexOf":49}],84:[function(require,module,exports){ -var assocIndexOf = require('./_assocIndexOf'); - /** - * Gets the list cache value for `key`. + * The base implementation of `_.isArguments`. * * @private - * @name get - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, */ -function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - return index < 0 ? undefined : data[index][1]; +function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; } -module.exports = listCacheGet; - -},{"./_assocIndexOf":49}],85:[function(require,module,exports){ -var assocIndexOf = require('./_assocIndexOf'); - /** - * Checks if a list cache value for `key` exists. + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. * * @private - * @name has - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ -function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; +function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); } -module.exports = listCacheHas; - -},{"./_assocIndexOf":49}],86:[function(require,module,exports){ -var assocIndexOf = require('./_assocIndexOf'); - /** - * Sets the list cache `key` to `value`. + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. * * @private - * @name set - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ -function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); +function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); - if (index < 0) { - ++this.size; - data.push([key, value]); - } else { - data[index][1] = value; + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; } - return this; -} + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); -module.exports = listCacheSet; + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; -},{"./_assocIndexOf":49}],87:[function(require,module,exports){ -var Hash = require('./_Hash'), - ListCache = require('./_ListCache'), - Map = require('./_Map'); + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); +} /** - * Removes all key-value entries from the map. + * The base implementation of `_.isNative` without bad shim checks. * * @private - * @name clear - * @memberOf MapCache + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. */ -function mapCacheClear() { - this.size = 0; - this.__data__ = { - 'hash': new Hash, - 'map': new (Map || ListCache), - 'string': new Hash - }; +function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); } -module.exports = mapCacheClear; - -},{"./_Hash":34,"./_ListCache":35,"./_Map":36}],88:[function(require,module,exports){ -var getMapData = require('./_getMapData'); - /** - * Removes `key` and its value from the map. + * The base implementation of `_.isTypedArray` without Node.js optimizations. * * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. */ -function mapCacheDelete(key) { - var result = getMapData(this, key)['delete'](key); - this.size -= result ? 1 : 0; - return result; +function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; } -module.exports = mapCacheDelete; - -},{"./_getMapData":67}],89:[function(require,module,exports){ -var getMapData = require('./_getMapData'); - /** - * Gets the map value for `key`. + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. */ -function mapCacheGet(key) { - return getMapData(this, key).get(key); +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; } -module.exports = mapCacheGet; - -},{"./_getMapData":67}],90:[function(require,module,exports){ -var getMapData = require('./_getMapData'); - /** - * Checks if a map value for `key` exists. + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. * * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ -function mapCacheHas(key) { - return getMapData(this, key).has(key); -} +function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + arrLength = array.length, + othLength = other.length; -module.exports = mapCacheHas; + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(array); + if (stacked && stack.get(other)) { + return stacked == other; + } + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; -},{"./_getMapData":67}],91:[function(require,module,exports){ -var getMapData = require('./_getMapData'); + stack.set(array, other); + stack.set(other, array); -/** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ -function mapCacheSet(key, value) { - var data = getMapData(this, key), - size = data.size; + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; - data.set(key, value); - this.size += data.size == size ? 0 : 1; - return this; + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } + } + stack['delete'](array); + stack['delete'](other); + return result; } -module.exports = mapCacheSet; - -},{"./_getMapData":67}],92:[function(require,module,exports){ /** - * Converts `map` to its key-value pairs. + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * * @private - * @param {Object} map The map to convert. - * @returns {Array} Returns the key-value pairs. + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ -function mapToArray(map) { - var index = -1, - result = Array(map.size); - - map.forEach(function(value, key) { - result[++index] = [key, value]; - }); - return result; -} - -module.exports = mapToArray; - -},{}],93:[function(require,module,exports){ -var getNative = require('./_getNative'); - -/* Built-in method references that are verified to be native. */ -var nativeCreate = getNative(Object, 'create'); +function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; -module.exports = nativeCreate; + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; -},{"./_getNative":68}],94:[function(require,module,exports){ -var overArg = require('./_overArg'); + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeKeys = overArg(Object.keys, Object); + case errorTag: + return object.name == other.name && object.message == other.message; -module.exports = nativeKeys; + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); -},{"./_overArg":97}],95:[function(require,module,exports){ -var freeGlobal = require('./_freeGlobal'); + case mapTag: + var convert = mapToArray; -/** Detect free variable `exports`. */ -var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert || (convert = setToArray); -/** Detect free variable `module`. */ -var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; -/** Detect free variable `process` from Node.js. */ -var freeProcess = moduleExports && freeGlobal.process; + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; +} -/** Used to access faster Node.js helpers. */ -var nodeUtil = (function() { - try { - // Use `util.types` for Node.js 10+. - var types = freeModule && freeModule.require && freeModule.require('util').types; +/** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; - if (types) { - return types; + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; } + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked && stack.get(other)) { + return stacked == other; + } + var result = true; + stack.set(object, other); + stack.set(other, object); - // Legacy `process.binding('util')` for Node.js < 10. - return freeProcess && freeProcess.binding && freeProcess.binding('util'); - } catch (e) {} -}()); - -module.exports = nodeUtil; + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; -},{"./_freeGlobal":65}],96:[function(require,module,exports){ -/** Used for built-in method references. */ -var objectProto = Object.prototype; + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var nativeObjectToString = objectProto.toString; + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } + } + stack['delete'](object); + stack['delete'](other); + return result; +} /** - * Converts `value` to a string using `Object.prototype.toString`. + * Creates an array of own enumerable property names and symbols of `object`. * * @private - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. */ -function objectToString(value) { - return nativeObjectToString.call(value); +function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); } -module.exports = objectToString; - -},{}],97:[function(require,module,exports){ /** - * Creates a unary function that invokes `func` with its argument transformed. + * Gets the data for `map`. * * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. */ -function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; -} - -module.exports = overArg; - -},{}],98:[function(require,module,exports){ -var freeGlobal = require('./_freeGlobal'); - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -module.exports = root; - -},{"./_freeGlobal":65}],99:[function(require,module,exports){ -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; +function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} /** - * Adds `value` to the array cache. + * Gets the native function at `key` of `object`. * * @private - * @name add - * @memberOf SetCache - * @alias push - * @param {*} value The value to cache. - * @returns {Object} Returns the cache instance. + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. */ -function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; +function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; } -module.exports = setCacheAdd; - -},{}],100:[function(require,module,exports){ /** - * Checks if `value` is in the array cache. + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. * * @private - * @name has - * @memberOf SetCache - * @param {*} value The value to search for. - * @returns {number} Returns `true` if `value` is found, else `false`. + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. */ -function setCacheHas(value) { - return this.__data__.has(value); -} +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} -module.exports = setCacheHas; + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; +} -},{}],101:[function(require,module,exports){ /** - * Converts `set` to an array of its values. + * Creates an array of the own enumerable symbols of `object`. * * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the values. + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. */ -function setToArray(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function(value) { - result[++index] = value; +var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); }); - return result; -} - -module.exports = setToArray; - -},{}],102:[function(require,module,exports){ -var ListCache = require('./_ListCache'); +}; /** - * Removes all key-value entries from the stack. + * Gets the `toStringTag` of `value`. * * @private - * @name clear - * @memberOf Stack + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. */ -function stackClear() { - this.__data__ = new ListCache; - this.size = 0; -} +var getTag = baseGetTag; + +// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. +if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || + (Set && getTag(new Set) != setTag) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = baseGetTag(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; -module.exports = stackClear; + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; +} -},{"./_ListCache":35}],103:[function(require,module,exports){ /** - * Removes `key` and its value from the stack. + * Checks if `value` is a valid array-like index. * * @private - * @name delete - * @memberOf Stack - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ -function stackDelete(key) { - var data = this.__data__, - result = data['delete'](key); - - this.size = data.size; - return result; +function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && + (typeof value == 'number' || reIsUint.test(value)) && + (value > -1 && value % 1 == 0 && value < length); } -module.exports = stackDelete; - -},{}],104:[function(require,module,exports){ /** - * Gets the stack value for `key`. + * Checks if `value` is suitable for use as unique object key. * * @private - * @name get - * @memberOf Stack - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. */ -function stackGet(key) { - return this.__data__.get(key); +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); } -module.exports = stackGet; - -},{}],105:[function(require,module,exports){ /** - * Checks if a stack value for `key` exists. + * Checks if `func` has its source masked. * * @private - * @name has - * @memberOf Stack - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. */ -function stackHas(key) { - return this.__data__.has(key); +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); } -module.exports = stackHas; - -},{}],106:[function(require,module,exports){ -var ListCache = require('./_ListCache'), - Map = require('./_Map'), - MapCache = require('./_MapCache'); +/** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; -/** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; + return value === proto; +} /** - * Sets the stack `key` to `value`. + * Converts `value` to a string using `Object.prototype.toString`. * * @private - * @name set - * @memberOf Stack - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the stack cache instance. + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. */ -function stackSet(key, value) { - var data = this.__data__; - if (data instanceof ListCache) { - var pairs = data.__data__; - if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { - pairs.push([key, value]); - this.size = ++data.size; - return this; - } - data = this.__data__ = new MapCache(pairs); - } - data.set(key, value); - this.size = data.size; - return this; +function objectToString(value) { + return nativeObjectToString.call(value); } -module.exports = stackSet; - -},{"./_ListCache":35,"./_Map":36,"./_MapCache":37}],107:[function(require,module,exports){ -/** Used for built-in method references. */ -var funcProto = Function.prototype; - -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; - /** * Converts `func` to its source code. * @@ -7245,9 +6723,6 @@ function toSource(func) { return ''; } -module.exports = toSource; - -},{}],108:[function(require,module,exports){ /** * Performs a * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) @@ -7284,21 +6759,6 @@ function eq(value, other) { return value === other || (value !== value && other !== other); } -module.exports = eq; - -},{}],109:[function(require,module,exports){ -var baseIsArguments = require('./_baseIsArguments'), - isObjectLike = require('./isObjectLike'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** Built-in value references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; - /** * Checks if `value` is likely an `arguments` object. * @@ -7322,9 +6782,6 @@ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsAr !propertyIsEnumerable.call(value, 'callee'); }; -module.exports = isArguments; - -},{"./_baseIsArguments":52,"./isObjectLike":117}],110:[function(require,module,exports){ /** * Checks if `value` is classified as an `Array` object. * @@ -7350,12 +6807,6 @@ module.exports = isArguments; */ var isArray = Array.isArray; -module.exports = isArray; - -},{}],111:[function(require,module,exports){ -var isFunction = require('./isFunction'), - isLength = require('./isLength'); - /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or @@ -7385,27 +6836,6 @@ function isArrayLike(value) { return value != null && isLength(value.length) && !isFunction(value); } -module.exports = isArrayLike; - -},{"./isFunction":114,"./isLength":115}],112:[function(require,module,exports){ -var root = require('./_root'), - stubFalse = require('./stubFalse'); - -/** Detect free variable `exports`. */ -var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; - -/** Built-in value references. */ -var Buffer = moduleExports ? root.Buffer : undefined; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; - /** * Checks if `value` is a buffer. * @@ -7425,11 +6855,6 @@ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; */ var isBuffer = nativeIsBuffer || stubFalse; -module.exports = isBuffer; - -},{"./_root":98,"./stubFalse":121}],113:[function(require,module,exports){ -var baseIsEqual = require('./_baseIsEqual'); - /** * Performs a deep comparison between two values to determine if they are * equivalent. @@ -7462,18 +6887,6 @@ function isEqual(value, other) { return baseIsEqual(value, other); } -module.exports = isEqual; - -},{"./_baseIsEqual":53}],114:[function(require,module,exports){ -var baseGetTag = require('./_baseGetTag'), - isObject = require('./isObject'); - -/** `Object#toString` result references. */ -var asyncTag = '[object AsyncFunction]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - proxyTag = '[object Proxy]'; - /** * Checks if `value` is classified as a `Function` object. * @@ -7501,12 +6914,6 @@ function isFunction(value) { return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } -module.exports = isFunction; - -},{"./_baseGetTag":51,"./isObject":116}],115:[function(require,module,exports){ -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - /** * Checks if `value` is a valid array-like length. * @@ -7538,9 +6945,6 @@ function isLength(value) { value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } -module.exports = isLength; - -},{}],116:[function(require,module,exports){ /** * Checks if `value` is the * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) @@ -7571,9 +6975,6 @@ function isObject(value) { return value != null && (type == 'object' || type == 'function'); } -module.exports = isObject; - -},{}],117:[function(require,module,exports){ /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". @@ -7602,16 +7003,6 @@ function isObjectLike(value) { return value != null && typeof value == 'object'; } -module.exports = isObjectLike; - -},{}],118:[function(require,module,exports){ -var baseIsTypedArray = require('./_baseIsTypedArray'), - baseUnary = require('./_baseUnary'), - nodeUtil = require('./_nodeUtil'); - -/* Node.js helper references. */ -var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - /** * Checks if `value` is classified as a typed array. * @@ -7631,13 +7022,6 @@ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; */ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; -module.exports = isTypedArray; - -},{"./_baseIsTypedArray":56,"./_baseUnary":59,"./_nodeUtil":95}],119:[function(require,module,exports){ -var arrayLikeKeys = require('./_arrayLikeKeys'), - baseKeys = require('./_baseKeys'), - isArrayLike = require('./isArrayLike'); - /** * Creates an array of the own enumerable property names of `object`. * @@ -7670,9 +7054,6 @@ function keys(object) { return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } -module.exports = keys; - -},{"./_arrayLikeKeys":46,"./_baseKeys":57,"./isArrayLike":111}],120:[function(require,module,exports){ /** * This method returns a new empty array. * @@ -7695,9 +7076,6 @@ function stubArray() { return []; } -module.exports = stubArray; - -},{}],121:[function(require,module,exports){ /** * This method returns `false`. * @@ -7715,9 +7093,10 @@ function stubFalse() { return false; } -module.exports = stubFalse; +module.exports = isEqual; -},{}],122:[function(require,module,exports){ +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],34:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -7903,7 +7282,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],123:[function(require,module,exports){ +},{}],35:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -7967,7 +7346,7 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":4}],124:[function(require,module,exports){ +},{"buffer":4}],36:[function(require,module,exports){ var cbor = require('cbor-js'); var CRC = require('crc'); var base58 = require('./crypto/base58'); @@ -8004,7 +7383,7 @@ module.exports = { } }; -},{"./crypto/base58":128,"cbor-js":5,"crc":30}],125:[function(require,module,exports){ +},{"./crypto/base58":40,"cbor-js":5,"crc":30}],37:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var bech32 = require('./crypto/bech32'); var BTCValidator = require('./bitcoin_validator'); @@ -8052,7 +7431,7 @@ module.exports = { return validateAddress(address, currency, networkType) || BTCValidator.isValidAddress(address, currency, networkType); } } -},{"./bitcoin_validator":126,"./crypto/bech32":129,"./crypto/utils":136}],126:[function(require,module,exports){ +},{"./bitcoin_validator":38,"./crypto/bech32":41,"./crypto/utils":48}],38:[function(require,module,exports){ (function (Buffer){ var base58 = require('./crypto/base58'); var segwit = require('./crypto/segwit_addr'); @@ -8142,7 +7521,7 @@ module.exports = { }; }).call(this,require("buffer").Buffer) -},{"./crypto/base58":128,"./crypto/segwit_addr":134,"./crypto/utils":136,"buffer":4}],127:[function(require,module,exports){ +},{"./crypto/base58":40,"./crypto/segwit_addr":46,"./crypto/utils":48,"buffer":4}],39:[function(require,module,exports){ var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; /** @@ -8209,7 +7588,7 @@ module.exports = { b32decode: b32decode, b32encode: b32encode }; -},{}],128:[function(require,module,exports){ +},{}],40:[function(require,module,exports){ // Base58 encoding/decoding // Originally written by Mike Hearn for BitcoinJ // Copyright (c) 2011 Google Inc @@ -8257,7 +7636,7 @@ module.exports = { } }; -},{}],129:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -8376,7 +7755,7 @@ function decode (bechString) { return {hrp: hrp, data: data.slice(0, data.length - 6)}; } -},{}],130:[function(require,module,exports){ +},{}],42:[function(require,module,exports){ /* JavaScript BigInteger library version 0.9.1 http://silentmatt.com/biginteger/ @@ -9827,7 +9206,7 @@ function decode (bechString) { exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt })(typeof exports !== 'undefined' ? exports : this); -},{}],131:[function(require,module,exports){ +},{}],43:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -10018,7 +9397,7 @@ Blake256.prototype.digest = function (encoding) { module.exports = Blake256; }).call(this,require("buffer").Buffer) -},{"buffer":4}],132:[function(require,module,exports){ +},{"buffer":4}],44:[function(require,module,exports){ 'use strict'; /** @@ -10296,7 +9675,7 @@ function toHex (n) { module.exports = Blake2b; -},{}],133:[function(require,module,exports){ +},{}],45:[function(require,module,exports){ var JSBigInt = require('./biginteger')['JSBigInt']; /** @@ -10523,7 +9902,7 @@ var cnBase58 = (function () { return b58; })(); module.exports = cnBase58; -},{"./biginteger":130}],134:[function(require,module,exports){ +},{"./biginteger":42}],46:[function(require,module,exports){ // Copyright (c) 2017 Pieter Wuille // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -10619,7 +9998,7 @@ module.exports = { isValidAddress: isValidAddress, }; -},{"./bech32":129}],135:[function(require,module,exports){ +},{"./bech32":41}],47:[function(require,module,exports){ (function (process,global){ /** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -11263,7 +10642,7 @@ var f = function (s) { module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":122}],136:[function(require,module,exports){ +},{"_process":34}],48:[function(require,module,exports){ (function (Buffer){ var jsSHA = require('jssha/src/sha256'); var Blake256 = require('./blake256'); @@ -11392,7 +10771,7 @@ module.exports = { } }).call(this,require("buffer").Buffer) -},{"./base32":127,"./base58":128,"./blake256":131,"./blake2b":132,"./sha3":135,"browserify-bignum":3,"buffer":4,"jssha/src/sha256":32}],137:[function(require,module,exports){ +},{"./base32":39,"./base58":40,"./blake256":43,"./blake2b":44,"./sha3":47,"browserify-bignum":3,"buffer":4,"jssha/src/sha256":32}],49:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); @@ -11902,7 +11281,7 @@ module.exports = { -},{"./ada_validator":124,"./bch_validator":125,"./bitcoin_validator":126,"./eos_validator":138,"./ethereum_validator":139,"./lisk_validator":140,"./monero_validator":141,"./nano_validator":142,"./nem_validator":143,"./ripple_validator":144,"./siacoin_validator":145,"./stellar_validator":146,"./tezos_validator":147,"./tron_validator":148}],138:[function(require,module,exports){ +},{"./ada_validator":36,"./bch_validator":37,"./bitcoin_validator":38,"./eos_validator":50,"./ethereum_validator":51,"./lisk_validator":52,"./monero_validator":53,"./nano_validator":54,"./nem_validator":55,"./ripple_validator":56,"./siacoin_validator":57,"./stellar_validator":58,"./tezos_validator":59,"./tron_validator":60}],50:[function(require,module,exports){ function isValidEOSAddress (address, currency, networkType) { var regex = /^[a-z0-9]+$/g // Must be numbers and lowercase letters only if (address.search(regex) !== -1 && address.length === 12) { @@ -11918,7 +11297,7 @@ module.exports = { } } -},{}],139:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); module.exports = { @@ -11954,7 +11333,7 @@ module.exports = { } }; -},{"./crypto/utils":136}],140:[function(require,module,exports){ +},{"./crypto/utils":48}],52:[function(require,module,exports){ (function (Buffer){ var cryptoUtils = require('./crypto/utils'); @@ -11976,7 +11355,7 @@ module.exports = { } }; }).call(this,require("buffer").Buffer) -},{"./crypto/utils":136,"buffer":4}],141:[function(require,module,exports){ +},{"./crypto/utils":48,"buffer":4}],53:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils') var cnBase58 = require('./crypto/cnBase58') @@ -12040,7 +11419,7 @@ module.exports = { } } -},{"./crypto/cnBase58":133,"./crypto/utils":136}],142:[function(require,module,exports){ +},{"./crypto/cnBase58":45,"./crypto/utils":48}],54:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -12069,7 +11448,7 @@ module.exports = { } }; -},{"./crypto/utils":136,"base-x":1}],143:[function(require,module,exports){ +},{"./crypto/utils":48,"base-x":1}],55:[function(require,module,exports){ (function (Buffer){ var cryptoUtils = require('./crypto/utils'); @@ -12095,7 +11474,7 @@ module.exports = { isValidAddress: isValidAddress, } }).call(this,require("buffer").Buffer) -},{"./crypto/utils":136,"buffer":4}],144:[function(require,module,exports){ +},{"./crypto/utils":48,"buffer":4}],56:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); var baseX = require('base-x'); @@ -12125,9 +11504,9 @@ module.exports = { } }; -},{"./crypto/utils":136,"base-x":1}],145:[function(require,module,exports){ +},{"./crypto/utils":48,"base-x":1}],57:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils') -var isEqual = require('lodash/isEqual') +var isEqual = require('lodash.isequal') function hexToBytes(hex) { var bytes = [] @@ -12155,7 +11534,7 @@ module.exports = { } } -},{"./crypto/utils":136,"lodash/isEqual":113}],146:[function(require,module,exports){ +},{"./crypto/utils":48,"lodash.isequal":33}],58:[function(require,module,exports){ var baseX = require('base-x'); var crc = require('crc'); var cryptoUtils = require('./crypto/utils'); @@ -12202,7 +11581,7 @@ var ed25519PublicKeyVersionByte = (6 << 3); return computedChecksum === checksum } }; -},{"./crypto/utils":136,"base-x":1,"crc":30}],147:[function(require,module,exports){ +},{"./crypto/utils":48,"base-x":1,"crc":30}],59:[function(require,module,exports){ const base58 = require('./crypto/base58'); const cryptoUtils = require('./crypto/utils'); @@ -12240,7 +11619,7 @@ module.exports = { isValidAddress }; -},{"./crypto/base58":128,"./crypto/utils":136}],148:[function(require,module,exports){ +},{"./crypto/base58":40,"./crypto/utils":48}],60:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); function decodeBase58Address(base58Sting) { @@ -12302,7 +11681,7 @@ module.exports = { return getEnv(currency, networkType) === address[0]; } }; -},{"./crypto/utils":136}],149:[function(require,module,exports){ +},{"./crypto/utils":48}],61:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -12325,5 +11704,5 @@ module.exports = { } }; -},{"./currencies":137}]},{},[149])(149) +},{"./currencies":49}]},{},[61])(61) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 789b9f7f..0a233a7a 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return o(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");var e=new Uint8Array(256);e.fill(255);for(var r=0;r>>0,c=new Uint8Array(f);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=f-1;(0!==l||h>>0,c[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}if(" "!==t[r]){for(var d=f-i;d!==f&&0===c[d];)d++;var v=n.allocUnsafe(o+(f-d));v.fill(0,0,o);for(var y=o;d!==f;)v[y++]=c[d++];return v}}}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,o=0,i=0,u=e.length;i!==u&&0===e[i];)i++,r++;for(var c=(u-i)*f+1>>>0,l=new Uint8Array(c);i!==u;){for(var h=e[i],p=0,d=c-1;(0!==h||p>>0,l[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,i++}for(var v=c-o;v!==c&&0===l[v];)v++;for(var y=s.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=o[t.charCodeAt(l)]<<2|o[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=o[t.charCodeAt(l)]<<10|o[t.charCodeAt(l+1)]<<4|o[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;as?s:a+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,a=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,o=4,i=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",p=0,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var i,a,c,l,y,m,w=this;if(!(w instanceof g))return new g(t,e);if(t instanceof g){if(p=0,e===i)return w.s=t.s,w.e=t.e,void(w.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),m=t,e===i&&d.test(t))w.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,o);if(t=v.call(t).replace(/^\+(?!-)/,""),w.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=d.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(m,0),c=!c),t=_(t,10,e,w.s)):"Infinity"!=t&&"NaN"!=t&&(b(m,1,e),t="NaN")):y=d.test(t),!y)return w.c=w.e=null,"Infinity"!=t&&("NaN"!=t&&b(m,3),w.s=null),void(p=0)}for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(i<0&&(i=a),i+=+t.slice(a+1),t=t.substring(0,a)):i<0&&(i=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(m,0),p=0,(i-=a+1)>u)w.c=w.e=null;else if(a==e||ie-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/e^0,u[o]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(o=t.length-o-1,i=c(new g(r).pow(o).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=m(a,i,a.length-i.length,n,e,1&s[s.length-1])).c,o=f.e){for(;++o;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[o=s.length-1]m?1:-1;else for(p=-1,h=0;++p_[p]?1:-1;break}if(!(h<0))break;for(c=m==f?e:d;m;){if(_[--m]C&&A(w,n,i,a,null!=_[0]),w.e>u?w.c=w.e=null:w.e++e&&A(t,n,10),n=0==o[0]?n+1:r?e:t.e+n+1;o.length1?(o.splice(1,0,"."),o.join("")):o[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,i){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=i||f<0||null!=a[f+1];if(i=o<4?(null!=c||l)&&(0==o||2==o&&!s||3==o&&s):c>u||c==u&&(4==o||l||6==o&&(1&a[f-1]||!e&&n)||7==o&&!s||8==o&&s),f<1||!a[0])return a.length=0,a.push(0),i?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,i)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=o;return o=r,(t=new g(t)).c&&A(t,e,10),o=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var o=[],i=0;in)||c(t)!=t&&0!==t)},_=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(d.length>l)return null!=(t=d[l++])};return _(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,_(e="ROUNDING_MODE")&&(g(t,0,8)?o=0|t:b(t,e,y)),h[e]=o,_(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?i=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(i=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[i,a],_(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],_(e="ERRORS")&&(t===!!t||1===t||0===t?(r=p=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,o=n.c,i=(p=-p,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=o&&!o[0],e=i&&!i[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!o||!i)return e?0:!o^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=o.length)<(f=i.length)?u:f;++ai[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,o=this.s,i=(p=2,t=new g(t,e)).c,a=t.e,s=t.s,u=o==s?1:-1;return(n||r&&r[0])&&(a||i&&i[0])?m(r,i,n-a,u,10):new g(o&&s&&(r?!i||r[0]!=i[0]:i)?r&&0==r[0]||!i?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return p=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return p=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return p=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return p=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return p=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,i,a,u=this,f=u.s;if(e=(p=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,d=t.e;if(!l||!d){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==o?-0:0)}if(c=c.slice(),f=l-d){for((r=(a=f<0)?(f=-f,c):(d=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(i=((a=c.length0)for(;e--;c[i++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=i,f):(o=-o,a)).reverse();o--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),o=f.length,e=0;o;e=(a[--o]=a[o]+f[o]+e)/10^0,a[o]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),o=a.length;0==a[--o];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),o=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(o=o.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(o):o},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?o:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,i,a=this,s=a.c,u=a.s,f=a.e,c=n,l=o,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),o=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(i=e,e=h.times(i.plus(a.div(i))),i.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+i[a]*o[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(o,4+(128&c[0]?1:0)),128&c[0]&&(o[4]=0),o[0]=n&255<<24,o[1]=n&255<<16,o[2]=65280&n,o[3]=255&n;var i=this.lt(0);if(i)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,o,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(o=s.e+(0|t)),e=i,t=a,i=-(a=1/0),o==n?n=s.toS():(n=w(s,o),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),i=e,a=t,n},l.toFraction=l.toFr=function(t){var e,i,a,s,c,l,h,d=s=new g(y),v=a=new g("0"),_=this,m=_.c,w=u,A=n,x=o,E=new g(y);if(!m)return _.toS();for(h=E.e=m.length-_.e-1,(null==t||(!(p=12,l=new g(t)).s||(r=l.cmp(d)<0||!l.c)||f&&l.e0)&&(t=h>0?E:d),u=1/0,l=new g(m.join("")),n=0,o=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,d=a.plus(e.times(c=d)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(d)),s=s.plus(c.times(v)),a.s=d.s=_.s,n=2*h,o=x,i=d.div(v).minus(_).abs().cmp(a.div(s).minus(_).abs())<1?[d.toS(),v.toS()]:[a.toS(),s.toS()],u=w,n=A,i},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():w(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,o,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=i||u>=a))return w(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(o=n.length,u>0)if(++u>o)for(u-=o;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=_(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:L(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),z(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var c=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;ho&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,a=r-e,u=Math.min(i,a),f=this.slice(n,o),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||U(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||U(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||U(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||U(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||U(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||U(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);O(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);O(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function z(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),o=Math.pow(2,32),i=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,o=s+t;r>2,f=0;f>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),l(o);default:var p;if(Array.isArray(e))for(h(4,p=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof i&&(i=function(){return r});var g=function t(){var o,h,g=c(),b=g>>5,_=31&g;if(7===b)switch(_){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),o=32768&r,i=31744&r,a=1023&r;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*n;return e.setUint32(0,o<<16|i<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(_))<0&&(b<2||6=0;)w+=h,m.push(f(h));var A=new Uint8Array(w),x=0;for(o=0;o=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var C;if(h<0)for(C=[];!p();)C.push(t());else for(C=new Array(h),o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:65535,i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=i(t("./create_buffer"));function i(t){return t&&t.__esModule?t:{default:t}}var a=(0,i(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:0,i=0;i>>8&255;a^=255&t[i],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=void 0!==e?~~e:11994318,i=0;i>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:-1^~~e,i=0;i>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=a(t("./create_buffer")),i=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,i.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=~~e,i=0;i1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,o.default)(t));for(var r=0===e?0:~~e,i=0;i>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),o=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=o},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,o,i,p,d,v,y,g,b,_=0,m=[],w=0,A=!1,C=[],k=[],B=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return E(e,r,t)},y=function(e,r,n,o){var i,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(i=15+(r+65>>>9<<4),a=16;e.length<=i;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[i]=4294967295&r,e[i-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=i(t,m,w)).binLen,r=e.value,e=t>>>5,n=0;n>>5),w=t%d,B=!0},this.getHash=function(e,r){var n,i,h,d;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,p,h)};break;case"B64":n=function(t){return s(t,p,h)};break;case"BYTES":n=function(t){return u(t,p)};break;case"ARRAYBUFFER":try{i=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,p)};break;case"UINT8ARRAY":try{i=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,p)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(d=y(m.slice(),w,_,g(o)),i=1;i>>3,n=0;n>>2,e.length<=i&&e.push(0),e[i]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,o,i="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}function s(t,e,r){var n,o,i,a="",s=e/8;for(n=0;n>>2]:0,i=n+2>>2]:0,i=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(o>>>8*(3+(n+1)%4*-1)&255)<<8|i>>>8*(3+(n+2)%4*-1)&255,o=0;4>o;o+=1)a+=8*n+6*o<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-o)&63):r.b64Pad;return a}function u(t,e){var r,n,o="",i=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,o+=String.fromCharCode(n);return o}function f(t,e){var r,n,o=e/8,i=new ArrayBuffer(o);for(n=new Uint8Array(i),r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function c(t,e){var r,n=e/8,o=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,o,i,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=i;)e.push(0);e[i]|=o<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var o,i,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(o=t.charCodeAt(a))?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(a)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=i[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,i="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=o<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,o,i,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=t.indexOf("="),t=t.replace(/\=/g,""),-1!==o&&o=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],U=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,U=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i Date: Sat, 25 Apr 2020 11:29:25 +0200 Subject: [PATCH 096/108] merged monero stagenet --- dist/wallet-address-validator.js | 781 ++++----- dist/wallet-address-validator.min.js | 2 +- package.json | 2 +- src/currencies.js | 775 +++++---- src/monero_validator.js | 4 +- test/wallet_address_validator.js | 2265 ++++++++++++++++---------- 6 files changed, 2157 insertions(+), 1672 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 1af045f4..e2996f97 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -10788,399 +10788,398 @@ var EOSValidator = require('./eos_validator'); var XTZValidator = require('./tezos_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks -var CURRENCIES = [ - { - name: 'Bitcoin', - symbol: 'btc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26'] }, - validator: BTCValidator - }, { - name: 'BitcoinCash', - symbol: 'bch', - regexp: '^[qQpP]{1}[0-9a-zA-Z]{41}$', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BCHValidator - }, { - name: 'Bitcoin SV', - symbol: 'bsv', - regexp: '^[qQ]{1}[0-9a-zA-Z]{41}$', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BCHValidator - }, { - name: 'LiteCoin', - symbol: 'ltc', - addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, - validator: BTCValidator - }, { - name: 'PeerCoin', - symbol: 'ppc', - addressTypes: { prod: ['37', '75'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'DogeCoin', - symbol: 'doge', - addressTypes: { prod: ['1e', '16'], testnet: ['71', 'c4'] }, - validator: BTCValidator - }, { - name: 'BeaverCoin', - symbol: 'bvc', - addressTypes: { prod: ['19', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator, - }, { - name: 'FreiCoin', - symbol: 'frc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'ProtoShares', - symbol: 'pts', - addressTypes: { prod: ['38', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'MegaCoin', - symbol: 'mec', - addressTypes: { prod: ['32', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'PrimeCoin', - symbol: 'xpm', - addressTypes: { prod: ['17', '53'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'AuroraCoin', - symbol: 'aur', - addressTypes: { prod: ['17', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'NameCoin', - symbol: 'nmc', - addressTypes: { prod: ['34'], testnet: [] }, - validator: BTCValidator - }, { - name: 'BioCoin', - symbol: 'bio', - addressTypes: { prod: ['19', '14'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'GarliCoin', - symbol: 'grlc', - addressTypes: { prod: ['26', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'VertCoin', - symbol: 'vtc', - addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - - }, { - name: 'BitcoinGold', - symbol: 'btg', - addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'Komodo', - symbol: 'kmd', - addressTypes: { prod: ['3c', '55'], testnet: ['0', '5'] }, - validator: BTCValidator - }, { - name: 'BitcoinZ', - symbol: 'btcz', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator - }, { - name: 'BitcoinPrivate', - symbol: 'btcp', - expectedLength: 26, - addressTypes: { prod: ['1325', '13af'], testnet: ['1957', '19e0'] }, - validator: BTCValidator - }, { - name: 'Hush', - symbol: 'hush', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator - }, { - name: 'SnowGem', - symbol: 'sng', - expectedLength: 26, - addressTypes: { prod: ['1c28', '1c2d'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator - }, { - name: 'ZCash', - symbol: 'zec', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator - }, { - name: 'ZClassic', - symbol: 'zcl', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator - }, { - name: 'ZenCash', - symbol: 'zen', - expectedLength: 26, - addressTypes: { prod: ['2089', '2096'], testnet: ['2092', '2098'] }, - validator: BTCValidator - }, { - name: 'VoteCoin', - symbol: 'vot', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator - }, { - name: 'Decred', - symbol: 'dcr', - addressTypes: { prod: ['073f', '071a'], testnet: ['0f21', '0efc'] }, - hashFunction: 'blake256', - expectedLength: 26, - validator: BTCValidator - }, { - name: 'GameCredits', - symbol: 'game', - addressTypes: { prod: ['26', '05'], testnet: [] }, - validator: BTCValidator - }, { - name: 'PIVX', - symbol: 'pivx', - addressTypes: { prod: ['1e', '0d'], testnet: [] }, - validator: BTCValidator - }, { - name: 'SolarCoin', - symbol: 'slr', - addressTypes: { prod: ['12', '05'], testnet: [] }, - validator: BTCValidator - }, { - name: 'MonaCoin', - symbol: 'mona', - addressTypes: { prod: ['32', '37'], testnet: [] }, - validator: BTCValidator - }, { - name: 'DigiByte', - symbol: 'dgb', - addressTypes: { prod: ['1e'], testnet: [] }, - validator: BTCValidator - }, { - name: 'Tether', - symbol: 'usdt', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - }, { - name: 'Ripple', - symbol: 'xrp', - validator: XRPValidator, - }, { - name: 'Dash', - symbol: 'dash', - addressTypes: { prod: ['4c', '10'], testnet: ['8c', '13'] }, - validator: BTCValidator - }, { - name: 'Neo', - symbol: 'neo', - addressTypes: { prod: ['17'], testnet: [] }, - validator: BTCValidator - }, { - name: 'NeoGas', - symbol: 'gas', - addressTypes: { prod: ['17'], testnet: [] }, - validator: BTCValidator - }, { - name: 'Qtum', - symbol: 'qtum', - addressTypes: { prod: ['3a', '32'], testnet: ['78', '6e'] }, - validator: BTCValidator - }, { - name: 'Waves', - symbol: 'waves', - addressTypes: { prod: ['0157'], testnet: ['0154'] }, - expectedLength: 26, - hashFunction: 'blake256keccak256', - regex: /^[a-zA-Z0-9]{35}$/, - validator: BTCValidator - }, { - name: 'Ethereum', - symbol: 'eth', - validator: ETHValidator, - }, { - name: 'EtherZero', - symbol: 'etz', - validator: ETHValidator, - }, { - name: 'EthereumClassic', - symbol: 'etc', - validator: ETHValidator, - }, { - name: 'Callisto', - symbol: 'clo', - validator: ETHValidator, - }, { - name: 'Bankex', - symbol: 'bkx', - validator: ETHValidator - }, { - name: 'Cardano', - symbol: 'ada', - validator: ADAValidator - }, { - name: 'Monero', - symbol: 'xmr', - addressTypes: { prod: ['18', '42'], testnet: ['53', '63'] }, - iAddressTypes: { prod: ['19'], testnet: ['54'] }, - validator: XMRValidator - }, { - name: 'Aragon', - symbol: 'ant', - validator: ETHValidator - }, { - name: 'Basic Attention Token', - symbol: 'bat', - validator: ETHValidator - }, { - name: 'Bancor', - symbol: 'bnt', - validator: ETHValidator - }, { - name: 'Civic', - symbol: 'cvc', - validator: ETHValidator - }, { - name: 'District0x', - symbol: 'dnt', - validator: ETHValidator - }, { - name: 'Gnosis', - symbol: 'gno', - validator: ETHValidator - }, { - name: 'Golem', - symbol: 'gnt', - validator: ETHValidator - }, { - name: 'Matchpool', - symbol: 'gup', - validator: ETHValidator - }, { - name: 'Melon', - symbol: 'mln', - validator: ETHValidator - }, { - name: 'Numeraire', - symbol: 'nmr', - validator: ETHValidator - }, { - name: 'OmiseGO', - symbol: 'omg', - validator: ETHValidator - }, { - name: 'TenX', - symbol: 'pay', - validator: ETHValidator - }, { - name: 'Ripio Credit Network', - symbol: 'rcn', - validator: ETHValidator - }, { - name: 'Augur', - symbol: 'rep', - validator: ETHValidator - }, { - name: 'iExec RLC', - symbol: 'rlc', - validator: ETHValidator - }, { - name: 'Salt', - symbol: 'salt', - validator: ETHValidator - }, { - name: 'Status', - symbol: 'snt', - validator: ETHValidator - }, { - name: 'Storj', - symbol: 'storj', - validator: ETHValidator - }, { - name: 'Swarm City', - symbol: 'swt', - validator: ETHValidator - }, { - name: 'TrueUSD', - symbol: 'tusd', - validator: ETHValidator - }, { - name: 'Wings', - symbol: 'wings', - validator: ETHValidator - }, { - name: '0x', - symbol: 'zrx', - validator: ETHValidator - }, { - name: 'Expanse', - symbol: 'exp', - validator: ETHValidator - }, { - name: 'Viberate', - symbol: 'vib', - validator: ETHValidator - }, { - name: 'Odyssey', - symbol: 'ocn', - validator: ETHValidator - }, { - name: 'Polymath', - symbol: 'poly', - validator: ETHValidator - }, { - name: 'Storm', - symbol: 'storm', - validator: ETHValidator - }, { - name: 'Nano', - symbol: 'nano', - validator: NANOValidator, - }, { - name: 'RaiBlocks', - symbol: 'xrb', - validator: NANOValidator, - }, { - name: 'Siacoin', - symbol: 'sc', - validator: SCValidator - }, { - name: 'HyperSpace', - symbol: 'xsc', - validator: SCValidator - }, { - name: 'loki', - symbol: 'loki', - addressTypes: { prod: ['114', '115', '116'], testnet: [] }, - iAddressTypes: { prod: ['115'], testnet: [] }, - validator: XMRValidator - }, { - name: 'LBRY Credits', - symbol: 'lbc', - addressTypes: { prod: ['55'], testnet: [] }, - validator: BTCValidator - }, { +var CURRENCIES = [{ + name: 'Bitcoin', + symbol: 'btc', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26'] }, + validator: BTCValidator +}, { + name: 'BitcoinCash', + symbol: 'bch', + regexp: '^[qQpP]{1}[0-9a-zA-Z]{41}$', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BCHValidator +}, { + name: 'Bitcoin SV', + symbol: 'bsv', + regexp: '^[qQ]{1}[0-9a-zA-Z]{41}$', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BCHValidator +}, { + name: 'LiteCoin', + symbol: 'ltc', + addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, + validator: BTCValidator +}, { + name: 'PeerCoin', + symbol: 'ppc', + addressTypes: { prod: ['37', '75'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'DogeCoin', + symbol: 'doge', + addressTypes: { prod: ['1e', '16'], testnet: ['71', 'c4'] }, + validator: BTCValidator +}, { + name: 'BeaverCoin', + symbol: 'bvc', + addressTypes: { prod: ['19', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator, +}, { + name: 'FreiCoin', + symbol: 'frc', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'ProtoShares', + symbol: 'pts', + addressTypes: { prod: ['38', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'MegaCoin', + symbol: 'mec', + addressTypes: { prod: ['32', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'PrimeCoin', + symbol: 'xpm', + addressTypes: { prod: ['17', '53'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'AuroraCoin', + symbol: 'aur', + addressTypes: { prod: ['17', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'NameCoin', + symbol: 'nmc', + addressTypes: { prod: ['34'], testnet: [] }, + validator: BTCValidator +}, { + name: 'BioCoin', + symbol: 'bio', + addressTypes: { prod: ['19', '14'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'GarliCoin', + symbol: 'grlc', + addressTypes: { prod: ['26', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'VertCoin', + symbol: 'vtc', + addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + +}, { + name: 'BitcoinGold', + symbol: 'btg', + addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'Komodo', + symbol: 'kmd', + addressTypes: { prod: ['3c', '55'], testnet: ['0', '5'] }, + validator: BTCValidator +}, { + name: 'BitcoinZ', + symbol: 'btcz', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator +}, { + name: 'BitcoinPrivate', + symbol: 'btcp', + expectedLength: 26, + addressTypes: { prod: ['1325', '13af'], testnet: ['1957', '19e0'] }, + validator: BTCValidator +}, { + name: 'Hush', + symbol: 'hush', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator +}, { + name: 'SnowGem', + symbol: 'sng', + expectedLength: 26, + addressTypes: { prod: ['1c28', '1c2d'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator +}, { + name: 'ZCash', + symbol: 'zec', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator +}, { + name: 'ZClassic', + symbol: 'zcl', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator +}, { + name: 'ZenCash', + symbol: 'zen', + expectedLength: 26, + addressTypes: { prod: ['2089', '2096'], testnet: ['2092', '2098'] }, + validator: BTCValidator +}, { + name: 'VoteCoin', + symbol: 'vot', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator +}, { + name: 'Decred', + symbol: 'dcr', + addressTypes: { prod: ['073f', '071a'], testnet: ['0f21', '0efc'] }, + hashFunction: 'blake256', + expectedLength: 26, + validator: BTCValidator +}, { + name: 'GameCredits', + symbol: 'game', + addressTypes: { prod: ['26', '05'], testnet: [] }, + validator: BTCValidator +}, { + name: 'PIVX', + symbol: 'pivx', + addressTypes: { prod: ['1e', '0d'], testnet: [] }, + validator: BTCValidator +}, { + name: 'SolarCoin', + symbol: 'slr', + addressTypes: { prod: ['12', '05'], testnet: [] }, + validator: BTCValidator +}, { + name: 'MonaCoin', + symbol: 'mona', + addressTypes: { prod: ['32', '37'], testnet: [] }, + validator: BTCValidator +}, { + name: 'DigiByte', + symbol: 'dgb', + addressTypes: { prod: ['1e'], testnet: [] }, + validator: BTCValidator +}, { + name: 'Tether', + symbol: 'usdt', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator +}, { + name: 'Ripple', + symbol: 'xrp', + validator: XRPValidator, +}, { + name: 'Dash', + symbol: 'dash', + addressTypes: { prod: ['4c', '10'], testnet: ['8c', '13'] }, + validator: BTCValidator +}, { + name: 'Neo', + symbol: 'neo', + addressTypes: { prod: ['17'], testnet: [] }, + validator: BTCValidator +}, { + name: 'NeoGas', + symbol: 'gas', + addressTypes: { prod: ['17'], testnet: [] }, + validator: BTCValidator +}, { + name: 'Qtum', + symbol: 'qtum', + addressTypes: { prod: ['3a', '32'], testnet: ['78', '6e'] }, + validator: BTCValidator +}, { + name: 'Waves', + symbol: 'waves', + addressTypes: { prod: ['0157'], testnet: ['0154'] }, + expectedLength: 26, + hashFunction: 'blake256keccak256', + regex: /^[a-zA-Z0-9]{35}$/, + validator: BTCValidator +}, { + name: 'Ethereum', + symbol: 'eth', + validator: ETHValidator, +}, { + name: 'EtherZero', + symbol: 'etz', + validator: ETHValidator, +}, { + name: 'EthereumClassic', + symbol: 'etc', + validator: ETHValidator, +}, { + name: 'Callisto', + symbol: 'clo', + validator: ETHValidator, +}, { + name: 'Bankex', + symbol: 'bkx', + validator: ETHValidator +}, { + name: 'Cardano', + symbol: 'ada', + validator: ADAValidator +}, { + name: 'Monero', + symbol: 'xmr', + addressTypes: { prod: ['18', '42'], testnet: ['53', '63'], stagenet: ['24'] }, + iAddressTypes: { prod: ['19'], testnet: ['54'], stagenet: ['25'] }, + validator: XMRValidator +}, { + name: 'Aragon', + symbol: 'ant', + validator: ETHValidator +}, { + name: 'Basic Attention Token', + symbol: 'bat', + validator: ETHValidator +}, { + name: 'Bancor', + symbol: 'bnt', + validator: ETHValidator +}, { + name: 'Civic', + symbol: 'cvc', + validator: ETHValidator +}, { + name: 'District0x', + symbol: 'dnt', + validator: ETHValidator +}, { + name: 'Gnosis', + symbol: 'gno', + validator: ETHValidator +}, { + name: 'Golem', + symbol: 'gnt', + validator: ETHValidator +}, { + name: 'Matchpool', + symbol: 'gup', + validator: ETHValidator +}, { + name: 'Melon', + symbol: 'mln', + validator: ETHValidator +}, { + name: 'Numeraire', + symbol: 'nmr', + validator: ETHValidator +}, { + name: 'OmiseGO', + symbol: 'omg', + validator: ETHValidator +}, { + name: 'TenX', + symbol: 'pay', + validator: ETHValidator +}, { + name: 'Ripio Credit Network', + symbol: 'rcn', + validator: ETHValidator +}, { + name: 'Augur', + symbol: 'rep', + validator: ETHValidator +}, { + name: 'iExec RLC', + symbol: 'rlc', + validator: ETHValidator +}, { + name: 'Salt', + symbol: 'salt', + validator: ETHValidator +}, { + name: 'Status', + symbol: 'snt', + validator: ETHValidator +}, { + name: 'Storj', + symbol: 'storj', + validator: ETHValidator +}, { + name: 'Swarm City', + symbol: 'swt', + validator: ETHValidator +}, { + name: 'TrueUSD', + symbol: 'tusd', + validator: ETHValidator +}, { + name: 'Wings', + symbol: 'wings', + validator: ETHValidator +}, { + name: '0x', + symbol: 'zrx', + validator: ETHValidator +}, { + name: 'Expanse', + symbol: 'exp', + validator: ETHValidator +}, { + name: 'Viberate', + symbol: 'vib', + validator: ETHValidator +}, { + name: 'Odyssey', + symbol: 'ocn', + validator: ETHValidator +}, { + name: 'Polymath', + symbol: 'poly', + validator: ETHValidator +}, { + name: 'Storm', + symbol: 'storm', + validator: ETHValidator +}, { + name: 'Nano', + symbol: 'nano', + validator: NANOValidator, +}, { + name: 'RaiBlocks', + symbol: 'xrb', + validator: NANOValidator, +}, { + name: 'Siacoin', + symbol: 'sc', + validator: SCValidator +}, { + name: 'HyperSpace', + symbol: 'xsc', + validator: SCValidator +}, { + name: 'loki', + symbol: 'loki', + addressTypes: { prod: ['114', '115', '116'], testnet: [] }, + iAddressTypes: { prod: ['115'], testnet: [] }, + validator: XMRValidator +}, { + name: 'LBRY Credits', + symbol: 'lbc', + addressTypes: { prod: ['55'], testnet: [] }, + validator: BTCValidator +}, { name: 'Tron', - symbol: 'trx', - addressTypes: { prod: [0x41], testnet: [0xa0] }, - validator: TRXValidator - }, { + symbol: 'trx', + addressTypes: { prod: [0x41], testnet: [0xa0] }, + validator: TRXValidator +}, { name: 'Nem', - symbol: 'xem', - validator: NEMValidator - }, { + symbol: 'xem', + validator: NEMValidator +}, { name: 'Lisk', - symbol: 'lsk', - validator: LSKValidator - }, { + symbol: 'lsk', + validator: LSKValidator +}, { name: 'Stellar', - symbol: 'xlm', - validator: XLMValidator, + symbol: 'xlm', + validator: XLMValidator, }, { name: 'BTU Protocol', symbol: 'btu', @@ -11379,8 +11378,10 @@ function validateNetwork(decoded, currency, networkType, addressType) { return network.prod.indexOf(at) >= 0 case 'testnet': return network.testnet.indexOf(at) >= 0 + case 'stagenet': + return network.stagenet.indexOf(at) >= 0 case 'both': - return network.prod.indexOf(at) >= 0 || network.testnet.indexOf(at) >= 0 + return network.prod.indexOf(at) >= 0 || network.testnet.indexOf(at) >= 0 || network.stagenet.indexOf(at) >= 0 default: return false } diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 0a233a7a..359b32e8 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],U=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,U=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],U=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,U=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i= 0 case 'testnet': return network.testnet.indexOf(at) >= 0 + case 'stagenet': + return network.stagenet.indexOf(at) >= 0 case 'both': - return network.prod.indexOf(at) >= 0 || network.testnet.indexOf(at) >= 0 + return network.prod.indexOf(at) >= 0 || network.testnet.indexOf(at) >= 0 || network.stagenet.indexOf(at) >= 0 default: return false } diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index d75a521d..4ae493ec 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -1,907 +1,1390 @@ var isNode = typeof module !== 'undefined' && typeof module.exports !== 'undefined' var chai = isNode ? require('chai') : window.chai, - expect = chai.expect + expect = chai.expect var WAValidator = isNode ? require('../src/wallet_address_validator') : window.WAValidator function valid(address, currency, networkType) { - var valid = WAValidator.validate(address, currency, networkType); - expect({ address, currency, valid }).to.deep.equal({ address, currency, valid: true }); + var valid = WAValidator.validate(address, currency, networkType); + expect({ address, currency, valid }).to.deep.equal({ address, currency, valid: true }); } function invalid(address, currency, networkType) { - var valid = WAValidator.validate(address, currency, networkType); - expect({ address, currency, valid }).to.deep.equal({ address, currency, valid: false }); + var valid = WAValidator.validate(address, currency, networkType); + expect({ address, currency, valid }).to.deep.equal({ address, currency, valid: false }); } describe('WAValidator.validate()', function () { - describe('valid results', function () { - it('should return true for correct bitcoin addresses', function () { - valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoin'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bitcoin'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BTC'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc', 'prod'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc', 'both'); - valid('15uwigGExiNQxTNr1QSZYPXJMp9Px2YnVU', 'btc', 'prod'); - valid('3FyVFsEyyBPzHjD3qUEgX7Jsn4tcHNZFkn', 'btc', 'prod'); - valid('38mKdURe1zcQyrFqRLzR8PRao3iLGEPVsU', 'btc', 'prod'); - valid('mptPo5AvLzJXi4T82vR6g82fT5uJ6HsQCu', 'btc', 'both'); - valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'bitcoin'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoin', 'testnet'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoin', 'both'); - - valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez'); - valid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd'); - - // p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt'); - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoin', 'testnet'); - - // regtest - valid('GSa5espVLNseXEfKt46zEdS6jrPkmFghBU', 'bitcoin', 'testnet'); - - // segwit addresses - valid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'bitcoin'); - valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 'bitcoin'); - valid('bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx', 'bitcoin'); - valid('BC1SW50QA3JX3S', 'bitcoin'); - valid('bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj', 'bitcoin'); - valid('tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy', 'bitcoin'); - - invalid("tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", 'bitcoin'), - invalid("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", 'bitcoin'), - invalid("BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", 'bitcoin'), - invalid("bc1rw5uspcuh", 'bitcoin'), - invalid("bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90", 'bitcoin'), - invalid("BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P", 'bitcoin'), - invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7", 'bitcoin'), - invalid("bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", 'bitcoin'), - invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv", 'bitcoin'), - invalid("bc1gmk9yu", 'bitcoin') - }); - - it('should return true for correct bitcoincash addresses', function () { - valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoincash'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bitcoincash'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BCH'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'prod'); - valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'both'); - valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'bitcoincash'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'testnet'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'both'); - - // p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoincash'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoincash', 'testnet'); - - valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bch'); - - }); - - it('should return true for correct litecoin addresses', function () { - valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'litecoin'); - valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'LTC'); - valid('LTpYZG19YmfvY2bBDYtCKpunVRw7nVgRHW', 'litecoin'); - valid('Lb6wDP2kHGyWC7vrZuZAgV7V4ECyDdH7a6', 'litecoin'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'litecoin', 'testnet'); - - // p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'litecoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'litecoin', 'testnet'); - valid('QW2SvwjaJU8LD6GSmtm1PHnBG2xPuxwZFy', 'litecoin', 'testnet'); - valid('QjpzxpbLp5pCGsCczMbfh1uhC3P89QZavY', 'litecoin', 'testnet'); - }); - - it('should return true for correct peercoin addresses', function () { - valid('PHCEsP6od3WJ8K2WKWEDBYKhH95pc9kiZN', 'peercoin'); - valid('PSbM1pGoE9dnAuVWvpQqTTYVpKZU41dNAz', 'peercoin'); - valid('PUULeHrJL2WujJkorc2RsUAR3SardKUauu', 'peercoin'); - valid('PUULeHrJL2WujJkorc2RsUAR3SardKUauu', 'PPC'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'peercoin', 'testnet'); - - // p2sh addresses - valid('pNms4CaWqgZUxbNZaA1yP2gPr3BYnez9EM', 'peercoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'peercoin', 'testnet'); - }); - - it('should return true for correct dogecoin addresses', function () { - valid('DPpJVPpvPNP6i6tMj4rTycAGh8wReTqaSU', 'dogecoin'); - valid('DNzLUN6MyYVS5zf4Xc2yK69V3dXs6Mxia5', 'dogecoin'); - valid('DPS6iZj7roHquvwRYXNBua9QtKPzigUUhM', 'dogecoin'); - valid('DPS6iZj7roHquvwRYXNBua9QtKPzigUUhM', 'DOGE'); - //TODO: NEED A DOGECOIN TESTNET ADDRESS - - //p2sh addresses - valid('A7JjzK9k9x5b2MkkQzqt91WZsuu7wTu6iS', 'dogecoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'dogecoin', 'testnet'); - }); - - it('should return true for correct beavercoin addresses', function () { - valid('BPPtB4EpPi5wCaGXZuNyKQgng8ya579qUh', 'beavercoin'); - valid('BC1LLYoE4mTCHTJhVYvLGxhRTwAHyWTQ49', 'beavercoin'); - valid('BBuyeg2vjtyFdMNj3LTxuVra4wJMKVAY9C', 'beavercoin'); - valid('BBuyeg2vjtyFdMNj3LTxuVra4wJMKVAY9C', 'BVC'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'beavercoin', 'testnet'); - - // p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'beavercoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'beavercoin', 'testnet'); - }); - - it('should return true for correct freicoin addresses', function () { - valid('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', 'freicoin'); - valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'freicoin'); - valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'freicoin'); - valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'FRC'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'freicoin', 'testnet'); - - // p2sh addresse - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'freicoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'freicoin', 'testnet'); - }); - - it('should return true for correct protoshares addresses', function () { - valid('PaNGELmZgzRQCKeEKM6ifgTqNkC4ceiAWw', 'protoshares'); - valid('Piev8TMX2fT5mFtgxx2TXJaqXP37weMPuD', 'protoshares'); - valid('PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD', 'protoshares'); - valid('PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD', 'PTS'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'protoshares', 'testnet'); - - //p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'protoshares'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'protoshares', 'testnet'); - }); - - it('should return true for correct megacoin addresses', function () { - valid('MWUHaNxjXGZUYTh92i3zuDmsnH1rHSBk5M', 'megacoin'); - valid('MSAkrhRyte7bz999Ga5SqYjzypFFYa2oEb', 'megacoin'); - valid('MLUTAtDQFcfo1QACWocLuufFq5fBDTpCHE', 'megacoin'); - valid('MLUTAtDQFcfo1QACWocLuufFq5fBDTpCHE', 'MEC'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'megacoin', 'testnet'); - - //p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'megacoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'megacoin', 'testnet'); - }); - - it('should return true for correct primecoin addresses', function () { - valid('AVKeiZ5JadfWdH2EYVgVRfX4ufoyd4ehuM', 'primecoin'); - valid('AQXBRPyob4dywUJ21RUKrR1xetQCDVenKD', 'primecoin'); - valid('ANHfTZnskKqaBU7oZuSha9SpbHU3YBfeKf', 'primecoin'); - valid('AYdiYMKSGYxLcZNDmqB8jNcck7SQibrfiK', 'primecoin'); - valid('AYdiYMKSGYxLcZNDmqB8jNcck7SQibrfiK', 'XPM'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'primecoin', 'testnet'); - - //p2sh addresses - valid('af5CvTQq7agDh717Wszb5QDbWb7nT2mukP', 'primecoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'primecoin', 'testnet'); - }); - - it('should return true for correct auroracoin addresses', function () { - valid('ARM3GLZXF1PDTZ5vz3wh5MVahbK9BHTWAN', 'auroracoin'); - valid('AUtfc6ThCLb7FuEu7QPrWpJuaXaJRPciDF', 'auroracoin'); - valid('AUN1oaj5hjispGnczt8Aruw3TxgGyRqB3V', 'auroracoin'); - valid('AXGcBkGX6NiaDXj85C5dCrhTRUgwxSkKDK', 'auroracoin'); - valid('AXGcBkGX6NiaDXj85C5dCrhTRUgwxSkKDK', 'AUR'); - valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'auroracoin', 'testnet'); - - //p2sh addresses - valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'auroracoin'); - valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'auroracoin', 'testnet'); - }); - - it('should return true for correct namecoin addresses', function () { - valid('NEpeRmS775fnti8TDgJA28m8KLEfNNRZvT', 'namecoin'); - valid('MyJ691bGJ48RBK2LS8n1U57wcFLFScFXxi', 'namecoin'); - valid('NFY9aw1RXLGtWpeqgNQXprnUcZXyKNinTh', 'namecoin'); - valid('NCPPc7Pzb75CpRPJQPRRh6ouJTq7BCy1H4', 'namecoin'); - valid('NCPPc7Pzb75CpRPJQPRRh6ouJTq7BCy1H4', 'NMC'); - }); - - it('should return true for correct BioCoin addresses', function () { - valid('B7xseoLGk7hEpMDDeSvZDKmmiAMHWiccok', 'biocoin'); - valid('B8zjmYFGhWmiaQSJshfrnefE72xCapCkvo', 'biocoin'); - valid('muH8LL42DiMs8GEQ6Grfi8KUw2uFvuKr1J', 'biocoin', 'testnet'); - valid('muH8LL42DiMs8GEQ6Grfi8KUw2uFvuKr1J', 'BIO', 'testnet'); - valid('B8zjmYFGhWmiaQSJshfrnefE72xCapCkvo', 'BIO'); - }); - - it('should return true for correct Garlicoin addresses', function () { - valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'garlicoin'); - valid('GNWeWaoQ6rv21ZFjJWT9vb91hXUzFTLkru', 'garlicoin'); - valid('mjKbQTkgwzmsL3J86tdVzhyW9pc4NePqTb', 'garlicoin', 'testnet'); - valid('mnYp36NuyRavMKQ9Q9Q6oGqoorAs9p3zYn', 'GRLC', 'testnet'); - valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'GRLC'); - }); - - it('should return true for correct Vertcoin addresses', function () { - valid('3PgeyhEJEnS5CeBu3iFcu3JHVKemeHx1AW', 'VTC'); - valid('353nERPQKhGj4WGzoiWcareA76TPgRCVNA', 'VTC'); - valid('376g4TmL8uQKFYsRFrbv5iz9srmb5bocEt', 'VTC'); - valid('3AMtM4Zk5oNHu9i4jDiwKB6Kg5YEReBsav', 'VTC'); - - valid('VmoMjGf3zgZLy8sk3PMKd3xikZHXWvnYi7', 'vertcoin'); - valid('VmhHwXr3J8xMZpy62WuBGpu3xVvThWzcTQ', 'vertcoin'); - valid('mvww6DEJ18dbyQUukpVQXvLgrNDJazZn1Y', 'vertcoin', 'testnet'); - valid('mn3mdEE6cf1snxVsknNz4GRTdSrWXqYp7c', 'VTC', 'testnet'); - valid('Vri6Q4GgNFfdtcpxD961TotJwaSaYQCaL5', 'VTC'); - }); - - it('should return true for correct BitcoinGold addresses', function () { - valid('GW3JrQyHtoVfEFES3Y9JagiX3VSKQStLwj', 'bitcoingold'); - valid('GUDWdeMyAXQbrNFFivAhkJQ1GfBCFdc7JF', 'bitcoingold'); - valid('mvww6DEJ18dbyQUukpVQXvLgrNDJazZn1Y', 'bitcoingold', 'testnet'); - valid('mn3mdEE6cf1snxVsknNz4GRTdSrWXqYp7c', 'BTG', 'testnet'); - valid('GSNFPRsdaM3MXrU5HW1AxgFwmUQC8HXK9F', 'BTG'); - }); - - it('should return true for correct Decred addresses', function () { - valid('Dsesax2GJnMN4wwmWo5rJGq73dDK217Rh85', 'DCR'); - valid('DsYuxtvGRfN8rncXAndtLUpJm55F77K17RA', 'decred'); - valid('DsaXDG2NrJW8g4tFAb8n9MNx81Sn3Qc8AEV', 'decred'); - valid('TsijUgejaRnLKF5WAbpUxNtwKGUiKVeXLr7', 'decred', 'testnet'); - valid('TsZ9QmAoadF12hGvyALp6qvaF4be3BmLqG9', 'dcr', 'testnet'); - }); - - it('should return true for correct Digibyte addresses', function () { - valid('DG2rM2orU2JH5i4ACh3AKNpRTNESdv5xf8', 'DGB'); - valid('DBR2Lj1F17eHGHXgbpae2Wb4m39bDyA1qo', 'DGB'); - valid('D9TDZTR9Z9Mx2NoDJnhqhnYhDLKRAmsL9n', 'digibyte'); - valid('DHRzA1YHA1kFWpz2apRckZJy6KZRyGq4EV', 'digibyte'); - valid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'digibyte'); - }); - - it('should return true for correct Ethereum addresses', function () { - valid('0xE37c0D48d68da5c5b14E5c1a9f1CFE802776D9FF', 'ethereum'); - valid('0xa00354276d2fC74ee91e37D085d35748613f4748', 'ethereum'); - valid('0xAff4d6793F584a473348EbA058deb8caad77a288', 'ETH'); - valid('0xc6d9d2cd449a754c494264e1809c50e34d64562b', 'ETH'); - valid('0x52908400098527886E0F7030069857D2E4169EE7', 'ETH'); - valid('0x8617E340B3D01FA5F11F306F4090FD50E238070D', 'ETH'); - valid('0xde709f2102306220921060314715629080e2fb77', 'ETH'); - valid('0x27b1fdb04752bbc536007a920d24acb045561c26', 'ETH'); - valid('0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', 'ETH'); - valid('0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359', 'ETH'); - valid('0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB', 'ETH'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETH'); - - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ethereumclassic'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETC'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'etherzero'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETZ'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'callisto'); - valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'CLO'); - }); - - it('should return true for correct Ripple addresses', function () { - valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'ripple'); - valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'XRP'); - valid('r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV', 'XRP'); - valid('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', 'XRP'); - valid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN', 'XRP'); - }); - - it('should return true for correct dash addresses', function () { - valid('Xx4dYKgz3Zcv6kheaqog3fynaKWjbahb6b', 'dash'); - valid('XcY4WJ6Z2Q8w7vcYER1JypC8s2oa3SQ1b1', 'DASH'); - valid('XqMkVUZnqe3w4xvgdZRtZoe7gMitDudGs4', 'dash'); - valid('yPv7h2i8v3dJjfSH4L3x91JSJszjdbsJJA', 'dash', 'testnet'); - valid('XoAAqv3oUYZ6xRjX3brfbf9PotrGanS6Th', 'dash'); - valid('yP5oXZQXBfBf9FyfZDpFiKDypxuNUKUV2E', 'dash', 'testnet'); - }); - - it('should return true for correct neo addresses', function () { - valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neo'); - valid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X', 'NEO'); - }); - - it('should return true for correct neo gas addresses', function () { - valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neogas'); - }); - - it('should return true for correct qtum addresses', function () { - valid('QNjUiD3bVVZwYTc5AhpeQbS1mfb2guyWhe', 'qtum'); - valid('QVZnSrMwKp6AL4FjUPPnfFgsma6j1DXQXu', 'QTUM'); - valid('MCgyroQse81wuv5RwPpY5DXDNxeafzLFJ8', 'QTUM'); - valid('QQYySVc5WEe3g6PnNFYmspqG5CfSG8rnma', 'QTUM'); - valid('MSvJQBJMZs1dhxz7UAWa2si4iyMD2FHQd5', 'QTUM'); - - valid('qcSLSxN1sngCWSrKFZ6UC7ri4hhVSdq9SU', 'qtum', 'testnet'); - valid('qJnbEdrm9ybjVqDCaX5SWNBHmZy2X7YbPT', 'qtum', 'testnet'); - valid('qchBPDUYswobzpDmY5DsTStt74sTYQtaQv', 'qtum', 'testnet'); - }); - - it('should return true for correct votecoin addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); - }); - - it('should return true for correct bitcoinz addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); - }); - - it('should return true for correct zclassic addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); - }); - - it('should return true for correct hush addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); - }); - - it('should return true for correct zcash addresses', function () { - valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); - valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); - }); - - it('should return true for correct bitcoinprivate addresses', function () { - valid('b1M4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); - //valid('bx....', 'BTCP'); - //valid('nx....', 'bitcoinprivate', 'testnet'); - }); - - it('should return true for correct snowgem addresses', function () { - valid('s1fx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); - valid('s3d27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); - valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); - }); - - it('should return true for correct zencash addresses', function () { - valid('znhiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); - valid('zssEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); - valid('ztmWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); - }); - - it('should return true for correct komodo addresses', function () { - valid('R9R5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); - valid('RAvj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); - //valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); - }); - - it('should return true for correct Bankex addresses', function () { - valid('0xeac39e1bc802baae3d4b9cb518f3f60374bbad6c', 'bankex'); - valid('0x45245bc59219eeaaf6cd3f382e078a461ff9de7b', 'BKX'); - valid('0xf40d80FCfa5cdEa0bB1E570c2D52132ac9bC6aEC', 'bankex', 'testnet'); - valid('0x8A7395f281EeCf2B471B689E87Cf4C7fa8bb957d', 'BKX', 'testnet'); - }); - - - it('should return true for correct Cardano addresses', function () { - valid( 'Ae2tdPwUPEYzs5BRbGcoS3DXvK8mwgggmESz4HqUwMyaS9eNksZGz1LMS9v', 'ada'); - valid('Ae2tdPwUPEYxYNJw1He1esdZYvjmr4NtPzUsGTiqL9zd8ohjZYQcwu6kom7', 'cardano'); - valid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg', 'ada'); - valid('Ae2tdPwUPEZKmwoy3AU3cXb5Chnasj6mvVNxV1H11997q3VW5ihbSfQwGpm', 'ada'); - valid('4swhHtxKapQbj3TZEipgtp7NQzcRWDYqCxXYoPQWjGyHmhxS1w1TjUEszCQT1sQucGwmPQMYdv1FYs3d51KgoubviPBf', 'cardano'); - }); - - it('should return true for correct monero addresses', function () { - valid('47zQ5LAivg6hNCgijXSEFVLX7mke1bgM6YGLFaANDoJbgXDymcAAZvvMNt2PmMpqEe5qRy2zyfMYXdwpmdyitiFh84xnPG2', 'monero'); - valid('48bWuoDG75CXMDHbmPEvUF2hm1vLDic7ZJ7hqRkL65QR9p13AQAX4eEACXNk4YP115Q4KRVZnAvmMBHrcGfv9FvKPZnH6vH', 'XMR'); - valid('88WB4JKdQVhWfkc8cBT9EEJ6vejSAqKJHbV1dXBAXdpgQovtNDNRxfKCS7wB8rHQ5D5zH2Pd1YkyMNNQDie6ZfeZ311fPgn', 'XMR'); - valid('A2be3UvzMtkJtxRYgcCbQt2y7Rp2eLVGqNTWfZeankrWimSMM4y7uMP6B9oAZaHsXTj8KFSerkSkkVRuEuEca9QM8VhxCNU', 'monero', 'testnet'); - - //integrated addresses - valid('4Gd4DLiXzBmbVX2FZZ3Cvu6fUaWACup1qDowprUCje1kSP4FmbftiJMSfV8kWZXNqmVwj4m52xqtgFNUudVmsmGkGvkLcCibWfVUfUFVB7', 'monero'); - valid('4J5sF94AzXgFgx8LuWc9dcWkJkGkD3cL3L2AuhX6QA9jFvSxxj6QhHqHXqM2b2Go7G8RyDzEbHxYd9G26XUUbuJChipEyBz9fENMU2Ua9b', 'XMR'); - - valid('9uXRFi4PZMqhsnthBF6bGdfVnBSZtfKkR7Td8qPM7jUKZeTfR1tLhCoTLqYNE12xuiQg3aWGiLw83bWsqwTRLaM4Jk47xYM', 'XMR', 'testnet'); - valid('9tFTaQM39JXhULZsHauPHhjFrjcGSGXoijEPYoRgAky9Veck2mFp3EifQ2tKHmEHuuUoFfgYRNR2bVaborz5oi8JA8xkqjY', 'monero', 'testnet') - }); - - it('should return true for correct gamecredits addresses', function () { - valid('GU5BBtW9gxSKvAknvFi9yUaXKUNW9zUN2p', 'game'); - valid('GYxQMVzP6YpzX59QNRYqmJeHNtUMYSZPri', 'game'); - }); - - it('should return true for correct monacoin addresses', function () { - valid('MMN1Q1aRVUzanmg9DJjcRYzQSJQoBeQPui', 'mona'); - valid('PFMzNYnBm5X4c9qJkJPkfgdCyd9fuuy2vT', 'mona'); - valid('PCtN7VUYHW8w4g59BaphrfPs8g7pNgAzxn', 'mona'); - valid('MXCcYFGRmsd4d3CcQugFiqG8uarj5tVu76', 'mona'); - valid('MNK1pGsBf9WdoE54fZM9VFhkeYHW6VUf2u', 'mona'); - }); - - it('should return true for correct pivx addresses', function () { - valid('DJXFW9oJJBUX7QKrG6GKvmTs63MYKzwtpZ', 'pivx'); - valid('DEaYb8EHQgyKvX6VXDS3DZQautJrHBmK3T', 'pivx'); - valid('DDeCGR3QSgqsBxVR23bJvteiyYE34ZmxAc', 'pivx'); - valid('DSqQM8DPpBHHoZXHgRdwmaf6hZPEoZcFkh', 'pivx'); - }); - - it('should return true for correct solarcoin addresses', function () { - valid('8VxVLzwB26E2YZZ82o1NcQe96QSM2z6GwW', 'slr'); - valid('8YW5qcTjeyqX5kESsqu2BUdXiedgssegtQ', 'SolarCoin'); - }); - - it('should return true for correct tether addresses', function () { - valid('3MbYQMMmSkC3AgWkj9FMo5LsPTW1zBTwXL', 'usdt'); - valid('1KdXaqcBeoMAFVAPwTmYvDbEq6RnvNPF6J', 'tether'); - }); - - it('should return true for correct expanse addresses', function () { - valid('0xbab463743603a253bdf1f84975b1a9517505ae05', 'exp'); - valid('0x5d0777cb5d6977873904864c6ab531f4b3261f0b', 'expanse'); - }); - - it('should return true for correct waves addresses', function () { - valid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); - valid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHajj', 'waves'); - - valid('3Myrq5QDgRq3nBVRSSv9UYrP36xTtpJND5y', 'waves', 'testnet'); - valid('3My3KZgFQ3CrVHgz6vGRt8687sH4oAA1qp8', 'waves', 'testnet'); - }); - - it('should return true for correct nano addresses', function () { - valid('xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3', 'nano'); - valid('xrb_13ezf4od79h1tgj9aiu4djzcmmguendtjfuhwfukhuucboua8cpoihmh8byo', 'nano'); - valid('xrb_35jjmmmh81kydepzeuf9oec8hzkay7msr6yxagzxpcht7thwa5bus5tomgz9', 'nano'); - valid('xrb_1111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); - valid('xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est', 'nano'); - valid('xrb_3wm37qz19zhei7nzscjcopbrbnnachs4p1gnwo5oroi3qonw6inwgoeuufdp', 'nano'); - valid('xrb_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4', 'nano'); - valid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjmgu', 'nano'); - valid('xrb_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); - valid('nano_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); - }); - - it('should return true for correct siacoin addresses', function () { - valid( - 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', - 'siacoin' - ) - valid( - 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', - 'siacoin' - ) - valid( - 'ab0c327982abfcc6055a6c9551589167d8a73501aca8769f106371fbc937ad100c955c3b7ba9', - 'siacoin' - ) - valid( - 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530373', - 'siacoin' - ) - }) - - it('should return true for correct loki addresses', function () { - // public - valid( - 'L63ymg8cb5aRz1PhXrEQ22PWw9KBhBS8rMsgqbABhTGFfh53U3Rc2iWCJpCPsHZT5hfyt7fPQa612a5Z1tBnGYEA9h6YHnn', - 'loki' - ) - valid( - 'L5QKRGMNpQU3eCAdjMVTCR631bRKqnW1oEWWBEHAtFJLieA5VvuxyyubCd9FczEEatg8jfy39UJZ13npLJqZG6dtMtM99ha', - 'loki' - ) - // integrated - valid( - 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiD1xbPb6dpYo7toNRqk', - 'loki' - ) - valid( - 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiCtWq1AYo1oJTVqgUcQ', - 'loki' - ) - // subaddress - valid( - 'LW1VMYcvWPZZJ2h1pKGEku2y9WeDiAU2VhgrgVgvjybaRuCdcEkg6FhXjVNSd37Bp7fhYH8tVa5T9VmRaYiWyxYdCpEGBg8', - 'loki' - ) - }) - - it('should return true for correct lbry addresses', function () { - valid('bDb6NmobyDVeNGpizWQQBZkYjKCRQBdKdG', 'LBC') - valid('bTFXPcV3a8iVDezogvHTHezWZ1mZGWpPDc', 'lbc') - valid('bK2uEVn6UuwjCTUZ1Dfj5HhWYi9BtqZDDm', 'lbc') - valid('bNEMVqeUZUqTrYUxud5ehnUhtTAiWDXQ5e', 'lbc') - }) - - it('should return true for correct trx addresses', function () { - valid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r', 'trx'); - valid('27bLJCYjbH6MT8DBF9xcrK6yZnm43vx7MNQ', 'trx', 'testnet'); - }); - - it('should return true for correct nem addresses', function () { - valid('NBZMQO7ZPBYNBDUR7F75MAKA2S3DHDCIFG775N3D', 'xem'); - valid('TDWTRGT6GVWCV7GRWFNI45S53PGOJBKNUF3GE6PB', 'xem', 'testnet'); - }); - - it('should return true for correct lsk addresses', function () { - valid('469226551L', 'lsk'); - valid('15823701926930889868L', 'lsk'); - valid('1657699692452120239L', 'lsk'); - valid('555666666999992L', 'lsk'); - valid('6853061742992593192L', 'lsk'); - valid('530464791801L', 'lsk'); - }); - - it('should return true for correct bsv addresses', function () { - valid('qzwryn9fxnpqkf7zt878tp2g9cg8kpl65qh2ml0w0r', 'bsv'); - valid('qp65yngy5uds4wxtrkynptal4f76qzmrh52pa3mpaf', 'bsv'); - valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); - valid('qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); - valid('qz97s7ee0rvwlymtxrwafmvs87x6027jwuf3wepug7', 'bsv'); - valid('bitcoincash:qpp32ssez340wfspnt79h6c4xds4fzf3m5j0cplx0l', 'bsv'); - valid('qqg82u7tq2eahs3gkh9m6kjnmjehr69m5v37alepq4', 'bsv'); - valid('bitcoincash:qrwkk9a3es2wu7mdvzh0vekfvjuzysq8tv7r3hcwr5', 'bsv'); - valid('1DrNXqCj2B8FKyx66RAWDkiEJhw2yrvhT3', 'bsv'); - }); - - it('should return true for correct stellar addresses', function () { - valid('GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB', 'stellar'); - valid('GB7KKHHVYLDIZEKYJPAJUOTBE5E3NJAXPSDZK7O6O44WR3EBRO5HRPVT', 'stellar'); - valid('GD6WVYRVID442Y4JVWFWKWCZKB45UGHJAABBJRS22TUSTWGJYXIUR7N2', 'stellar'); - valid('GBCG42WTVWPO4Q6OZCYI3D6ZSTFSJIXIS6INCIUF23L6VN3ADE4337AP', 'stellar'); - valid('GDFX463YPLCO2EY7NGFMI7SXWWDQAMASGYZXCG2LATOF3PP5NQIUKBPT', 'stellar'); - valid('GBXEODUMM3SJ3QSX2VYUWFU3NRP7BQRC2ERWS7E2LZXDJXL2N66ZQ5PT', 'stellar'); - valid('GAJHORKJKDDEPYCD6URDFODV7CVLJ5AAOJKR6PG2VQOLWFQOF3X7XLOG', 'stellar'); - valid('GACXQEAXYBEZLBMQ2XETOBRO4P66FZAJENDHOQRYPUIXZIIXLKMZEXBJ', 'stellar'); - valid('GDD3XRXU3G4DXHVRUDH7LJM4CD4PDZTVP4QHOO4Q6DELKXUATR657OZV', 'stellar'); - valid('GDTYVCTAUQVPKEDZIBWEJGKBQHB4UGGXI2SXXUEW7LXMD4B7MK37CWLJ', 'stellar'); - }); - - it('should return true for correct xtz(tezos) address', function () { - valid('tz1Lhf4J9Qxoe3DZ2nfe8FGDnvVj7oKjnMY6', 'xtz'); - valid('tz1PyxsQ7xVTa5J7gtBeT7pST5Zi5nk5GSjg', 'xtz'); - valid('tz1LcuQHNVQEWP2fZjk1QYZGNrfLDwrT3SyZ', 'xtz'); - valid('tz1Lhf4J9Qxoe3DZ2nfe8FGDnvVj7oKjnMY6', 'xtz'); - valid('tz1RR6wETy9BeXG3Fjk25YmkSMGHxTtKkhpX', 'xtz'); - valid('tz1h3rQ8wBxFd8L9B3d7Jhaawu6Z568XU3xY', 'xtz'); - valid('KT1EM2LvxxFGB3Svh9p9HCP2jEEYyHjABMbK', 'xtz'); - }); - - it('should return true for correct eos addresses', function () { - valid('bittrexacct1', 'eos'); - valid('binancecleos', 'eos'); - valid('123456789012', 'eos'); - }); - }); - - describe('invalid results', function () { - function commonTests(currency) { - invalid('', currency); //reject blank - invalid('%%@', currency); //reject invalid base58 string - invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency); //reject invalid address - invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency); //reject transaction id's - //testnet - invalid('', currency, 'testnet'); //reject blank - invalid('%%@', currency, 'testnet'); //reject invalid base58 string - invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency, 'testnet'); //reject invalid address - invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency, 'testnet'); //reject transaction id's - } - - it('should return false for incorrect bitcoin addresses', function () { - commonTests('bitcoin'); - }); - - it('should return false for incorrect bitcoincash addresses', function () { - commonTests('bitcoincash'); - }); - - it('should return false for incorrect litecoin addresses', function () { - commonTests('litecoin'); - }); - - it('should return false for incorrect peercoin addresses', function () { - commonTests('peercoin'); - }); - - it('should return false for incorrect dogecoin addresses', function () { - commonTests('dogecoin'); - }); - - it('should return false for incorrect beavercoin addresses', function () { - commonTests('beavercoin'); - }); - - it('should return false for incorrect freicoin addresses', function () { - commonTests('freicoin'); - }); - - it('should return false for incorrect protoshares addresses', function () { - commonTests('protoshares'); - }); - - it('should return false for incorrect megacoin addresses', function () { - commonTests('megacoin'); - }); - - it('should return false for incorrect primecoin addresses', function () { - commonTests('primecoin'); - }); - - it('should return false for incorrect auroracoin addresses', function () { - commonTests('auroracoin'); - }); - - it('should return false for incorrect namecoin addresses', function () { - commonTests('namecoin'); - }); - - it('should return false for incorrect biocoin addresses', function () { - commonTests('biocoin'); - }); - - it('should return false for incorrect garlicoin addresses', function () { - commonTests('garlicoin'); - }); - - it('should return false for incorrect vertcoin addresses', function () { - commonTests('vertcoin'); - }); - - it('should return false for incorrect bitcoingold addresses', function () { - commonTests('bitcoingold'); - }); - - it('should return false for incorrect decred addresses', function () { - commonTests('decred'); - }); - - it('should return false for incorrect gamecredits addresses', function () { - commonTests('game'); - }); - - it('should return false for incorrect monacoin addresses', function () { - commonTests('mona'); - }); - - it('should return false for incorrect solarcoin addresses', function () { - commonTests('slr'); - }); - - it('should return false for incorrect tether addresses', function () { - commonTests('usdt'); - }); - - it('should return false for incorrect expanse addresses', function () { - commonTests('exp'); - }); - - it('should return false for incorrect usdt addresses', function () { - commonTests('usdt'); - }); - - it('should return false for incorrect bankex addresses', function () { - invalid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'bankex'); - invalid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd', 'BKX'); - invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bankex', 'testnet'); - invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'BKX', 'testnet'); - }); - - it('should return false for incorrect digibyte addresses', function () { - commonTests('digibyte'); - }); - - it('should return false for incorrect eip55 addresses', function () { - invalid('6xAff4d6793F584a473348EbA058deb8caad77a288', 'ethereum'); - invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereum'); - invalid('0XD1220A0CF47C7B9BE7A2E6BA89F429762E7B9ADB', 'ethereum'); - invalid('aFf4d6793f584a473348ebA058deb8caad77a2885', 'ethereum'); - invalid('0xff4d6793F584a473', 'ethereum'); - - invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereumclassic'); - invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'etherzero'); - invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'callisto'); - }); - - it('should return false for incorrect ripple addresses', function () { - invalid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCN', 'ripple'); - invalid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhMN', 'XRP'); - invalid('6xAff4d6793F584a473348EbA058deb8ca', 'ripple'); - invalid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'ripple'); - }); - - it('should return false for incorrect dash addresses', function () { - commonTests('dash'); - }); - - it('should return false for incorrect neo addresses', function () { - commonTests('neo'); - invalid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTa', 'neo'); - invalid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ10', 'NEO'); - }); - - it('should return false for incorrect qtum addresses', function () { - commonTests('qtum'); - invalid('QNPhBbVhDghASxcUh2vHotQUgNeLRFTcfb', 'qtum'); - invalid('QOPhBbVhDghASxcUh2vHotQUgNeLRFTcfa', 'QTUM'); - }); - - it('should return false for incorrect votecoin addresses', function () { - commonTests('votecoin'); - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); - }); - - it('should return false for incorrect bitcoinz addresses', function () { - commonTests('bitcoinz'); - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); - }); - - it('should return false for incorrect zclassic addresses', function () { - commonTests('zclassic'); - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); - }); - - it('should return false for incorrect hush addresses', function () { - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); - }); - - it('should return false for incorrect zcash addresses', function () { - commonTests('zcash'); - invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); - invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); - }); - - it('should return false for incorrect bitcoinprivate addresses', function () { - commonTests('bitcoinprivate'); - invalid('b1Y4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); - //invalid('bx....', 'BTCP'); - //invalid('nx....', 'bitcoinprivate', 'testnet'); - }); - - it('should return false for incorrect snowgem addresses', function () { - commonTests('snowgem'); - invalid('s1Yx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); - invalid('s3Y27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); - invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); - }); - - it('should return false for incorrect zencash addresses', function () { - commonTests('zencash'); - invalid('znYiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); - invalid('zsYEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); - invalid('ztYWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); - }); - - it('should return false for incorrect komodo addresses', function () { - commonTests('komodo'); - invalid('R9Y5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); - invalid('RAYj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); - //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); - }); - - it('should return false for incorrect cardano addresses', function () { - commonTests('cardano'); - invalid('Ae2tdPwUPEYxYNJw1He1esdZYvjmr4NtPzUsGTiqL9zd8ohjZYQcwu6lom7', 'cardano'); - invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg1', 'cardano'); - invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRT', 'ada'); - //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); - }); - - it('should return false for incorrect monero addresses', function () { - commonTests('monero'); - invalid('4AWygwA3hHNE4e4Yr9PtRWJiorXTjZkCi57g4ExYzfXDFFQ8DRFEFyui1dLqVknpqQjGUBdTMbgaFAZaDbrVHdk3GAKBZ3E', 'monero'); - invalid('44643dtxcxjgMWEQLo6mh1c4d9Zxx9GbgK9hEj9iGSiFEryCkbwHyJ3JqxZJRqeC3Hb7ZBLKq5NkaJwR1x95EYnR1bTgN6d', 'xmr'); - invalid('A17N9ztrxjQD3v3JJtHGvHVnq6BAbujDNEuensB6PFwBYFpkjAicih8hDtX76HBuEag5NeaCuMZmRMe6eE5NMRGxFTQn8nJ', 'monero', 'testnet'); - - //integrated - invalid('4LNSCKNSTPNbJYkyAEgL966eHJHLDHiq1PpwKoiFBybcSqNGYfLBJApC62uQEeGAFxfYEd29uXBBrJFo7DhKqFVNi3GhmN79EtD5dgycYz', 'monero'); - invalid('4JpzTwf3i1GeCV76beVr19179oa8j1L8xNSC1bXMtAxxdf4aTTLqubL8EvXfQmUGKt9MMigFtKy91VtoTTSfg1LU7LocPruT6KcGC9RKJV', 'xmr'); - }); - - it('should return false for incorrect waves addresses', function () { - commonTests('waves'); - invalid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs1', 'waves'); - invalid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHaj', 'waves'); - invalid('2P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); - - invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'waves', 'testnet'); - invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'waves', 'testnet'); - }); - - it('should return false for incorrect nano addresses', function () { - commonTests('nano'); - invalid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); - invalid('nano_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nano'); - invalid('nano_111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); - }); - - it('should return false for incorrect siacoin addresses', function () { - commonTests('siacoin') - invalid( - 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372', - 'siacoin' - ) - }) - - it('should return false for incorrect lbry addresses', function () { - commonTests('lbc') - invalid('ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372') - }) - - it('should return false for incorrect tron addresses', function () { - commonTests('trx'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'trx'); - invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'trx'); - }); - - it('should return false for incorrect nem addresses', function () { - commonTests('nem'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nem'); - invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'nem'); - - invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'nem', 'testnet'); - invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'nem', 'testnet'); - }); - //15823701926930889868L - it('should return false for incorrect lsk addresses', function () { - commonTests('lsk'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'lsk'); - invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'lsk'); - - invalid('158237019269308898689L', 'lsk'); - invalid('158237A192B930C898689L', 'lsk'); - }); - - it('should return false for incorrect bsv addresses', function () { - commonTests('bsv'); - invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'bsv'); - invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'bsv'); - - invalid('158237019269308898689L', 'bsv'); - invalid('158237A192B930C898689L', 'bsv'); - invalid('bitcoin:qzpuefrpg3kl2ykQe52rxn96pd3Kp4qudywr5pyrsf', 'bsv'); - invalid('pzuefrpg3kl2ykqe52rxn96pd3kp4qudywr5py', 'bsv'); - invalid('rlt2c2wuxr644encp3as0hygtj9djrsaumku3cex5', 'bsv'); - invalid('qra607y4wnkmnpy3wcmrxmltzkrxywcq85c7watpdx09', 'bsv'); - }); - - it('should return false for incorrect stellar addresses', function () { - commonTests('stellar'); - invalid('SBGWKM3CD4IL47QN6X54N6Y33T3JDNVI6AIJ6CD5IM47HG3IG4O36XCU', 'stellar'); - invalid('GBPXX0A5N4JYPESHAADMQKBPWZWQDQ64ZV6ZL2S3LAGW4SY7NTCMWIVL', 'stellar'); - invalid('GCFZB6L25D26RQFDWSSBDEYQ32JHLRMTT44ZYE3DZQUTYOL7WY43PLBG++', 'stellar'); - invalid('GADE5QJ2TY7S5ZB65Q43DFGWYWCPHIYDJ2326KZGAGBN7AE5UY6JVDRRA', 'stellar'); - invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2', 'stellar'); - invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2T', 'stellar'); - invalid('GDXIIZTKTLVYCBHURXL2UPMTYXOVNI7BRAEFQCP6EZCY4JLKY4VKFNLT', 'stellar'); - invalid('SAB5556L5AN5KSR5WF7UOEFDCIODEWEO7H2UR4S5R62DFTQOGLKOVZDY', 'stellar'); - invalid('gWRYUerEKuz53tstxEuR3NCkiQDcV4wzFHmvLnZmj7PUqxW2wt', 'stellar'); - invalid('g4VPBPrHZkfE8CsjuG2S4yBQNd455UWmk', 'stellar'); - }); - - it('should return false for incorrect xtz(tezos) address', function () { - commonTests('xtz'); - invalid('SBGWKM3CD4IL47QN6X54N6Y33T3JDNVI6AIJ6CD5IM47HG3IG4O36XCU', 'xtz'); - invalid('GBPXX0A5N4JYPESHAADMQKBPWZWQDQ64ZV6ZL2S3LAGW4SY7NTCMWIVL', 'xtz'); - invalid('GCFZB6L25D26RQFDWSSBDEYQ32JHLRMTT44ZYE3DZQUTYOL7WY43PLBG', 'xtz'); - invalid('tz1RR6wy9BeXG3Fjk25YmkSMGHxTtKkhpX', 'xtz'); - invalid('tz1h3rQ8wBxFd8L9B3d7JhaPQawu6Z568XU3xY', 'xtz'); - invalid('tz1Lhf4J9Qxoe4DZ2nfe8FGDnvVj7oKjnMY6', 'xtz'); - invalid('KT1E2LvxxFGB3Svh9p9HCP2jEEYyHjABMbK', 'xtz'); - - }); - - it('should return false for incorrect eos addresses', function () { - commonTests('eos'); - invalid('1234567890123', 'eos'); - invalid('12345678901', 'eos'); - invalid('12345678901@', 'eos'); - }); + describe('valid results', function () { + it('should return true for correct bitcoin addresses', function () { + valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoin'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bitcoin'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BTC'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc', 'prod'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'btc', 'both'); + valid('15uwigGExiNQxTNr1QSZYPXJMp9Px2YnVU', 'btc', 'prod'); + valid('3FyVFsEyyBPzHjD3qUEgX7Jsn4tcHNZFkn', 'btc', 'prod'); + valid('38mKdURe1zcQyrFqRLzR8PRao3iLGEPVsU', 'btc', 'prod'); + valid('mptPo5AvLzJXi4T82vR6g82fT5uJ6HsQCu', 'btc', 'both'); + valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'bitcoin'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoin', 'testnet'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoin', 'both'); + + valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez'); + valid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd'); + + // p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt'); + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoin', 'testnet'); + + // regtest + valid('GSa5espVLNseXEfKt46zEdS6jrPkmFghBU', 'bitcoin', 'testnet'); + + // segwit addresses + valid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'bitcoin'); + valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 'bitcoin'); + valid('bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx', 'bitcoin'); + valid('BC1SW50QA3JX3S', 'bitcoin'); + valid('bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj', 'bitcoin'); + valid('tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy', 'bitcoin'); + + invalid("tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", 'bitcoin'), + invalid("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", 'bitcoin'), + invalid("BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", 'bitcoin'), + invalid("bc1rw5uspcuh", 'bitcoin'), + invalid("bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90", 'bitcoin'), + invalid("BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P", 'bitcoin'), + invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7", 'bitcoin'), + invalid("bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", 'bitcoin'), + invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv", 'bitcoin'), + invalid("bc1gmk9yu", 'bitcoin') + }); + + it('should return true for correct bitcoincash addresses', function () { + valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoincash'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bitcoincash'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BCH'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'prod'); + valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'both'); + valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'bitcoincash'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'testnet'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'both'); + + // p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoincash'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoincash', 'testnet'); + + valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bch'); + + }); + + it('should return true for correct litecoin addresses', function () { + valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'litecoin'); + valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'LTC'); + valid('LTpYZG19YmfvY2bBDYtCKpunVRw7nVgRHW', 'litecoin'); + valid('Lb6wDP2kHGyWC7vrZuZAgV7V4ECyDdH7a6', 'litecoin'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'litecoin', 'testnet'); + + // p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'litecoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'litecoin', 'testnet'); + valid('QW2SvwjaJU8LD6GSmtm1PHnBG2xPuxwZFy', 'litecoin', 'testnet'); + valid('QjpzxpbLp5pCGsCczMbfh1uhC3P89QZavY', 'litecoin', 'testnet'); + }); + + it('should return true for correct peercoin addresses', function () { + valid('PHCEsP6od3WJ8K2WKWEDBYKhH95pc9kiZN', 'peercoin'); + valid('PSbM1pGoE9dnAuVWvpQqTTYVpKZU41dNAz', 'peercoin'); + valid('PUULeHrJL2WujJkorc2RsUAR3SardKUauu', 'peercoin'); + valid('PUULeHrJL2WujJkorc2RsUAR3SardKUauu', 'PPC'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'peercoin', 'testnet'); + + // p2sh addresses + valid('pNms4CaWqgZUxbNZaA1yP2gPr3BYnez9EM', 'peercoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'peercoin', 'testnet'); + }); + + it('should return true for correct dogecoin addresses', function () { + valid('DPpJVPpvPNP6i6tMj4rTycAGh8wReTqaSU', 'dogecoin'); + valid('DNzLUN6MyYVS5zf4Xc2yK69V3dXs6Mxia5', 'dogecoin'); + valid('DPS6iZj7roHquvwRYXNBua9QtKPzigUUhM', 'dogecoin'); + valid('DPS6iZj7roHquvwRYXNBua9QtKPzigUUhM', 'DOGE'); + //TODO: NEED A DOGECOIN TESTNET ADDRESS + + //p2sh addresses + valid('A7JjzK9k9x5b2MkkQzqt91WZsuu7wTu6iS', 'dogecoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'dogecoin', 'testnet'); + }); + + it('should return true for correct beavercoin addresses', function () { + valid('BPPtB4EpPi5wCaGXZuNyKQgng8ya579qUh', 'beavercoin'); + valid('BC1LLYoE4mTCHTJhVYvLGxhRTwAHyWTQ49', 'beavercoin'); + valid('BBuyeg2vjtyFdMNj3LTxuVra4wJMKVAY9C', 'beavercoin'); + valid('BBuyeg2vjtyFdMNj3LTxuVra4wJMKVAY9C', 'BVC'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'beavercoin', 'testnet'); + + // p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'beavercoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'beavercoin', 'testnet'); + }); + + it('should return true for correct freicoin addresses', function () { + valid('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', 'freicoin'); + valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'freicoin'); + valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'freicoin'); + valid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'FRC'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'freicoin', 'testnet'); + + // p2sh addresse + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'freicoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'freicoin', 'testnet'); + }); + + it('should return true for correct protoshares addresses', function () { + valid('PaNGELmZgzRQCKeEKM6ifgTqNkC4ceiAWw', 'protoshares'); + valid('Piev8TMX2fT5mFtgxx2TXJaqXP37weMPuD', 'protoshares'); + valid('PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD', 'protoshares'); + valid('PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD', 'PTS'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'protoshares', 'testnet'); + + //p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'protoshares'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'protoshares', 'testnet'); + }); + + it('should return true for correct megacoin addresses', function () { + valid('MWUHaNxjXGZUYTh92i3zuDmsnH1rHSBk5M', 'megacoin'); + valid('MSAkrhRyte7bz999Ga5SqYjzypFFYa2oEb', 'megacoin'); + valid('MLUTAtDQFcfo1QACWocLuufFq5fBDTpCHE', 'megacoin'); + valid('MLUTAtDQFcfo1QACWocLuufFq5fBDTpCHE', 'MEC'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'megacoin', 'testnet'); + + //p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'megacoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'megacoin', 'testnet'); + }); + + it('should return true for correct primecoin addresses', function () { + valid('AVKeiZ5JadfWdH2EYVgVRfX4ufoyd4ehuM', 'primecoin'); + valid('AQXBRPyob4dywUJ21RUKrR1xetQCDVenKD', 'primecoin'); + valid('ANHfTZnskKqaBU7oZuSha9SpbHU3YBfeKf', 'primecoin'); + valid('AYdiYMKSGYxLcZNDmqB8jNcck7SQibrfiK', 'primecoin'); + valid('AYdiYMKSGYxLcZNDmqB8jNcck7SQibrfiK', 'XPM'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'primecoin', 'testnet'); + + //p2sh addresses + valid('af5CvTQq7agDh717Wszb5QDbWb7nT2mukP', 'primecoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'primecoin', 'testnet'); + }); + + it('should return true for correct auroracoin addresses', function () { + valid('ARM3GLZXF1PDTZ5vz3wh5MVahbK9BHTWAN', 'auroracoin'); + valid('AUtfc6ThCLb7FuEu7QPrWpJuaXaJRPciDF', 'auroracoin'); + valid('AUN1oaj5hjispGnczt8Aruw3TxgGyRqB3V', 'auroracoin'); + valid('AXGcBkGX6NiaDXj85C5dCrhTRUgwxSkKDK', 'auroracoin'); + valid('AXGcBkGX6NiaDXj85C5dCrhTRUgwxSkKDK', 'AUR'); + valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'auroracoin', 'testnet'); + + //p2sh addresses + valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'auroracoin'); + valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'auroracoin', 'testnet'); + }); + + it('should return true for correct namecoin addresses', function () { + valid('NEpeRmS775fnti8TDgJA28m8KLEfNNRZvT', 'namecoin'); + valid('MyJ691bGJ48RBK2LS8n1U57wcFLFScFXxi', 'namecoin'); + valid('NFY9aw1RXLGtWpeqgNQXprnUcZXyKNinTh', 'namecoin'); + valid('NCPPc7Pzb75CpRPJQPRRh6ouJTq7BCy1H4', 'namecoin'); + valid('NCPPc7Pzb75CpRPJQPRRh6ouJTq7BCy1H4', 'NMC'); + }); + + it('should return true for correct BioCoin addresses', function () { + valid('B7xseoLGk7hEpMDDeSvZDKmmiAMHWiccok', 'biocoin'); + valid('B8zjmYFGhWmiaQSJshfrnefE72xCapCkvo', 'biocoin'); + valid('muH8LL42DiMs8GEQ6Grfi8KUw2uFvuKr1J', 'biocoin', 'testnet'); + valid('muH8LL42DiMs8GEQ6Grfi8KUw2uFvuKr1J', 'BIO', 'testnet'); + valid('B8zjmYFGhWmiaQSJshfrnefE72xCapCkvo', 'BIO'); + }); + + it('should return true for correct Garlicoin addresses', function () { + valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'garlicoin'); + valid('GNWeWaoQ6rv21ZFjJWT9vb91hXUzFTLkru', 'garlicoin'); + valid('mjKbQTkgwzmsL3J86tdVzhyW9pc4NePqTb', 'garlicoin', 'testnet'); + valid('mnYp36NuyRavMKQ9Q9Q6oGqoorAs9p3zYn', 'GRLC', 'testnet'); + valid('GU2NtcNotWFiZjTp2Vdgf5CjeMfgsWYCua', 'GRLC'); + }); + + it('should return true for correct Vertcoin addresses', function () { + valid('3PgeyhEJEnS5CeBu3iFcu3JHVKemeHx1AW', 'VTC'); + valid('353nERPQKhGj4WGzoiWcareA76TPgRCVNA', 'VTC'); + valid('376g4TmL8uQKFYsRFrbv5iz9srmb5bocEt', 'VTC'); + valid('3AMtM4Zk5oNHu9i4jDiwKB6Kg5YEReBsav', 'VTC'); + + valid('VmoMjGf3zgZLy8sk3PMKd3xikZHXWvnYi7', 'vertcoin'); + valid('VmhHwXr3J8xMZpy62WuBGpu3xVvThWzcTQ', 'vertcoin'); + valid('mvww6DEJ18dbyQUukpVQXvLgrNDJazZn1Y', 'vertcoin', 'testnet'); + valid('mn3mdEE6cf1snxVsknNz4GRTdSrWXqYp7c', 'VTC', 'testnet'); + valid('Vri6Q4GgNFfdtcpxD961TotJwaSaYQCaL5', 'VTC'); + }); + + it('should return true for correct BitcoinGold addresses', function () { + valid('GW3JrQyHtoVfEFES3Y9JagiX3VSKQStLwj', 'bitcoingold'); + valid('GUDWdeMyAXQbrNFFivAhkJQ1GfBCFdc7JF', 'bitcoingold'); + valid('mvww6DEJ18dbyQUukpVQXvLgrNDJazZn1Y', 'bitcoingold', 'testnet'); + valid('mn3mdEE6cf1snxVsknNz4GRTdSrWXqYp7c', 'BTG', 'testnet'); + valid('GSNFPRsdaM3MXrU5HW1AxgFwmUQC8HXK9F', 'BTG'); + }); + + it('should return true for correct Decred addresses', function () { + valid('Dsesax2GJnMN4wwmWo5rJGq73dDK217Rh85', 'DCR'); + valid('DsYuxtvGRfN8rncXAndtLUpJm55F77K17RA', 'decred'); + valid('DsaXDG2NrJW8g4tFAb8n9MNx81Sn3Qc8AEV', 'decred'); + valid('TsijUgejaRnLKF5WAbpUxNtwKGUiKVeXLr7', 'decred', 'testnet'); + valid('TsZ9QmAoadF12hGvyALp6qvaF4be3BmLqG9', 'dcr', 'testnet'); + }); + + it('should return true for correct Digibyte addresses', function () { + valid('DG2rM2orU2JH5i4ACh3AKNpRTNESdv5xf8', 'DGB'); + valid('DBR2Lj1F17eHGHXgbpae2Wb4m39bDyA1qo', 'DGB'); + valid('D9TDZTR9Z9Mx2NoDJnhqhnYhDLKRAmsL9n', 'digibyte'); + valid('DHRzA1YHA1kFWpz2apRckZJy6KZRyGq4EV', 'digibyte'); + valid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'digibyte'); + }); + + it('should return true for correct Ethereum addresses', function () { + valid('0xE37c0D48d68da5c5b14E5c1a9f1CFE802776D9FF', 'ethereum'); + valid('0xa00354276d2fC74ee91e37D085d35748613f4748', 'ethereum'); + valid('0xAff4d6793F584a473348EbA058deb8caad77a288', 'ETH'); + valid('0xc6d9d2cd449a754c494264e1809c50e34d64562b', 'ETH'); + valid('0x52908400098527886E0F7030069857D2E4169EE7', 'ETH'); + valid('0x8617E340B3D01FA5F11F306F4090FD50E238070D', 'ETH'); + valid('0xde709f2102306220921060314715629080e2fb77', 'ETH'); + valid('0x27b1fdb04752bbc536007a920d24acb045561c26', 'ETH'); + valid('0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', 'ETH'); + valid('0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359', 'ETH'); + valid('0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB', 'ETH'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETH'); + + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ethereumclassic'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETC'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'etherzero'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'ETZ'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'callisto'); + valid('0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb', 'CLO'); + }); + + it('should return true for correct Ripple addresses', function () { + valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'ripple'); + valid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'XRP'); + valid('r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV', 'XRP'); + valid('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', 'XRP'); + valid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN', 'XRP'); + }); + + it('should return true for correct dash addresses', function () { + valid('Xx4dYKgz3Zcv6kheaqog3fynaKWjbahb6b', 'dash'); + valid('XcY4WJ6Z2Q8w7vcYER1JypC8s2oa3SQ1b1', 'DASH'); + valid('XqMkVUZnqe3w4xvgdZRtZoe7gMitDudGs4', 'dash'); + valid('yPv7h2i8v3dJjfSH4L3x91JSJszjdbsJJA', 'dash', 'testnet'); + valid('XoAAqv3oUYZ6xRjX3brfbf9PotrGanS6Th', 'dash'); + valid('yP5oXZQXBfBf9FyfZDpFiKDypxuNUKUV2E', 'dash', 'testnet'); + }); + + it('should return true for correct neo addresses', function () { + valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neo'); + valid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X', 'NEO'); + }); + + it('should return true for correct neo gas addresses', function () { + valid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTT', 'neogas'); + }); + + it('should return true for correct qtum addresses', function () { + valid('QNjUiD3bVVZwYTc5AhpeQbS1mfb2guyWhe', 'qtum'); + valid('QVZnSrMwKp6AL4FjUPPnfFgsma6j1DXQXu', 'QTUM'); + valid('MCgyroQse81wuv5RwPpY5DXDNxeafzLFJ8', 'QTUM'); + valid('QQYySVc5WEe3g6PnNFYmspqG5CfSG8rnma', 'QTUM'); + valid('MSvJQBJMZs1dhxz7UAWa2si4iyMD2FHQd5', 'QTUM'); + valid('qcSLSxN1sngCWSrKFZ6UC7ri4hhVSdq9SU', 'qtum', 'testnet'); + valid('qJnbEdrm9ybjVqDCaX5SWNBHmZy2X7YbPT', 'qtum', 'testnet'); + valid('qchBPDUYswobzpDmY5DsTStt74sTYQtaQv', 'qtum', 'testnet'); }); + + it('should return true for correct votecoin addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); + }); + + it('should return true for correct bitcoinz addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); + }); + + it('should return true for correct zclassic addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); + }); + + it('should return true for correct hush addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); + }); + + it('should return true for correct zcash addresses', function () { + valid('t1U9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); + valid('t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); + }); + + it('should return true for correct bitcoinprivate addresses', function () { + valid('b1M4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); + //valid('bx....', 'BTCP'); + //valid('nx....', 'bitcoinprivate', 'testnet'); + }); + + it('should return true for correct snowgem addresses', function () { + valid('s1fx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); + valid('s3d27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); + valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); + }); + + it('should return true for correct zencash addresses', function () { + valid('znhiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); + valid('zssEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); + valid('ztmWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); + }); + + it('should return true for correct komodo addresses', function () { + valid('R9R5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); + valid('RAvj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); + //valid('t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + }); + + it('should return true for correct Bankex addresses', function () { + valid('0xeac39e1bc802baae3d4b9cb518f3f60374bbad6c', 'bankex'); + valid('0x45245bc59219eeaaf6cd3f382e078a461ff9de7b', 'BKX'); + valid('0xf40d80FCfa5cdEa0bB1E570c2D52132ac9bC6aEC', 'bankex', 'testnet'); + valid('0x8A7395f281EeCf2B471B689E87Cf4C7fa8bb957d', 'BKX', 'testnet'); + }); + + + it('should return true for correct Cardano addresses', function () { + valid('Ae2tdPwUPEYzs5BRbGcoS3DXvK8mwgggmESz4HqUwMyaS9eNksZGz1LMS9v', 'ada'); + valid('Ae2tdPwUPEYxYNJw1He1esdZYvjmr4NtPzUsGTiqL9zd8ohjZYQcwu6kom7', 'cardano'); + valid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg', 'ada'); + valid('Ae2tdPwUPEZKmwoy3AU3cXb5Chnasj6mvVNxV1H11997q3VW5ihbSfQwGpm', 'ada'); + valid('4swhHtxKapQbj3TZEipgtp7NQzcRWDYqCxXYoPQWjGyHmhxS1w1TjUEszCQT1sQucGwmPQMYdv1FYs3d51KgoubviPBf', 'cardano'); + }); + + it('should return true for correct monero addresses', function () { + valid('47zQ5LAivg6hNCgijXSEFVLX7mke1bgM6YGLFaANDoJbgXDymcAAZvvMNt2PmMpqEe5qRy2zyfMYXdwpmdyitiFh84xnPG2', 'monero'); + valid('48bWuoDG75CXMDHbmPEvUF2hm1vLDic7ZJ7hqRkL65QR9p13AQAX4eEACXNk4YP115Q4KRVZnAvmMBHrcGfv9FvKPZnH6vH', 'XMR'); + valid('88WB4JKdQVhWfkc8cBT9EEJ6vejSAqKJHbV1dXBAXdpgQovtNDNRxfKCS7wB8rHQ5D5zH2Pd1YkyMNNQDie6ZfeZ311fPgn', 'XMR'); + valid('A2be3UvzMtkJtxRYgcCbQt2y7Rp2eLVGqNTWfZeankrWimSMM4y7uMP6B9oAZaHsXTj8KFSerkSkkVRuEuEca9QM8VhxCNU', 'monero', 'testnet'); + + //integrated addresses + valid('4Gd4DLiXzBmbVX2FZZ3Cvu6fUaWACup1qDowprUCje1kSP4FmbftiJMSfV8kWZXNqmVwj4m52xqtgFNUudVmsmGkGvkLcCibWfVUfUFVB7', 'monero'); + valid('4J5sF94AzXgFgx8LuWc9dcWkJkGkD3cL3L2AuhX6QA9jFvSxxj6QhHqHXqM2b2Go7G8RyDzEbHxYd9G26XUUbuJChipEyBz9fENMU2Ua9b', 'XMR'); + + valid('9uXRFi4PZMqhsnthBF6bGdfVnBSZtfKkR7Td8qPM7jUKZeTfR1tLhCoTLqYNE12xuiQg3aWGiLw83bWsqwTRLaM4Jk47xYM', 'XMR', 'testnet'); + valid('9tFTaQM39JXhULZsHauPHhjFrjcGSGXoijEPYoRgAky9Veck2mFp3EifQ2tKHmEHuuUoFfgYRNR2bVaborz5oi8JA8xkqjY', 'monero', 'testnet') + }); + + it('should return true for correct gamecredits addresses', function () { + valid('GU5BBtW9gxSKvAknvFi9yUaXKUNW9zUN2p', 'game'); + valid('GYxQMVzP6YpzX59QNRYqmJeHNtUMYSZPri', 'game'); + }); + + it('should return true for correct monacoin addresses', function () { + valid('MMN1Q1aRVUzanmg9DJjcRYzQSJQoBeQPui', 'mona'); + valid('PFMzNYnBm5X4c9qJkJPkfgdCyd9fuuy2vT', 'mona'); + valid('PCtN7VUYHW8w4g59BaphrfPs8g7pNgAzxn', 'mona'); + valid('MXCcYFGRmsd4d3CcQugFiqG8uarj5tVu76', 'mona'); + valid('MNK1pGsBf9WdoE54fZM9VFhkeYHW6VUf2u', 'mona'); + }); + + it('should return true for correct pivx addresses', function () { + valid('DJXFW9oJJBUX7QKrG6GKvmTs63MYKzwtpZ', 'pivx'); + valid('DEaYb8EHQgyKvX6VXDS3DZQautJrHBmK3T', 'pivx'); + valid('DDeCGR3QSgqsBxVR23bJvteiyYE34ZmxAc', 'pivx'); + valid('DSqQM8DPpBHHoZXHgRdwmaf6hZPEoZcFkh', 'pivx'); + }); + + it('should return true for correct solarcoin addresses', function () { + valid('8VxVLzwB26E2YZZ82o1NcQe96QSM2z6GwW', 'slr'); + valid('8YW5qcTjeyqX5kESsqu2BUdXiedgssegtQ', 'SolarCoin'); + }); + + it('should return true for correct tether addresses', function () { + valid('3MbYQMMmSkC3AgWkj9FMo5LsPTW1zBTwXL', 'usdt'); + valid('1KdXaqcBeoMAFVAPwTmYvDbEq6RnvNPF6J', 'tether'); + }); + + it('should return true for correct expanse addresses', function () { + valid('0xbab463743603a253bdf1f84975b1a9517505ae05', 'exp'); + valid('0x5d0777cb5d6977873904864c6ab531f4b3261f0b', 'expanse'); + }); + + it('should return true for correct waves addresses', function () { + valid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); + valid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHajj', 'waves'); + + valid('3Myrq5QDgRq3nBVRSSv9UYrP36xTtpJND5y', 'waves', 'testnet'); + valid('3My3KZgFQ3CrVHgz6vGRt8687sH4oAA1qp8', 'waves', 'testnet'); + }); + + it('should return true for correct nano addresses', function () { + valid('xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3', 'nano'); + valid('xrb_13ezf4od79h1tgj9aiu4djzcmmguendtjfuhwfukhuucboua8cpoihmh8byo', 'nano'); + valid('xrb_35jjmmmh81kydepzeuf9oec8hzkay7msr6yxagzxpcht7thwa5bus5tomgz9', 'nano'); + valid('xrb_1111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); + valid('xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est', 'nano'); + valid('xrb_3wm37qz19zhei7nzscjcopbrbnnachs4p1gnwo5oroi3qonw6inwgoeuufdp', 'nano'); + valid('xrb_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4', 'nano'); + valid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjmgu', 'nano'); + valid('xrb_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); + valid('nano_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); + }); + + it('should return true for correct siacoin addresses', function () { + valid( + 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', + 'siacoin' + ) + valid( + 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', + 'siacoin' + ) + valid( + 'ab0c327982abfcc6055a6c9551589167d8a73501aca8769f106371fbc937ad100c955c3b7ba9', + 'siacoin' + ) + valid( + 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530373', + 'siacoin' + ) + }) + + it('should return true for correct loki addresses', function () { + // public + valid( + 'L63ymg8cb5aRz1PhXrEQ22PWw9KBhBS8rMsgqbABhTGFfh53U3Rc2iWCJpCPsHZT5hfyt7fPQa612a5Z1tBnGYEA9h6YHnn', + 'loki' + ) + valid( + 'L5QKRGMNpQU3eCAdjMVTCR631bRKqnW1oEWWBEHAtFJLieA5VvuxyyubCd9FczEEatg8jfy39UJZ13npLJqZG6dtMtM99ha', + 'loki' + ) + // integrated + valid( + 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiD1xbPb6dpYo7toNRqk', + 'loki' + ) + valid( + 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiCtWq1AYo1oJTVqgUcQ', + 'loki' + ) + // subaddress + valid( + 'LW1VMYcvWPZZJ2h1pKGEku2y9WeDiAU2VhgrgVgvjybaRuCdcEkg6FhXjVNSd37Bp7fhYH8tVa5T9VmRaYiWyxYdCpEGBg8', + 'loki' + ) + }) + + it('should return true for correct lbry addresses', function () { + valid('bDb6NmobyDVeNGpizWQQBZkYjKCRQBdKdG', 'LBC') + valid('bTFXPcV3a8iVDezogvHTHezWZ1mZGWpPDc', 'lbc') + valid('bK2uEVn6UuwjCTUZ1Dfj5HhWYi9BtqZDDm', 'lbc') + valid('bNEMVqeUZUqTrYUxud5ehnUhtTAiWDXQ5e', 'lbc') + }) + + it('should return true for correct trx addresses', function () { + valid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r', 'trx'); + valid('27bLJCYjbH6MT8DBF9xcrK6yZnm43vx7MNQ', 'trx', 'testnet'); + }); + + it('should return true for correct nem addresses', function () { + valid('NBZMQO7ZPBYNBDUR7F75MAKA2S3DHDCIFG775N3D', 'xem'); + valid('TDWTRGT6GVWCV7GRWFNI45S53PGOJBKNUF3GE6PB', 'xem', 'testnet'); + }); + + it('should return true for correct lsk addresses', function () { + valid('469226551L', 'lsk'); + valid('15823701926930889868L', 'lsk'); + valid('1657699692452120239L', 'lsk'); + valid('555666666999992L', 'lsk'); + valid('6853061742992593192L', 'lsk'); + valid('530464791801L', 'lsk'); + }); + + it('should return true for correct bsv addresses', function () { + valid('qzwryn9fxnpqkf7zt878tp2g9cg8kpl65qh2ml0w0r', 'bsv'); + valid('qp65yngy5uds4wxtrkynptal4f76qzmrh52pa3mpaf', 'bsv'); + valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); + valid('qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); + valid('qz97s7ee0rvwlymtxrwafmvs87x6027jwuf3wepug7', 'bsv'); + valid('bitcoincash:qpp32ssez340wfspnt79h6c4xds4fzf3m5j0cplx0l', 'bsv'); + valid('qqg82u7tq2eahs3gkh9m6kjnmjehr69m5v37alepq4', 'bsv'); + valid('bitcoincash:qrwkk9a3es2wu7mdvzh0vekfvjuzysq8tv7r3hcwr5', 'bsv'); + valid('1DrNXqCj2B8FKyx66RAWDkiEJhw2yrvhT3', 'bsv'); + }); + + it('should return true for correct stellar addresses', function () { + valid('GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB', 'stellar'); + valid('GB7KKHHVYLDIZEKYJPAJUOTBE5E3NJAXPSDZK7O6O44WR3EBRO5HRPVT', 'stellar'); + valid('GD6WVYRVID442Y4JVWFWKWCZKB45UGHJAABBJRS22TUSTWGJYXIUR7N2', 'stellar'); + valid('GBCG42WTVWPO4Q6OZCYI3D6ZSTFSJIXIS6INCIUF23L6VN3ADE4337AP', 'stellar'); + valid('GDFX463YPLCO2EY7NGFMI7SXWWDQAMASGYZXCG2LATOF3PP5NQIUKBPT', 'stellar'); + valid('GBXEODUMM3SJ3QSX2VYUWFU3NRP7BQRC2ERWS7E2LZXDJXL2N66ZQ5PT', 'stellar'); + valid('GAJHORKJKDDEPYCD6URDFODV7CVLJ5AAOJKR6PG2VQOLWFQOF3X7XLOG', 'stellar'); + valid('GACXQEAXYBEZLBMQ2XETOBRO4P66FZAJENDHOQRYPUIXZIIXLKMZEXBJ', 'stellar'); + valid('GDD3XRXU3G4DXHVRUDH7LJM4CD4PDZTVP4QHOO4Q6DELKXUATR657OZV', 'stellar'); + valid('GDTYVCTAUQVPKEDZIBWEJGKBQHB4UGGXI2SXXUEW7LXMD4B7MK37CWLJ', 'stellar'); + }); + + it('should return true for correct xtz(tezos) address', function () { + valid('tz1Lhf4J9Qxoe3DZ2nfe8FGDnvVj7oKjnMY6', 'xtz'); + valid('tz1PyxsQ7xVTa5J7gtBeT7pST5Zi5nk5GSjg', 'xtz'); + valid('tz1LcuQHNVQEWP2fZjk1QYZGNrfLDwrT3SyZ', 'xtz'); + valid('tz1Lhf4J9Qxoe3DZ2nfe8FGDnvVj7oKjnMY6', 'xtz'); + valid('tz1RR6wETy9BeXG3Fjk25YmkSMGHxTtKkhpX', 'xtz'); + valid('tz1h3rQ8wBxFd8L9B3d7Jhaawu6Z568XU3xY', 'xtz'); + valid('KT1EM2LvxxFGB3Svh9p9HCP2jEEYyHjABMbK', 'xtz'); + }); + + it('should return true for correct eos addresses', function () { + valid('bittrexacct1', 'eos'); + valid('binancecleos', 'eos'); + valid('123456789012', 'eos'); + }); + }); + + describe('invalid results', function () { + function commonTests(currency) { + invalid('', currency); //reject blank + invalid('%%@', currency); //reject invalid base58 string + invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency); //reject invalid address + invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency); //reject transaction id's + //testnet + invalid('', currency, 'testnet'); //reject blank + invalid('%%@', currency, 'testnet'); //reject invalid base58 string + invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency, 'testnet'); //reject invalid address + invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency, 'testnet'); //reject transaction id's + } + + it('should return false for incorrect bitcoin addresses', function () { + commonTests('bitcoin'); + }); + + it('should return false for incorrect bitcoincash addresses', function () { + commonTests('bitcoincash'); + }); + + it('should return false for incorrect litecoin addresses', function () { + commonTests('litecoin'); + }); + + it('should return false for incorrect peercoin addresses', function () { + commonTests('peercoin'); + }); + + it('should return false for incorrect dogecoin addresses', function () { + commonTests('dogecoin'); + }); + + it('should return false for incorrect beavercoin addresses', function () { + commonTests('beavercoin'); + }); + + it('should return false for incorrect freicoin addresses', function () { + commonTests('freicoin'); + }); + + it('should return false for incorrect protoshares addresses', function () { + commonTests('protoshares'); + }); + + it('should return false for incorrect megacoin addresses', function () { + commonTests('megacoin'); + }); + + it('should return false for incorrect primecoin addresses', function () { + commonTests('primecoin'); + }); + + it('should return false for incorrect auroracoin addresses', function () { + commonTests('auroracoin'); + }); + + it('should return false for incorrect namecoin addresses', function () { + commonTests('namecoin'); + }); + + it('should return false for incorrect biocoin addresses', function () { + commonTests('biocoin'); + }); + + it('should return false for incorrect garlicoin addresses', function () { + commonTests('garlicoin'); + }); + + it('should return false for incorrect vertcoin addresses', function () { + commonTests('vertcoin'); + }); + + it('should return false for incorrect bitcoingold addresses', function () { + commonTests('bitcoingold'); + }); + + it('should return false for incorrect decred addresses', function () { + commonTests('decred'); + }); + + it('should return false for incorrect gamecredits addresses', function () { + commonTests('game'); + }); + + it('should return false for incorrect monacoin addresses', function () { + commonTests('mona'); + }); + + it('should return false for incorrect solarcoin addresses', function () { + commonTests('slr'); + }); + + it('should return false for incorrect tether addresses', function () { + commonTests('usdt'); + }); + + it('should return false for incorrect expanse addresses', function () { + commonTests('exp'); + }); + + it('should return false for incorrect usdt addresses', function () { + commonTests('usdt'); + }); + + it('should return false for incorrect bankex addresses', function () { + invalid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'bankex'); + invalid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd', 'BKX'); + invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bankex', 'testnet'); + invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'BKX', 'testnet'); + }); + + it('should return false for incorrect digibyte addresses', function () { + commonTests('digibyte'); + }); + + it('should return false for incorrect eip55 addresses', function () { + invalid('6xAff4d6793F584a473348EbA058deb8caad77a288', 'ethereum'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereum'); + invalid('0XD1220A0CF47C7B9BE7A2E6BA89F429762E7B9ADB', 'ethereum'); + invalid('aFf4d6793f584a473348ebA058deb8caad77a2885', 'ethereum'); + invalid('0xff4d6793F584a473', 'ethereum'); + + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereumclassic'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'etherzero'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'callisto'); + }); + + it('should return false for incorrect ripple addresses', function () { + invalid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCN', 'ripple'); + invalid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhMN', 'XRP'); + invalid('6xAff4d6793F584a473348EbA058deb8ca', 'ripple'); + invalid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'ripple'); + }); + + it('should return false for incorrect dash addresses', function () { + commonTests('dash'); + }); + + it('should return false for incorrect neo addresses', function () { + commonTests('neo'); + invalid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTa', 'neo'); + invalid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ10', 'NEO'); + }); + + it('should return false for incorrect qtum addresses', function () { + commonTests('qtum'); + invalid('QNPhBbVhDghASxcUh2vHotQUgNeLRFTcfb', 'qtum'); + invalid('QOPhBbVhDghASxcUh2vHotQUgNeLRFTcfa', 'QTUM'); + }); + + it('should return false for incorrect votecoin addresses', function () { + commonTests('votecoin'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); + }); + + it('should return false for incorrect bitcoinz addresses', function () { + commonTests('bitcoinz'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); + }); + + it('should return false for incorrect zclassic addresses', function () { + commonTests('zclassic'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); + }); + + it('should return false for incorrect hush addresses', function () { + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); + }); + + it('should return false for incorrect zcash addresses', function () { + commonTests('zcash'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); + }); + + it('should return false for incorrect bitcoinprivate addresses', function () { + commonTests('bitcoinprivate'); + invalid('b1Y4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); + //invalid('bx....', 'BTCP'); + //invalid('nx....', 'bitcoinprivate', 'testnet'); + }); + + it('should return false for incorrect snowgem addresses', function () { + commonTests('snowgem'); + invalid('s1Yx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); + invalid('s3Y27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); + }); + + it('should return false for incorrect zencash addresses', function () { + commonTests('zencash'); + invalid('znYiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); + invalid('zsYEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); + invalid('ztYWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); + }); + + it('should return false for incorrect komodo addresses', function () { + commonTests('komodo'); + invalid('R9Y5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); + invalid('RAYj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); + //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + }); + + it('should return false for incorrect cardano addresses', function () { + commonTests('cardano'); + invalid('Ae2tdPwUPEYxYNJw1He1esdZYvjmr4NtPzUsGTiqL9zd8ohjZYQcwu6lom7', 'cardano'); + invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg1', 'cardano'); + invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRT', 'ada'); + //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + }); + + it('should return false for incorrect monero addresses', function () { + commonTests('monero'); + invalid('4AWygwA3hHNE4e4Yr9PtRWJiorXTjZkCi57g4ExYzfXDFFQ8DRFEFyui1dLqVknpqQjGUBdTMbgaFAZaDbrVHdk3GAKBZ3E', 'monero'); + invalid('44643dtxcxjgMWEQLo6mh1c4d9Zxx9GbgK9hEj9iGSiFEryCkbwHyJ3JqxZJRqeC3Hb7ZBLKq5NkaJwR1x95EYnR1bTgN6d', 'xmr'); + invalid('A17N9ztrxjQD3v3JJtHGvHVnq6BAbujDNEuensB6PFwBYFpkjAicih8hDtX76HBuEag5NeaCuMZmRMe6eE5NMRGxFTQn8nJ', 'monero', 'testnet'); + + //integrated + invalid('4LNSCKNSTPNbJYkyAEgL966eHJHLDHiq1PpwKoiFBybcSqNGYfLBJApC62uQEeGAFxfYEd29uXBBrJFo7DhKqFVNi3GhmN79EtD5dgycYz', 'monero'); + invalid('4JpzTwf3i1GeCV76beVr19179oa8j1L8xNSC1bXMtAxxdf4aTTLqubL8EvXfQmUGKt9MMigFtKy91VtoTTSfg1LU7LocPruT6KcGC9RKJV', 'xmr'); + }); + + it('should return false for incorrect waves addresses', function () { + commonTests('waves'); + invalid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs1', 'waves'); + invalid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHaj', 'waves'); + invalid('2P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); + + invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'waves', 'testnet'); + invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'waves', 'testnet'); + }); + + it('should return false for incorrect nano addresses', function () { + commonTests('nano'); + invalid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); + invalid('nano_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nano'); + invalid('nano_111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); + }); + + it('should return false for incorrect siacoin addresses', function () { + commonTests('siacoin') + invalid( + 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372', + 'siacoin' + ) + }) + + it('should return false for incorrect lbry addresses', function () { + commonTests('lbc') + invalid('ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372') + }) + + it('should return false for incorrect tron addresses', function () { + commonTests('trx'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'trx'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'trx'); + }); + + it('should return false for incorrect nem addresses', function () { + commonTests('nem'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nem'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'nem'); + + invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'nem', 'testnet'); + invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'nem', 'testnet'); + }); + //15823701926930889868L + it('should return false for incorrect lsk addresses', function () { + commonTests('lsk'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'lsk'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'lsk'); + + invalid('158237019269308898689L', 'lsk'); + invalid('158237A192B930C898689L', 'lsk'); + }); + + it('should return false for incorrect bsv addresses', function () { + commonTests('bsv'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'bsv'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'bsv'); + + invalid('158237019269308898689L', 'bsv'); + invalid('158237A192B930C898689L', 'bsv'); + invalid('bitcoin:qzpuefrpg3kl2ykQe52rxn96pd3Kp4qudywr5pyrsf', 'bsv'); + invalid('pzuefrpg3kl2ykqe52rxn96pd3kp4qudywr5py', 'bsv'); + invalid('rlt2c2wuxr644encp3as0hygtj9djrsaumku3cex5', 'bsv'); + invalid('qra607y4wnkmnpy3wcmrxmltzkrxywcq85c7watpdx09', 'bsv'); + }); + + it('should return false for incorrect stellar addresses', function () { + commonTests('stellar'); + invalid('SBGWKM3CD4IL47QN6X54N6Y33T3JDNVI6AIJ6CD5IM47HG3IG4O36XCU', 'stellar'); + invalid('GBPXX0A5N4JYPESHAADMQKBPWZWQDQ64ZV6ZL2S3LAGW4SY7NTCMWIVL', 'stellar'); + invalid('GCFZB6L25D26RQFDWSSBDEYQ32JHLRMTT44ZYE3DZQUTYOL7WY43PLBG++', 'stellar'); + invalid('GADE5QJ2TY7S5ZB65Q43DFGWYWCPHIYDJ2326KZGAGBN7AE5UY6JVDRRA', 'stellar'); + invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2', 'stellar'); + invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2T', 'stellar'); + invalid('GDXIIZTKTLVYCBHURXL2UPMTYXOVNI7BRAEFQCP6EZCY4JLKY4VKFNLT', 'stellar'); + invalid('SAB5556L5AN5KSR5WF7UOEFDCIODEWEO7H2UR4S5R62DFTQOGLKOVZDY', 'stellar'); + invalid('gWRYUerEKuz53tstxEuR3NCkiQDcV4wzFHmvLnZmj7PUqxW2wt', 'stellar'); + invalid('g4VPBPrHZkfE8CsjuG2S4yBQNd455UWmk', 'stellar'); + }); + + it('should return false for incorrect xtz(tezos) address', function () { + commonTests('xtz'); + invalid('SBGWKM3CD4IL47QN6X54N6Y33T3JDNVI6AIJ6CD5IM47HG3IG4O36XCU', 'xtz'); + invalid('GBPXX0A5N4JYPESHAADMQKBPWZWQDQ64ZV6ZL2S3LAGW4SY7NTCMWIVL', 'xtz'); + invalid('GCFZB6L25D26RQFDWSSBDEYQ32JHLRMTT44ZYE3DZQUTYOL7WY43PLBG', 'xtz'); + invalid('tz1RR6wy9BeXG3Fjk25YmkSMGHxTtKkhpX', 'xtz'); + invalid('tz1h3rQ8wBxFd8L9B3d7JhaPQawu6Z568XU3xY', 'xtz'); + invalid('tz1Lhf4J9Qxoe4DZ2nfe8FGDnvVj7oKjnMY6', 'xtz'); + invalid('KT1E2LvxxFGB3Svh9p9HCP2jEEYyHjABMbK', 'xtz'); + + }); + + it('should return false for incorrect eos addresses', function () { + commonTests('eos'); + invalid('1234567890123', 'eos'); + invalid('12345678901', 'eos'); + invalid('12345678901@', 'eos'); + }); + + }); + + it('should return true for correct monero addresses', function () { + valid('47zQ5LAivg6hNCgijXSEFVLX7mke1bgM6YGLFaANDoJbgXDymcAAZvvMNt2PmMpqEe5qRy2zyfMYXdwpmdyitiFh84xnPG2', 'monero'); + valid('48bWuoDG75CXMDHbmPEvUF2hm1vLDic7ZJ7hqRkL65QR9p13AQAX4eEACXNk4YP115Q4KRVZnAvmMBHrcGfv9FvKPZnH6vH', 'XMR'); + valid('A2be3UvzMtkJtxRYgcCbQt2y7Rp2eLVGqNTWfZeankrWimSMM4y7uMP6B9oAZaHsXTj8KFSerkSkkVRuEuEca9QM8VhxCNU', 'monero', 'testnet'); + + //integrated addresses + valid('4Gd4DLiXzBmbVX2FZZ3Cvu6fUaWACup1qDowprUCje1kSP4FmbftiJMSfV8kWZXNqmVwj4m52xqtgFNUudVmsmGkGvkLcCibWfVUfUFVB7', 'monero'); + valid('4J5sF94AzXgFgx8LuWc9dcWkJkGkD3cL3L2AuhX6QA9jFvSxxj6QhHqHXqM2b2Go7G8RyDzEbHxYd9G26XUUbuJChipEyBz9fENMU2Ua9b', 'XMR'); + + //stagenet public address + valid('5BAP9qLbRseYrGneYVRaFANMajuaD4KZrf3fGWvt5cVDR1xUXm6qoFYLkgU6Vp12fs2R24r4269inAWHFEdsLnE87rGCxYK', 'XMR', 'stagenet'); + + //stagenet integrated address + valid('5Ls4AeA639AYrGneYVRaFANMajuaD4KZrf3fGWvt5cVDR1xUXm6qoFYLkgU6Vp12fs2R24r4269inAWHFEdsLnE8BCU5Q2gDkbq2HYDrn2', 'monero', 'both'); + }); + + it('should return true for correct gamecredits addresses', function () { + valid('GU5BBtW9gxSKvAknvFi9yUaXKUNW9zUN2p', 'game'); + valid('GYxQMVzP6YpzX59QNRYqmJeHNtUMYSZPri', 'game'); + }); + + it('should return true for correct monacoin addresses', function () { + valid('MMN1Q1aRVUzanmg9DJjcRYzQSJQoBeQPui', 'mona'); + valid('PFMzNYnBm5X4c9qJkJPkfgdCyd9fuuy2vT', 'mona'); + valid('PCtN7VUYHW8w4g59BaphrfPs8g7pNgAzxn', 'mona'); + valid('MXCcYFGRmsd4d3CcQugFiqG8uarj5tVu76', 'mona'); + valid('MNK1pGsBf9WdoE54fZM9VFhkeYHW6VUf2u', 'mona'); + }); + + it('should return true for correct pivx addresses', function () { + valid('DJXFW9oJJBUX7QKrG6GKvmTs63MYKzwtpZ', 'pivx'); + valid('DEaYb8EHQgyKvX6VXDS3DZQautJrHBmK3T', 'pivx'); + valid('DDeCGR3QSgqsBxVR23bJvteiyYE34ZmxAc', 'pivx'); + valid('DSqQM8DPpBHHoZXHgRdwmaf6hZPEoZcFkh', 'pivx'); + }); + + it('should return true for correct solarcoin addresses', function () { + valid('8VxVLzwB26E2YZZ82o1NcQe96QSM2z6GwW', 'slr'); + valid('8YW5qcTjeyqX5kESsqu2BUdXiedgssegtQ', 'SolarCoin'); + }); + + it('should return true for correct tether addresses', function () { + valid('3MbYQMMmSkC3AgWkj9FMo5LsPTW1zBTwXL', 'usdt'); + valid('1KdXaqcBeoMAFVAPwTmYvDbEq6RnvNPF6J', 'tether'); + }); + + it('should return true for correct expanse addresses', function () { + valid('0xbab463743603a253bdf1f84975b1a9517505ae05', 'exp'); + valid('0x5d0777cb5d6977873904864c6ab531f4b3261f0b', 'expanse'); + }); + + it('should return true for correct waves addresses', function () { + valid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); + valid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHajj', 'waves'); + + valid('3Myrq5QDgRq3nBVRSSv9UYrP36xTtpJND5y', 'waves', 'testnet'); + valid('3My3KZgFQ3CrVHgz6vGRt8687sH4oAA1qp8', 'waves', 'testnet'); + }); + + it('should return true for correct nano addresses', function () { + valid('xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3', 'nano'); + valid('xrb_13ezf4od79h1tgj9aiu4djzcmmguendtjfuhwfukhuucboua8cpoihmh8byo', 'nano'); + valid('xrb_35jjmmmh81kydepzeuf9oec8hzkay7msr6yxagzxpcht7thwa5bus5tomgz9', 'nano'); + valid('xrb_1111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); + valid('xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est', 'nano'); + valid('xrb_3wm37qz19zhei7nzscjcopbrbnnachs4p1gnwo5oroi3qonw6inwgoeuufdp', 'nano'); + valid('xrb_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4', 'nano'); + valid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjmgu', 'nano'); + valid('xrb_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); + valid('nano_1q79ahdr36uqn38p5tp5sqwkn73rnpj1k8obtuetdbjcx37d5gahhd1u9cuh', 'nano'); + }); + + it('should return true for correct siacoin addresses', function () { + valid( + 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', + 'siacoin' + ) + valid( + 'a9b01c85163638682b170d82de02b8bb99ba86092e9ab1b0d25111284fe618e93456915820f1', + 'siacoin' + ) + valid( + 'ab0c327982abfcc6055a6c9551589167d8a73501aca8769f106371fbc937ad100c955c3b7ba9', + 'siacoin' + ) + valid( + 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530373', + 'siacoin' + ) + }) + + it('should return true for correct loki addresses', function () { + // public + valid( + 'L63ymg8cb5aRz1PhXrEQ22PWw9KBhBS8rMsgqbABhTGFfh53U3Rc2iWCJpCPsHZT5hfyt7fPQa612a5Z1tBnGYEA9h6YHnn', + 'loki' + ) + valid( + 'L5QKRGMNpQU3eCAdjMVTCR631bRKqnW1oEWWBEHAtFJLieA5VvuxyyubCd9FczEEatg8jfy39UJZ13npLJqZG6dtMtM99ha', + 'loki' + ) + // integrated + valid( + 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiD1xbPb6dpYo7toNRqk', + 'loki' + ) + valid( + 'LK8CGQ17G9R3ys3Xf33wCeViD2B95jgdpjAhcRsjuheJ784dumXn7g3RPAzedWpFq364jJKYL9dkQ8mY66sZG9BiCtWq1AYo1oJTVqgUcQ', + 'loki' + ) + // subaddress + valid( + 'LW1VMYcvWPZZJ2h1pKGEku2y9WeDiAU2VhgrgVgvjybaRuCdcEkg6FhXjVNSd37Bp7fhYH8tVa5T9VmRaYiWyxYdCpEGBg8', + 'loki' + ) + }) + + it('should return true for correct lbry addresses', function () { + valid('bNEMVqeUZUqTrYUxud5ehnUhtTAiWDXQ5e', 'lbc') + valid('bDb6NmobyDVeNGpizWQQBZkYjKCRQBdKdG', 'LBC') + valid('bTFXPcV3a8iVDezogvHTHezWZ1mZGWpPDc', 'lbc') + valid('bK2uEVn6UuwjCTUZ1Dfj5HhWYi9BtqZDDm', 'LBRY Credits') + }) + + it('should return true for correct trx addresses', function () { + valid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r', 'trx'); + valid('27bLJCYjbH6MT8DBF9xcrK6yZnm43vx7MNQ', 'trx', 'testnet'); + }); + + it('should return true for correct nem addresses', function () { + valid('NBZMQO7ZPBYNBDUR7F75MAKA2S3DHDCIFG775N3D', 'xem'); + valid('TDWTRGT6GVWCV7GRWFNI45S53PGOJBKNUF3GE6PB', 'xem', 'testnet'); + }); + + it('should return true for correct lsk addresses', function () { + valid('469226551L', 'lsk'); + valid('15823701926930889868L', 'lsk'); + valid('1657699692452120239L', 'lsk'); + valid('555666666999992L', 'lsk'); + valid('6853061742992593192L', 'lsk'); + valid('530464791801L', 'lsk'); + }); + + it('should return true for correct bsv addresses', function () { + valid('qzwryn9fxnpqkf7zt878tp2g9cg8kpl65qh2ml0w0r', 'bsv'); + valid('qp65yngy5uds4wxtrkynptal4f76qzmrh52pa3mpaf', 'bsv'); + valid('bitcoincash:qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); + valid('qq4v32mtagxac29my6gwj6fd4tmqg8rysu23dax807', 'bsv'); + valid('qz97s7ee0rvwlymtxrwafmvs87x6027jwuf3wepug7', 'bsv'); + valid('bitcoincash:qpp32ssez340wfspnt79h6c4xds4fzf3m5j0cplx0l', 'bsv'); + valid('qqg82u7tq2eahs3gkh9m6kjnmjehr69m5v37alepq4', 'bsv'); + valid('bitcoincash:qrwkk9a3es2wu7mdvzh0vekfvjuzysq8tv7r3hcwr5', 'bsv'); + valid('1DrNXqCj2B8FKyx66RAWDkiEJhw2yrvhT3', 'bsv'); + }); + + it('should return true for correct stellar addresses', function () { + valid('GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB', 'stellar'); + valid('GB7KKHHVYLDIZEKYJPAJUOTBE5E3NJAXPSDZK7O6O44WR3EBRO5HRPVT', 'stellar'); + valid('GD6WVYRVID442Y4JVWFWKWCZKB45UGHJAABBJRS22TUSTWGJYXIUR7N2', 'stellar'); + valid('GBCG42WTVWPO4Q6OZCYI3D6ZSTFSJIXIS6INCIUF23L6VN3ADE4337AP', 'stellar'); + valid('GDFX463YPLCO2EY7NGFMI7SXWWDQAMASGYZXCG2LATOF3PP5NQIUKBPT', 'stellar'); + valid('GBXEODUMM3SJ3QSX2VYUWFU3NRP7BQRC2ERWS7E2LZXDJXL2N66ZQ5PT', 'stellar'); + valid('GAJHORKJKDDEPYCD6URDFODV7CVLJ5AAOJKR6PG2VQOLWFQOF3X7XLOG', 'stellar'); + valid('GACXQEAXYBEZLBMQ2XETOBRO4P66FZAJENDHOQRYPUIXZIIXLKMZEXBJ', 'stellar'); + valid('GDD3XRXU3G4DXHVRUDH7LJM4CD4PDZTVP4QHOO4Q6DELKXUATR657OZV', 'stellar'); + valid('GDTYVCTAUQVPKEDZIBWEJGKBQHB4UGGXI2SXXUEW7LXMD4B7MK37CWLJ', 'stellar'); + }); +}); + +describe('invalid results', function () { + function commonTests(currency) { + invalid('', currency); //reject blank + invalid('%%@', currency); //reject invalid base58 string + invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency); //reject invalid address + invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency); //reject transaction id's + //testnet + invalid('', currency, 'testnet'); //reject blank + invalid('%%@', currency, 'testnet'); //reject invalid base58 string + invalid('1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa', currency, 'testnet'); //reject invalid address + invalid('bd839e4f6fadb293ba580df5dea7814399989983', currency, 'testnet'); //reject transaction id's + } + + it('should return false for incorrect bitcoin addresses', function () { + commonTests('bitcoin'); + }); + + it('should return false for incorrect bitcoincash addresses', function () { + commonTests('bitcoincash'); + }); + + it('should return false for incorrect litecoin addresses', function () { + commonTests('litecoin'); + }); + + it('should return false for incorrect peercoin addresses', function () { + commonTests('peercoin'); + }); + + it('should return false for incorrect dogecoin addresses', function () { + commonTests('dogecoin'); + }); + + it('should return false for incorrect beavercoin addresses', function () { + commonTests('beavercoin'); + }); + + it('should return false for incorrect freicoin addresses', function () { + commonTests('freicoin'); + }); + + it('should return false for incorrect protoshares addresses', function () { + commonTests('protoshares'); + }); + + it('should return false for incorrect megacoin addresses', function () { + commonTests('megacoin'); + }); + + it('should return false for incorrect primecoin addresses', function () { + commonTests('primecoin'); + }); + + it('should return false for incorrect auroracoin addresses', function () { + commonTests('auroracoin'); + }); + + it('should return false for incorrect namecoin addresses', function () { + commonTests('namecoin'); + }); + + it('should return false for incorrect biocoin addresses', function () { + commonTests('biocoin'); + }); + + it('should return false for incorrect garlicoin addresses', function () { + commonTests('garlicoin'); + }); + + it('should return false for incorrect vertcoin addresses', function () { + commonTests('vertcoin'); + }); + + it('should return false for incorrect bitcoingold addresses', function () { + commonTests('bitcoingold'); + }); + + it('should return false for incorrect decred addresses', function () { + commonTests('decred'); + }); + + it('should return false for incorrect gamecredits addresses', function () { + commonTests('game'); + }); + + it('should return false for incorrect monacoin addresses', function () { + commonTests('mona'); + }); + + it('should return false for incorrect solarcoin addresses', function () { + commonTests('slr'); + }); + + it('should return false for incorrect tether addresses', function () { + commonTests('usdt'); + }); + + it('should return false for incorrect expanse addresses', function () { + commonTests('exp'); + }); + + it('should return false for incorrect usdt addresses', function () { + commonTests('usdt'); + }); + + it('should return false for incorrect bankex addresses', function () { + invalid('1SQHtwR5oJRKLfiWQ2APsAd9miUc4k2ez', 'bankex'); + invalid('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd', 'BKX'); + invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bankex', 'testnet'); + invalid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'BKX', 'testnet'); + }); + + it('should return false for incorrect digibyte addresses', function () { + commonTests('digibyte'); + }); + + it('should return false for incorrect eip55 addresses', function () { + invalid('6xAff4d6793F584a473348EbA058deb8caad77a288', 'ethereum'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereum'); + invalid('0XD1220A0CF47C7B9BE7A2E6BA89F429762E7B9ADB', 'ethereum'); + invalid('aFf4d6793f584a473348ebA058deb8caad77a2885', 'ethereum'); + invalid('0xff4d6793F584a473', 'ethereum'); + + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'ethereumclassic'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'etherzero'); + invalid('0x02fcd51aAbB814FfFe17908fbc888A8975D839A5', 'callisto'); + }); + + it('should return false for incorrect ripple addresses', function () { + invalid('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCN', 'ripple'); + invalid('rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhMN', 'XRP'); + invalid('6xAff4d6793F584a473348EbA058deb8ca', 'ripple'); + invalid('DJ53hTyLBdZp2wMi5BsCS3rtEL1ioYUkva', 'ripple'); + }); + + it('should return false for incorrect dash addresses', function () { + commonTests('dash'); + }); + + it('should return false for incorrect neo addresses', function () { + commonTests('neo'); + invalid('AR4QmqYENiZAD6oXe7ftm6eDcwtHk7rVTa', 'neo'); + invalid('AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ10', 'NEO'); + }); + + it('should return false for incorrect qtum addresses', function () { + commonTests('qtum'); + invalid('QNPhBbVhDghASxcUh2vHotQUgNeLRFTcfb', 'qtum'); + invalid('QOPhBbVhDghASxcUh2vHotQUgNeLRFTcfa', 'QTUM'); + }); + + it('should return false for incorrect votecoin addresses', function () { + commonTests('votecoin'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'votecoin'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'VOT'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'votecoin', 'testnet'); + }); + + it('should return false for incorrect bitcoinz addresses', function () { + commonTests('bitcoinz'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'bitcoinz'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'BTCZ'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'bitcoinz', 'testnet'); + }); + + it('should return false for incorrect zclassic addresses', function () { + commonTests('zclassic'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zclassic'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZCL'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zclassic', 'testnet'); + }); + + it('should return false for incorrect hush addresses', function () { + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'hush'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'HUSH'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'hush', 'testnet'); + }); + + it('should return false for incorrect zcash addresses', function () { + commonTests('zcash'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'zcash'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'ZEC'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'zcash', 'testnet'); + }); + + it('should return false for incorrect bitcoinprivate addresses', function () { + commonTests('bitcoinprivate'); + invalid('b1Y4XXPFhwMb1SP33yhzn3h9qWXjujkgep4', 'bitcoinprivate'); + //invalid('bx....', 'BTCP'); + //invalid('nx....', 'bitcoinprivate', 'testnet'); + }); + + it('should return false for incorrect snowgem addresses', function () { + commonTests('snowgem'); + invalid('s1Yx7WBkjB4UH6qQjPp6Ysmtr1C1JiTK2Yw', 'snowgem'); + invalid('s3Y27MhkBRt3ha2UuxhjXaYF4DCnttTMnL1', 'SNG'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'snowgem', 'testnet'); + }); + + it('should return false for incorrect zencash addresses', function () { + commonTests('zencash'); + invalid('znYiGGfYRepxkBjXYvA2kFrXiC351i9ta4z', 'zencash'); + invalid('zsYEdGnZCQ9G86LZFtbynMn1hYTVhn6eYCL', 'ZEN'); + invalid('ztYWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); + }); + + it('should return false for incorrect komodo addresses', function () { + commonTests('komodo'); + invalid('R9Y5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); + invalid('RAYj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); + //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + }); + + it('should return false for incorrect cardano addresses', function () { + commonTests('cardano'); + invalid('Ae2tdPwUPEYxYNJw1He1esdZYvjmr4NtPzUsGTiqL9zd8ohjZYQcwu6lom7', 'cardano'); + invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg1', 'cardano'); + invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRT', 'ada'); + //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + }); + + it('should return false for incorrect monero addresses', function () { + commonTests('monero'); + invalid('4AWygwA3hHNE4e4Yr9PtRWJiorXTjZkCi57g4ExYzfXDFFQ8DRFEFyui1dLqVknpqQjGUBdTMbgaFAZaDbrVHdk3GAKBZ3E', 'monero'); + invalid('44643dtxcxjgMWEQLo6mh1c4d9Zxx9GbgK9hEj9iGSiFEryCkbwHyJ3JqxZJRqeC3Hb7ZBLKq5NkaJwR1x95EYnR1bTgN6d', 'xmr'); + invalid('A17N9ztrxjQD3v3JJtHGvHVnq6BAbujDNEuensB6PFwBYFpkjAicih8hDtX76HBuEag5NeaCuMZmRMe6eE5NMRGxFTQn8nJ', 'monero', 'testnet'); + + //integrated + invalid('4LNSCKNSTPNbJYkyAEgL966eHJHLDHiq1PpwKoiFBybcSqNGYfLBJApC62uQEeGAFxfYEd29uXBBrJFo7DhKqFVNi3GhmN79EtD5dgycYz', 'monero'); + invalid('4JpzTwf3i1GeCV76beVr19179oa8j1L8xNSC1bXMtAxxdf4aTTLqubL8EvXfQmUGKt9MMigFtKy91VtoTTSfg1LU7LocPruT6KcGC9RKJV', 'xmr'); + }); + + it('should return false for incorrect waves addresses', function () { + commonTests('waves'); + invalid('3P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs1', 'waves'); + invalid('3P4eeU7v1LMHQFwwT2GW9W99c6vZyytHaj', 'waves'); + invalid('2P93mVrYnQ4ahaRMYwA2BeWY32eDxTpLVEs', 'waves'); + + invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'waves', 'testnet'); + invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'waves', 'testnet'); + }); + + it('should return false for incorrect nano addresses', function () { + commonTests('nano'); + invalid('xrb_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); + invalid('nano_1f5e4w33ndqbkx4bw5jtp13kp5xghebfxcmw9hdt1f7goid1s4373w6tjdgu', 'nano'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nano'); + invalid('nano_111111111111111111111111111111111111111111111111111hifc8npp', 'nano'); + }); + + it('should return false for incorrect siacoin addresses', function () { + commonTests('siacoin') + invalid( + 'ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372', + 'siacoin' + ) + }) + + it('should return false for incorrect lbry addresses', function () { + commonTests('lbc') + invalid('ffe1308c044ade30392a0cdc1fd5a4dbe94f9616a95faf888ed36123d9e711557aa497530372') + }) + + it('should return false for incorrect tron addresses', function () { + commonTests('trx'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'trx'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'trx'); + }); + + it('should return false for incorrect nem addresses', function () { + commonTests('nem'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'nem'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'nem'); + + invalid('3Myrq5QDgRq3nBVRSSv9UYRP36xTtpJND5y', 'nem', 'testnet'); + invalid('3My3KZgFQ3CrVHgz6vGRt8787sH4oAA1qp8', 'nem', 'testnet'); + }); + //15823701926930889868L + it('should return false for incorrect lsk addresses', function () { + commonTests('lsk'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'lsk'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'lsk'); + + invalid('158237019269308898689L', 'lsk'); + invalid('158237A192B930C898689L', 'lsk'); + }); + + it('should return false for incorrect bsv addresses', function () { + commonTests('bsv'); + invalid('xrb_1111111112111111111111111111111111111111111111111111hifc8npp', 'bsv'); + invalid('TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg31', 'bsv'); + + invalid('158237019269308898689L', 'bsv'); + invalid('158237A192B930C898689L', 'bsv'); + invalid('bitcoin:qzpuefrpg3kl2ykQe52rxn96pd3Kp4qudywr5pyrsf', 'bsv'); + invalid('pzuefrpg3kl2ykqe52rxn96pd3kp4qudywr5py', 'bsv'); + invalid('rlt2c2wuxr644encp3as0hygtj9djrsaumku3cex5', 'bsv'); + invalid('qra607y4wnkmnpy3wcmrxmltzkrxywcq85c7watpdx09', 'bsv'); + }); + + it('should return false for incorrect stellar addresses', function () { + commonTests('stellar'); + invalid('SBGWKM3CD4IL47QN6X54N6Y33T3JDNVI6AIJ6CD5IM47HG3IG4O36XCU', 'stellar'); + invalid('GBPXX0A5N4JYPESHAADMQKBPWZWQDQ64ZV6ZL2S3LAGW4SY7NTCMWIVL', 'stellar'); + invalid('GCFZB6L25D26RQFDWSSBDEYQ32JHLRMTT44ZYE3DZQUTYOL7WY43PLBG++', 'stellar'); + invalid('GADE5QJ2TY7S5ZB65Q43DFGWYWCPHIYDJ2326KZGAGBN7AE5UY6JVDRRA', 'stellar'); + invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2', 'stellar'); + invalid('GB6OWYST45X57HCJY5XWOHDEBULB6XUROWPIKW77L5DSNANBEQGUPADT2T', 'stellar'); + invalid('GDXIIZTKTLVYCBHURXL2UPMTYXOVNI7BRAEFQCP6EZCY4JLKY4VKFNLT', 'stellar'); + invalid('SAB5556L5AN5KSR5WF7UOEFDCIODEWEO7H2UR4S5R62DFTQOGLKOVZDY', 'stellar'); + invalid('gWRYUerEKuz53tstxEuR3NCkiQDcV4wzFHmvLnZmj7PUqxW2wt', 'stellar'); + invalid('g4VPBPrHZkfE8CsjuG2S4yBQNd455UWmk', 'stellar'); + }); }); From f90438fdc877324f95026ee1b9d3105916e0abcb Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Thu, 7 May 2020 21:58:32 +0200 Subject: [PATCH 097/108] updating yarn before running travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 34ed7e4e..750b05e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,7 @@ language: node_js node_js: - "8" - "10" + - "12" - "stable" +before_install: + - npm install -g yarn --cache-min 999999999 From bddefc7749c4fb98387b84b9754e34e1962553df Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Thu, 7 May 2020 22:00:40 +0200 Subject: [PATCH 098/108] fixing travis build added install command --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 750b05e3..5ab390b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,5 @@ node_js: - "stable" before_install: - npm install -g yarn --cache-min 999999999 +install: + - yarn From 8be8d08effeb003c84a1260256fad5fbc0412bed Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Thu, 7 May 2020 22:03:58 +0200 Subject: [PATCH 099/108] removed node 8 from travis as it is out of lts maintenance. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5ab390b2..46b9b018 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ addons: chrome: stable language: node_js node_js: - - "8" - "10" - "12" - "stable" From 7f01b417351cab6ec1058a3f04c4a68b95f73172 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Sat, 25 Jul 2020 20:41:42 +0200 Subject: [PATCH 100/108] Added VET and StormX --- README.md | 2 + dist/wallet-address-validator.js | 793 +++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- package.json | 313 ++++------ src/currencies.js | 791 +++++++++++++------------- test/wallet_address_validator.js | 15 + yarn.lock | 822 +++++++++++++++------------ 7 files changed, 1399 insertions(+), 1339 deletions(-) diff --git a/README.md b/README.md index abf269b7..d340cb32 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ npm install multicoin-address-validator * Stellar/xlm `'Stellar'` or `'xlm'` * Storj/storj `'Storj'` or `'storj'` * Storm/storm `'Storm'` or `'storm'` +* StormX/stmx `'StormX'` or `'stmx'` * Swarm City/swt `'Swarm City'` or `'swt'` * Synthetix Network/snx `'Synthetix Network'` or `'snx'` * TEMCO/temco `'TEMCO'` or `'temco'` @@ -125,6 +126,7 @@ npm install multicoin-address-validator * Tezos/xtz `'Tezos'` or `'xtz'` * Tron/trx `'Tron'` or `'trx'` * TrueUSD/tusd `'TrueUSD'` or `'tusd'` +* VeChain/vet `'VeChain'` or `'vet'` * VertCoin/vtc `'VertCoin'` or `'vtc'` * Viberate/vib `'Viberate'` or `'vib'` * VoteCoin/vot `'VoteCoin'` or `'vot'` diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index e2996f97..d9ee2964 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -10789,397 +10789,397 @@ var XTZValidator = require('./tezos_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ - name: 'Bitcoin', - symbol: 'btc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26'] }, - validator: BTCValidator -}, { - name: 'BitcoinCash', - symbol: 'bch', - regexp: '^[qQpP]{1}[0-9a-zA-Z]{41}$', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BCHValidator -}, { - name: 'Bitcoin SV', - symbol: 'bsv', - regexp: '^[qQ]{1}[0-9a-zA-Z]{41}$', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BCHValidator -}, { - name: 'LiteCoin', - symbol: 'ltc', - addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, - validator: BTCValidator -}, { - name: 'PeerCoin', - symbol: 'ppc', - addressTypes: { prod: ['37', '75'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'DogeCoin', - symbol: 'doge', - addressTypes: { prod: ['1e', '16'], testnet: ['71', 'c4'] }, - validator: BTCValidator -}, { - name: 'BeaverCoin', - symbol: 'bvc', - addressTypes: { prod: ['19', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator, -}, { - name: 'FreiCoin', - symbol: 'frc', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'ProtoShares', - symbol: 'pts', - addressTypes: { prod: ['38', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'MegaCoin', - symbol: 'mec', - addressTypes: { prod: ['32', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'PrimeCoin', - symbol: 'xpm', - addressTypes: { prod: ['17', '53'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'AuroraCoin', - symbol: 'aur', - addressTypes: { prod: ['17', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'NameCoin', - symbol: 'nmc', - addressTypes: { prod: ['34'], testnet: [] }, - validator: BTCValidator -}, { - name: 'BioCoin', - symbol: 'bio', - addressTypes: { prod: ['19', '14'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'GarliCoin', - symbol: 'grlc', - addressTypes: { prod: ['26', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'VertCoin', - symbol: 'vtc', - addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator - -}, { - name: 'BitcoinGold', - symbol: 'btg', - addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'Komodo', - symbol: 'kmd', - addressTypes: { prod: ['3c', '55'], testnet: ['0', '5'] }, - validator: BTCValidator -}, { - name: 'BitcoinZ', - symbol: 'btcz', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'BitcoinPrivate', - symbol: 'btcp', - expectedLength: 26, - addressTypes: { prod: ['1325', '13af'], testnet: ['1957', '19e0'] }, - validator: BTCValidator -}, { - name: 'Hush', - symbol: 'hush', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'SnowGem', - symbol: 'sng', - expectedLength: 26, - addressTypes: { prod: ['1c28', '1c2d'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'ZCash', - symbol: 'zec', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'ZClassic', - symbol: 'zcl', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'ZenCash', - symbol: 'zen', - expectedLength: 26, - addressTypes: { prod: ['2089', '2096'], testnet: ['2092', '2098'] }, - validator: BTCValidator -}, { - name: 'VoteCoin', - symbol: 'vot', - expectedLength: 26, - addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, - validator: BTCValidator -}, { - name: 'Decred', - symbol: 'dcr', - addressTypes: { prod: ['073f', '071a'], testnet: ['0f21', '0efc'] }, - hashFunction: 'blake256', - expectedLength: 26, - validator: BTCValidator -}, { - name: 'GameCredits', - symbol: 'game', - addressTypes: { prod: ['26', '05'], testnet: [] }, - validator: BTCValidator -}, { - name: 'PIVX', - symbol: 'pivx', - addressTypes: { prod: ['1e', '0d'], testnet: [] }, - validator: BTCValidator -}, { - name: 'SolarCoin', - symbol: 'slr', - addressTypes: { prod: ['12', '05'], testnet: [] }, - validator: BTCValidator -}, { - name: 'MonaCoin', - symbol: 'mona', - addressTypes: { prod: ['32', '37'], testnet: [] }, - validator: BTCValidator -}, { - name: 'DigiByte', - symbol: 'dgb', - addressTypes: { prod: ['1e'], testnet: [] }, - validator: BTCValidator -}, { - name: 'Tether', - symbol: 'usdt', - addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator -}, { - name: 'Ripple', - symbol: 'xrp', - validator: XRPValidator, -}, { - name: 'Dash', - symbol: 'dash', - addressTypes: { prod: ['4c', '10'], testnet: ['8c', '13'] }, - validator: BTCValidator -}, { - name: 'Neo', - symbol: 'neo', - addressTypes: { prod: ['17'], testnet: [] }, - validator: BTCValidator -}, { - name: 'NeoGas', - symbol: 'gas', - addressTypes: { prod: ['17'], testnet: [] }, - validator: BTCValidator -}, { - name: 'Qtum', - symbol: 'qtum', - addressTypes: { prod: ['3a', '32'], testnet: ['78', '6e'] }, - validator: BTCValidator -}, { - name: 'Waves', - symbol: 'waves', - addressTypes: { prod: ['0157'], testnet: ['0154'] }, - expectedLength: 26, - hashFunction: 'blake256keccak256', - regex: /^[a-zA-Z0-9]{35}$/, - validator: BTCValidator -}, { - name: 'Ethereum', - symbol: 'eth', - validator: ETHValidator, -}, { - name: 'EtherZero', - symbol: 'etz', - validator: ETHValidator, -}, { - name: 'EthereumClassic', - symbol: 'etc', - validator: ETHValidator, -}, { - name: 'Callisto', - symbol: 'clo', - validator: ETHValidator, -}, { - name: 'Bankex', - symbol: 'bkx', - validator: ETHValidator -}, { - name: 'Cardano', - symbol: 'ada', - validator: ADAValidator -}, { - name: 'Monero', - symbol: 'xmr', - addressTypes: { prod: ['18', '42'], testnet: ['53', '63'], stagenet: ['24'] }, - iAddressTypes: { prod: ['19'], testnet: ['54'], stagenet: ['25'] }, - validator: XMRValidator -}, { - name: 'Aragon', - symbol: 'ant', - validator: ETHValidator -}, { - name: 'Basic Attention Token', - symbol: 'bat', - validator: ETHValidator -}, { - name: 'Bancor', - symbol: 'bnt', - validator: ETHValidator -}, { - name: 'Civic', - symbol: 'cvc', - validator: ETHValidator -}, { - name: 'District0x', - symbol: 'dnt', - validator: ETHValidator -}, { - name: 'Gnosis', - symbol: 'gno', - validator: ETHValidator -}, { - name: 'Golem', - symbol: 'gnt', - validator: ETHValidator -}, { - name: 'Matchpool', - symbol: 'gup', - validator: ETHValidator -}, { - name: 'Melon', - symbol: 'mln', - validator: ETHValidator -}, { - name: 'Numeraire', - symbol: 'nmr', - validator: ETHValidator -}, { - name: 'OmiseGO', - symbol: 'omg', - validator: ETHValidator -}, { - name: 'TenX', - symbol: 'pay', - validator: ETHValidator -}, { - name: 'Ripio Credit Network', - symbol: 'rcn', - validator: ETHValidator -}, { - name: 'Augur', - symbol: 'rep', - validator: ETHValidator -}, { - name: 'iExec RLC', - symbol: 'rlc', - validator: ETHValidator -}, { - name: 'Salt', - symbol: 'salt', - validator: ETHValidator -}, { - name: 'Status', - symbol: 'snt', - validator: ETHValidator -}, { - name: 'Storj', - symbol: 'storj', - validator: ETHValidator -}, { - name: 'Swarm City', - symbol: 'swt', - validator: ETHValidator -}, { - name: 'TrueUSD', - symbol: 'tusd', - validator: ETHValidator -}, { - name: 'Wings', - symbol: 'wings', - validator: ETHValidator -}, { - name: '0x', - symbol: 'zrx', - validator: ETHValidator -}, { - name: 'Expanse', - symbol: 'exp', - validator: ETHValidator -}, { - name: 'Viberate', - symbol: 'vib', - validator: ETHValidator -}, { - name: 'Odyssey', - symbol: 'ocn', - validator: ETHValidator -}, { - name: 'Polymath', - symbol: 'poly', - validator: ETHValidator -}, { - name: 'Storm', - symbol: 'storm', - validator: ETHValidator -}, { - name: 'Nano', - symbol: 'nano', - validator: NANOValidator, -}, { - name: 'RaiBlocks', - symbol: 'xrb', - validator: NANOValidator, -}, { - name: 'Siacoin', - symbol: 'sc', - validator: SCValidator -}, { - name: 'HyperSpace', - symbol: 'xsc', - validator: SCValidator -}, { - name: 'loki', - symbol: 'loki', - addressTypes: { prod: ['114', '115', '116'], testnet: [] }, - iAddressTypes: { prod: ['115'], testnet: [] }, - validator: XMRValidator -}, { - name: 'LBRY Credits', - symbol: 'lbc', - addressTypes: { prod: ['55'], testnet: [] }, - validator: BTCValidator -}, { + name: 'Bitcoin', + symbol: 'btc', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26'] }, + validator: BTCValidator + }, { + name: 'BitcoinCash', + symbol: 'bch', + regexp: '^[qQpP]{1}[0-9a-zA-Z]{41}$', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BCHValidator + }, { + name: 'Bitcoin SV', + symbol: 'bsv', + regexp: '^[qQ]{1}[0-9a-zA-Z]{41}$', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BCHValidator + }, { + name: 'LiteCoin', + symbol: 'ltc', + addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, + validator: BTCValidator + }, { + name: 'PeerCoin', + symbol: 'ppc', + addressTypes: { prod: ['37', '75'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'DogeCoin', + symbol: 'doge', + addressTypes: { prod: ['1e', '16'], testnet: ['71', 'c4'] }, + validator: BTCValidator + }, { + name: 'BeaverCoin', + symbol: 'bvc', + addressTypes: { prod: ['19', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator, + }, { + name: 'FreiCoin', + symbol: 'frc', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'ProtoShares', + symbol: 'pts', + addressTypes: { prod: ['38', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'MegaCoin', + symbol: 'mec', + addressTypes: { prod: ['32', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'PrimeCoin', + symbol: 'xpm', + addressTypes: { prod: ['17', '53'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'AuroraCoin', + symbol: 'aur', + addressTypes: { prod: ['17', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'NameCoin', + symbol: 'nmc', + addressTypes: { prod: ['34'], testnet: [] }, + validator: BTCValidator + }, { + name: 'BioCoin', + symbol: 'bio', + addressTypes: { prod: ['19', '14'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'GarliCoin', + symbol: 'grlc', + addressTypes: { prod: ['26', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'VertCoin', + symbol: 'vtc', + addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + + }, { + name: 'BitcoinGold', + symbol: 'btg', + addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'Komodo', + symbol: 'kmd', + addressTypes: { prod: ['3c', '55'], testnet: ['0', '5'] }, + validator: BTCValidator + }, { + name: 'BitcoinZ', + symbol: 'btcz', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'BitcoinPrivate', + symbol: 'btcp', + expectedLength: 26, + addressTypes: { prod: ['1325', '13af'], testnet: ['1957', '19e0'] }, + validator: BTCValidator + }, { + name: 'Hush', + symbol: 'hush', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'SnowGem', + symbol: 'sng', + expectedLength: 26, + addressTypes: { prod: ['1c28', '1c2d'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'ZCash', + symbol: 'zec', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'ZClassic', + symbol: 'zcl', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'ZenCash', + symbol: 'zen', + expectedLength: 26, + addressTypes: { prod: ['2089', '2096'], testnet: ['2092', '2098'] }, + validator: BTCValidator + }, { + name: 'VoteCoin', + symbol: 'vot', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator + }, { + name: 'Decred', + symbol: 'dcr', + addressTypes: { prod: ['073f', '071a'], testnet: ['0f21', '0efc'] }, + hashFunction: 'blake256', + expectedLength: 26, + validator: BTCValidator + }, { + name: 'GameCredits', + symbol: 'game', + addressTypes: { prod: ['26', '05'], testnet: [] }, + validator: BTCValidator + }, { + name: 'PIVX', + symbol: 'pivx', + addressTypes: { prod: ['1e', '0d'], testnet: [] }, + validator: BTCValidator + }, { + name: 'SolarCoin', + symbol: 'slr', + addressTypes: { prod: ['12', '05'], testnet: [] }, + validator: BTCValidator + }, { + name: 'MonaCoin', + symbol: 'mona', + addressTypes: { prod: ['32', '37'], testnet: [] }, + validator: BTCValidator + }, { + name: 'DigiByte', + symbol: 'dgb', + addressTypes: { prod: ['1e'], testnet: [] }, + validator: BTCValidator + }, { + name: 'Tether', + symbol: 'usdt', + addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, + validator: BTCValidator + }, { + name: 'Ripple', + symbol: 'xrp', + validator: XRPValidator, + }, { + name: 'Dash', + symbol: 'dash', + addressTypes: { prod: ['4c', '10'], testnet: ['8c', '13'] }, + validator: BTCValidator + }, { + name: 'Neo', + symbol: 'neo', + addressTypes: { prod: ['17'], testnet: [] }, + validator: BTCValidator + }, { + name: 'NeoGas', + symbol: 'gas', + addressTypes: { prod: ['17'], testnet: [] }, + validator: BTCValidator + }, { + name: 'Qtum', + symbol: 'qtum', + addressTypes: { prod: ['3a', '32'], testnet: ['78', '6e'] }, + validator: BTCValidator + }, { + name: 'Waves', + symbol: 'waves', + addressTypes: { prod: ['0157'], testnet: ['0154'] }, + expectedLength: 26, + hashFunction: 'blake256keccak256', + regex: /^[a-zA-Z0-9]{35}$/, + validator: BTCValidator + }, { + name: 'Ethereum', + symbol: 'eth', + validator: ETHValidator, + }, { + name: 'EtherZero', + symbol: 'etz', + validator: ETHValidator, + }, { + name: 'EthereumClassic', + symbol: 'etc', + validator: ETHValidator, + }, { + name: 'Callisto', + symbol: 'clo', + validator: ETHValidator, + }, { + name: 'Bankex', + symbol: 'bkx', + validator: ETHValidator + }, { + name: 'Cardano', + symbol: 'ada', + validator: ADAValidator + }, { + name: 'Monero', + symbol: 'xmr', + addressTypes: { prod: ['18', '42'], testnet: ['53', '63'], stagenet: ['24'] }, + iAddressTypes: { prod: ['19'], testnet: ['54'], stagenet: ['25'] }, + validator: XMRValidator + }, { + name: 'Aragon', + symbol: 'ant', + validator: ETHValidator + }, { + name: 'Basic Attention Token', + symbol: 'bat', + validator: ETHValidator + }, { + name: 'Bancor', + symbol: 'bnt', + validator: ETHValidator + }, { + name: 'Civic', + symbol: 'cvc', + validator: ETHValidator + }, { + name: 'District0x', + symbol: 'dnt', + validator: ETHValidator + }, { + name: 'Gnosis', + symbol: 'gno', + validator: ETHValidator + }, { + name: 'Golem', + symbol: 'gnt', + validator: ETHValidator + }, { + name: 'Matchpool', + symbol: 'gup', + validator: ETHValidator + }, { + name: 'Melon', + symbol: 'mln', + validator: ETHValidator + }, { + name: 'Numeraire', + symbol: 'nmr', + validator: ETHValidator + }, { + name: 'OmiseGO', + symbol: 'omg', + validator: ETHValidator + }, { + name: 'TenX', + symbol: 'pay', + validator: ETHValidator + }, { + name: 'Ripio Credit Network', + symbol: 'rcn', + validator: ETHValidator + }, { + name: 'Augur', + symbol: 'rep', + validator: ETHValidator + }, { + name: 'iExec RLC', + symbol: 'rlc', + validator: ETHValidator + }, { + name: 'Salt', + symbol: 'salt', + validator: ETHValidator + }, { + name: 'Status', + symbol: 'snt', + validator: ETHValidator + }, { + name: 'Storj', + symbol: 'storj', + validator: ETHValidator + }, { + name: 'Swarm City', + symbol: 'swt', + validator: ETHValidator + }, { + name: 'TrueUSD', + symbol: 'tusd', + validator: ETHValidator + }, { + name: 'Wings', + symbol: 'wings', + validator: ETHValidator + }, { + name: '0x', + symbol: 'zrx', + validator: ETHValidator + }, { + name: 'Expanse', + symbol: 'exp', + validator: ETHValidator + }, { + name: 'Viberate', + symbol: 'vib', + validator: ETHValidator + }, { + name: 'Odyssey', + symbol: 'ocn', + validator: ETHValidator + }, { + name: 'Polymath', + symbol: 'poly', + validator: ETHValidator + }, { + name: 'Storm', + symbol: 'storm', + validator: ETHValidator + }, { + name: 'Nano', + symbol: 'nano', + validator: NANOValidator, + }, { + name: 'RaiBlocks', + symbol: 'xrb', + validator: NANOValidator, + }, { + name: 'Siacoin', + symbol: 'sc', + validator: SCValidator + }, { + name: 'HyperSpace', + symbol: 'xsc', + validator: SCValidator + }, { + name: 'loki', + symbol: 'loki', + addressTypes: { prod: ['114', '115', '116'], testnet: [] }, + iAddressTypes: { prod: ['115'], testnet: [] }, + validator: XMRValidator + }, { + name: 'LBRY Credits', + symbol: 'lbc', + addressTypes: { prod: ['55'], testnet: [] }, + validator: BTCValidator + }, { name: 'Tron', - symbol: 'trx', - addressTypes: { prod: [0x41], testnet: [0xa0] }, - validator: TRXValidator -}, { + symbol: 'trx', + addressTypes: { prod: [0x41], testnet: [0xa0] }, + validator: TRXValidator + }, { name: 'Nem', - symbol: 'xem', - validator: NEMValidator -}, { + symbol: 'xem', + validator: NEMValidator + }, { name: 'Lisk', - symbol: 'lsk', - validator: LSKValidator -}, { + symbol: 'lsk', + validator: LSKValidator + }, { name: 'Stellar', - symbol: 'xlm', - validator: XLMValidator, + symbol: 'xlm', + validator: XLMValidator, }, { name: 'BTU Protocol', symbol: 'btu', @@ -11245,18 +11245,27 @@ var CURRENCIES = [{ symbol: 'temco', validator: ETHValidator, }, { - name: 'EOS', - symbol: 'eos', - validator: EOSValidator + name: 'EOS', + symbol: 'eos', + validator: EOSValidator }, { name: 'Tezos', symbol: 'xtz', validator: XTZValidator + }, { + name: 'VeChain', + symbol: 'vet', + validator: ETHValidator + }, + { + name: 'StormX', + symbol: 'stmx', + validator: ETHValidator } -]; + ]; -module.exports = { + module.exports = { getByNameOrSymbol: function (currencyNameOrSymbol) { var nameOrSymbol = currencyNameOrSymbol.toLowerCase(); return CURRENCIES.find(function (currency) { diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 359b32e8..822e22a7 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],U=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,U=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,C=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i= 1.4.0 < 2" + setprototypeof "1.1.1" + statuses ">= 1.5.0 < 2" + toidentifier "1.0.0" -http-proxy@^1.13.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.17.0.tgz#7ad38494658f84605e2f6db4436df410f4e5be9a" - integrity sha512-Taqn+3nNvYRfJ3bGvKfBSRwy1v6eePlm3oc/aWVxZp57DQr5Eq3xhKJi7Z4hZpS8PC3H4qI+Yly5EmFacGuA/g== +http-proxy@^1.18.1: + version "1.18.1" + resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" + integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== dependencies: - eventemitter3 "^3.0.0" + eventemitter3 "^4.0.0" follow-redirects "^1.0.0" requires-port "^1.0.0" @@ -1181,10 +1225,10 @@ https-browserify@^1.0.0: resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= -iconv-lite@0.4.23: - version "0.4.23" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63" - integrity sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA== +iconv-lite@0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== dependencies: safer-buffer ">= 2.1.2 < 3" @@ -1239,6 +1283,11 @@ insert-module-globals@^7.0.0: undeclared-identifiers "^1.1.2" xtend "^4.0.0" +is-arguments@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.0.4.tgz#3faf966c7cba0ff437fb31f6250082fcf0448cf3" + integrity sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA== + is-binary-path@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" @@ -1261,6 +1310,11 @@ is-callable@^1.1.4: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== +is-callable@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.0.tgz#83336560b54a38e35e3a2df7afd0454d691468bb" + integrity sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw== + is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" @@ -1288,17 +1342,32 @@ is-glob@^4.0.1, is-glob@~4.0.1: dependencies: is-extglob "^2.1.1" +is-map@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.1.tgz#520dafc4307bb8ebc33b813de5ce7c9400d644a1" + integrity sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw== + is-number@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== -is-regex@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" - integrity sha1-VRdIm1RwkbCTDglWVM7SXul+lJE= +is-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.0.tgz#ece38e389e490df0dc21caea2bd596f987f767ff" + integrity sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw== dependencies: - has "^1.0.1" + has-symbols "^1.0.1" + +is-set@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.1.tgz#d1604afdab1724986d30091575f54945da7e5f43" + integrity sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA== + +is-string@^1.0.4, is-string@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" + integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== is-symbol@^1.0.2: version "1.0.2" @@ -1317,12 +1386,17 @@ isarray@^2.0.4: resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.4.tgz#38e7bcbb0f3ba1b7933c86ba1894ddfc3781bbb7" integrity sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA== +isarray@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" + integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== + isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= -isbinaryfile@^4.0.2: +isbinaryfile@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.6.tgz#edcb62b224e2b4710830b67498c8e4e5a4d2610b" integrity sha512-ORrEy+SNVqUhrCaal4hA4fBzhggQQ+BaLntyPOdoEiwlKZW9BZiJXjg3RMiruE4tPEI3pyVPpySHQF/dKWperg== @@ -1332,6 +1406,19 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= +iterate-iterator@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/iterate-iterator/-/iterate-iterator-1.0.1.tgz#1693a768c1ddd79c969051459453f082fe82e9f6" + integrity sha512-3Q6tudGN05kbkDQDI4CqjaBf4qf85w6W6GnuZDtUVYwKgtC1q8yxYX7CZed7N+tLzQqS6roujWvszf13T+n9aw== + +iterate-value@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/iterate-value/-/iterate-value-1.0.2.tgz#935115bd37d006a52046535ebc8d07e9c9337f57" + integrity sha512-A6fMAio4D2ot2r/TYzr4yUWrmwNdsN5xL7+HUiyACE4DXm+q8HtPcnFTp+NnW3k4N05tZ7FVYFFb2CR13NxyHQ== + dependencies: + es-get-iterator "^1.0.2" + iterate-iterator "^1.0.1" + js-yaml@3.13.1: version "3.13.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" @@ -1381,40 +1468,40 @@ karma-chrome-launcher@^3.1.0: dependencies: which "^1.2.1" -karma-mocha@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/karma-mocha/-/karma-mocha-2.0.0.tgz#ad6b56b6a72e9b191e4c432dd30f4a44fc2435bc" - integrity sha512-qiZkZDJnn2kb9t2m4LoM4cYJHJVPoxvAYYe0B+go5s+A/3vc/3psUT05zW4yFz4vT0xHf+XzTTery8zdr8GWgA== +karma-mocha@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/karma-mocha/-/karma-mocha-2.0.1.tgz#4b0254a18dfee71bdbe6188d9a6861bf86b0cd7d" + integrity sha512-Tzd5HBjm8his2OA4bouAsATYEpZrp9vC7z5E5j4C5Of5Rrs1jY67RAwXNcVmd/Bnk1wgvQRou0zGVLey44G4tQ== dependencies: minimist "^1.2.3" -karma@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/karma/-/karma-5.0.2.tgz#e404373dac6e3fa08409ae4d9eda7d83adb43ee5" - integrity sha512-RpUuCuGJfN3WnjYPGIH+VBF8023Lfm3TQH6D1kcNL+FxtEPc2UUz/nVjbVAGXH4Pm+Q7FVOAQjdAeFUpXpQ3IA== +karma@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/karma/-/karma-5.1.0.tgz#deaa5f3939f75d7d78ded33283fa5f9bb67e9a05" + integrity sha512-I3aPbkuIbwuBo6wSog97P5WnnhCgUTsWTu/bEw1vZVQFbXmKO3PK+cfFhZioOgVtJAuQxoyauGNjnwXNHMCxbw== dependencies: - body-parser "^1.16.1" + body-parser "^1.19.0" braces "^3.0.2" chokidar "^3.0.0" - colors "^1.1.0" - connect "^3.6.0" + colors "^1.4.0" + connect "^3.7.0" di "^0.0.1" - dom-serialize "^2.2.0" - flatted "^2.0.0" - glob "^7.1.1" - graceful-fs "^4.1.2" - http-proxy "^1.13.0" - isbinaryfile "^4.0.2" - lodash "^4.17.14" - log4js "^4.0.0" - mime "^2.3.1" - minimatch "^3.0.2" - qjobs "^1.1.4" - range-parser "^1.2.0" - rimraf "^2.6.0" - socket.io "2.1.1" + dom-serialize "^2.2.1" + flatted "^2.0.2" + glob "^7.1.6" + graceful-fs "^4.2.4" + http-proxy "^1.18.1" + isbinaryfile "^4.0.6" + lodash "^4.17.15" + log4js "^6.2.1" + mime "^2.4.5" + minimatch "^3.0.4" + qjobs "^1.2.0" + range-parser "^1.2.1" + rimraf "^3.0.2" + socket.io "^2.3.0" source-map "^0.6.1" - tmp "0.0.33" + tmp "0.2.1" ua-parser-js "0.7.21" yargs "^15.3.1" @@ -1452,7 +1539,7 @@ lodash.memoize@~3.0.3: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" integrity sha1-LcvSwofLwKVcxCMovQxzYVDVPj8= -lodash@^4.17.14, lodash@^4.17.15: +lodash@^4.17.15: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== @@ -1464,16 +1551,16 @@ log-symbols@3.0.0: dependencies: chalk "^2.4.2" -log4js@^4.0.0: - version "4.5.1" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-4.5.1.tgz#e543625e97d9e6f3e6e7c9fc196dd6ab2cae30b5" - integrity sha512-EEEgFcE9bLgaYUKuozyFfytQM2wDHtXn4tAN41pkaxpNjAykv11GVdeI4tHtmPWW4Xrgh9R/2d7XYghDVjbKKw== +log4js@^6.2.1: + version "6.3.0" + resolved "https://registry.yarnpkg.com/log4js/-/log4js-6.3.0.tgz#10dfafbb434351a3e30277a00b9879446f715bcb" + integrity sha512-Mc8jNuSFImQUIateBFwdOQcmC6Q5maU0VVvdC2R6XMb66/VnT+7WS4D/0EeNMZu1YODmJe5NIn2XftCzEocUgw== dependencies: - date-format "^2.0.0" + date-format "^3.0.0" debug "^4.1.1" - flatted "^2.0.0" + flatted "^2.0.1" rfdc "^1.1.4" - streamroller "^1.0.6" + streamroller "^2.2.4" md5.js@^1.3.4: version "1.3.5" @@ -1497,6 +1584,11 @@ miller-rabin@^4.0.0: bn.js "^4.0.0" brorand "^1.0.1" +mime-db@1.44.0: + version "1.44.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" + integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== + mime-db@~1.37.0: version "1.37.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8" @@ -1509,10 +1601,17 @@ mime-types@~2.1.18: dependencies: mime-db "~1.37.0" -mime@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369" - integrity sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg== +mime-types@~2.1.24: + version "2.1.27" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" + integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== + dependencies: + mime-db "1.44.0" + +mime@^2.4.5: + version "2.4.6" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1" + integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA== minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" @@ -1524,7 +1623,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= -minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.4: +minimatch@3.0.4, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== @@ -1536,7 +1635,7 @@ minimist@^1.1.0, minimist@^1.1.1: resolved "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= -minimist@^1.2.3, minimist@^1.2.5: +minimist@^1.2.3: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== @@ -1546,39 +1645,33 @@ mkdirp-classic@^0.5.2: resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.2.tgz#54c441ce4c96cd7790e10b41a87aa51068ecab2b" integrity sha512-ejdnDQcR75gwknmMw/tx02AuRs8jCtqFoFqDZMjiNxsu85sRIJVXDKHuLYvUUPRBUtV2FpSZa9bL1BUa3BdR2g== -mkdirp@0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.3.tgz#5a514b7179259287952881e94410ec5465659f8c" - integrity sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg== - dependencies: - minimist "^1.2.5" - -mocha@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.1.1.tgz#89fbb30d09429845b1bb893a830bf5771049a441" - integrity sha512-3qQsu3ijNS3GkWcccT5Zw0hf/rWvu1fTN9sPvEd81hlwsr30GX2GcDSSoBxo24IR8FelmrAydGC6/1J5QQP4WA== +mocha@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-8.0.1.tgz#fe01f0530362df271aa8f99510447bc38b88d8ed" + integrity sha512-vefaXfdYI8+Yo8nPZQQi0QO2o+5q9UIMX1jZ1XMmK3+4+CQjc7+B0hPdUeglXiTlr8IHMVRo63IhO9Mzt6fxOg== dependencies: - ansi-colors "3.2.3" + ansi-colors "4.1.1" browser-stdout "1.3.1" - chokidar "3.3.0" + chokidar "3.3.1" debug "3.2.6" - diff "3.5.0" + diff "4.0.2" escape-string-regexp "1.0.5" - find-up "3.0.0" - glob "7.1.3" + find-up "4.1.0" + glob "7.1.6" growl "1.10.5" he "1.2.0" js-yaml "3.13.1" log-symbols "3.0.0" minimatch "3.0.4" - mkdirp "0.5.3" - ms "2.1.1" - node-environment-flags "1.0.6" + ms "2.1.2" object.assign "4.1.0" - strip-json-comments "2.0.1" - supports-color "6.0.0" - which "1.3.1" + promise.allsettled "1.0.2" + serialize-javascript "3.0.0" + strip-json-comments "3.0.1" + supports-color "7.1.0" + which "2.0.2" wide-align "1.1.3" + workerpool "6.0.0" yargs "13.3.2" yargs-parser "13.1.2" yargs-unparser "1.6.0" @@ -1609,7 +1702,12 @@ ms@2.0.0: resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= -ms@2.1.1, ms@^2.1.1: +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== @@ -1619,14 +1717,6 @@ negotiator@0.6.1: resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" integrity sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk= -node-environment-flags@1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.6.tgz#a30ac13621f6f7d674260a54dede048c3982c088" - integrity sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw== - dependencies: - object.getownpropertydescriptors "^2.0.3" - semver "^5.7.0" - normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" @@ -1637,12 +1727,22 @@ object-component@0.0.3: resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" integrity sha1-8MaapQ78lbhmwYb0AKM3acsvEpE= +object-inspect@^1.7.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" + integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA== + object-keys@^1.0.11, object-keys@^1.0.12: version "1.1.0" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.0.tgz#11bd22348dd2e096a045ab06f6c85bcc340fa032" integrity sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg== -object.assign@4.1.0: +object-keys@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + +object.assign@4.1.0, object.assign@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== @@ -1652,14 +1752,6 @@ object.assign@4.1.0: has-symbols "^1.0.0" object-keys "^1.0.11" -object.getownpropertydescriptors@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" - integrity sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY= - dependencies: - define-properties "^1.1.2" - es-abstract "^1.5.1" - on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -1679,11 +1771,6 @@ os-browserify@~0.3.0: resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - p-limit@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" @@ -1754,10 +1841,10 @@ parseuri@0.0.5: dependencies: better-assert "~1.0.0" -parseurl@~1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" - integrity sha1-/CidTtiZMRlGDBViUyYs3I3mW/M= +parseurl@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" + integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== path-browserify@~0.0.0: version "0.0.1" @@ -1820,6 +1907,17 @@ process@~0.11.0: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= +promise.allsettled@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/promise.allsettled/-/promise.allsettled-1.0.2.tgz#d66f78fbb600e83e863d893e98b3d4376a9c47c9" + integrity sha512-UpcYW5S1RaNKT6pd+s9jp9K9rlQge1UXKskec0j6Mmuq7UJCvlS2J2/s/yuPN8ehftf9HXMxWlKiPbGGUzpoRg== + dependencies: + array.prototype.map "^1.0.1" + define-properties "^1.1.3" + es-abstract "^1.17.0-next.1" + function-bind "^1.1.1" + iterate-value "^1.0.0" + public-encrypt@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" @@ -1842,15 +1940,15 @@ punycode@^1.3.2: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= -qjobs@^1.1.4: +qjobs@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" integrity sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg== -qs@6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" - integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== +qs@6.7.0: + version "6.7.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" + integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== querystring-es3@~0.2.0: version "0.2.1" @@ -1877,19 +1975,19 @@ randomfill@^1.0.3: randombytes "^2.0.5" safe-buffer "^5.1.0" -range-parser@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" - integrity sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4= +range-parser@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" + integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== -raw-body@2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.3.tgz#1b324ece6b5706e153855bc1148c65bb7f6ea0c3" - integrity sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw== +raw-body@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332" + integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q== dependencies: - bytes "3.0.0" - http-errors "1.6.3" - iconv-lite "0.4.23" + bytes "3.1.0" + http-errors "1.7.2" + iconv-lite "0.4.24" unpipe "1.0.0" read-only-stream@^2.0.0: @@ -1921,13 +2019,6 @@ readable-stream@^3.0.6: string_decoder "^1.1.1" util-deprecate "^1.0.1" -readdirp@~3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.2.0.tgz#c30c33352b12c96dfb4b895421a49fd5a9593839" - integrity sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ== - dependencies: - picomatch "^2.0.4" - readdirp@~3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.3.0.tgz#984458d13a1e42e2e9f5841b129e162f369aff17" @@ -1967,12 +2058,12 @@ rfdc@^1.1.4: resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.1.4.tgz#ba72cc1367a0ccd9cf81a870b3b58bd3ad07f8c2" integrity sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug== -rimraf@^2.6.0: - version "2.6.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" - integrity sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w== +rimraf@^3.0.0, rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== dependencies: - glob "^7.0.5" + glob "^7.1.3" ripemd160@^2.0.0, ripemd160@^2.0.1: version "2.0.2" @@ -1992,20 +2083,20 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -semver@^5.7.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== +serialize-javascript@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-3.0.0.tgz#492e489a2d77b7b804ad391a5f5d97870952548e" + integrity sha512-skZcHYw2vEX4bw90nAr2iTTsz6x2SrHEnfxgKYmZlvJYBEZrvbKtobJWlQ20zczKb3bsHHXXTYt48zBA7ni9cw== set-blocking@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= -setprototypeof@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" - integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== +setprototypeof@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" + integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== sha.js@^2.4.0, sha.js@^2.4.8, sha.js@~2.4.4: version "2.4.11" @@ -2043,46 +2134,55 @@ socket.io-adapter@~1.1.0: resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz#2a805e8a14d6372124dd9159ad4502f8cb07f06b" integrity sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs= -socket.io-client@2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.1.1.tgz#dcb38103436ab4578ddb026638ae2f21b623671f" - integrity sha512-jxnFyhAuFxYfjqIgduQlhzqTcOEQSn+OHKVfAxWaNWa7ecP7xSNk2Dx/3UEsDcY7NcFafxvNvKPmmO7HTwTxGQ== +socket.io-client@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.3.0.tgz#14d5ba2e00b9bcd145ae443ab96b3f86cbcc1bb4" + integrity sha512-cEQQf24gET3rfhxZ2jJ5xzAOo/xhZwK+mOqtGRg5IowZsMgwvHwnf/mCRapAAkadhM26y+iydgwsXGObBB5ZdA== dependencies: backo2 "1.0.2" base64-arraybuffer "0.1.5" component-bind "1.0.0" component-emitter "1.2.1" - debug "~3.1.0" - engine.io-client "~3.2.0" + debug "~4.1.0" + engine.io-client "~3.4.0" has-binary2 "~1.0.2" has-cors "1.1.0" indexof "0.0.1" object-component "0.0.3" parseqs "0.0.5" parseuri "0.0.5" - socket.io-parser "~3.2.0" + socket.io-parser "~3.3.0" to-array "0.1.4" -socket.io-parser@~3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.2.0.tgz#e7c6228b6aa1f814e6148aea325b51aa9499e077" - integrity sha512-FYiBx7rc/KORMJlgsXysflWx/RIvtqZbyGLlHZvjfmPTPeuD/I8MaW7cfFrj5tRltICJdgwflhfZ3NVVbVLFQA== +socket.io-parser@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.0.tgz#2b52a96a509fdf31440ba40fed6094c7d4f1262f" + integrity sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng== dependencies: component-emitter "1.2.1" debug "~3.1.0" isarray "2.0.1" -socket.io@2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.1.1.tgz#a069c5feabee3e6b214a75b40ce0652e1cfb9980" - integrity sha512-rORqq9c+7W0DAK3cleWNSyfv/qKXV99hV4tZe+gGLfBECw3XEhBy7x85F3wypA9688LKjtwO9pX9L33/xQI8yA== +socket.io-parser@~3.4.0: + version "3.4.1" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.4.1.tgz#b06af838302975837eab2dc980037da24054d64a" + integrity sha512-11hMgzL+WCLWf1uFtHSNvliI++tcRUWdoeYuwIl+Axvwy9z2gQM+7nJyN3STj1tLj5JyIUH8/gpDGxzAlDdi0A== dependencies: - debug "~3.1.0" - engine.io "~3.2.0" + component-emitter "1.2.1" + debug "~4.1.0" + isarray "2.0.1" + +socket.io@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.3.0.tgz#cd762ed6a4faeca59bc1f3e243c0969311eb73fb" + integrity sha512-2A892lrj0GcgR/9Qk81EaY2gYhCBxurV0PfmmESO6p27QPrUK1J3zdns+5QPqvUYK2q657nSj0guoIil9+7eFg== + dependencies: + debug "~4.1.0" + engine.io "~3.4.0" has-binary2 "~1.0.2" socket.io-adapter "~1.1.0" - socket.io-client "2.1.1" - socket.io-parser "~3.2.0" + socket.io-client "2.3.0" + socket.io-parser "~3.4.0" source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" @@ -2099,16 +2199,11 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= -"statuses@>= 1.4.0 < 2": +"statuses@>= 1.5.0 < 2", statuses@~1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= -statuses@~1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" - integrity sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4= - stream-browserify@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.1.tgz#66266ee5f9bdb9940a4e4514cafb43bb71e5c9db" @@ -2143,16 +2238,14 @@ stream-splicer@^2.0.0: inherits "^2.0.1" readable-stream "^2.0.2" -streamroller@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-1.0.6.tgz#8167d8496ed9f19f05ee4b158d9611321b8cacd9" - integrity sha512-3QC47Mhv3/aZNFpDDVO44qQb9gwB9QggMEE0sQmkTAwBVYdBRWISdsywlkfm5II1Q5y/pmrHflti/IgmIzdDBg== +streamroller@^2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-2.2.4.tgz#c198ced42db94086a6193608187ce80a5f2b0e53" + integrity sha512-OG79qm3AujAM9ImoqgWEY1xG4HX+Lw+yY6qZj9R1K2mhF5bEmQ849wvrb+4vt4jLMLzwXttJlQbOdPOQVRv7DQ== dependencies: - async "^2.6.2" - date-format "^2.0.0" - debug "^3.2.6" - fs-extra "^7.0.1" - lodash "^4.17.14" + date-format "^2.1.0" + debug "^4.1.1" + fs-extra "^8.1.0" "string-width@^1.0.2 || 2": version "2.1.1" @@ -2180,6 +2273,22 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string.prototype.trimend@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" + integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + +string.prototype.trimstart@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" + integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + string_decoder@^1.1.1, string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -2208,10 +2317,10 @@ strip-ansi@^6.0.0: dependencies: ansi-regex "^5.0.0" -strip-json-comments@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= +strip-json-comments@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7" + integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw== subarg@^1.0.0: version "1.0.0" @@ -2220,12 +2329,12 @@ subarg@^1.0.0: dependencies: minimist "^1.1.0" -supports-color@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a" - integrity sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg== +supports-color@7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1" + integrity sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g== dependencies: - has-flag "^3.0.0" + has-flag "^4.0.0" supports-color@^5.3.0: version "5.5.0" @@ -2261,12 +2370,12 @@ timers-browserify@^1.0.1: dependencies: process "~0.11.0" -tmp@0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== +tmp@0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" + integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ== dependencies: - os-tmpdir "~1.0.2" + rimraf "^3.0.0" to-array@0.1.4: version "0.1.4" @@ -2280,6 +2389,11 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +toidentifier@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" + integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== + tty-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" @@ -2290,13 +2404,13 @@ type-detect@^4.0.0, type-detect@^4.0.5: resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -type-is@~1.6.16: - version "1.6.16" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" - integrity sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q== +type-is@~1.6.17: + version "1.6.18" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" + integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== dependencies: media-typer "0.3.0" - mime-types "~2.1.18" + mime-types "~2.1.24" typedarray@^0.0.6: version "0.0.6" @@ -2316,11 +2430,6 @@ uglify-es@^3.3.9: commander "~2.13.0" source-map "~0.6.1" -ultron@~1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" - integrity sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og== - umd@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.3.tgz#aa9fe653c42b9097678489c01000acb69f0b26cf" @@ -2393,7 +2502,14 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= -which@1.3.1, which@^1.2.1: +which@2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +which@^1.2.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== @@ -2407,6 +2523,11 @@ wide-align@1.1.3: dependencies: string-width "^1.0.2 || 2" +workerpool@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.0.0.tgz#85aad67fa1a2c8ef9386a1b43539900f61d03d58" + integrity sha512-fU2OcNA/GVAJLLyKUoHkAgIhKb0JoCpSjLC/G2vYKxUjVmQwGbRVeoPJ1a8U4pnVofz4AQV5Y/NEw8oKqxEBtA== + wrap-ansi@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" @@ -2430,14 +2551,17 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -ws@~3.3.1: - version "3.3.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" - integrity sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA== +ws@^7.1.2: + version "7.3.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8" + integrity sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA== + +ws@~6.1.0: + version "6.1.4" + resolved "https://registry.yarnpkg.com/ws/-/ws-6.1.4.tgz#5b5c8800afab925e94ccb29d153c8d02c1776ef9" + integrity sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA== dependencies: async-limiter "~1.0.0" - safe-buffer "~5.1.0" - ultron "~1.1.0" xmlhttprequest-ssl@~1.5.4: version "1.5.5" From ed00e0457eeadbf549c1fdd9b3b6770a0e9766e7 Mon Sep 17 00:00:00 2001 From: Stephen Ephraim Date: Tue, 18 Aug 2020 12:07:38 +0200 Subject: [PATCH 101/108] Adds validation of both omni and erc20 addresses for Tether (#21) --- dist/wallet-address-validator.js | 845 ++++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- package.json | 313 ++++++---- src/bch_validator.js | 7 +- src/bitcoin_validator.js | 4 +- src/currencies.js | 3 +- src/monero_validator.js | 4 +- src/nem_validator.js | 2 +- src/tron_validator.js | 5 +- src/usdt_validator.js | 21 + src/wallet_address_validator.js | 8 +- test/wallet_address_validator.js | 13 +- yarn.lock | 123 +++- 13 files changed, 819 insertions(+), 531 deletions(-) create mode 100644 src/usdt_validator.js diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index d9ee2964..37f706a7 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -4174,412 +4174,412 @@ function numberIsNaN (obj) { } },{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014 Patrick Gansterer - * - * 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. - */ - -(function(global, undefined) { "use strict"; -var POW_2_24 = Math.pow(2, -24), - POW_2_32 = Math.pow(2, 32), - POW_2_53 = Math.pow(2, 53); - -function encode(value) { - var data = new ArrayBuffer(256); - var dataView = new DataView(data); - var lastLength; - var offset = 0; - - function ensureSpace(length) { - var newByteLength = data.byteLength; - var requiredLength = offset + length; - while (newByteLength < requiredLength) - newByteLength *= 2; - if (newByteLength !== data.byteLength) { - var oldDataView = dataView; - data = new ArrayBuffer(newByteLength); - dataView = new DataView(data); - var uint32count = (offset + 3) >> 2; - for (var i = 0; i < uint32count; ++i) - dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); - } - - lastLength = length; - return dataView; - } - function write() { - offset += lastLength; - } - function writeFloat64(value) { - write(ensureSpace(8).setFloat64(offset, value)); - } - function writeUint8(value) { - write(ensureSpace(1).setUint8(offset, value)); - } - function writeUint8Array(value) { - var dataView = ensureSpace(value.length); - for (var i = 0; i < value.length; ++i) - dataView.setUint8(offset + i, value[i]); - write(); - } - function writeUint16(value) { - write(ensureSpace(2).setUint16(offset, value)); - } - function writeUint32(value) { - write(ensureSpace(4).setUint32(offset, value)); - } - function writeUint64(value) { - var low = value % POW_2_32; - var high = (value - low) / POW_2_32; - var dataView = ensureSpace(8); - dataView.setUint32(offset, high); - dataView.setUint32(offset + 4, low); - write(); - } - function writeTypeAndLength(type, length) { - if (length < 24) { - writeUint8(type << 5 | length); - } else if (length < 0x100) { - writeUint8(type << 5 | 24); - writeUint8(length); - } else if (length < 0x10000) { - writeUint8(type << 5 | 25); - writeUint16(length); - } else if (length < 0x100000000) { - writeUint8(type << 5 | 26); - writeUint32(length); - } else { - writeUint8(type << 5 | 27); - writeUint64(length); - } - } - - function encodeItem(value) { - var i; - - if (value === false) - return writeUint8(0xf4); - if (value === true) - return writeUint8(0xf5); - if (value === null) - return writeUint8(0xf6); - if (value === undefined) - return writeUint8(0xf7); - - switch (typeof value) { - case "number": - if (Math.floor(value) === value) { - if (0 <= value && value <= POW_2_53) - return writeTypeAndLength(0, value); - if (-POW_2_53 <= value && value < 0) - return writeTypeAndLength(1, -(value + 1)); - } - writeUint8(0xfb); - return writeFloat64(value); - - case "string": - var utf8data = []; - for (i = 0; i < value.length; ++i) { - var charCode = value.charCodeAt(i); - if (charCode < 0x80) { - utf8data.push(charCode); - } else if (charCode < 0x800) { - utf8data.push(0xc0 | charCode >> 6); - utf8data.push(0x80 | charCode & 0x3f); - } else if (charCode < 0xd800) { - utf8data.push(0xe0 | charCode >> 12); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } else { - charCode = (charCode & 0x3ff) << 10; - charCode |= value.charCodeAt(++i) & 0x3ff; - charCode += 0x10000; - - utf8data.push(0xf0 | charCode >> 18); - utf8data.push(0x80 | (charCode >> 12) & 0x3f); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } - } - - writeTypeAndLength(3, utf8data.length); - return writeUint8Array(utf8data); - - default: - var length; - if (Array.isArray(value)) { - length = value.length; - writeTypeAndLength(4, length); - for (i = 0; i < length; ++i) - encodeItem(value[i]); - } else if (value instanceof Uint8Array) { - writeTypeAndLength(2, value.length); - writeUint8Array(value); - } else { - var keys = Object.keys(value); - length = keys.length; - writeTypeAndLength(5, length); - for (i = 0; i < length; ++i) { - var key = keys[i]; - encodeItem(key); - encodeItem(value[key]); - } - } - } - } - - encodeItem(value); - - if ("slice" in data) - return data.slice(0, offset); - - var ret = new ArrayBuffer(offset); - var retView = new DataView(ret); - for (var i = 0; i < offset; ++i) - retView.setUint8(i, dataView.getUint8(i)); - return ret; -} - -function decode(data, tagger, simpleValue) { - var dataView = new DataView(data); - var offset = 0; - - if (typeof tagger !== "function") - tagger = function(value) { return value; }; - if (typeof simpleValue !== "function") - simpleValue = function() { return undefined; }; - - function read(value, length) { - offset += length; - return value; - } - function readArrayBuffer(length) { - return read(new Uint8Array(data, offset, length), length); - } - function readFloat16() { - var tempArrayBuffer = new ArrayBuffer(4); - var tempDataView = new DataView(tempArrayBuffer); - var value = readUint16(); - - var sign = value & 0x8000; - var exponent = value & 0x7c00; - var fraction = value & 0x03ff; - - if (exponent === 0x7c00) - exponent = 0xff << 10; - else if (exponent !== 0) - exponent += (127 - 15) << 10; - else if (fraction !== 0) - return fraction * POW_2_24; - - tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); - return tempDataView.getFloat32(0); - } - function readFloat32() { - return read(dataView.getFloat32(offset), 4); - } - function readFloat64() { - return read(dataView.getFloat64(offset), 8); - } - function readUint8() { - return read(dataView.getUint8(offset), 1); - } - function readUint16() { - return read(dataView.getUint16(offset), 2); - } - function readUint32() { - return read(dataView.getUint32(offset), 4); - } - function readUint64() { - return readUint32() * POW_2_32 + readUint32(); - } - function readBreak() { - if (dataView.getUint8(offset) !== 0xff) - return false; - offset += 1; - return true; - } - function readLength(additionalInformation) { - if (additionalInformation < 24) - return additionalInformation; - if (additionalInformation === 24) - return readUint8(); - if (additionalInformation === 25) - return readUint16(); - if (additionalInformation === 26) - return readUint32(); - if (additionalInformation === 27) - return readUint64(); - if (additionalInformation === 31) - return -1; - throw "Invalid length encoding"; - } - function readIndefiniteStringLength(majorType) { - var initialByte = readUint8(); - if (initialByte === 0xff) - return -1; - var length = readLength(initialByte & 0x1f); - if (length < 0 || (initialByte >> 5) !== majorType) - throw "Invalid indefinite length element"; - return length; - } - - function appendUtf16data(utf16data, length) { - for (var i = 0; i < length; ++i) { - var value = readUint8(); - if (value & 0x80) { - if (value < 0xe0) { - value = (value & 0x1f) << 6 - | (readUint8() & 0x3f); - length -= 1; - } else if (value < 0xf0) { - value = (value & 0x0f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 2; - } else { - value = (value & 0x0f) << 18 - | (readUint8() & 0x3f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 3; - } - } - - if (value < 0x10000) { - utf16data.push(value); - } else { - value -= 0x10000; - utf16data.push(0xd800 | (value >> 10)); - utf16data.push(0xdc00 | (value & 0x3ff)); - } - } - } - - function decodeItem() { - var initialByte = readUint8(); - var majorType = initialByte >> 5; - var additionalInformation = initialByte & 0x1f; - var i; - var length; - - if (majorType === 7) { - switch (additionalInformation) { - case 25: - return readFloat16(); - case 26: - return readFloat32(); - case 27: - return readFloat64(); - } - } - - length = readLength(additionalInformation); - if (length < 0 && (majorType < 2 || 6 < majorType)) - throw "Invalid length"; - - switch (majorType) { - case 0: - return length; - case 1: - return -1 - length; - case 2: - if (length < 0) { - var elements = []; - var fullArrayLength = 0; - while ((length = readIndefiniteStringLength(majorType)) >= 0) { - fullArrayLength += length; - elements.push(readArrayBuffer(length)); - } - var fullArray = new Uint8Array(fullArrayLength); - var fullArrayOffset = 0; - for (i = 0; i < elements.length; ++i) { - fullArray.set(elements[i], fullArrayOffset); - fullArrayOffset += elements[i].length; - } - return fullArray; - } - return readArrayBuffer(length); - case 3: - var utf16data = []; - if (length < 0) { - while ((length = readIndefiniteStringLength(majorType)) >= 0) - appendUtf16data(utf16data, length); - } else - appendUtf16data(utf16data, length); - return String.fromCharCode.apply(null, utf16data); - case 4: - var retArray; - if (length < 0) { - retArray = []; - while (!readBreak()) - retArray.push(decodeItem()); - } else { - retArray = new Array(length); - for (i = 0; i < length; ++i) - retArray[i] = decodeItem(); - } - return retArray; - case 5: - var retObject = {}; - for (i = 0; i < length || length < 0 && !readBreak(); ++i) { - var key = decodeItem(); - retObject[key] = decodeItem(); - } - return retObject; - case 6: - return tagger(decodeItem(), length); - case 7: - switch (length) { - case 20: - return false; - case 21: - return true; - case 22: - return null; - case 23: - return undefined; - default: - return simpleValue(length); - } - } - } - - var ret = decodeItem(); - if (offset !== data.byteLength) - throw "Remaining bytes"; - return ret; -} - -var obj = { encode: encode, decode: decode }; - -if (typeof define === "function" && define.amd) - define("cbor/cbor", obj); -else if (typeof module !== 'undefined' && module.exports) - module.exports = obj; -else if (!global.CBOR) - global.CBOR = obj; - -})(this); +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 Patrick Gansterer + * + * 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. + */ + +(function(global, undefined) { "use strict"; +var POW_2_24 = Math.pow(2, -24), + POW_2_32 = Math.pow(2, 32), + POW_2_53 = Math.pow(2, 53); + +function encode(value) { + var data = new ArrayBuffer(256); + var dataView = new DataView(data); + var lastLength; + var offset = 0; + + function ensureSpace(length) { + var newByteLength = data.byteLength; + var requiredLength = offset + length; + while (newByteLength < requiredLength) + newByteLength *= 2; + if (newByteLength !== data.byteLength) { + var oldDataView = dataView; + data = new ArrayBuffer(newByteLength); + dataView = new DataView(data); + var uint32count = (offset + 3) >> 2; + for (var i = 0; i < uint32count; ++i) + dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); + } + + lastLength = length; + return dataView; + } + function write() { + offset += lastLength; + } + function writeFloat64(value) { + write(ensureSpace(8).setFloat64(offset, value)); + } + function writeUint8(value) { + write(ensureSpace(1).setUint8(offset, value)); + } + function writeUint8Array(value) { + var dataView = ensureSpace(value.length); + for (var i = 0; i < value.length; ++i) + dataView.setUint8(offset + i, value[i]); + write(); + } + function writeUint16(value) { + write(ensureSpace(2).setUint16(offset, value)); + } + function writeUint32(value) { + write(ensureSpace(4).setUint32(offset, value)); + } + function writeUint64(value) { + var low = value % POW_2_32; + var high = (value - low) / POW_2_32; + var dataView = ensureSpace(8); + dataView.setUint32(offset, high); + dataView.setUint32(offset + 4, low); + write(); + } + function writeTypeAndLength(type, length) { + if (length < 24) { + writeUint8(type << 5 | length); + } else if (length < 0x100) { + writeUint8(type << 5 | 24); + writeUint8(length); + } else if (length < 0x10000) { + writeUint8(type << 5 | 25); + writeUint16(length); + } else if (length < 0x100000000) { + writeUint8(type << 5 | 26); + writeUint32(length); + } else { + writeUint8(type << 5 | 27); + writeUint64(length); + } + } + + function encodeItem(value) { + var i; + + if (value === false) + return writeUint8(0xf4); + if (value === true) + return writeUint8(0xf5); + if (value === null) + return writeUint8(0xf6); + if (value === undefined) + return writeUint8(0xf7); + + switch (typeof value) { + case "number": + if (Math.floor(value) === value) { + if (0 <= value && value <= POW_2_53) + return writeTypeAndLength(0, value); + if (-POW_2_53 <= value && value < 0) + return writeTypeAndLength(1, -(value + 1)); + } + writeUint8(0xfb); + return writeFloat64(value); + + case "string": + var utf8data = []; + for (i = 0; i < value.length; ++i) { + var charCode = value.charCodeAt(i); + if (charCode < 0x80) { + utf8data.push(charCode); + } else if (charCode < 0x800) { + utf8data.push(0xc0 | charCode >> 6); + utf8data.push(0x80 | charCode & 0x3f); + } else if (charCode < 0xd800) { + utf8data.push(0xe0 | charCode >> 12); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } else { + charCode = (charCode & 0x3ff) << 10; + charCode |= value.charCodeAt(++i) & 0x3ff; + charCode += 0x10000; + + utf8data.push(0xf0 | charCode >> 18); + utf8data.push(0x80 | (charCode >> 12) & 0x3f); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } + } + + writeTypeAndLength(3, utf8data.length); + return writeUint8Array(utf8data); + + default: + var length; + if (Array.isArray(value)) { + length = value.length; + writeTypeAndLength(4, length); + for (i = 0; i < length; ++i) + encodeItem(value[i]); + } else if (value instanceof Uint8Array) { + writeTypeAndLength(2, value.length); + writeUint8Array(value); + } else { + var keys = Object.keys(value); + length = keys.length; + writeTypeAndLength(5, length); + for (i = 0; i < length; ++i) { + var key = keys[i]; + encodeItem(key); + encodeItem(value[key]); + } + } + } + } + + encodeItem(value); + + if ("slice" in data) + return data.slice(0, offset); + + var ret = new ArrayBuffer(offset); + var retView = new DataView(ret); + for (var i = 0; i < offset; ++i) + retView.setUint8(i, dataView.getUint8(i)); + return ret; +} + +function decode(data, tagger, simpleValue) { + var dataView = new DataView(data); + var offset = 0; + + if (typeof tagger !== "function") + tagger = function(value) { return value; }; + if (typeof simpleValue !== "function") + simpleValue = function() { return undefined; }; + + function read(value, length) { + offset += length; + return value; + } + function readArrayBuffer(length) { + return read(new Uint8Array(data, offset, length), length); + } + function readFloat16() { + var tempArrayBuffer = new ArrayBuffer(4); + var tempDataView = new DataView(tempArrayBuffer); + var value = readUint16(); + + var sign = value & 0x8000; + var exponent = value & 0x7c00; + var fraction = value & 0x03ff; + + if (exponent === 0x7c00) + exponent = 0xff << 10; + else if (exponent !== 0) + exponent += (127 - 15) << 10; + else if (fraction !== 0) + return fraction * POW_2_24; + + tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); + return tempDataView.getFloat32(0); + } + function readFloat32() { + return read(dataView.getFloat32(offset), 4); + } + function readFloat64() { + return read(dataView.getFloat64(offset), 8); + } + function readUint8() { + return read(dataView.getUint8(offset), 1); + } + function readUint16() { + return read(dataView.getUint16(offset), 2); + } + function readUint32() { + return read(dataView.getUint32(offset), 4); + } + function readUint64() { + return readUint32() * POW_2_32 + readUint32(); + } + function readBreak() { + if (dataView.getUint8(offset) !== 0xff) + return false; + offset += 1; + return true; + } + function readLength(additionalInformation) { + if (additionalInformation < 24) + return additionalInformation; + if (additionalInformation === 24) + return readUint8(); + if (additionalInformation === 25) + return readUint16(); + if (additionalInformation === 26) + return readUint32(); + if (additionalInformation === 27) + return readUint64(); + if (additionalInformation === 31) + return -1; + throw "Invalid length encoding"; + } + function readIndefiniteStringLength(majorType) { + var initialByte = readUint8(); + if (initialByte === 0xff) + return -1; + var length = readLength(initialByte & 0x1f); + if (length < 0 || (initialByte >> 5) !== majorType) + throw "Invalid indefinite length element"; + return length; + } + + function appendUtf16data(utf16data, length) { + for (var i = 0; i < length; ++i) { + var value = readUint8(); + if (value & 0x80) { + if (value < 0xe0) { + value = (value & 0x1f) << 6 + | (readUint8() & 0x3f); + length -= 1; + } else if (value < 0xf0) { + value = (value & 0x0f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 2; + } else { + value = (value & 0x0f) << 18 + | (readUint8() & 0x3f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 3; + } + } + + if (value < 0x10000) { + utf16data.push(value); + } else { + value -= 0x10000; + utf16data.push(0xd800 | (value >> 10)); + utf16data.push(0xdc00 | (value & 0x3ff)); + } + } + } + + function decodeItem() { + var initialByte = readUint8(); + var majorType = initialByte >> 5; + var additionalInformation = initialByte & 0x1f; + var i; + var length; + + if (majorType === 7) { + switch (additionalInformation) { + case 25: + return readFloat16(); + case 26: + return readFloat32(); + case 27: + return readFloat64(); + } + } + + length = readLength(additionalInformation); + if (length < 0 && (majorType < 2 || 6 < majorType)) + throw "Invalid length"; + + switch (majorType) { + case 0: + return length; + case 1: + return -1 - length; + case 2: + if (length < 0) { + var elements = []; + var fullArrayLength = 0; + while ((length = readIndefiniteStringLength(majorType)) >= 0) { + fullArrayLength += length; + elements.push(readArrayBuffer(length)); + } + var fullArray = new Uint8Array(fullArrayLength); + var fullArrayOffset = 0; + for (i = 0; i < elements.length; ++i) { + fullArray.set(elements[i], fullArrayOffset); + fullArrayOffset += elements[i].length; + } + return fullArray; + } + return readArrayBuffer(length); + case 3: + var utf16data = []; + if (length < 0) { + while ((length = readIndefiniteStringLength(majorType)) >= 0) + appendUtf16data(utf16data, length); + } else + appendUtf16data(utf16data, length); + return String.fromCharCode.apply(null, utf16data); + case 4: + var retArray; + if (length < 0) { + retArray = []; + while (!readBreak()) + retArray.push(decodeItem()); + } else { + retArray = new Array(length); + for (i = 0; i < length; ++i) + retArray[i] = decodeItem(); + } + return retArray; + case 5: + var retObject = {}; + for (i = 0; i < length || length < 0 && !readBreak(); ++i) { + var key = decodeItem(); + retObject[key] = decodeItem(); + } + return retObject; + case 6: + return tagger(decodeItem(), length); + case 7: + switch (length) { + case 20: + return false; + case 21: + return true; + case 22: + return null; + case 23: + return undefined; + default: + return simpleValue(length); + } + } + } + + var ret = decodeItem(); + if (offset !== data.byteLength) + throw "Remaining bytes"; + return ret; +} + +var obj = { encode: encode, decode: decode }; + +if (typeof define === "function" && define.amd) + define("cbor/cbor", obj); +else if (typeof module !== 'undefined' && module.exports) + module.exports = obj; +else if (!global.CBOR) + global.CBOR = obj; + +})(this); },{}],6:[function(require,module,exports){ 'use strict'; @@ -10786,6 +10786,7 @@ var BCHValidator = require('./bch_validator'); var XLMValidator = require('./stellar_validator'); var EOSValidator = require('./eos_validator'); var XTZValidator = require('./tezos_validator'); +var USDTValidator = require('./usdt_validator'); // defines P2PKH and P2SH address types for standard (prod) and testnet networks var CURRENCIES = [{ @@ -10965,7 +10966,7 @@ var CURRENCIES = [{ name: 'Tether', symbol: 'usdt', addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4'] }, - validator: BTCValidator + validator: USDTValidator }, { name: 'Ripple', symbol: 'xrp', @@ -11289,7 +11290,7 @@ var CURRENCIES = [{ -},{"./ada_validator":36,"./bch_validator":37,"./bitcoin_validator":38,"./eos_validator":50,"./ethereum_validator":51,"./lisk_validator":52,"./monero_validator":53,"./nano_validator":54,"./nem_validator":55,"./ripple_validator":56,"./siacoin_validator":57,"./stellar_validator":58,"./tezos_validator":59,"./tron_validator":60}],50:[function(require,module,exports){ +},{"./ada_validator":36,"./bch_validator":37,"./bitcoin_validator":38,"./eos_validator":50,"./ethereum_validator":51,"./lisk_validator":52,"./monero_validator":53,"./nano_validator":54,"./nem_validator":55,"./ripple_validator":56,"./siacoin_validator":57,"./stellar_validator":58,"./tezos_validator":59,"./tron_validator":60,"./usdt_validator":61}],50:[function(require,module,exports){ function isValidEOSAddress (address, currency, networkType) { var regex = /^[a-z0-9]+$/g // Must be numbers and lowercase letters only if (address.search(regex) !== -1 && address.length === 12) { @@ -11483,6 +11484,7 @@ var isValidAddress = function(_address) { module.exports = { isValidAddress: isValidAddress, } + }).call(this,require("buffer").Buffer) },{"./crypto/utils":48,"buffer":4}],56:[function(require,module,exports){ var cryptoUtils = require('./crypto/utils'); @@ -11692,6 +11694,31 @@ module.exports = { } }; },{"./crypto/utils":48}],61:[function(require,module,exports){ +var BTCValidator = require('./bitcoin_validator'); +var ETHValidator = require('./ethereum_validator'); + +function checkBothValidators(address, currency, networkType) { + var result = BTCValidator.isValidAddress(address, currency, networkType); + return result ? result : + ETHValidator.isValidAddress(address, currency, networkType); +} + +module.exports = { + isValidAddress: function (address, currency, opts) { + if (opts && typeof opts === 'object') { + if (opts.chainType === 'erc20') { + return ETHValidator.isValidAddress(address, currency, opts.networkType); + } else if (opts.chainType === 'omni') { + return BTCValidator.isValidAddress(address, currency, opts.networkType); + } else { + throw new Error(`Unknown chainType: ${opts.chainType}`); + } + } + return checkBothValidators(address, currency, opts); + } +}; + +},{"./bitcoin_validator":38,"./ethereum_validator":51}],62:[function(require,module,exports){ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; @@ -11714,5 +11741,5 @@ module.exports = { } }; -},{"./currencies":49}]},{},[61])(61) +},{"./currencies":49}]},{},[62])(62) }); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 822e22a7..35589a23 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,C=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],U=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,U=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i Date: Tue, 18 Aug 2020 12:09:46 +0200 Subject: [PATCH 102/108] updated version --- dist/wallet-address-validator.js | 842 ++++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- package.json | 2 +- 3 files changed, 426 insertions(+), 420 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 37f706a7..7b44ec0e 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -4174,412 +4174,412 @@ function numberIsNaN (obj) { } },{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014 Patrick Gansterer - * - * 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. - */ - -(function(global, undefined) { "use strict"; -var POW_2_24 = Math.pow(2, -24), - POW_2_32 = Math.pow(2, 32), - POW_2_53 = Math.pow(2, 53); - -function encode(value) { - var data = new ArrayBuffer(256); - var dataView = new DataView(data); - var lastLength; - var offset = 0; - - function ensureSpace(length) { - var newByteLength = data.byteLength; - var requiredLength = offset + length; - while (newByteLength < requiredLength) - newByteLength *= 2; - if (newByteLength !== data.byteLength) { - var oldDataView = dataView; - data = new ArrayBuffer(newByteLength); - dataView = new DataView(data); - var uint32count = (offset + 3) >> 2; - for (var i = 0; i < uint32count; ++i) - dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); - } - - lastLength = length; - return dataView; - } - function write() { - offset += lastLength; - } - function writeFloat64(value) { - write(ensureSpace(8).setFloat64(offset, value)); - } - function writeUint8(value) { - write(ensureSpace(1).setUint8(offset, value)); - } - function writeUint8Array(value) { - var dataView = ensureSpace(value.length); - for (var i = 0; i < value.length; ++i) - dataView.setUint8(offset + i, value[i]); - write(); - } - function writeUint16(value) { - write(ensureSpace(2).setUint16(offset, value)); - } - function writeUint32(value) { - write(ensureSpace(4).setUint32(offset, value)); - } - function writeUint64(value) { - var low = value % POW_2_32; - var high = (value - low) / POW_2_32; - var dataView = ensureSpace(8); - dataView.setUint32(offset, high); - dataView.setUint32(offset + 4, low); - write(); - } - function writeTypeAndLength(type, length) { - if (length < 24) { - writeUint8(type << 5 | length); - } else if (length < 0x100) { - writeUint8(type << 5 | 24); - writeUint8(length); - } else if (length < 0x10000) { - writeUint8(type << 5 | 25); - writeUint16(length); - } else if (length < 0x100000000) { - writeUint8(type << 5 | 26); - writeUint32(length); - } else { - writeUint8(type << 5 | 27); - writeUint64(length); - } - } - - function encodeItem(value) { - var i; - - if (value === false) - return writeUint8(0xf4); - if (value === true) - return writeUint8(0xf5); - if (value === null) - return writeUint8(0xf6); - if (value === undefined) - return writeUint8(0xf7); - - switch (typeof value) { - case "number": - if (Math.floor(value) === value) { - if (0 <= value && value <= POW_2_53) - return writeTypeAndLength(0, value); - if (-POW_2_53 <= value && value < 0) - return writeTypeAndLength(1, -(value + 1)); - } - writeUint8(0xfb); - return writeFloat64(value); - - case "string": - var utf8data = []; - for (i = 0; i < value.length; ++i) { - var charCode = value.charCodeAt(i); - if (charCode < 0x80) { - utf8data.push(charCode); - } else if (charCode < 0x800) { - utf8data.push(0xc0 | charCode >> 6); - utf8data.push(0x80 | charCode & 0x3f); - } else if (charCode < 0xd800) { - utf8data.push(0xe0 | charCode >> 12); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } else { - charCode = (charCode & 0x3ff) << 10; - charCode |= value.charCodeAt(++i) & 0x3ff; - charCode += 0x10000; - - utf8data.push(0xf0 | charCode >> 18); - utf8data.push(0x80 | (charCode >> 12) & 0x3f); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } - } - - writeTypeAndLength(3, utf8data.length); - return writeUint8Array(utf8data); - - default: - var length; - if (Array.isArray(value)) { - length = value.length; - writeTypeAndLength(4, length); - for (i = 0; i < length; ++i) - encodeItem(value[i]); - } else if (value instanceof Uint8Array) { - writeTypeAndLength(2, value.length); - writeUint8Array(value); - } else { - var keys = Object.keys(value); - length = keys.length; - writeTypeAndLength(5, length); - for (i = 0; i < length; ++i) { - var key = keys[i]; - encodeItem(key); - encodeItem(value[key]); - } - } - } - } - - encodeItem(value); - - if ("slice" in data) - return data.slice(0, offset); - - var ret = new ArrayBuffer(offset); - var retView = new DataView(ret); - for (var i = 0; i < offset; ++i) - retView.setUint8(i, dataView.getUint8(i)); - return ret; -} - -function decode(data, tagger, simpleValue) { - var dataView = new DataView(data); - var offset = 0; - - if (typeof tagger !== "function") - tagger = function(value) { return value; }; - if (typeof simpleValue !== "function") - simpleValue = function() { return undefined; }; - - function read(value, length) { - offset += length; - return value; - } - function readArrayBuffer(length) { - return read(new Uint8Array(data, offset, length), length); - } - function readFloat16() { - var tempArrayBuffer = new ArrayBuffer(4); - var tempDataView = new DataView(tempArrayBuffer); - var value = readUint16(); - - var sign = value & 0x8000; - var exponent = value & 0x7c00; - var fraction = value & 0x03ff; - - if (exponent === 0x7c00) - exponent = 0xff << 10; - else if (exponent !== 0) - exponent += (127 - 15) << 10; - else if (fraction !== 0) - return fraction * POW_2_24; - - tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); - return tempDataView.getFloat32(0); - } - function readFloat32() { - return read(dataView.getFloat32(offset), 4); - } - function readFloat64() { - return read(dataView.getFloat64(offset), 8); - } - function readUint8() { - return read(dataView.getUint8(offset), 1); - } - function readUint16() { - return read(dataView.getUint16(offset), 2); - } - function readUint32() { - return read(dataView.getUint32(offset), 4); - } - function readUint64() { - return readUint32() * POW_2_32 + readUint32(); - } - function readBreak() { - if (dataView.getUint8(offset) !== 0xff) - return false; - offset += 1; - return true; - } - function readLength(additionalInformation) { - if (additionalInformation < 24) - return additionalInformation; - if (additionalInformation === 24) - return readUint8(); - if (additionalInformation === 25) - return readUint16(); - if (additionalInformation === 26) - return readUint32(); - if (additionalInformation === 27) - return readUint64(); - if (additionalInformation === 31) - return -1; - throw "Invalid length encoding"; - } - function readIndefiniteStringLength(majorType) { - var initialByte = readUint8(); - if (initialByte === 0xff) - return -1; - var length = readLength(initialByte & 0x1f); - if (length < 0 || (initialByte >> 5) !== majorType) - throw "Invalid indefinite length element"; - return length; - } - - function appendUtf16data(utf16data, length) { - for (var i = 0; i < length; ++i) { - var value = readUint8(); - if (value & 0x80) { - if (value < 0xe0) { - value = (value & 0x1f) << 6 - | (readUint8() & 0x3f); - length -= 1; - } else if (value < 0xf0) { - value = (value & 0x0f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 2; - } else { - value = (value & 0x0f) << 18 - | (readUint8() & 0x3f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 3; - } - } - - if (value < 0x10000) { - utf16data.push(value); - } else { - value -= 0x10000; - utf16data.push(0xd800 | (value >> 10)); - utf16data.push(0xdc00 | (value & 0x3ff)); - } - } - } - - function decodeItem() { - var initialByte = readUint8(); - var majorType = initialByte >> 5; - var additionalInformation = initialByte & 0x1f; - var i; - var length; - - if (majorType === 7) { - switch (additionalInformation) { - case 25: - return readFloat16(); - case 26: - return readFloat32(); - case 27: - return readFloat64(); - } - } - - length = readLength(additionalInformation); - if (length < 0 && (majorType < 2 || 6 < majorType)) - throw "Invalid length"; - - switch (majorType) { - case 0: - return length; - case 1: - return -1 - length; - case 2: - if (length < 0) { - var elements = []; - var fullArrayLength = 0; - while ((length = readIndefiniteStringLength(majorType)) >= 0) { - fullArrayLength += length; - elements.push(readArrayBuffer(length)); - } - var fullArray = new Uint8Array(fullArrayLength); - var fullArrayOffset = 0; - for (i = 0; i < elements.length; ++i) { - fullArray.set(elements[i], fullArrayOffset); - fullArrayOffset += elements[i].length; - } - return fullArray; - } - return readArrayBuffer(length); - case 3: - var utf16data = []; - if (length < 0) { - while ((length = readIndefiniteStringLength(majorType)) >= 0) - appendUtf16data(utf16data, length); - } else - appendUtf16data(utf16data, length); - return String.fromCharCode.apply(null, utf16data); - case 4: - var retArray; - if (length < 0) { - retArray = []; - while (!readBreak()) - retArray.push(decodeItem()); - } else { - retArray = new Array(length); - for (i = 0; i < length; ++i) - retArray[i] = decodeItem(); - } - return retArray; - case 5: - var retObject = {}; - for (i = 0; i < length || length < 0 && !readBreak(); ++i) { - var key = decodeItem(); - retObject[key] = decodeItem(); - } - return retObject; - case 6: - return tagger(decodeItem(), length); - case 7: - switch (length) { - case 20: - return false; - case 21: - return true; - case 22: - return null; - case 23: - return undefined; - default: - return simpleValue(length); - } - } - } - - var ret = decodeItem(); - if (offset !== data.byteLength) - throw "Remaining bytes"; - return ret; -} - -var obj = { encode: encode, decode: decode }; - -if (typeof define === "function" && define.amd) - define("cbor/cbor", obj); -else if (typeof module !== 'undefined' && module.exports) - module.exports = obj; -else if (!global.CBOR) - global.CBOR = obj; - -})(this); +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 Patrick Gansterer + * + * 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. + */ + +(function(global, undefined) { "use strict"; +var POW_2_24 = Math.pow(2, -24), + POW_2_32 = Math.pow(2, 32), + POW_2_53 = Math.pow(2, 53); + +function encode(value) { + var data = new ArrayBuffer(256); + var dataView = new DataView(data); + var lastLength; + var offset = 0; + + function ensureSpace(length) { + var newByteLength = data.byteLength; + var requiredLength = offset + length; + while (newByteLength < requiredLength) + newByteLength *= 2; + if (newByteLength !== data.byteLength) { + var oldDataView = dataView; + data = new ArrayBuffer(newByteLength); + dataView = new DataView(data); + var uint32count = (offset + 3) >> 2; + for (var i = 0; i < uint32count; ++i) + dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); + } + + lastLength = length; + return dataView; + } + function write() { + offset += lastLength; + } + function writeFloat64(value) { + write(ensureSpace(8).setFloat64(offset, value)); + } + function writeUint8(value) { + write(ensureSpace(1).setUint8(offset, value)); + } + function writeUint8Array(value) { + var dataView = ensureSpace(value.length); + for (var i = 0; i < value.length; ++i) + dataView.setUint8(offset + i, value[i]); + write(); + } + function writeUint16(value) { + write(ensureSpace(2).setUint16(offset, value)); + } + function writeUint32(value) { + write(ensureSpace(4).setUint32(offset, value)); + } + function writeUint64(value) { + var low = value % POW_2_32; + var high = (value - low) / POW_2_32; + var dataView = ensureSpace(8); + dataView.setUint32(offset, high); + dataView.setUint32(offset + 4, low); + write(); + } + function writeTypeAndLength(type, length) { + if (length < 24) { + writeUint8(type << 5 | length); + } else if (length < 0x100) { + writeUint8(type << 5 | 24); + writeUint8(length); + } else if (length < 0x10000) { + writeUint8(type << 5 | 25); + writeUint16(length); + } else if (length < 0x100000000) { + writeUint8(type << 5 | 26); + writeUint32(length); + } else { + writeUint8(type << 5 | 27); + writeUint64(length); + } + } + + function encodeItem(value) { + var i; + + if (value === false) + return writeUint8(0xf4); + if (value === true) + return writeUint8(0xf5); + if (value === null) + return writeUint8(0xf6); + if (value === undefined) + return writeUint8(0xf7); + + switch (typeof value) { + case "number": + if (Math.floor(value) === value) { + if (0 <= value && value <= POW_2_53) + return writeTypeAndLength(0, value); + if (-POW_2_53 <= value && value < 0) + return writeTypeAndLength(1, -(value + 1)); + } + writeUint8(0xfb); + return writeFloat64(value); + + case "string": + var utf8data = []; + for (i = 0; i < value.length; ++i) { + var charCode = value.charCodeAt(i); + if (charCode < 0x80) { + utf8data.push(charCode); + } else if (charCode < 0x800) { + utf8data.push(0xc0 | charCode >> 6); + utf8data.push(0x80 | charCode & 0x3f); + } else if (charCode < 0xd800) { + utf8data.push(0xe0 | charCode >> 12); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } else { + charCode = (charCode & 0x3ff) << 10; + charCode |= value.charCodeAt(++i) & 0x3ff; + charCode += 0x10000; + + utf8data.push(0xf0 | charCode >> 18); + utf8data.push(0x80 | (charCode >> 12) & 0x3f); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } + } + + writeTypeAndLength(3, utf8data.length); + return writeUint8Array(utf8data); + + default: + var length; + if (Array.isArray(value)) { + length = value.length; + writeTypeAndLength(4, length); + for (i = 0; i < length; ++i) + encodeItem(value[i]); + } else if (value instanceof Uint8Array) { + writeTypeAndLength(2, value.length); + writeUint8Array(value); + } else { + var keys = Object.keys(value); + length = keys.length; + writeTypeAndLength(5, length); + for (i = 0; i < length; ++i) { + var key = keys[i]; + encodeItem(key); + encodeItem(value[key]); + } + } + } + } + + encodeItem(value); + + if ("slice" in data) + return data.slice(0, offset); + + var ret = new ArrayBuffer(offset); + var retView = new DataView(ret); + for (var i = 0; i < offset; ++i) + retView.setUint8(i, dataView.getUint8(i)); + return ret; +} + +function decode(data, tagger, simpleValue) { + var dataView = new DataView(data); + var offset = 0; + + if (typeof tagger !== "function") + tagger = function(value) { return value; }; + if (typeof simpleValue !== "function") + simpleValue = function() { return undefined; }; + + function read(value, length) { + offset += length; + return value; + } + function readArrayBuffer(length) { + return read(new Uint8Array(data, offset, length), length); + } + function readFloat16() { + var tempArrayBuffer = new ArrayBuffer(4); + var tempDataView = new DataView(tempArrayBuffer); + var value = readUint16(); + + var sign = value & 0x8000; + var exponent = value & 0x7c00; + var fraction = value & 0x03ff; + + if (exponent === 0x7c00) + exponent = 0xff << 10; + else if (exponent !== 0) + exponent += (127 - 15) << 10; + else if (fraction !== 0) + return fraction * POW_2_24; + + tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); + return tempDataView.getFloat32(0); + } + function readFloat32() { + return read(dataView.getFloat32(offset), 4); + } + function readFloat64() { + return read(dataView.getFloat64(offset), 8); + } + function readUint8() { + return read(dataView.getUint8(offset), 1); + } + function readUint16() { + return read(dataView.getUint16(offset), 2); + } + function readUint32() { + return read(dataView.getUint32(offset), 4); + } + function readUint64() { + return readUint32() * POW_2_32 + readUint32(); + } + function readBreak() { + if (dataView.getUint8(offset) !== 0xff) + return false; + offset += 1; + return true; + } + function readLength(additionalInformation) { + if (additionalInformation < 24) + return additionalInformation; + if (additionalInformation === 24) + return readUint8(); + if (additionalInformation === 25) + return readUint16(); + if (additionalInformation === 26) + return readUint32(); + if (additionalInformation === 27) + return readUint64(); + if (additionalInformation === 31) + return -1; + throw "Invalid length encoding"; + } + function readIndefiniteStringLength(majorType) { + var initialByte = readUint8(); + if (initialByte === 0xff) + return -1; + var length = readLength(initialByte & 0x1f); + if (length < 0 || (initialByte >> 5) !== majorType) + throw "Invalid indefinite length element"; + return length; + } + + function appendUtf16data(utf16data, length) { + for (var i = 0; i < length; ++i) { + var value = readUint8(); + if (value & 0x80) { + if (value < 0xe0) { + value = (value & 0x1f) << 6 + | (readUint8() & 0x3f); + length -= 1; + } else if (value < 0xf0) { + value = (value & 0x0f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 2; + } else { + value = (value & 0x0f) << 18 + | (readUint8() & 0x3f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 3; + } + } + + if (value < 0x10000) { + utf16data.push(value); + } else { + value -= 0x10000; + utf16data.push(0xd800 | (value >> 10)); + utf16data.push(0xdc00 | (value & 0x3ff)); + } + } + } + + function decodeItem() { + var initialByte = readUint8(); + var majorType = initialByte >> 5; + var additionalInformation = initialByte & 0x1f; + var i; + var length; + + if (majorType === 7) { + switch (additionalInformation) { + case 25: + return readFloat16(); + case 26: + return readFloat32(); + case 27: + return readFloat64(); + } + } + + length = readLength(additionalInformation); + if (length < 0 && (majorType < 2 || 6 < majorType)) + throw "Invalid length"; + + switch (majorType) { + case 0: + return length; + case 1: + return -1 - length; + case 2: + if (length < 0) { + var elements = []; + var fullArrayLength = 0; + while ((length = readIndefiniteStringLength(majorType)) >= 0) { + fullArrayLength += length; + elements.push(readArrayBuffer(length)); + } + var fullArray = new Uint8Array(fullArrayLength); + var fullArrayOffset = 0; + for (i = 0; i < elements.length; ++i) { + fullArray.set(elements[i], fullArrayOffset); + fullArrayOffset += elements[i].length; + } + return fullArray; + } + return readArrayBuffer(length); + case 3: + var utf16data = []; + if (length < 0) { + while ((length = readIndefiniteStringLength(majorType)) >= 0) + appendUtf16data(utf16data, length); + } else + appendUtf16data(utf16data, length); + return String.fromCharCode.apply(null, utf16data); + case 4: + var retArray; + if (length < 0) { + retArray = []; + while (!readBreak()) + retArray.push(decodeItem()); + } else { + retArray = new Array(length); + for (i = 0; i < length; ++i) + retArray[i] = decodeItem(); + } + return retArray; + case 5: + var retObject = {}; + for (i = 0; i < length || length < 0 && !readBreak(); ++i) { + var key = decodeItem(); + retObject[key] = decodeItem(); + } + return retObject; + case 6: + return tagger(decodeItem(), length); + case 7: + switch (length) { + case 20: + return false; + case 21: + return true; + case 22: + return null; + case 23: + return undefined; + default: + return simpleValue(length); + } + } + } + + var ret = decodeItem(); + if (offset !== data.byteLength) + throw "Remaining bytes"; + return ret; +} + +var obj = { encode: encode, decode: decode }; + +if (typeof define === "function" && define.amd) + define("cbor/cbor", obj); +else if (typeof module !== 'undefined' && module.exports) + module.exports = obj; +else if (!global.CBOR) + global.CBOR = obj; + +})(this); },{}],6:[function(require,module,exports){ 'use strict'; @@ -7388,7 +7388,8 @@ var cryptoUtils = require('./crypto/utils'); var bech32 = require('./crypto/bech32'); var BTCValidator = require('./bitcoin_validator'); -function validateAddress(address, currency, networkType) { +function validateAddress(address, currency, opts) { + var networkType = opts ? opts.networkType : '' var prefix = 'bitcoincash'; var regexp = new RegExp(currency.regexp); var raw_address; @@ -7418,7 +7419,7 @@ function validateAddress(address, currency, networkType) { try { if (bech32.verifyChecksum(prefix, decoded)) { - return false; + return false; } } catch(e) { return false; @@ -7431,6 +7432,7 @@ module.exports = { return validateAddress(address, currency, networkType) || BTCValidator.isValidAddress(address, currency, networkType); } } + },{"./bitcoin_validator":38,"./crypto/bech32":41,"./crypto/utils":48}],38:[function(require,module,exports){ (function (Buffer){ var base58 = require('./crypto/base58'); @@ -7495,8 +7497,8 @@ function getAddressType(address, currency) { return null; } -function isValidP2PKHandP2SHAddress(address, currency, networkType) { - networkType = networkType || DEFAULT_NETWORK_TYPE; +function isValidP2PKHandP2SHAddress(address, currency, opts) { + var networkType = opts ? (opts.networkType || DEFAULT_NETWORK_TYPE) : DEFAULT_NETWORK_TYPE var correctAddressTypes; var addressType = getAddressType(address, currency); @@ -11407,8 +11409,8 @@ function hextobin(hex) { } module.exports = { - isValidAddress: function(address, currency, networkType) { - networkType = networkType || DEFAULT_NETWORK_TYPE + isValidAddress: function(address, currency, opts) { + var networkType = opts ? (opts.networkType || DEFAULT_NETWORK_TYPE) : DEFAULT_NETWORK_TYPE var addressType = 'standard' if (!addressRegTest.test(address)) { if (integratedAddressRegTest.test(address)) { @@ -11679,7 +11681,8 @@ module.exports = { /** * tron address validation */ - isValidAddress: function (mainAddress, currency, networkType) { + isValidAddress: function (mainAddress, currency, opts) { + var networkType = opts ? opts.networkType : ''; var address = decodeBase58Address(mainAddress); if (!address) { @@ -11693,6 +11696,7 @@ module.exports = { return getEnv(currency, networkType) === address[0]; } }; + },{"./crypto/utils":48}],61:[function(require,module,exports){ var BTCValidator = require('./bitcoin_validator'); var ETHValidator = require('./ethereum_validator'); @@ -11705,13 +11709,11 @@ function checkBothValidators(address, currency, networkType) { module.exports = { isValidAddress: function (address, currency, opts) { - if (opts && typeof opts === 'object') { + if (opts) { if (opts.chainType === 'erc20') { return ETHValidator.isValidAddress(address, currency, opts.networkType); } else if (opts.chainType === 'omni') { return BTCValidator.isValidAddress(address, currency, opts.networkType); - } else { - throw new Error(`Unknown chainType: ${opts.chainType}`); } } return checkBothValidators(address, currency, opts); @@ -11724,11 +11726,15 @@ var currencies = require('./currencies'); var DEFAULT_CURRENCY_NAME = 'bitcoin'; module.exports = { - validate: function (address, currencyNameOrSymbol, networkType) { + //validate: function (address, currencyNameOrSymbol, networkType) { + validate: function (address, currencyNameOrSymbol, opts) { var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME); if (currency && currency.validator) { - return currency.validator.isValidAddress(address, currency, networkType); + if (opts && typeof opts === 'string') { + return currency.validator.isValidAddress(address, currency, { networkType: opts }); + } + return currency.validator.isValidAddress(address, currency, opts); } throw new Error('Missing validator for currency: ' + currencyNameOrSymbol); diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 35589a23..633f45bf 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],U=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,U=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,C=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i 16) { + if (dec === null || dec.data.length < 1 || dec.data[0] > 16) { return null; } var res = convertbits(dec.data.slice(1), 5, 8, false); @@ -9966,32 +9974,43 @@ function decode (hrp, addr) { if (dec.data[0] === 0 && res.length !== 20 && res.length !== 32) { return null; } - return {version: dec.data[0], program: res}; + return {hrp: dec.hrp, version: dec.data[0], program: res}; } function encode (hrp, version, program) { var ret = bech32.encode(hrp, [version].concat(convertbits(program, 8, 5, true))); - if (decode(hrp, ret) === null) { + + if (decode(ret) === null) { return null; } return ret; } -function isValidAddress(address) { - var hrp = 'bc'; - var ret = decode(hrp, address); +function isValidAddress(address, currency, opts) { + var networkType = opts ? (opts.networkType || DEFAULT_NETWORK_TYPE) : DEFAULT_NETWORK_TYPE + var ret = decode(address); - if (ret === null) { - hrp = 'tb'; - ret = decode(hrp, address); + if(ret === null) { + return false; } - if (ret === null) { + var correctBech32Hrps; + var bech32Hrp = ret.hrp; + + if (bech32Hrp) { + if (networkType === 'prod' || networkType === 'testnet') { + correctBech32Hrps = currency.bech32Hrp[networkType]; + } else { + correctBech32Hrps = currency.bech32Hrp.prod.concat(currency.bech32Hrp.testnet) + } + + if (correctBech32Hrps.indexOf(bech32Hrp) === -1) { return false; + } + + return encode(ret.hrp, ret.version, ret.program) === address.toLowerCase(); } - var recreate = encode(hrp, ret.version, ret.program); - return recreate === address.toLowerCase(); } module.exports = { @@ -10795,6 +10814,7 @@ var CURRENCIES = [{ name: 'Bitcoin', symbol: 'btc', addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26'] }, + bech32Hrp: { prod: ['bc'], testnet: ['tb'] }, validator: BTCValidator }, { name: 'BitcoinCash', @@ -10812,6 +10832,7 @@ var CURRENCIES = [{ name: 'LiteCoin', symbol: 'ltc', addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, + bech32Hrp: { prod: ['ltc'], testnet: ['tltc'] }, validator: BTCValidator }, { name: 'PeerCoin', diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 633f45bf..af7213d1 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,C=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?a-4:a;for(r=0;r>16&255,u[c++]=e>>8&255,u[c++]=255&e;2===s&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[c++]=255&e);1===s&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[c++]=e>>8&255,u[c++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){(function(e){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=e,r.SlowBuffer=function(t){+t!=t&&(t=0);return e.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return r.__proto__=e.prototype,r}function e(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,r,n){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|h(t,r),i=a(n),o=i.write(t,r);o!==n&&(i=i.slice(0,o));return i}(t,r);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(z(t,ArrayBuffer)||t&&z(t.buffer,ArrayBuffer))return function(t,r,n){if(r<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function h(t,r){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var o=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return L(t).length;default:if(o)return i?-1:N(t).length;r=(""+r).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function p(t,r,n,i,o){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),H(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof r&&(r=e.from(r,i)),e.isBuffer(r))return 0===r.length?-1:v(t,r,n,i,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):v(t,[r],n,i,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},e.prototype.compare=function(t,r,n,i,o){if(z(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var a=o-i,s=n-r,u=Math.min(a,s),f=this.slice(i,o),c=t.slice(r,n),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return y(this,t,e,r);case"utf8":case"utf-8":return g(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function S(t,r,n,i,o,a){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||rt.length)throw new RangeError("Index out of range")}function O(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,o){return e=+e,r>>>=0,o||O(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,o){return e=+e,r>>>=0,o||O(t,0,r,8),i.write(t,e,r,n,52,8),r+8}e.prototype.slice=function(t,r){var n=this.length;t=~~t,r=void 0===r?n:~~r,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},e.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,i){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r=0;--a)t[a+r]=this[a+n];else Uint8Array.prototype.set.call(t,this.subarray(n,i),r);return o},e.prototype.fill=function(t,r,n,i){if("string"==typeof t){if("string"==typeof r?(i=r,r=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!e.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){var o=t.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(t=o)}}else"number"==typeof t&&(t&=255);if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(a=r;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function L(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}}).call(this,t("buffer").Buffer)},{"base64-js":2,buffer:4,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,C=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i 16) { + if (dec === null || dec.data.length < 1 || dec.data[0] > 16) { return null; } var res = convertbits(dec.data.slice(1), 5, 8, false); @@ -59,32 +61,43 @@ function decode (hrp, addr) { if (dec.data[0] === 0 && res.length !== 20 && res.length !== 32) { return null; } - return {version: dec.data[0], program: res}; + return {hrp: dec.hrp, version: dec.data[0], program: res}; } function encode (hrp, version, program) { var ret = bech32.encode(hrp, [version].concat(convertbits(program, 8, 5, true))); - if (decode(hrp, ret) === null) { + + if (decode(ret) === null) { return null; } return ret; } -function isValidAddress(address) { - var hrp = 'bc'; - var ret = decode(hrp, address); +function isValidAddress(address, currency, opts) { + var networkType = opts ? (opts.networkType || DEFAULT_NETWORK_TYPE) : DEFAULT_NETWORK_TYPE + var ret = decode(address); - if (ret === null) { - hrp = 'tb'; - ret = decode(hrp, address); + if(ret === null) { + return false; } - if (ret === null) { + var correctBech32Hrps; + var bech32Hrp = ret.hrp; + + if (bech32Hrp) { + if (networkType === 'prod' || networkType === 'testnet') { + correctBech32Hrps = currency.bech32Hrp[networkType]; + } else { + correctBech32Hrps = currency.bech32Hrp.prod.concat(currency.bech32Hrp.testnet) + } + + if (correctBech32Hrps.indexOf(bech32Hrp) === -1) { return false; + } + + return encode(ret.hrp, ret.version, ret.program) === address.toLowerCase(); } - var recreate = encode(hrp, ret.version, ret.program); - return recreate === address.toLowerCase(); } module.exports = { diff --git a/src/currencies.js b/src/currencies.js index 98027787..443ddfdc 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -19,6 +19,7 @@ var CURRENCIES = [{ name: 'Bitcoin', symbol: 'btc', addressTypes: { prod: ['00', '05'], testnet: ['6f', 'c4', '3c', '26'] }, + bech32Hrp: { prod: ['bc'], testnet: ['tb'] }, validator: BTCValidator }, { name: 'BitcoinCash', @@ -36,6 +37,7 @@ var CURRENCIES = [{ name: 'LiteCoin', symbol: 'ltc', addressTypes: { prod: ['30', '05', '32'], testnet: ['6f', 'c4', '3a'] }, + bech32Hrp: { prod: ['ltc'], testnet: ['tltc'] }, validator: BTCValidator }, { name: 'PeerCoin', diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 4d59fd42..368aa42d 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -46,22 +46,22 @@ describe('WAValidator.validate()', function () { // segwit addresses valid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'bitcoin'); - valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 'bitcoin'); + valid('tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 'bitcoin', 'testnet'); valid('bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx', 'bitcoin'); valid('BC1SW50QA3JX3S', 'bitcoin'); valid('bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj', 'bitcoin'); - valid('tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy', 'bitcoin'); + valid('tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy', 'bitcoin', 'testnet'); invalid("tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", 'bitcoin'), - invalid("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", 'bitcoin'), - invalid("BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", 'bitcoin'), - invalid("bc1rw5uspcuh", 'bitcoin'), - invalid("bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90", 'bitcoin'), - invalid("BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P", 'bitcoin'), - invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7", 'bitcoin'), - invalid("bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", 'bitcoin'), - invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv", 'bitcoin'), - invalid("bc1gmk9yu", 'bitcoin') + invalid("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", 'bitcoin'), + invalid("BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", 'bitcoin'), + invalid("bc1rw5uspcuh", 'bitcoin'), + invalid("bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90", 'bitcoin'), + invalid("BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P", 'bitcoin'), + invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7", 'bitcoin'), + invalid("bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", 'bitcoin'), + invalid("tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv", 'bitcoin'), + invalid("bc1gmk9yu", 'bitcoin') }); it('should return true for correct bitcoincash addresses', function () { @@ -96,6 +96,10 @@ describe('WAValidator.validate()', function () { valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'litecoin', 'testnet'); valid('QW2SvwjaJU8LD6GSmtm1PHnBG2xPuxwZFy', 'litecoin', 'testnet'); valid('QjpzxpbLp5pCGsCczMbfh1uhC3P89QZavY', 'litecoin', 'testnet'); + + // segwit addresses + valid('ltc1qg42tkwuuxefutzxezdkdel39gfstuap288mfea', 'litecoin'); + }); it('should return true for correct peercoin addresses', function () { From 597c24237d7fcd09e29a9c13a631191de59e3285 Mon Sep 17 00:00:00 2001 From: Chris Tsimogiannis Date: Thu, 20 Aug 2020 15:06:08 +0200 Subject: [PATCH 104/108] updated to version 0.4.7 after litecoin segwit pr merge. --- dist/wallet-address-validator.js | 10 +- dist/wallet-address-validator.min.js | 2 +- package.json | 2 +- test/wallet_address_validator.js | 2335 +++++++++++++------------- 4 files changed, 1172 insertions(+), 1177 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 6ecde6d2..9917bcb4 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -191,8 +191,7 @@ function toByteArray (b64) { ? validLen - 4 : validLen - var i - for (i = 0; i < len; i += 4) { + for (var i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | @@ -2396,7 +2395,6 @@ module.exports = BigNumber; }).call(this,require("buffer").Buffer) },{"buffer":4}],4:[function(require,module,exports){ -(function (Buffer){ /*! * The buffer module from node.js, for the browser. * @@ -4175,8 +4173,7 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -}).call(this,require("buffer").Buffer) -},{"base64-js":2,"buffer":4,"ieee754":31}],5:[function(require,module,exports){ +},{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ /* * The MIT License (MIT) * @@ -7286,7 +7283,6 @@ process.chdir = function (dir) { process.umask = function() { return 0; }; },{}],35:[function(require,module,exports){ -/*! safe-buffer. MIT License. Feross Aboukhadijeh */ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -7309,8 +7305,6 @@ function SafeBuffer (arg, encodingOrOffset, length) { return Buffer(arg, encodingOrOffset, length) } -SafeBuffer.prototype = Object.create(Buffer.prototype) - // Copy static methods from Buffer copyProps(Buffer, SafeBuffer) diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index af7213d1..2e620be7 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?a-4:a;for(r=0;r>16&255,u[c++]=e>>8&255,u[c++]=255&e;2===s&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[c++]=255&e);1===s&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[c++]=e>>8&255,u[c++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){(function(e){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=e,r.SlowBuffer=function(t){+t!=t&&(t=0);return e.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return r.__proto__=e.prototype,r}function e(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,r,n){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|h(t,r),i=a(n),o=i.write(t,r);o!==n&&(i=i.slice(0,o));return i}(t,r);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(z(t,ArrayBuffer)||t&&z(t.buffer,ArrayBuffer))return function(t,r,n){if(r<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function h(t,r){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var o=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return L(t).length;default:if(o)return i?-1:N(t).length;r=(""+r).toLowerCase(),o=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function p(t,r,n,i,o){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),H(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof r&&(r=e.from(r,i)),e.isBuffer(r))return 0===r.length?-1:v(t,r,n,i,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):v(t,[r],n,i,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},e.prototype.compare=function(t,r,n,i,o){if(z(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var a=o-i,s=n-r,u=Math.min(a,s),f=this.slice(i,o),c=t.slice(r,n),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return y(this,t,e,r);case"utf8":case"utf-8":return g(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function S(t,r,n,i,o,a){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||rt.length)throw new RangeError("Index out of range")}function O(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,o){return e=+e,r>>>=0,o||O(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,o){return e=+e,r>>>=0,o||O(t,0,r,8),i.write(t,e,r,n,52,8),r+8}e.prototype.slice=function(t,r){var n=this.length;t=~~t,r=void 0===r?n:~~r,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},e.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),i.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),i.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,i){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r=0;--a)t[a+r]=this[a+n];else Uint8Array.prototype.set.call(t,this.subarray(n,i),r);return o},e.prototype.fill=function(t,r,n,i){if("string"==typeof t){if("string"==typeof r?(i=r,r=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!e.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){var o=t.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(t=o)}}else"number"==typeof t&&(t&=255);if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(a=r;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function L(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}}).call(this,t("buffer").Buffer)},{"base64-js":2,buffer:4,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,C=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),P(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function P(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,C=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i Date: Tue, 6 Oct 2020 16:58:57 +0200 Subject: [PATCH 105/108] added cardano shelly support --- dist/wallet-address-validator.js | 128 ++++--- dist/wallet-address-validator.min.js | 2 +- package.json | 12 +- src/ada_validator.js | 56 ++- src/bitcoin_validator.js | 6 +- src/crypto/bech32.js | 2 +- src/crypto/segwit_addr.js | 4 +- src/crypto/utils.js | 2 +- src/currencies.js | 1 + src/monero_validator.js | 4 +- test/wallet_address_validator.js | 8 + yarn.lock | 490 +++++++++++++++++---------- 12 files changed, 442 insertions(+), 273 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index 9917bcb4..dd3b2a5a 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -5215,34 +5215,27 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { } },{}],32:[function(require,module,exports){ -/* - A JavaScript implementation of the SHA family of hashes, as - defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding - HMAC implementation as defined in FIPS PUB 198a - - Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors - Distributed under the BSD License - See http://caligatio.github.com/jsSHA/ for more information -*/ -'use strict';(function(K){function w(c,a,d){var g=0,b=[],h=0,e,k,n,f,l,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};e=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(a,b){return A(a,b,c)},y=function(a,b,g,h){var d,e;if("SHA-224"===c||"SHA-256"===c)d=(b+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;a.length<=d;)a.push(0);a[b>>>5]|=128<<24-b%32;b=b+g;a[d]=b&4294967295; -a[d-1]=b/4294967296|0;g=a.length;for(b=0;b>>3;h=d/4-1;for(d>>5;c=n(a,b,h);a=c.binLen;d=c.value;c=a>>>5;for(e=0;e>>5);h=a%l;z=!0};this.getHash=function(a,d){var e,l,n,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key"); -n=C(d);switch(a){case "HEX":e=function(a){return D(a,f,n)};break;case "B64":e=function(a){return E(a,f,n)};break;case "BYTES":e=function(a){return F(a,f)};break;case "ARRAYBUFFER":try{l=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}e=function(a){return G(a,f)};break;case "UINT8ARRAY":try{l=new Uint8Array(0)}catch(v){throw Error("UINT8ARRAY not supported by this environment");}e=function(a){return H(a,f)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY"); -}q=y(b.slice(),h,g,p(k));for(l=1;l>>3;for(g=0;g>>2,a.length<=h&&a.push(0),a[h]|=c[g]<<8*(3+e%4*-1);return{value:a,binLen:8*c.length+d}}function D(c,a,d){var g="";a/=8;var b, -h;for(b=0;b>>2]>>>8*(3+b%4*-1),g+="0123456789abcdef".charAt(h>>>4&15)+"0123456789abcdef".charAt(h&15);return d.outputUpper?g.toUpperCase():g}function E(c,a,d){var g="",b=a/8,h,e,k;for(h=0;h>>2]:0,k=h+2>>2]:0,k=(c[h>>>2]>>>8*(3+h%4*-1)&255)<<16|(e>>>8*(3+(h+1)%4*-1)&255)<<8|k>>>8*(3+(h+2)%4*-1)&255,e=0;4>e;e+=1)8*h+6*e<=a?g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(k>>>6*(3-e)&63):g+=d.b64Pad;return g}function F(c,a){var d= -"",g=a/8,b,h;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(h);return d}function G(c,a){var d=a/8,g,b=new ArrayBuffer(d),h;h=new Uint8Array(b);for(g=0;g>>2]>>>8*(3+g%4*-1)&255;return b}function H(c,a){var d=a/8,g,b=new Uint8Array(d);for(g=0;g>>2]>>>8*(3+g%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); -if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var d=a.length,k,n,f,l,q;if(0!==d%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(k=0;k>>1)+q;for(f=l>>>2;b.length<=f;)b.push(0);b[f]|=n<<8*(3+l%4*-1)}return{value:b,binLen:4*d+c}};break;case "TEXT":d=function(c,b,d){var e,k,n=0,f,l,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,f=0;fe?k.push(e):2048>e?(k.push(192|e>>>6),k.push(128|e&63)):55296>e||57344<=e?k.push(224|e>>>12,128|e>>>6&63,128|e&63):(f+=1,e=65536+((e&1023)<<10|c.charCodeAt(f)&1023),k.push(240|e>>>18,128|e>>>12&63,128|e>>>6&63,128|e&63)),l=0;l>>2;b.length<=m;)b.push(0);b[m]|=k[l]<<8*(r+p%4*-1);n+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,k="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,f=0;f>>8);p=n+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=e<<8*(r+p%4*-1);n+=2}return{value:b,binLen:8*n+d}};break;case "B64":d=function(a,b,c){var d=0,k,n,f,l,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");n=a.indexOf("=");a=a.replace(/\=/g, -"");if(-1!==n&&n>>2;w.length<=h;)w.push(0);w[h]|=(s>>>16-8*u&255)<<8*(E+e*(a%4)),c+=1}}return{value:w,binLen:8*c+i}}(t,n,i,e)};case"BYTES":return function(t,r,n){return function(t,r,n,i){var e,o,u,s,f=r||[0],h=(n=n||0)>>>3,a=-1===i?3:0;for(o=0;o>>2,f.length<=u&&f.push(0),f[u]|=e<<8*(a+i*(s%4));return{value:f,binLen:8*t.length+n}}(t,r,n,e)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,r,i){return function(t,r,i,e){return n(new Uint8Array(t),r,i,e)}(t,r,i,e)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,r,i){return n(t,r,i,e)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function e(t,n,i,e){switch(t){case"HEX":return function(t){return function(t,r,n,i){var e,o,u="",s=r/8,f=-1===n?3:0;for(e=0;e>>2]>>>8*(f+n*(e%4)),u+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return i.outputUpper?u.toUpperCase():u}(t,n,i,e)};case"B64":return function(t){return function(t,n,i,e){var o,u,s,f,h,a="",c=n/8,w=-1===i?3:0;for(o=0;o>>2]:0,h=o+2>>2]:0,s=(t[o>>>2]>>>8*(w+i*(o%4))&255)<<16|(f>>>8*(w+i*((o+1)%4))&255)<<8|h>>>8*(w+i*((o+2)%4))&255,u=0;u<4;u+=1)a+=8*o+6*u<=n?r.charAt(s>>>6*(3-u)&63):e.b64Pad;return a}(t,n,i,e)};case"BYTES":return function(t){return function(t,r,n){var i,e,o="",u=r/8,s=-1===n?3:0;for(i=0;i>>2]>>>8*(s+n*(i%4))&255,o+=String.fromCharCode(e);return o}(t,n,i)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,r,n){var i,e=r/8,o=new ArrayBuffer(e),u=new Uint8Array(o),s=-1===n?3:0;for(i=0;i>>2]>>>8*(s+n*(i%4))&255;return o}(t,n,i)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,r,n){var i,e=r/8,o=-1===n?3:0,u=new Uint8Array(e);for(i=0;i>>2]>>>8*(o+n*(i%4))&255;return u}(t,n,i)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}var o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],u=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],s=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function f(t){var r={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},i="Output length must be a multiple of 8";if(r.outputUpper=n.outputUpper||!1,n.b64Pad&&(r.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(i);r.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(i);r.outputLen=n.shakeLen}if("boolean"!=typeof r.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof r.b64Pad)throw new Error("Invalid b64Pad formatting option");return r}function h(t,r){return t>>>r|t<<32-r}function a(t,r){return t>>>r}function c(t,r,n){return t&r^~t&n}function w(t,r,n){return t&r^t&n^r&n}function v(t){return h(t,2)^h(t,13)^h(t,22)}function E(t,r){var n=(65535&t)+(65535&r);return(65535&(t>>>16)+(r>>>16)+(n>>>16))<<16|65535&n}function A(t,r,n,i){var e=(65535&t)+(65535&r)+(65535&n)+(65535&i);return(65535&(t>>>16)+(r>>>16)+(n>>>16)+(i>>>16)+(e>>>16))<<16|65535&e}function p(t,r,n,i,e){var o=(65535&t)+(65535&r)+(65535&n)+(65535&i)+(65535&e);return(65535&(t>>>16)+(r>>>16)+(n>>>16)+(i>>>16)+(e>>>16)+(o>>>16))<<16|65535&o}function d(t){return h(t,7)^h(t,18)^a(t,3)}function l(t){return h(t,6)^h(t,11)^h(t,25)}function R(t){return"SHA-224"==t?u.slice():s.slice()}function U(t,r){var n,i,e,u,s,f,R,U,y,b,T,m,F=[];for(n=r[0],i=r[1],e=r[2],u=r[3],s=r[4],f=r[5],R=r[6],U=r[7],T=0;T<64;T+=1)F[T]=T<16?t[T]:A(h(m=F[T-2],17)^h(m,19)^a(m,10),F[T-7],d(F[T-15]),F[T-16]),y=p(U,l(s),c(s,f,R),o[T],F[T]),b=E(v(n),w(n,i,e)),U=R,R=f,f=s,s=E(u,y),u=e,e=i,i=n,n=E(y,b);return r[0]=E(n,r[0]),r[1]=E(i,r[1]),r[2]=E(e,r[2]),r[3]=E(u,r[3]),r[4]=E(s,r[4]),r[5]=E(f,r[5]),r[6]=E(R,r[6]),r[7]=E(U,r[7]),r}return function(r){function n(t,n,e){var o=this;if("SHA-224"!==t&&"SHA-256"!==t)throw new Error("Chosen SHA variant is not supported");var u=e||{};return(o=r.call(this,t,n,e)||this).t=o.i,o.o=!0,o.u=-1,o.s=i(o.h,o.v,o.u),o.A=U,o.p=function(t){return t.slice()},o.l=R,o.R=function(r,n,i,e){return function(t,r,n,i,e){for(var o,u=15+(r+65>>>9<<4),s=r+n;t.length<=u;)t.push(0);for(t[r>>>5]|=128<<24-r%32,t[u]=4294967295&s,t[u-1]=s/4294967296|0,o=0;othis.numRounds)throw new Error("numRounds must a integer >= 1");this.g=t,this.Y=[],this.H=0,this.S=!1,this.I=0,this.C=!1,this.L=[],this.N=[]}return t.prototype.update=function(t){var r,n=0,i=this.T>>>5,e=this.s(t,this.Y,this.H),o=e.binLen,u=e.value,s=o>>>5;for(r=0;r>>5),this.H=o%this.T,this.S=!0},t.prototype.getHash=function(t,r){var n,i,o=this.m,u=f(r);if(this.F){if(-1===u.outputLen)throw new Error("Output length must be specified in options");o=u.outputLen}var s=e(t,o,this.u,u);if(this.C&&this.t)return s(this.t(u));for(i=this.R(this.Y.slice(),this.H,this.I,this.p(this.U),o),n=1;n>>24-o%32),i=this.R(i,o,0,this.l(this.g),o);return s(i)},t.prototype.setHMACKey=function(t,r,n){if(!this.o)throw new Error("Variant does not support HMAC");if(this.S)throw new Error("Cannot set MAC key after calling update");var e=i(r,(n||{}).encoding||"UTF8",this.u);this.B(e(t))},t.prototype.B=function(t){var r,n=this.T>>>3,i=n/4-1;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.C)throw new Error("MAC key already set");for(n bechString.length || bechString.length > 90) { + if (pos < 1 || pos + 7 > bechString.length || bechString.length > 110) { return null; } var hrp = bechString.substring(0, pos); @@ -9981,7 +10000,7 @@ function encode (hrp, version, program) { } function isValidAddress(address, currency, opts) { - var networkType = opts ? (opts.networkType || DEFAULT_NETWORK_TYPE) : DEFAULT_NETWORK_TYPE + const { networkType = DEFAULT_NETWORK_TYPE} = opts; var ret = decode(address); if(ret === null) { @@ -9997,7 +10016,7 @@ function isValidAddress(address, currency, opts) { } else { correctBech32Hrps = currency.bech32Hrp.prod.concat(currency.bech32Hrp.testnet) } - + if (correctBech32Hrps.indexOf(bech32Hrp) === -1) { return false; } @@ -10659,7 +10678,7 @@ module.exports = methods; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"_process":34}],48:[function(require,module,exports){ (function (Buffer){ -var jsSHA = require('jssha/src/sha256'); +var jsSHA = require('jssha/dist/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; var Blake2B = require('./blake2b'); @@ -10786,7 +10805,7 @@ module.exports = { } }).call(this,require("buffer").Buffer) -},{"./base32":39,"./base58":40,"./blake256":43,"./blake2b":44,"./sha3":47,"browserify-bignum":3,"buffer":4,"jssha/src/sha256":32}],49:[function(require,module,exports){ +},{"./base32":39,"./base58":40,"./blake256":43,"./blake2b":44,"./sha3":47,"browserify-bignum":3,"buffer":4,"jssha/dist/sha256":32}],49:[function(require,module,exports){ var XRPValidator = require('./ripple_validator'); var ETHValidator = require('./ethereum_validator'); var BTCValidator = require('./bitcoin_validator'); @@ -11039,6 +11058,7 @@ var CURRENCIES = [{ }, { name: 'Cardano', symbol: 'ada', + bech32Hrp: { prod: ['addr'], testnet: ['addr']}, validator: ADAValidator }, { name: 'Monero', @@ -11424,8 +11444,8 @@ function hextobin(hex) { } module.exports = { - isValidAddress: function(address, currency, opts) { - var networkType = opts ? (opts.networkType || DEFAULT_NETWORK_TYPE) : DEFAULT_NETWORK_TYPE + isValidAddress: function(address, currency, opts = {}) { + const { networkType = DEFAULT_NETWORK_TYPE} = opts; var addressType = 'standard' if (!addressRegTest.test(address)) { if (integratedAddressRegTest.test(address)) { diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 2e620be7..41d490db 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return E(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function E(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return E(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return E(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return E(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,E=i,x=new g(y);if(!w)return m.toS();for(h=x.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?x:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(x),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,x=l.minus(e.times(c=x)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=E,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),P(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function P(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),E=0;for(i=0;i=0;)y(x,h);else y(x,h);return String.fromCharCode.apply(null,x);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){"use strict";!function(t){function n(t,e,r){var n,i,o,d,p,v,y,g,b,m=0,w=[],_=0,A=!1,B=[],k=[],C=!1;if(n=(r=r||{}).encoding||"UTF8",(b=r.numRounds||1)!==parseInt(b,10)||1>b)throw Error("numRounds must a integer >= 1");if(0!==t.lastIndexOf("SHA-",0))throw Error("Chosen SHA variant is not supported");if(v=function(e,r){return x(e,r,t)},y=function(e,r,n,i){var o,a;if("SHA-224"!==t&&"SHA-256"!==t)throw Error("Unexpected error in SHA-2 implementation");for(o=15+(r+65>>>9<<4),a=16;e.length<=o;)e.push(0);for(e[r>>>5]|=128<<24-r%32,r+=n,e[o]=4294967295&r,e[o-1]=r/4294967296|0,n=e.length,r=0;r>>3)/4-1,a>>5;for(t=(e=o(t,w,_)).binLen,r=e.value,e=t>>>5,n=0;n>>5),_=t%p,C=!0},this.getHash=function(e,r){var n,o,h,p;if(!0===A)throw Error("Cannot call getHash after setting HMAC key");switch(h=l(r),e){case"HEX":n=function(t){return a(t,d,h)};break;case"B64":n=function(t){return s(t,d,h)};break;case"BYTES":n=function(t){return u(t,d)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}n=function(t){return f(t,d)};break;case"UINT8ARRAY":try{o=new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}n=function(t){return c(t,d)};break;default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}for(p=y(w.slice(),_,m,g(i)),o=1;o>>3,n=0;n>>2,e.length<=o&&e.push(0),e[o]|=t[n]<<8*(3+a%4*-1);return{value:e,binLen:8*t.length+r}}function a(t,e,r){var n,i,o="";for(e/=8,n=0;n>>2]>>>8*(3+n%4*-1),o+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?o.toUpperCase():o}function s(t,e,r){var n,i,o,a="",s=e/8;for(n=0;n>>2]:0,o=n+2>>2]:0,o=(t[n>>>2]>>>8*(3+n%4*-1)&255)<<16|(i>>>8*(3+(n+1)%4*-1)&255)<<8|o>>>8*(3+(n+2)%4*-1)&255,i=0;4>i;i+=1)a+=8*n+6*i<=e?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(o>>>6*(3-i)&63):r.b64Pad;return a}function u(t,e){var r,n,i="",o=e/8;for(r=0;r>>2]>>>8*(3+r%4*-1)&255,i+=String.fromCharCode(n);return i}function f(t,e){var r,n,i=e/8,o=new ArrayBuffer(i);for(n=new Uint8Array(o),r=0;r>>2]>>>8*(3+r%4*-1)&255;return o}function c(t,e){var r,n=e/8,i=new Uint8Array(n);for(r=0;r>>2]>>>8*(3+r%4*-1)&255;return i}function l(t){var e={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(t=t||{},e.outputUpper=t.outputUpper||!1,!0===t.hasOwnProperty("b64Pad")&&(e.b64Pad=t.b64Pad),"boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function h(t,e){var r;switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":r=function(t,e,r){var n,i,o,a,s,u=t.length;if(0!=u%2)throw Error("String of HEX type must be in byte increments");for(e=e||[0],s=(r=r||0)>>>3,n=0;n>>1)+s)>>>2;e.length<=o;)e.push(0);e[o]|=i<<8*(3+a%4*-1)}return{value:e,binLen:4*u+r}};break;case"TEXT":r=function(t,r,n){var i,o,a,s,u,f,c,l,h=0;if(r=r||[0],u=(n=n||0)>>>3,"UTF8"===e)for(l=3,a=0;a(i=t.charCodeAt(a))?o.push(i):2048>i?(o.push(192|i>>>6),o.push(128|63&i)):55296>i||57344<=i?o.push(224|i>>>12,128|i>>>6&63,128|63&i):(a+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(a)),o.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),s=0;s>>2;r.length<=f;)r.push(0);r[f]|=o[s]<<8*(l+c%4*-1),h+=1}else if("UTF16BE"===e||"UTF16LE"===e)for(l=2,o="UTF16LE"===e||"UTF16LE"!==e&&!1,a=0;a>>8),f=(c=h+u)>>>2;r.length<=f;)r.push(0);r[f]|=i<<8*(l+c%4*-1),h+=2}return{value:r,binLen:8*h+n}};break;case"B64":r=function(t,e,r){var n,i,o,a,s,u,f,c=0;if(-1===t.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=t.indexOf("="),t=t.replace(/\=/g,""),-1!==i&&i=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,x=i,E=new g(y);if(!w)return m.toS();for(h=E.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?E:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=x,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:N(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),x=0;for(i=0;i=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){var n,i;n=this,i=function(){"use strict";var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)},e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function r(t,e,r,n){var i,o,a,s=e||[0],u=(r=r||0)>>>3,f=-1===n?3:0;for(i=0;i>>2,s.length<=o&&s.push(0),s[o]|=t[i]<<8*(f+n*(a%4));return{value:s,binLen:8*t.length+r}}function n(t,n,i){switch(n){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,r,n){var i,o,a,s;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");var u=e||[0],f=(r=r||0)>>>3,c=-1===n?3:0;for(i=0;i>>1)+f)>>>2;u.length<=a;)u.push(0);u[a]|=o<<8*(c+n*(s%4))}return{value:u,binLen:4*t.length+r}}(t,e,r,i)};case"TEXT":return function(t,e,r){return function(t,e,r,n,i){var o,a,s,u,f,c,l,h,d=0,p=r||[0],v=(n=n||0)>>>3;if("UTF8"===e)for(l=-1===i?3:0,s=0;s(o=t.charCodeAt(s))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(s)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),u=0;u>>2;p.length<=f;)p.push(0);p[f]|=a[u]<<8*(l+i*(c%4)),d+=1}else for(l=-1===i?2:0,h="UTF16LE"===e&&1!==i||"UTF16LE"!==e&&1===i,s=0;s>>8),f=(c=d+v)>>>2;p.length<=f;)p.push(0);p[f]|=o<<8*(l+i*(c%4)),d+=2}return{value:p,binLen:8*d+n}}(t,n,e,r,i)};case"B64":return function(t,r,n){return function(t,r,n,i){var o,a,s,u,f,c,l=0,h=r||[0],d=(n=n||0)>>>3,p=-1===i?3:0,v=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==v&&v bechString.length || bechString.length > 90) { + if (pos < 1 || pos + 7 > bechString.length || bechString.length > 110) { return null; } var hrp = bechString.substring(0, pos); diff --git a/src/crypto/segwit_addr.js b/src/crypto/segwit_addr.js index 7314d590..bf140d81 100644 --- a/src/crypto/segwit_addr.js +++ b/src/crypto/segwit_addr.js @@ -74,7 +74,7 @@ function encode (hrp, version, program) { } function isValidAddress(address, currency, opts) { - var networkType = opts ? (opts.networkType || DEFAULT_NETWORK_TYPE) : DEFAULT_NETWORK_TYPE + const { networkType = DEFAULT_NETWORK_TYPE} = opts; var ret = decode(address); if(ret === null) { @@ -90,7 +90,7 @@ function isValidAddress(address, currency, opts) { } else { correctBech32Hrps = currency.bech32Hrp.prod.concat(currency.bech32Hrp.testnet) } - + if (correctBech32Hrps.indexOf(bech32Hrp) === -1) { return false; } diff --git a/src/crypto/utils.js b/src/crypto/utils.js index dbcf827a..c12318f7 100644 --- a/src/crypto/utils.js +++ b/src/crypto/utils.js @@ -1,4 +1,4 @@ -var jsSHA = require('jssha/src/sha256'); +var jsSHA = require('jssha/dist/sha256'); var Blake256 = require('./blake256'); var keccak256 = require('./sha3')['keccak256']; var Blake2B = require('./blake2b'); diff --git a/src/currencies.js b/src/currencies.js index 443ddfdc..1b7aad4e 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -250,6 +250,7 @@ var CURRENCIES = [{ }, { name: 'Cardano', symbol: 'ada', + bech32Hrp: { prod: ['addr'], testnet: ['addr']}, validator: ADAValidator }, { name: 'Monero', diff --git a/src/monero_validator.js b/src/monero_validator.js index aab794d6..6066646a 100644 --- a/src/monero_validator.js +++ b/src/monero_validator.js @@ -40,8 +40,8 @@ function hextobin(hex) { } module.exports = { - isValidAddress: function(address, currency, opts) { - var networkType = opts ? (opts.networkType || DEFAULT_NETWORK_TYPE) : DEFAULT_NETWORK_TYPE + isValidAddress: function(address, currency, opts = {}) { + const { networkType = DEFAULT_NETWORK_TYPE} = opts; var addressType = 'standard' if (!addressRegTest.test(address)) { if (integratedAddressRegTest.test(address)) { diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 88f7b0d9..f7faf98e 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -390,6 +390,9 @@ describe('WAValidator.validate()', function () { valid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg', 'ada'); valid('Ae2tdPwUPEZKmwoy3AU3cXb5Chnasj6mvVNxV1H11997q3VW5ihbSfQwGpm', 'ada'); valid('4swhHtxKapQbj3TZEipgtp7NQzcRWDYqCxXYoPQWjGyHmhxS1w1TjUEszCQT1sQucGwmPQMYdv1FYs3d51KgoubviPBf', 'cardano'); + + valid('addr1qxy3w62dupy9pzmpdfzxz4k240w5vawyagl5m9djqquyymrtm3grn7gpnjh7rwh2dy62hk8639lt6kzn32yxq960usnq9pexvt', 'cardano'); + valid('addr1skemppwfevyk0lshu2w8j34707s3t3t58a04xcx5ccevrcmvpmxg2qt4pk0', 'cardano', 'testnet'); }); it('should return true for correct monero addresses', function () { @@ -812,6 +815,11 @@ describe('WAValidator.validate()', function () { invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRTg1', 'cardano'); invalid('DdzFFzCqrhsfdzUZxvuBkhV8Lpm9p43p9ubh79GCTkxJikAjKh51qhtCFMqUniC5tv5ZExyvSmAte2Du2tGimavSo6qSgXbjiy8qZRT', 'ada'); //invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'komodo', 'testnet'); + + invalid('adrr1qxy3w62dupy9pzmpdfzxz4k240w5vawyagl5m9djqquyymrtm3grn7gpnjh7rwh2dy62hk8639lt6kzn32yxq960usnq9pexvt', 'cardano'); + invalid('addr2qxy3w62dupy9pzmpdfzxz4k240w5vawyagl5m9djqquyymrtm3grn7gpnjh7rwh2dy62hk8639lt6kzn32yxq960usnq9pexvt', 'cardano', 'prod'); + invalid('addr1skemppmfevyk0lshu2w8j34707s3t3t58a04xcx5ccevrcmvpmxg2qt4pk0', 'cardano', 'testnet'); + }); it('should return false for incorrect monero addresses', function () { diff --git a/yarn.lock b/yarn.lock index c844e9f8..bdb749ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -38,16 +38,35 @@ acorn-node@^1.2.0, acorn-node@^1.3.0, acorn-node@^1.5.2: acorn-walk "^6.1.0" xtend "^4.0.1" +acorn-node@^1.6.1: + version "1.8.2" + resolved "https://registry.yarnpkg.com/acorn-node/-/acorn-node-1.8.2.tgz#114c95d64539e53dede23de8b9d96df7c7ae2af8" + integrity sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A== + dependencies: + acorn "^7.0.0" + acorn-walk "^7.0.0" + xtend "^4.0.2" + acorn-walk@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.1.0.tgz#c957f4a1460da46af4a0388ce28b4c99355b0cbc" integrity sha512-ugTb7Lq7u4GfWSqqpwE0bGyoBZNMTok/zDBXxfEG0QM50jNlGhIWjRC1pPN7bvV1anhF+bs+/gNcRw+o55Evbg== +acorn-walk@^7.0.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" + integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== + acorn@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.0.2.tgz#6a459041c320ab17592c6317abbfdf4bbaa98ca4" integrity sha512-GXmKIvbrN3TV7aVqAzVFaMW8F8wzVX7voEBRO3bDA64+EX37YSayggRJP5Xig6HYHBkWKpFg9W5gg6orklubhg== +acorn@^7.0.0: + version "7.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" + integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== + after@0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" @@ -73,7 +92,7 @@ ansi-regex@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== -ansi-styles@^3.2.0, ansi-styles@^3.2.1: +ansi-styles@^3.2.0: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== @@ -88,6 +107,13 @@ ansi-styles@^4.0.0: "@types/color-name" "^1.1.1" color-convert "^2.0.1" +ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + anymatch@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" @@ -261,12 +287,12 @@ browser-pack@^6.0.1: through2 "^2.0.0" umd "^3.0.0" -browser-resolve@^1.11.0, browser-resolve@^1.7.0: - version "1.11.3" - resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.3.tgz#9b7cbb3d0f510e4cb86bdbd796124d28b5890af6" - integrity sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ== +browser-resolve@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-2.0.0.tgz#99b7304cb392f8d73dba741bb2d7da28c6d7842b" + integrity sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ== dependencies: - resolve "1.1.7" + resolve "^1.17.0" browser-stdout@1.3.1: version "1.3.1" @@ -337,15 +363,15 @@ browserify-zlib@~0.2.0: dependencies: pako "~1.0.5" -browserify@^16.5.1: - version "16.5.1" - resolved "https://registry.yarnpkg.com/browserify/-/browserify-16.5.1.tgz#3c13c97436802930d5c3ae28658ddc33bfd37dc2" - integrity sha512-EQX0h59Pp+0GtSRb5rL6OTfrttlzv+uyaUVlK6GX3w11SQ0jKPKyjC/54RhPR2ib2KmfcELM06e8FxcI5XNU2A== +browserify@^16.5.2: + version "16.5.2" + resolved "https://registry.yarnpkg.com/browserify/-/browserify-16.5.2.tgz#d926835e9280fa5fd57f5bc301f2ef24a972ddfe" + integrity sha512-TkOR1cQGdmXU9zW4YukWzWVSJwrxmNdADFbqbE3HFgQWe5wqZmOawqZ7J/8MPCwk/W8yY7Y0h+7mOtcZxLP23g== dependencies: JSONStream "^1.0.3" assert "^1.4.0" browser-pack "^6.0.1" - browser-resolve "^1.11.0" + browser-resolve "^2.0.0" browserify-zlib "~0.2.0" buffer "~5.2.1" cached-path-relative "^1.0.0" @@ -366,7 +392,7 @@ browserify@^16.5.1: insert-module-globals "^7.0.0" labeled-stream-splicer "^2.0.0" mkdirp-classic "^0.5.2" - module-deps "^6.0.0" + module-deps "^6.2.3" os-browserify "~0.3.0" parents "^1.0.1" path-browserify "~0.0.0" @@ -429,24 +455,34 @@ cached-path-relative@^1.0.0: resolved "https://registry.yarnpkg.com/cached-path-relative/-/cached-path-relative-1.0.1.tgz#d09c4b52800aa4c078e2dd81a869aac90d2e54e7" integrity sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc= +cached-path-relative@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cached-path-relative/-/cached-path-relative-1.0.2.tgz#a13df4196d26776220cc3356eb147a52dba2c6db" + integrity sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg== + callsite@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" integrity sha1-KAOY5dZkvXQDi28JBRU+borxvCA= -camel-case@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/camel-case/-/camel-case-3.0.0.tgz#ca3c3688a4e9cf3a4cda777dc4dcbc713249cf73" - integrity sha1-yjw2iKTpzzpM2nd9xNy8cTJJz3M= +camel-case@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/camel-case/-/camel-case-4.1.1.tgz#1fc41c854f00e2f7d0139dfeba1542d6896fe547" + integrity sha512-7fa2WcG4fYFkclIvEmxBbTvmibwF2/agfEBc6q3lOpVu0A13ltLsA+Hr/8Hp6kp5f+G7hKi6t8lys6XxP+1K6Q== dependencies: - no-case "^2.2.0" - upper-case "^1.1.1" + pascal-case "^3.1.1" + tslib "^1.10.0" camelcase@^5.0.0: version "5.2.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.2.0.tgz#e7522abda5ed94cc0489e1b8466610e88404cf45" integrity sha512-IXFsBS2pC+X0j0N/GE7Dm7j3bsEBp+oTpb7F50dwEVX7rf3IgwO9XatnegTsDtniKCUtEJH4fSU6Asw7uoVLfQ== +camelcase@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + cbor-js@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/cbor-js/-/cbor-js-0.1.0.tgz#c80ce6120f387e8faa74370dfda21d965b8fc7f9" @@ -464,24 +500,23 @@ chai@^4.2.0: pathval "^1.1.0" type-detect "^4.0.5" -chalk@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== +chalk@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" + integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" + ansi-styles "^4.1.0" + supports-color "^7.1.0" check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= -chokidar@3.3.1, chokidar@^3.0.0: - version "3.3.1" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.1.tgz#c84e5b3d18d9a4d77558fef466b1bf16bbeb3450" - integrity sha512-4QYCEWOcK3OJrxwvyyAOxFuhpvOVCYkr33LPfFNBjAD/w3sEzWsp2BUOkI4l9bHvWioAd0rc6NlHUOEaWkTeqg== +chokidar@3.4.2, chokidar@^3.4.2: + version "3.4.2" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.2.tgz#38dc8e658dec3809741eb3ef7bb0a47fe424232d" + integrity sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A== dependencies: anymatch "~3.1.1" braces "~3.0.2" @@ -489,7 +524,7 @@ chokidar@3.3.1, chokidar@^3.0.0: is-binary-path "~2.1.0" is-glob "~4.0.1" normalize-path "~3.0.0" - readdirp "~3.3.0" + readdirp "~3.4.0" optionalDependencies: fsevents "~2.1.2" @@ -501,7 +536,7 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: inherits "^2.0.1" safe-buffer "^5.0.1" -clean-css@^4.1.6, clean-css@^4.2.1: +clean-css@^4.1.6, clean-css@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.3.tgz#507b5de7d97b48ee53d84adb0160ff6216380f78" integrity sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA== @@ -565,11 +600,16 @@ combine-source-map@^0.8.0, combine-source-map@~0.8.0: lodash.memoize "~3.0.3" source-map "~0.5.3" -commander@^2.19.0, commander@^2.20.0: +commander@^2.20.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== +commander@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" + integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== + commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" @@ -739,10 +779,10 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@3.2.6: - version "3.2.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== +debug@4.1.1, debug@^4.1.0, debug@^4.1.1, debug@~4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== dependencies: ms "^2.1.1" @@ -753,13 +793,6 @@ debug@=3.1.0, debug@~3.1.0: dependencies: ms "2.0.0" -debug@^4.1.0, debug@^4.1.1, debug@~4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== - dependencies: - ms "^2.1.1" - decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -807,12 +840,12 @@ des.js@^1.0.0: inherits "^2.0.1" minimalistic-assert "^1.0.0" -detective@^5.0.2: - version "5.1.0" - resolved "https://registry.yarnpkg.com/detective/-/detective-5.1.0.tgz#7a20d89236d7b331ccea65832e7123b5551bb7cb" - integrity sha512-TFHMqfOvxlgrfVzTEkNBSh9SvSNX/HfF4OFI2QFGCyPm02EsyILqnUeb5P6q7JZ3SFNTBL5t2sePRgrN4epUWQ== +detective@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/detective/-/detective-5.2.0.tgz#feb2a77e85b904ecdea459ad897cc90a99bd2a7b" + integrity sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg== dependencies: - acorn-node "^1.3.0" + acorn-node "^1.6.1" defined "^1.0.0" minimist "^1.1.1" @@ -850,6 +883,14 @@ domain-browser@^1.2.0: resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda" integrity sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA== +dot-case@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.3.tgz#21d3b52efaaba2ea5fda875bb1aa8124521cf4aa" + integrity sha512-7hwEmg6RiSQfm/GwPL4AAWXKy3YNNZA3oFv2Pdiey0mwkRCPZ9x6SZbkLcn8Ma5PYeVokzoD4Twv2n7LKp5WeA== + dependencies: + no-case "^3.0.3" + tslib "^1.10.0" + duplexer2@^0.1.2, duplexer2@~0.1.0, duplexer2@~0.1.2: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" @@ -984,10 +1025,10 @@ escape-html@~1.0.3: resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +escape-string-regexp@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== esprima@^4.0.0: version "4.0.1" @@ -1037,12 +1078,12 @@ finalhandler@1.1.2: statuses "~1.5.0" unpipe "~1.0.0" -find-up@4.1.0, find-up@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== dependencies: - locate-path "^5.0.0" + locate-path "^6.0.0" path-exists "^4.0.0" find-up@^3.0.0: @@ -1052,6 +1093,14 @@ find-up@^3.0.0: dependencies: locate-path "^3.0.0" +find-up@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" + integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + dependencies: + locate-path "^5.0.0" + path-exists "^4.0.0" + flat@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/flat/-/flat-4.1.0.tgz#090bec8b05e39cba309747f1d588f04dbaf98db2" @@ -1059,7 +1108,7 @@ flat@^4.1.0: dependencies: is-buffer "~2.0.3" -flatted@^2.0.1, flatted@^2.0.2: +flatted@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== @@ -1168,11 +1217,6 @@ has-cors@1.1.0: resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" integrity sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk= -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - has-flag@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" @@ -1225,18 +1269,18 @@ hmac-drbg@^1.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -html-minifier@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/html-minifier/-/html-minifier-4.0.0.tgz#cca9aad8bce1175e02e17a8c33e46d8988889f56" - integrity sha512-aoGxanpFPLg7MkIl/DDFYtb0iWz7jMFGqFhvEDZga6/4QTjneiD8I/NXL1x5aaoCp7FSIT6h/OhykDdPsbtMig== +html-minifier-terser@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz#922e96f1f3bb60832c2634b79884096389b1f054" + integrity sha512-ZPr5MNObqnV/T9akshPKbVgyOqLmy+Bxo7juKCfTfnjNniTAMdy4hz21YQqoofMBJD2kdREaqPPdThoR78Tgxg== dependencies: - camel-case "^3.0.0" - clean-css "^4.2.1" - commander "^2.19.0" + camel-case "^4.1.1" + clean-css "^4.2.3" + commander "^4.1.1" he "^1.2.0" - param-case "^2.1.1" + param-case "^3.0.3" relateurl "^0.2.7" - uglify-js "^3.5.1" + terser "^4.6.3" htmlescape@^1.1.0: version "1.1.1" @@ -1395,6 +1439,11 @@ is-number@^7.0.0: resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== +is-plain-obj@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" + integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= + is-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.0.tgz#ece38e389e490df0dc21caea2bd596f987f767ff" @@ -1462,10 +1511,10 @@ iterate-value@^1.0.0: es-get-iterator "^1.0.2" iterate-iterator "^1.0.1" -js-yaml@3.13.1: - version "3.13.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" - integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== +js-yaml@3.14.0: + version "3.14.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482" + integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== dependencies: argparse "^1.0.7" esprima "^4.0.0" @@ -1494,10 +1543,10 @@ jsonparse@^1.2.0: resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= -jssha@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/jssha/-/jssha-2.4.2.tgz#d950b095634928bd6b2bda1d42da9a3a762d65e9" - integrity sha512-/jsi/9C0S70zfkT/4UlKQa5E1xKurDnXcQizcww9JSR/Fv+uIbWM2btG+bFcL3iNoK9jIGS0ls9HWLr1iw0kFg== +jssha@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/jssha/-/jssha-3.1.2.tgz#e7b6daae8ae353a38da8e5b6afc106688fd24a59" + integrity sha512-6fEObA9he4vcCpz+dt9b5DjqhqvSsz9XMfNPU6/IyKHDQpCHsYayPRkWmAZG61lZC9XVJcjsQNAiUUd0NpskeQ== karma-chai@^0.1.0: version "0.1.0" @@ -1518,24 +1567,23 @@ karma-mocha@^2.0.1: dependencies: minimist "^1.2.3" -karma@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/karma/-/karma-5.1.0.tgz#deaa5f3939f75d7d78ded33283fa5f9bb67e9a05" - integrity sha512-I3aPbkuIbwuBo6wSog97P5WnnhCgUTsWTu/bEw1vZVQFbXmKO3PK+cfFhZioOgVtJAuQxoyauGNjnwXNHMCxbw== +karma@^5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/karma/-/karma-5.2.3.tgz#3264024219bad2728e92542e0058a2492d7a46e4" + integrity sha512-tHdyFADhVVPBorIKCX8A37iLHxc6RBRphkSoQ+MLKdAtFn1k97tD8WUGi1KlEtDZKL3hui0qhsY9HXUfSNDYPQ== dependencies: body-parser "^1.19.0" braces "^3.0.2" - chokidar "^3.0.0" + chokidar "^3.4.2" colors "^1.4.0" connect "^3.7.0" di "^0.0.1" dom-serialize "^2.2.1" - flatted "^2.0.2" glob "^7.1.6" graceful-fs "^4.2.4" http-proxy "^1.18.1" isbinaryfile "^4.0.6" - lodash "^4.17.15" + lodash "^4.17.19" log4js "^6.2.1" mime "^2.4.5" minimatch "^3.0.4" @@ -1545,7 +1593,7 @@ karma@^5.1.0: socket.io "^2.3.0" source-map "^0.6.1" tmp "0.2.1" - ua-parser-js "0.7.21" + ua-parser-js "0.7.22" yargs "^15.3.1" labeled-stream-splicer@^2.0.0: @@ -1572,6 +1620,13 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + lodash.isequal@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" @@ -1582,17 +1637,17 @@ lodash.memoize@~3.0.3: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" integrity sha1-LcvSwofLwKVcxCMovQxzYVDVPj8= -lodash@^4.17.15: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +lodash@^4.17.19: + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== -log-symbols@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4" - integrity sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ== +log-symbols@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920" + integrity sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA== dependencies: - chalk "^2.4.2" + chalk "^4.0.0" log4js@^6.2.1: version "6.3.0" @@ -1605,10 +1660,12 @@ log4js@^6.2.1: rfdc "^1.1.4" streamroller "^2.2.4" -lower-case@^1.1.1: - version "1.1.4" - resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac" - integrity sha1-miyr0bno4K6ZOkv31YdcOcQujqw= +lower-case@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.1.tgz#39eeb36e396115cc05e29422eaea9e692c9408c7" + integrity sha512-LiWgfDLLb1dwbFQZsSglpRj+1ctGnayXz3Uv0/WO8n558JycT5fg6zkNcnW0G68Nn0aEldTFeEfmjCfmqry/rQ== + dependencies: + tslib "^1.10.0" md5.js@^1.3.4: version "1.3.5" @@ -1661,16 +1718,16 @@ mime@^2.4.5: resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1" integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA== -minify@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/minify/-/minify-5.1.1.tgz#6b361361859d3a562ff6a097ae064c20bccb5b40" - integrity sha512-1aAsFXuW+CpkqzHe1sQpJuPDMuX3o13laF1hs0rH0BhQTRwvYDuzrYgB5qXqR/8WafaqK3+oHQVaaSHHMFw3Pg== +minify@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/minify/-/minify-6.0.0.tgz#b7b16e1c39cf17763ed50736d7042073665adb46" + integrity sha512-KowQkxrGMJsovq1nK2RkL0eOFy7gI6t+gpTEh3GQ9J+VutzlL/MiXlxXA1OdhddgGaA/AsBkGAYTHDZzSa36cQ== dependencies: clean-css "^4.1.6" css-b64-images "~0.2.5" debug "^4.1.0" - html-minifier "^4.0.0" - terser "^4.0.0" + html-minifier-terser "^5.1.1" + terser "^5.3.2" try-catch "^3.0.0" try-to-catch "^3.0.0" @@ -1706,28 +1763,28 @@ mkdirp-classic@^0.5.2: resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.2.tgz#54c441ce4c96cd7790e10b41a87aa51068ecab2b" integrity sha512-ejdnDQcR75gwknmMw/tx02AuRs8jCtqFoFqDZMjiNxsu85sRIJVXDKHuLYvUUPRBUtV2FpSZa9bL1BUa3BdR2g== -mocha@^8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-8.0.1.tgz#fe01f0530362df271aa8f99510447bc38b88d8ed" - integrity sha512-vefaXfdYI8+Yo8nPZQQi0QO2o+5q9UIMX1jZ1XMmK3+4+CQjc7+B0hPdUeglXiTlr8IHMVRo63IhO9Mzt6fxOg== +mocha@^8.1.3: + version "8.1.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-8.1.3.tgz#5e93f873e35dfdd69617ea75f9c68c2ca61c2ac5" + integrity sha512-ZbaYib4hT4PpF4bdSO2DohooKXIn4lDeiYqB+vTmCdr6l2woW0b6H3pf5x4sM5nwQMru9RvjjHYWVGltR50ZBw== dependencies: ansi-colors "4.1.1" browser-stdout "1.3.1" - chokidar "3.3.1" - debug "3.2.6" + chokidar "3.4.2" + debug "4.1.1" diff "4.0.2" - escape-string-regexp "1.0.5" - find-up "4.1.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" glob "7.1.6" growl "1.10.5" he "1.2.0" - js-yaml "3.13.1" - log-symbols "3.0.0" + js-yaml "3.14.0" + log-symbols "4.0.0" minimatch "3.0.4" ms "2.1.2" object.assign "4.1.0" promise.allsettled "1.0.2" - serialize-javascript "3.0.0" + serialize-javascript "4.0.0" strip-json-comments "3.0.1" supports-color "7.1.0" which "2.0.2" @@ -1735,19 +1792,19 @@ mocha@^8.0.1: workerpool "6.0.0" yargs "13.3.2" yargs-parser "13.1.2" - yargs-unparser "1.6.0" + yargs-unparser "1.6.1" -module-deps@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-6.1.0.tgz#d1e1efc481c6886269f7112c52c3236188e16479" - integrity sha512-NPs5N511VD1rrVJihSso/LiBShRbJALYBKzDW91uZYy7BpjnO4bGnZL3HjZ9yKcFdZUWwaYjDz9zxbuP7vKMuQ== +module-deps@^6.2.3: + version "6.2.3" + resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-6.2.3.tgz#15490bc02af4b56cf62299c7c17cba32d71a96ee" + integrity sha512-fg7OZaQBcL4/L+AK5f4iVqf9OMbCclXfy/znXRxTVhJSeW5AIlS9AwheYwDaXM3lVW7OBeaeUEY3gbaC6cLlSA== dependencies: JSONStream "^1.0.3" - browser-resolve "^1.7.0" - cached-path-relative "^1.0.0" + browser-resolve "^2.0.0" + cached-path-relative "^1.0.2" concat-stream "~1.6.0" defined "^1.0.0" - detective "^5.0.2" + detective "^5.2.0" duplexer2 "^0.1.2" inherits "^2.0.1" parents "^1.0.0" @@ -1778,12 +1835,13 @@ negotiator@0.6.1: resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" integrity sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk= -no-case@^2.2.0: - version "2.3.2" - resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac" - integrity sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ== +no-case@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.3.tgz#c21b434c1ffe48b39087e86cfb4d2582e9df18f8" + integrity sha512-ehY/mVQCf9BL0gKfsJBvFJen+1V//U+0HQMPrWct40ixE4jnv0bfvxDbWtAHL9EcaPEOJHVVYKoQn1TlZUB8Tw== dependencies: - lower-case "^1.1.1" + lower-case "^2.0.1" + tslib "^1.10.0" normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" @@ -1853,6 +1911,13 @@ p-limit@^2.2.0: dependencies: p-try "^2.0.0" +p-limit@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.0.2.tgz#1664e010af3cadc681baafd3e2a437be7b0fb5fe" + integrity sha512-iwqZSOoWIW+Ew4kAGUlN16J4M7OB3ysMLSZtnhmqx7njIHFPlxWBX8xo3lVTyFVq6mI/lL9qt2IsN1sHwaxJkg== + dependencies: + p-try "^2.0.0" + p-locate@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" @@ -1867,6 +1932,13 @@ p-locate@^4.1.0: dependencies: p-limit "^2.2.0" +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + p-try@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1" @@ -1877,12 +1949,13 @@ pako@~1.0.5: resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258" integrity sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg== -param-case@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/param-case/-/param-case-2.1.1.tgz#df94fd8cf6531ecf75e6bef9a0858fbc72be2247" - integrity sha1-35T9jPZTHs915r75oIWPvHK+Ikc= +param-case@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/param-case/-/param-case-3.0.3.tgz#4be41f8399eff621c56eebb829a5e451d9801238" + integrity sha512-VWBVyimc1+QrzappRs7waeN2YmoZFCGXWASRYX1/rGHtXqEcrGEIDm+jqIwFa2fRXNgQEwrxaYuIrX0WcAguTA== dependencies: - no-case "^2.2.0" + dot-case "^3.0.3" + tslib "^1.10.0" parents@^1.0.0, parents@^1.0.1: version "1.0.1" @@ -1921,6 +1994,14 @@ parseurl@~1.3.3: resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== +pascal-case@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/pascal-case/-/pascal-case-3.1.1.tgz#5ac1975133ed619281e88920973d2cd1f279de5f" + integrity sha512-XIeHKqIrsquVTQL2crjq3NfJUxmdLasn3TYOU0VBM+UX2a6ztAWBlJQBePLGY7VHW8+2dRadeIPK5+KImwTxQA== + dependencies: + no-case "^3.0.3" + tslib "^1.10.0" + path-browserify@~0.0.0: version "0.0.1" resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" @@ -1941,7 +2022,7 @@ path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= -path-parse@^1.0.5: +path-parse@^1.0.5, path-parse@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== @@ -1967,11 +2048,16 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" -picomatch@^2.0.4, picomatch@^2.0.7: +picomatch@^2.0.4: version "2.2.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a" integrity sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA== +picomatch@^2.2.1: + version "2.2.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" + integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== + process-nextick-args@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" @@ -2042,6 +2128,13 @@ randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: dependencies: safe-buffer "^5.1.0" +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + randomfill@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" @@ -2094,12 +2187,12 @@ readable-stream@^3.0.6: string_decoder "^1.1.1" util-deprecate "^1.0.1" -readdirp@~3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.3.0.tgz#984458d13a1e42e2e9f5841b129e162f369aff17" - integrity sha512-zz0pAkSPOXXm1viEwygWIPSPkcBYjW1xU5j/JBh5t9bGCJwa6f9+BJa6VaB2g+b55yVrmXzqkyLf4xaWYM0IkQ== +readdirp@~3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz#9fdccdf9e9155805449221ac645e8303ab5b9ada" + integrity sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ== dependencies: - picomatch "^2.0.7" + picomatch "^2.2.1" relateurl@^0.2.7: version "0.2.7" @@ -2121,11 +2214,6 @@ requires-port@^1.0.0: resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= -resolve@1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" - integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs= - resolve@^1.1.4, resolve@^1.4.0: version "1.8.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" @@ -2133,6 +2221,13 @@ resolve@^1.1.4, resolve@^1.4.0: dependencies: path-parse "^1.0.5" +resolve@^1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + rfdc@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.1.4.tgz#ba72cc1367a0ccd9cf81a870b3b58bd3ad07f8c2" @@ -2163,10 +2258,12 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -serialize-javascript@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-3.0.0.tgz#492e489a2d77b7b804ad391a5f5d97870952548e" - integrity sha512-skZcHYw2vEX4bw90nAr2iTTsz6x2SrHEnfxgKYmZlvJYBEZrvbKtobJWlQ20zczKb3bsHHXXTYt48zBA7ni9cw== +serialize-javascript@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-4.0.0.tgz#b525e1238489a5ecfc42afacc3fe99e666f4b1aa" + integrity sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw== + dependencies: + randombytes "^2.1.0" set-blocking@^2.0.0: version "2.0.0" @@ -2264,7 +2361,7 @@ socket.io@^2.3.0: socket.io-client "2.3.0" socket.io-parser "~3.4.0" -source-map-support@~0.5.12: +source-map-support@~0.5.12, source-map-support@~0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== @@ -2282,6 +2379,11 @@ source-map@~0.5.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= +source-map@~0.7.2: + version "0.7.3" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" + integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -2424,12 +2526,12 @@ supports-color@7.1.0: dependencies: has-flag "^4.0.0" -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== dependencies: - has-flag "^3.0.0" + has-flag "^4.0.0" syntax-error@^1.1.1: version "1.4.0" @@ -2438,7 +2540,7 @@ syntax-error@^1.1.1: dependencies: acorn-node "^1.2.0" -terser@^4.0.0: +terser@^4.6.3: version "4.8.0" resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.0.tgz#63056343d7c70bb29f3af665865a46fe03a0df17" integrity sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw== @@ -2447,6 +2549,15 @@ terser@^4.0.0: source-map "~0.6.1" source-map-support "~0.5.12" +terser@^5.3.2: + version "5.3.4" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.3.4.tgz#e510e05f86e0bd87f01835c3238839193f77a60c" + integrity sha512-dxuB8KQo8Gt6OVOeLg/rxfcxdNZI/V1G6ze1czFUzPeCFWZRtvZMgSzlZZ5OYBZ4HoG607F6pFPNLekJyV+yVw== + dependencies: + commander "^2.20.0" + source-map "~0.7.2" + source-map-support "~0.5.19" + through2@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" @@ -2501,6 +2612,11 @@ try-to-catch@^3.0.0: resolved "https://registry.yarnpkg.com/try-to-catch/-/try-to-catch-3.0.0.tgz#a1903b44d13d5124c54d14a461d22ec1f52ea14b" integrity sha512-eIm6ZXwR35jVF8By/HdbbkcaCDTBI5PpCPkejRKrYp0jyf/DbCCcRhHD7/O9jtFI3ewsqo9WctFEiJTS6i+CQA== +tslib@^1.10.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" + integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== + tty-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" @@ -2524,10 +2640,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -ua-parser-js@0.7.21: - version "0.7.21" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.21.tgz#853cf9ce93f642f67174273cc34565ae6f308777" - integrity sha512-+O8/qh/Qj8CgC6eYBVBykMrNtp5Gebn4dlGD/kKXVkJNDwyrAwSIqwz8CDf+tsAIWVycKcku6gIXJ0qwx/ZXaQ== +ua-parser-js@0.7.22: + version "0.7.22" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.22.tgz#960df60a5f911ea8f1c818f3747b99c6e177eae3" + integrity sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q== uglify-es@^3.3.9: version "3.3.9" @@ -2537,11 +2653,6 @@ uglify-es@^3.3.9: commander "~2.13.0" source-map "~0.6.1" -uglify-js@^3.5.1: - version "3.10.1" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.10.1.tgz#dd14767eb7150de97f2573a5ff210db14fffe4ad" - integrity sha512-RjxApKkrPJB6kjJxQS3iZlf///REXWYxYJxO/MpmlQzVkDWVI3PSnCBWezMecmTU/TRkNxrl8bmsfFQCp+LO+Q== - umd@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.3.tgz#aa9fe653c42b9097678489c01000acb69f0b26cf" @@ -2567,11 +2678,6 @@ unpipe@1.0.0, unpipe@~1.0.0: resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= -upper-case@^1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/upper-case/-/upper-case-1.1.3.tgz#f6b4501c2ec4cdd26ba78be7222961de77621598" - integrity sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg= - url@~0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" @@ -2690,6 +2796,11 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= +xtend@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + y18n@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" @@ -2703,10 +2814,10 @@ yargs-parser@13.1.2, yargs-parser@^13.1.2: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^13.1.1: - version "13.1.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.1.tgz#d26058532aa06d365fe091f6a1fc06b2f7e5eca0" - integrity sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ== +yargs-parser@^15.0.1: + version "15.0.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-15.0.1.tgz#54786af40b820dcb2fb8025b11b4d659d76323b3" + integrity sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw== dependencies: camelcase "^5.0.0" decamelize "^1.2.0" @@ -2719,14 +2830,16 @@ yargs-parser@^18.1.1: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-unparser@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.6.0.tgz#ef25c2c769ff6bd09e4b0f9d7c605fb27846ea9f" - integrity sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw== +yargs-unparser@1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.6.1.tgz#bd4b0ee05b4c94d058929c32cb09e3fce71d3c5f" + integrity sha512-qZV14lK9MWsGCmcr7u5oXGH0dbGqZAIxTDrWXZDo5zUr6b6iUmelNKO6x6R1dQT24AH3LgRxJpr8meWy2unolA== dependencies: + camelcase "^5.3.1" + decamelize "^1.2.0" flat "^4.1.0" - lodash "^4.17.15" - yargs "^13.3.0" + is-plain-obj "^1.1.0" + yargs "^14.2.3" yargs@13.3.2: version "13.3.2" @@ -2744,12 +2857,13 @@ yargs@13.3.2: y18n "^4.0.0" yargs-parser "^13.1.2" -yargs@^13.3.0: - version "13.3.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.0.tgz#4c657a55e07e5f2cf947f8a366567c04a0dedc83" - integrity sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA== +yargs@^14.2.3: + version "14.2.3" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.3.tgz#1a1c3edced1afb2a2fea33604bc6d1d8d688a414" + integrity sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg== dependencies: cliui "^5.0.0" + decamelize "^1.2.0" find-up "^3.0.0" get-caller-file "^2.0.1" require-directory "^2.1.1" @@ -2758,7 +2872,7 @@ yargs@^13.3.0: string-width "^3.0.0" which-module "^2.0.0" y18n "^4.0.0" - yargs-parser "^13.1.1" + yargs-parser "^15.0.1" yargs@^15.3.1: version "15.3.1" From 4106cd0ff829f16ef1364d0b01827ba5d0362d34 Mon Sep 17 00:00:00 2001 From: Stephen Ephraim Date: Fri, 20 Nov 2020 09:39:07 +0200 Subject: [PATCH 106/108] Adds segwit support for digibyte (#30) --- dist/wallet-address-validator.js | 813 ++++++++++++++------------- dist/wallet-address-validator.min.js | 2 +- src/currencies.js | 1 + test/wallet_address_validator.js | 1 + 4 files changed, 410 insertions(+), 407 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index dd3b2a5a..ae1c84bb 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -4174,412 +4174,412 @@ function numberIsNaN (obj) { } },{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014 Patrick Gansterer - * - * 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. - */ - -(function(global, undefined) { "use strict"; -var POW_2_24 = Math.pow(2, -24), - POW_2_32 = Math.pow(2, 32), - POW_2_53 = Math.pow(2, 53); - -function encode(value) { - var data = new ArrayBuffer(256); - var dataView = new DataView(data); - var lastLength; - var offset = 0; - - function ensureSpace(length) { - var newByteLength = data.byteLength; - var requiredLength = offset + length; - while (newByteLength < requiredLength) - newByteLength *= 2; - if (newByteLength !== data.byteLength) { - var oldDataView = dataView; - data = new ArrayBuffer(newByteLength); - dataView = new DataView(data); - var uint32count = (offset + 3) >> 2; - for (var i = 0; i < uint32count; ++i) - dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); - } - - lastLength = length; - return dataView; - } - function write() { - offset += lastLength; - } - function writeFloat64(value) { - write(ensureSpace(8).setFloat64(offset, value)); - } - function writeUint8(value) { - write(ensureSpace(1).setUint8(offset, value)); - } - function writeUint8Array(value) { - var dataView = ensureSpace(value.length); - for (var i = 0; i < value.length; ++i) - dataView.setUint8(offset + i, value[i]); - write(); - } - function writeUint16(value) { - write(ensureSpace(2).setUint16(offset, value)); - } - function writeUint32(value) { - write(ensureSpace(4).setUint32(offset, value)); - } - function writeUint64(value) { - var low = value % POW_2_32; - var high = (value - low) / POW_2_32; - var dataView = ensureSpace(8); - dataView.setUint32(offset, high); - dataView.setUint32(offset + 4, low); - write(); - } - function writeTypeAndLength(type, length) { - if (length < 24) { - writeUint8(type << 5 | length); - } else if (length < 0x100) { - writeUint8(type << 5 | 24); - writeUint8(length); - } else if (length < 0x10000) { - writeUint8(type << 5 | 25); - writeUint16(length); - } else if (length < 0x100000000) { - writeUint8(type << 5 | 26); - writeUint32(length); - } else { - writeUint8(type << 5 | 27); - writeUint64(length); - } - } - - function encodeItem(value) { - var i; - - if (value === false) - return writeUint8(0xf4); - if (value === true) - return writeUint8(0xf5); - if (value === null) - return writeUint8(0xf6); - if (value === undefined) - return writeUint8(0xf7); - - switch (typeof value) { - case "number": - if (Math.floor(value) === value) { - if (0 <= value && value <= POW_2_53) - return writeTypeAndLength(0, value); - if (-POW_2_53 <= value && value < 0) - return writeTypeAndLength(1, -(value + 1)); - } - writeUint8(0xfb); - return writeFloat64(value); - - case "string": - var utf8data = []; - for (i = 0; i < value.length; ++i) { - var charCode = value.charCodeAt(i); - if (charCode < 0x80) { - utf8data.push(charCode); - } else if (charCode < 0x800) { - utf8data.push(0xc0 | charCode >> 6); - utf8data.push(0x80 | charCode & 0x3f); - } else if (charCode < 0xd800) { - utf8data.push(0xe0 | charCode >> 12); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } else { - charCode = (charCode & 0x3ff) << 10; - charCode |= value.charCodeAt(++i) & 0x3ff; - charCode += 0x10000; - - utf8data.push(0xf0 | charCode >> 18); - utf8data.push(0x80 | (charCode >> 12) & 0x3f); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } - } - - writeTypeAndLength(3, utf8data.length); - return writeUint8Array(utf8data); - - default: - var length; - if (Array.isArray(value)) { - length = value.length; - writeTypeAndLength(4, length); - for (i = 0; i < length; ++i) - encodeItem(value[i]); - } else if (value instanceof Uint8Array) { - writeTypeAndLength(2, value.length); - writeUint8Array(value); - } else { - var keys = Object.keys(value); - length = keys.length; - writeTypeAndLength(5, length); - for (i = 0; i < length; ++i) { - var key = keys[i]; - encodeItem(key); - encodeItem(value[key]); - } - } - } - } - - encodeItem(value); - - if ("slice" in data) - return data.slice(0, offset); - - var ret = new ArrayBuffer(offset); - var retView = new DataView(ret); - for (var i = 0; i < offset; ++i) - retView.setUint8(i, dataView.getUint8(i)); - return ret; -} - -function decode(data, tagger, simpleValue) { - var dataView = new DataView(data); - var offset = 0; - - if (typeof tagger !== "function") - tagger = function(value) { return value; }; - if (typeof simpleValue !== "function") - simpleValue = function() { return undefined; }; - - function read(value, length) { - offset += length; - return value; - } - function readArrayBuffer(length) { - return read(new Uint8Array(data, offset, length), length); - } - function readFloat16() { - var tempArrayBuffer = new ArrayBuffer(4); - var tempDataView = new DataView(tempArrayBuffer); - var value = readUint16(); - - var sign = value & 0x8000; - var exponent = value & 0x7c00; - var fraction = value & 0x03ff; - - if (exponent === 0x7c00) - exponent = 0xff << 10; - else if (exponent !== 0) - exponent += (127 - 15) << 10; - else if (fraction !== 0) - return fraction * POW_2_24; - - tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); - return tempDataView.getFloat32(0); - } - function readFloat32() { - return read(dataView.getFloat32(offset), 4); - } - function readFloat64() { - return read(dataView.getFloat64(offset), 8); - } - function readUint8() { - return read(dataView.getUint8(offset), 1); - } - function readUint16() { - return read(dataView.getUint16(offset), 2); - } - function readUint32() { - return read(dataView.getUint32(offset), 4); - } - function readUint64() { - return readUint32() * POW_2_32 + readUint32(); - } - function readBreak() { - if (dataView.getUint8(offset) !== 0xff) - return false; - offset += 1; - return true; - } - function readLength(additionalInformation) { - if (additionalInformation < 24) - return additionalInformation; - if (additionalInformation === 24) - return readUint8(); - if (additionalInformation === 25) - return readUint16(); - if (additionalInformation === 26) - return readUint32(); - if (additionalInformation === 27) - return readUint64(); - if (additionalInformation === 31) - return -1; - throw "Invalid length encoding"; - } - function readIndefiniteStringLength(majorType) { - var initialByte = readUint8(); - if (initialByte === 0xff) - return -1; - var length = readLength(initialByte & 0x1f); - if (length < 0 || (initialByte >> 5) !== majorType) - throw "Invalid indefinite length element"; - return length; - } - - function appendUtf16data(utf16data, length) { - for (var i = 0; i < length; ++i) { - var value = readUint8(); - if (value & 0x80) { - if (value < 0xe0) { - value = (value & 0x1f) << 6 - | (readUint8() & 0x3f); - length -= 1; - } else if (value < 0xf0) { - value = (value & 0x0f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 2; - } else { - value = (value & 0x0f) << 18 - | (readUint8() & 0x3f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 3; - } - } - - if (value < 0x10000) { - utf16data.push(value); - } else { - value -= 0x10000; - utf16data.push(0xd800 | (value >> 10)); - utf16data.push(0xdc00 | (value & 0x3ff)); - } - } - } - - function decodeItem() { - var initialByte = readUint8(); - var majorType = initialByte >> 5; - var additionalInformation = initialByte & 0x1f; - var i; - var length; - - if (majorType === 7) { - switch (additionalInformation) { - case 25: - return readFloat16(); - case 26: - return readFloat32(); - case 27: - return readFloat64(); - } - } - - length = readLength(additionalInformation); - if (length < 0 && (majorType < 2 || 6 < majorType)) - throw "Invalid length"; - - switch (majorType) { - case 0: - return length; - case 1: - return -1 - length; - case 2: - if (length < 0) { - var elements = []; - var fullArrayLength = 0; - while ((length = readIndefiniteStringLength(majorType)) >= 0) { - fullArrayLength += length; - elements.push(readArrayBuffer(length)); - } - var fullArray = new Uint8Array(fullArrayLength); - var fullArrayOffset = 0; - for (i = 0; i < elements.length; ++i) { - fullArray.set(elements[i], fullArrayOffset); - fullArrayOffset += elements[i].length; - } - return fullArray; - } - return readArrayBuffer(length); - case 3: - var utf16data = []; - if (length < 0) { - while ((length = readIndefiniteStringLength(majorType)) >= 0) - appendUtf16data(utf16data, length); - } else - appendUtf16data(utf16data, length); - return String.fromCharCode.apply(null, utf16data); - case 4: - var retArray; - if (length < 0) { - retArray = []; - while (!readBreak()) - retArray.push(decodeItem()); - } else { - retArray = new Array(length); - for (i = 0; i < length; ++i) - retArray[i] = decodeItem(); - } - return retArray; - case 5: - var retObject = {}; - for (i = 0; i < length || length < 0 && !readBreak(); ++i) { - var key = decodeItem(); - retObject[key] = decodeItem(); - } - return retObject; - case 6: - return tagger(decodeItem(), length); - case 7: - switch (length) { - case 20: - return false; - case 21: - return true; - case 22: - return null; - case 23: - return undefined; - default: - return simpleValue(length); - } - } - } - - var ret = decodeItem(); - if (offset !== data.byteLength) - throw "Remaining bytes"; - return ret; -} - -var obj = { encode: encode, decode: decode }; - -if (typeof define === "function" && define.amd) - define("cbor/cbor", obj); -else if (typeof module !== 'undefined' && module.exports) - module.exports = obj; -else if (!global.CBOR) - global.CBOR = obj; - -})(this); +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 Patrick Gansterer + * + * 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. + */ + +(function(global, undefined) { "use strict"; +var POW_2_24 = Math.pow(2, -24), + POW_2_32 = Math.pow(2, 32), + POW_2_53 = Math.pow(2, 53); + +function encode(value) { + var data = new ArrayBuffer(256); + var dataView = new DataView(data); + var lastLength; + var offset = 0; + + function ensureSpace(length) { + var newByteLength = data.byteLength; + var requiredLength = offset + length; + while (newByteLength < requiredLength) + newByteLength *= 2; + if (newByteLength !== data.byteLength) { + var oldDataView = dataView; + data = new ArrayBuffer(newByteLength); + dataView = new DataView(data); + var uint32count = (offset + 3) >> 2; + for (var i = 0; i < uint32count; ++i) + dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); + } + + lastLength = length; + return dataView; + } + function write() { + offset += lastLength; + } + function writeFloat64(value) { + write(ensureSpace(8).setFloat64(offset, value)); + } + function writeUint8(value) { + write(ensureSpace(1).setUint8(offset, value)); + } + function writeUint8Array(value) { + var dataView = ensureSpace(value.length); + for (var i = 0; i < value.length; ++i) + dataView.setUint8(offset + i, value[i]); + write(); + } + function writeUint16(value) { + write(ensureSpace(2).setUint16(offset, value)); + } + function writeUint32(value) { + write(ensureSpace(4).setUint32(offset, value)); + } + function writeUint64(value) { + var low = value % POW_2_32; + var high = (value - low) / POW_2_32; + var dataView = ensureSpace(8); + dataView.setUint32(offset, high); + dataView.setUint32(offset + 4, low); + write(); + } + function writeTypeAndLength(type, length) { + if (length < 24) { + writeUint8(type << 5 | length); + } else if (length < 0x100) { + writeUint8(type << 5 | 24); + writeUint8(length); + } else if (length < 0x10000) { + writeUint8(type << 5 | 25); + writeUint16(length); + } else if (length < 0x100000000) { + writeUint8(type << 5 | 26); + writeUint32(length); + } else { + writeUint8(type << 5 | 27); + writeUint64(length); + } + } + + function encodeItem(value) { + var i; + + if (value === false) + return writeUint8(0xf4); + if (value === true) + return writeUint8(0xf5); + if (value === null) + return writeUint8(0xf6); + if (value === undefined) + return writeUint8(0xf7); + + switch (typeof value) { + case "number": + if (Math.floor(value) === value) { + if (0 <= value && value <= POW_2_53) + return writeTypeAndLength(0, value); + if (-POW_2_53 <= value && value < 0) + return writeTypeAndLength(1, -(value + 1)); + } + writeUint8(0xfb); + return writeFloat64(value); + + case "string": + var utf8data = []; + for (i = 0; i < value.length; ++i) { + var charCode = value.charCodeAt(i); + if (charCode < 0x80) { + utf8data.push(charCode); + } else if (charCode < 0x800) { + utf8data.push(0xc0 | charCode >> 6); + utf8data.push(0x80 | charCode & 0x3f); + } else if (charCode < 0xd800) { + utf8data.push(0xe0 | charCode >> 12); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } else { + charCode = (charCode & 0x3ff) << 10; + charCode |= value.charCodeAt(++i) & 0x3ff; + charCode += 0x10000; + + utf8data.push(0xf0 | charCode >> 18); + utf8data.push(0x80 | (charCode >> 12) & 0x3f); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } + } + + writeTypeAndLength(3, utf8data.length); + return writeUint8Array(utf8data); + + default: + var length; + if (Array.isArray(value)) { + length = value.length; + writeTypeAndLength(4, length); + for (i = 0; i < length; ++i) + encodeItem(value[i]); + } else if (value instanceof Uint8Array) { + writeTypeAndLength(2, value.length); + writeUint8Array(value); + } else { + var keys = Object.keys(value); + length = keys.length; + writeTypeAndLength(5, length); + for (i = 0; i < length; ++i) { + var key = keys[i]; + encodeItem(key); + encodeItem(value[key]); + } + } + } + } + + encodeItem(value); + + if ("slice" in data) + return data.slice(0, offset); + + var ret = new ArrayBuffer(offset); + var retView = new DataView(ret); + for (var i = 0; i < offset; ++i) + retView.setUint8(i, dataView.getUint8(i)); + return ret; +} + +function decode(data, tagger, simpleValue) { + var dataView = new DataView(data); + var offset = 0; + + if (typeof tagger !== "function") + tagger = function(value) { return value; }; + if (typeof simpleValue !== "function") + simpleValue = function() { return undefined; }; + + function read(value, length) { + offset += length; + return value; + } + function readArrayBuffer(length) { + return read(new Uint8Array(data, offset, length), length); + } + function readFloat16() { + var tempArrayBuffer = new ArrayBuffer(4); + var tempDataView = new DataView(tempArrayBuffer); + var value = readUint16(); + + var sign = value & 0x8000; + var exponent = value & 0x7c00; + var fraction = value & 0x03ff; + + if (exponent === 0x7c00) + exponent = 0xff << 10; + else if (exponent !== 0) + exponent += (127 - 15) << 10; + else if (fraction !== 0) + return fraction * POW_2_24; + + tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); + return tempDataView.getFloat32(0); + } + function readFloat32() { + return read(dataView.getFloat32(offset), 4); + } + function readFloat64() { + return read(dataView.getFloat64(offset), 8); + } + function readUint8() { + return read(dataView.getUint8(offset), 1); + } + function readUint16() { + return read(dataView.getUint16(offset), 2); + } + function readUint32() { + return read(dataView.getUint32(offset), 4); + } + function readUint64() { + return readUint32() * POW_2_32 + readUint32(); + } + function readBreak() { + if (dataView.getUint8(offset) !== 0xff) + return false; + offset += 1; + return true; + } + function readLength(additionalInformation) { + if (additionalInformation < 24) + return additionalInformation; + if (additionalInformation === 24) + return readUint8(); + if (additionalInformation === 25) + return readUint16(); + if (additionalInformation === 26) + return readUint32(); + if (additionalInformation === 27) + return readUint64(); + if (additionalInformation === 31) + return -1; + throw "Invalid length encoding"; + } + function readIndefiniteStringLength(majorType) { + var initialByte = readUint8(); + if (initialByte === 0xff) + return -1; + var length = readLength(initialByte & 0x1f); + if (length < 0 || (initialByte >> 5) !== majorType) + throw "Invalid indefinite length element"; + return length; + } + + function appendUtf16data(utf16data, length) { + for (var i = 0; i < length; ++i) { + var value = readUint8(); + if (value & 0x80) { + if (value < 0xe0) { + value = (value & 0x1f) << 6 + | (readUint8() & 0x3f); + length -= 1; + } else if (value < 0xf0) { + value = (value & 0x0f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 2; + } else { + value = (value & 0x0f) << 18 + | (readUint8() & 0x3f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 3; + } + } + + if (value < 0x10000) { + utf16data.push(value); + } else { + value -= 0x10000; + utf16data.push(0xd800 | (value >> 10)); + utf16data.push(0xdc00 | (value & 0x3ff)); + } + } + } + + function decodeItem() { + var initialByte = readUint8(); + var majorType = initialByte >> 5; + var additionalInformation = initialByte & 0x1f; + var i; + var length; + + if (majorType === 7) { + switch (additionalInformation) { + case 25: + return readFloat16(); + case 26: + return readFloat32(); + case 27: + return readFloat64(); + } + } + + length = readLength(additionalInformation); + if (length < 0 && (majorType < 2 || 6 < majorType)) + throw "Invalid length"; + + switch (majorType) { + case 0: + return length; + case 1: + return -1 - length; + case 2: + if (length < 0) { + var elements = []; + var fullArrayLength = 0; + while ((length = readIndefiniteStringLength(majorType)) >= 0) { + fullArrayLength += length; + elements.push(readArrayBuffer(length)); + } + var fullArray = new Uint8Array(fullArrayLength); + var fullArrayOffset = 0; + for (i = 0; i < elements.length; ++i) { + fullArray.set(elements[i], fullArrayOffset); + fullArrayOffset += elements[i].length; + } + return fullArray; + } + return readArrayBuffer(length); + case 3: + var utf16data = []; + if (length < 0) { + while ((length = readIndefiniteStringLength(majorType)) >= 0) + appendUtf16data(utf16data, length); + } else + appendUtf16data(utf16data, length); + return String.fromCharCode.apply(null, utf16data); + case 4: + var retArray; + if (length < 0) { + retArray = []; + while (!readBreak()) + retArray.push(decodeItem()); + } else { + retArray = new Array(length); + for (i = 0; i < length; ++i) + retArray[i] = decodeItem(); + } + return retArray; + case 5: + var retObject = {}; + for (i = 0; i < length || length < 0 && !readBreak(); ++i) { + var key = decodeItem(); + retObject[key] = decodeItem(); + } + return retObject; + case 6: + return tagger(decodeItem(), length); + case 7: + switch (length) { + case 20: + return false; + case 21: + return true; + case 22: + return null; + case 23: + return undefined; + default: + return simpleValue(length); + } + } + } + + var ret = decodeItem(); + if (offset !== data.byteLength) + throw "Remaining bytes"; + return ret; +} + +var obj = { encode: encode, decode: decode }; + +if (typeof define === "function" && define.amd) + define("cbor/cbor", obj); +else if (typeof module !== 'undefined' && module.exports) + module.exports = obj; +else if (!global.CBOR) + global.CBOR = obj; + +})(this); },{}],6:[function(require,module,exports){ 'use strict'; @@ -10997,6 +10997,7 @@ var CURRENCIES = [{ name: 'DigiByte', symbol: 'dgb', addressTypes: { prod: ['1e'], testnet: [] }, + bech32Hrp: { prod: ['dgb', 'S'], testnet: [] }, validator: BTCValidator }, { name: 'Tether', diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 41d490db..6f15c71a 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,x=i,E=new g(y);if(!w)return m.toS();for(h=E.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?E:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=x,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:N(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),x=0;for(i=0;i=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){var n,i;n=this,i=function(){"use strict";var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)},e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function r(t,e,r,n){var i,o,a,s=e||[0],u=(r=r||0)>>>3,f=-1===n?3:0;for(i=0;i>>2,s.length<=o&&s.push(0),s[o]|=t[i]<<8*(f+n*(a%4));return{value:s,binLen:8*t.length+r}}function n(t,n,i){switch(n){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,r,n){var i,o,a,s;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");var u=e||[0],f=(r=r||0)>>>3,c=-1===n?3:0;for(i=0;i>>1)+f)>>>2;u.length<=a;)u.push(0);u[a]|=o<<8*(c+n*(s%4))}return{value:u,binLen:4*t.length+r}}(t,e,r,i)};case"TEXT":return function(t,e,r){return function(t,e,r,n,i){var o,a,s,u,f,c,l,h,d=0,p=r||[0],v=(n=n||0)>>>3;if("UTF8"===e)for(l=-1===i?3:0,s=0;s(o=t.charCodeAt(s))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(s)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),u=0;u>>2;p.length<=f;)p.push(0);p[f]|=a[u]<<8*(l+i*(c%4)),d+=1}else for(l=-1===i?2:0,h="UTF16LE"===e&&1!==i||"UTF16LE"!==e&&1===i,s=0;s>>8),f=(c=d+v)>>>2;p.length<=f;)p.push(0);p[f]|=o<<8*(l+i*(c%4)),d+=2}return{value:p,binLen:8*d+n}}(t,n,e,r,i)};case"B64":return function(t,r,n){return function(t,r,n,i){var o,a,s,u,f,c,l=0,h=r||[0],d=(n=n||0)>>>3,p=-1===i?3:0,v=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==v&&v=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,x=i,E=new g(y);if(!w)return m.toS();for(h=E.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?E:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=x,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:N(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),x=0;for(i=0;i=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){var n,i;n=this,i=function(){"use strict";var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)},e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function r(t,e,r,n){var i,o,a,s=e||[0],u=(r=r||0)>>>3,f=-1===n?3:0;for(i=0;i>>2,s.length<=o&&s.push(0),s[o]|=t[i]<<8*(f+n*(a%4));return{value:s,binLen:8*t.length+r}}function n(t,n,i){switch(n){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,r,n){var i,o,a,s;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");var u=e||[0],f=(r=r||0)>>>3,c=-1===n?3:0;for(i=0;i>>1)+f)>>>2;u.length<=a;)u.push(0);u[a]|=o<<8*(c+n*(s%4))}return{value:u,binLen:4*t.length+r}}(t,e,r,i)};case"TEXT":return function(t,e,r){return function(t,e,r,n,i){var o,a,s,u,f,c,l,h,d=0,p=r||[0],v=(n=n||0)>>>3;if("UTF8"===e)for(l=-1===i?3:0,s=0;s(o=t.charCodeAt(s))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(s)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),u=0;u>>2;p.length<=f;)p.push(0);p[f]|=a[u]<<8*(l+i*(c%4)),d+=1}else for(l=-1===i?2:0,h="UTF16LE"===e&&1!==i||"UTF16LE"!==e&&1===i,s=0;s>>8),f=(c=d+v)>>>2;p.length<=f;)p.push(0);p[f]|=o<<8*(l+i*(c%4)),d+=2}return{value:p,binLen:8*d+n}}(t,n,e,r,i)};case"B64":return function(t,r,n){return function(t,r,n,i){var o,a,s,u,f,c,l=0,h=r||[0],d=(n=n||0)>>>3,p=-1===i?3:0,v=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==v&&v Date: Fri, 20 Nov 2020 09:53:01 +0200 Subject: [PATCH 107/108] Merged and fixed Digibyte segwit address validation --- dist/wallet-address-validator.js | 816 +++++++++++++-------------- dist/wallet-address-validator.min.js | 2 +- src/currencies.js | 4 +- test/wallet_address_validator.js | 1 + 4 files changed, 412 insertions(+), 411 deletions(-) diff --git a/dist/wallet-address-validator.js b/dist/wallet-address-validator.js index ae1c84bb..c0e80b41 100644 --- a/dist/wallet-address-validator.js +++ b/dist/wallet-address-validator.js @@ -4174,412 +4174,412 @@ function numberIsNaN (obj) { } },{"base64-js":2,"ieee754":31}],5:[function(require,module,exports){ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014 Patrick Gansterer - * - * 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. - */ - -(function(global, undefined) { "use strict"; -var POW_2_24 = Math.pow(2, -24), - POW_2_32 = Math.pow(2, 32), - POW_2_53 = Math.pow(2, 53); - -function encode(value) { - var data = new ArrayBuffer(256); - var dataView = new DataView(data); - var lastLength; - var offset = 0; - - function ensureSpace(length) { - var newByteLength = data.byteLength; - var requiredLength = offset + length; - while (newByteLength < requiredLength) - newByteLength *= 2; - if (newByteLength !== data.byteLength) { - var oldDataView = dataView; - data = new ArrayBuffer(newByteLength); - dataView = new DataView(data); - var uint32count = (offset + 3) >> 2; - for (var i = 0; i < uint32count; ++i) - dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); - } - - lastLength = length; - return dataView; - } - function write() { - offset += lastLength; - } - function writeFloat64(value) { - write(ensureSpace(8).setFloat64(offset, value)); - } - function writeUint8(value) { - write(ensureSpace(1).setUint8(offset, value)); - } - function writeUint8Array(value) { - var dataView = ensureSpace(value.length); - for (var i = 0; i < value.length; ++i) - dataView.setUint8(offset + i, value[i]); - write(); - } - function writeUint16(value) { - write(ensureSpace(2).setUint16(offset, value)); - } - function writeUint32(value) { - write(ensureSpace(4).setUint32(offset, value)); - } - function writeUint64(value) { - var low = value % POW_2_32; - var high = (value - low) / POW_2_32; - var dataView = ensureSpace(8); - dataView.setUint32(offset, high); - dataView.setUint32(offset + 4, low); - write(); - } - function writeTypeAndLength(type, length) { - if (length < 24) { - writeUint8(type << 5 | length); - } else if (length < 0x100) { - writeUint8(type << 5 | 24); - writeUint8(length); - } else if (length < 0x10000) { - writeUint8(type << 5 | 25); - writeUint16(length); - } else if (length < 0x100000000) { - writeUint8(type << 5 | 26); - writeUint32(length); - } else { - writeUint8(type << 5 | 27); - writeUint64(length); - } - } - - function encodeItem(value) { - var i; - - if (value === false) - return writeUint8(0xf4); - if (value === true) - return writeUint8(0xf5); - if (value === null) - return writeUint8(0xf6); - if (value === undefined) - return writeUint8(0xf7); - - switch (typeof value) { - case "number": - if (Math.floor(value) === value) { - if (0 <= value && value <= POW_2_53) - return writeTypeAndLength(0, value); - if (-POW_2_53 <= value && value < 0) - return writeTypeAndLength(1, -(value + 1)); - } - writeUint8(0xfb); - return writeFloat64(value); - - case "string": - var utf8data = []; - for (i = 0; i < value.length; ++i) { - var charCode = value.charCodeAt(i); - if (charCode < 0x80) { - utf8data.push(charCode); - } else if (charCode < 0x800) { - utf8data.push(0xc0 | charCode >> 6); - utf8data.push(0x80 | charCode & 0x3f); - } else if (charCode < 0xd800) { - utf8data.push(0xe0 | charCode >> 12); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } else { - charCode = (charCode & 0x3ff) << 10; - charCode |= value.charCodeAt(++i) & 0x3ff; - charCode += 0x10000; - - utf8data.push(0xf0 | charCode >> 18); - utf8data.push(0x80 | (charCode >> 12) & 0x3f); - utf8data.push(0x80 | (charCode >> 6) & 0x3f); - utf8data.push(0x80 | charCode & 0x3f); - } - } - - writeTypeAndLength(3, utf8data.length); - return writeUint8Array(utf8data); - - default: - var length; - if (Array.isArray(value)) { - length = value.length; - writeTypeAndLength(4, length); - for (i = 0; i < length; ++i) - encodeItem(value[i]); - } else if (value instanceof Uint8Array) { - writeTypeAndLength(2, value.length); - writeUint8Array(value); - } else { - var keys = Object.keys(value); - length = keys.length; - writeTypeAndLength(5, length); - for (i = 0; i < length; ++i) { - var key = keys[i]; - encodeItem(key); - encodeItem(value[key]); - } - } - } - } - - encodeItem(value); - - if ("slice" in data) - return data.slice(0, offset); - - var ret = new ArrayBuffer(offset); - var retView = new DataView(ret); - for (var i = 0; i < offset; ++i) - retView.setUint8(i, dataView.getUint8(i)); - return ret; -} - -function decode(data, tagger, simpleValue) { - var dataView = new DataView(data); - var offset = 0; - - if (typeof tagger !== "function") - tagger = function(value) { return value; }; - if (typeof simpleValue !== "function") - simpleValue = function() { return undefined; }; - - function read(value, length) { - offset += length; - return value; - } - function readArrayBuffer(length) { - return read(new Uint8Array(data, offset, length), length); - } - function readFloat16() { - var tempArrayBuffer = new ArrayBuffer(4); - var tempDataView = new DataView(tempArrayBuffer); - var value = readUint16(); - - var sign = value & 0x8000; - var exponent = value & 0x7c00; - var fraction = value & 0x03ff; - - if (exponent === 0x7c00) - exponent = 0xff << 10; - else if (exponent !== 0) - exponent += (127 - 15) << 10; - else if (fraction !== 0) - return fraction * POW_2_24; - - tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); - return tempDataView.getFloat32(0); - } - function readFloat32() { - return read(dataView.getFloat32(offset), 4); - } - function readFloat64() { - return read(dataView.getFloat64(offset), 8); - } - function readUint8() { - return read(dataView.getUint8(offset), 1); - } - function readUint16() { - return read(dataView.getUint16(offset), 2); - } - function readUint32() { - return read(dataView.getUint32(offset), 4); - } - function readUint64() { - return readUint32() * POW_2_32 + readUint32(); - } - function readBreak() { - if (dataView.getUint8(offset) !== 0xff) - return false; - offset += 1; - return true; - } - function readLength(additionalInformation) { - if (additionalInformation < 24) - return additionalInformation; - if (additionalInformation === 24) - return readUint8(); - if (additionalInformation === 25) - return readUint16(); - if (additionalInformation === 26) - return readUint32(); - if (additionalInformation === 27) - return readUint64(); - if (additionalInformation === 31) - return -1; - throw "Invalid length encoding"; - } - function readIndefiniteStringLength(majorType) { - var initialByte = readUint8(); - if (initialByte === 0xff) - return -1; - var length = readLength(initialByte & 0x1f); - if (length < 0 || (initialByte >> 5) !== majorType) - throw "Invalid indefinite length element"; - return length; - } - - function appendUtf16data(utf16data, length) { - for (var i = 0; i < length; ++i) { - var value = readUint8(); - if (value & 0x80) { - if (value < 0xe0) { - value = (value & 0x1f) << 6 - | (readUint8() & 0x3f); - length -= 1; - } else if (value < 0xf0) { - value = (value & 0x0f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 2; - } else { - value = (value & 0x0f) << 18 - | (readUint8() & 0x3f) << 12 - | (readUint8() & 0x3f) << 6 - | (readUint8() & 0x3f); - length -= 3; - } - } - - if (value < 0x10000) { - utf16data.push(value); - } else { - value -= 0x10000; - utf16data.push(0xd800 | (value >> 10)); - utf16data.push(0xdc00 | (value & 0x3ff)); - } - } - } - - function decodeItem() { - var initialByte = readUint8(); - var majorType = initialByte >> 5; - var additionalInformation = initialByte & 0x1f; - var i; - var length; - - if (majorType === 7) { - switch (additionalInformation) { - case 25: - return readFloat16(); - case 26: - return readFloat32(); - case 27: - return readFloat64(); - } - } - - length = readLength(additionalInformation); - if (length < 0 && (majorType < 2 || 6 < majorType)) - throw "Invalid length"; - - switch (majorType) { - case 0: - return length; - case 1: - return -1 - length; - case 2: - if (length < 0) { - var elements = []; - var fullArrayLength = 0; - while ((length = readIndefiniteStringLength(majorType)) >= 0) { - fullArrayLength += length; - elements.push(readArrayBuffer(length)); - } - var fullArray = new Uint8Array(fullArrayLength); - var fullArrayOffset = 0; - for (i = 0; i < elements.length; ++i) { - fullArray.set(elements[i], fullArrayOffset); - fullArrayOffset += elements[i].length; - } - return fullArray; - } - return readArrayBuffer(length); - case 3: - var utf16data = []; - if (length < 0) { - while ((length = readIndefiniteStringLength(majorType)) >= 0) - appendUtf16data(utf16data, length); - } else - appendUtf16data(utf16data, length); - return String.fromCharCode.apply(null, utf16data); - case 4: - var retArray; - if (length < 0) { - retArray = []; - while (!readBreak()) - retArray.push(decodeItem()); - } else { - retArray = new Array(length); - for (i = 0; i < length; ++i) - retArray[i] = decodeItem(); - } - return retArray; - case 5: - var retObject = {}; - for (i = 0; i < length || length < 0 && !readBreak(); ++i) { - var key = decodeItem(); - retObject[key] = decodeItem(); - } - return retObject; - case 6: - return tagger(decodeItem(), length); - case 7: - switch (length) { - case 20: - return false; - case 21: - return true; - case 22: - return null; - case 23: - return undefined; - default: - return simpleValue(length); - } - } - } - - var ret = decodeItem(); - if (offset !== data.byteLength) - throw "Remaining bytes"; - return ret; -} - -var obj = { encode: encode, decode: decode }; - -if (typeof define === "function" && define.amd) - define("cbor/cbor", obj); -else if (typeof module !== 'undefined' && module.exports) - module.exports = obj; -else if (!global.CBOR) - global.CBOR = obj; - -})(this); +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 Patrick Gansterer + * + * 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. + */ + +(function(global, undefined) { "use strict"; +var POW_2_24 = Math.pow(2, -24), + POW_2_32 = Math.pow(2, 32), + POW_2_53 = Math.pow(2, 53); + +function encode(value) { + var data = new ArrayBuffer(256); + var dataView = new DataView(data); + var lastLength; + var offset = 0; + + function ensureSpace(length) { + var newByteLength = data.byteLength; + var requiredLength = offset + length; + while (newByteLength < requiredLength) + newByteLength *= 2; + if (newByteLength !== data.byteLength) { + var oldDataView = dataView; + data = new ArrayBuffer(newByteLength); + dataView = new DataView(data); + var uint32count = (offset + 3) >> 2; + for (var i = 0; i < uint32count; ++i) + dataView.setUint32(i * 4, oldDataView.getUint32(i * 4)); + } + + lastLength = length; + return dataView; + } + function write() { + offset += lastLength; + } + function writeFloat64(value) { + write(ensureSpace(8).setFloat64(offset, value)); + } + function writeUint8(value) { + write(ensureSpace(1).setUint8(offset, value)); + } + function writeUint8Array(value) { + var dataView = ensureSpace(value.length); + for (var i = 0; i < value.length; ++i) + dataView.setUint8(offset + i, value[i]); + write(); + } + function writeUint16(value) { + write(ensureSpace(2).setUint16(offset, value)); + } + function writeUint32(value) { + write(ensureSpace(4).setUint32(offset, value)); + } + function writeUint64(value) { + var low = value % POW_2_32; + var high = (value - low) / POW_2_32; + var dataView = ensureSpace(8); + dataView.setUint32(offset, high); + dataView.setUint32(offset + 4, low); + write(); + } + function writeTypeAndLength(type, length) { + if (length < 24) { + writeUint8(type << 5 | length); + } else if (length < 0x100) { + writeUint8(type << 5 | 24); + writeUint8(length); + } else if (length < 0x10000) { + writeUint8(type << 5 | 25); + writeUint16(length); + } else if (length < 0x100000000) { + writeUint8(type << 5 | 26); + writeUint32(length); + } else { + writeUint8(type << 5 | 27); + writeUint64(length); + } + } + + function encodeItem(value) { + var i; + + if (value === false) + return writeUint8(0xf4); + if (value === true) + return writeUint8(0xf5); + if (value === null) + return writeUint8(0xf6); + if (value === undefined) + return writeUint8(0xf7); + + switch (typeof value) { + case "number": + if (Math.floor(value) === value) { + if (0 <= value && value <= POW_2_53) + return writeTypeAndLength(0, value); + if (-POW_2_53 <= value && value < 0) + return writeTypeAndLength(1, -(value + 1)); + } + writeUint8(0xfb); + return writeFloat64(value); + + case "string": + var utf8data = []; + for (i = 0; i < value.length; ++i) { + var charCode = value.charCodeAt(i); + if (charCode < 0x80) { + utf8data.push(charCode); + } else if (charCode < 0x800) { + utf8data.push(0xc0 | charCode >> 6); + utf8data.push(0x80 | charCode & 0x3f); + } else if (charCode < 0xd800) { + utf8data.push(0xe0 | charCode >> 12); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } else { + charCode = (charCode & 0x3ff) << 10; + charCode |= value.charCodeAt(++i) & 0x3ff; + charCode += 0x10000; + + utf8data.push(0xf0 | charCode >> 18); + utf8data.push(0x80 | (charCode >> 12) & 0x3f); + utf8data.push(0x80 | (charCode >> 6) & 0x3f); + utf8data.push(0x80 | charCode & 0x3f); + } + } + + writeTypeAndLength(3, utf8data.length); + return writeUint8Array(utf8data); + + default: + var length; + if (Array.isArray(value)) { + length = value.length; + writeTypeAndLength(4, length); + for (i = 0; i < length; ++i) + encodeItem(value[i]); + } else if (value instanceof Uint8Array) { + writeTypeAndLength(2, value.length); + writeUint8Array(value); + } else { + var keys = Object.keys(value); + length = keys.length; + writeTypeAndLength(5, length); + for (i = 0; i < length; ++i) { + var key = keys[i]; + encodeItem(key); + encodeItem(value[key]); + } + } + } + } + + encodeItem(value); + + if ("slice" in data) + return data.slice(0, offset); + + var ret = new ArrayBuffer(offset); + var retView = new DataView(ret); + for (var i = 0; i < offset; ++i) + retView.setUint8(i, dataView.getUint8(i)); + return ret; +} + +function decode(data, tagger, simpleValue) { + var dataView = new DataView(data); + var offset = 0; + + if (typeof tagger !== "function") + tagger = function(value) { return value; }; + if (typeof simpleValue !== "function") + simpleValue = function() { return undefined; }; + + function read(value, length) { + offset += length; + return value; + } + function readArrayBuffer(length) { + return read(new Uint8Array(data, offset, length), length); + } + function readFloat16() { + var tempArrayBuffer = new ArrayBuffer(4); + var tempDataView = new DataView(tempArrayBuffer); + var value = readUint16(); + + var sign = value & 0x8000; + var exponent = value & 0x7c00; + var fraction = value & 0x03ff; + + if (exponent === 0x7c00) + exponent = 0xff << 10; + else if (exponent !== 0) + exponent += (127 - 15) << 10; + else if (fraction !== 0) + return fraction * POW_2_24; + + tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); + return tempDataView.getFloat32(0); + } + function readFloat32() { + return read(dataView.getFloat32(offset), 4); + } + function readFloat64() { + return read(dataView.getFloat64(offset), 8); + } + function readUint8() { + return read(dataView.getUint8(offset), 1); + } + function readUint16() { + return read(dataView.getUint16(offset), 2); + } + function readUint32() { + return read(dataView.getUint32(offset), 4); + } + function readUint64() { + return readUint32() * POW_2_32 + readUint32(); + } + function readBreak() { + if (dataView.getUint8(offset) !== 0xff) + return false; + offset += 1; + return true; + } + function readLength(additionalInformation) { + if (additionalInformation < 24) + return additionalInformation; + if (additionalInformation === 24) + return readUint8(); + if (additionalInformation === 25) + return readUint16(); + if (additionalInformation === 26) + return readUint32(); + if (additionalInformation === 27) + return readUint64(); + if (additionalInformation === 31) + return -1; + throw "Invalid length encoding"; + } + function readIndefiniteStringLength(majorType) { + var initialByte = readUint8(); + if (initialByte === 0xff) + return -1; + var length = readLength(initialByte & 0x1f); + if (length < 0 || (initialByte >> 5) !== majorType) + throw "Invalid indefinite length element"; + return length; + } + + function appendUtf16data(utf16data, length) { + for (var i = 0; i < length; ++i) { + var value = readUint8(); + if (value & 0x80) { + if (value < 0xe0) { + value = (value & 0x1f) << 6 + | (readUint8() & 0x3f); + length -= 1; + } else if (value < 0xf0) { + value = (value & 0x0f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 2; + } else { + value = (value & 0x0f) << 18 + | (readUint8() & 0x3f) << 12 + | (readUint8() & 0x3f) << 6 + | (readUint8() & 0x3f); + length -= 3; + } + } + + if (value < 0x10000) { + utf16data.push(value); + } else { + value -= 0x10000; + utf16data.push(0xd800 | (value >> 10)); + utf16data.push(0xdc00 | (value & 0x3ff)); + } + } + } + + function decodeItem() { + var initialByte = readUint8(); + var majorType = initialByte >> 5; + var additionalInformation = initialByte & 0x1f; + var i; + var length; + + if (majorType === 7) { + switch (additionalInformation) { + case 25: + return readFloat16(); + case 26: + return readFloat32(); + case 27: + return readFloat64(); + } + } + + length = readLength(additionalInformation); + if (length < 0 && (majorType < 2 || 6 < majorType)) + throw "Invalid length"; + + switch (majorType) { + case 0: + return length; + case 1: + return -1 - length; + case 2: + if (length < 0) { + var elements = []; + var fullArrayLength = 0; + while ((length = readIndefiniteStringLength(majorType)) >= 0) { + fullArrayLength += length; + elements.push(readArrayBuffer(length)); + } + var fullArray = new Uint8Array(fullArrayLength); + var fullArrayOffset = 0; + for (i = 0; i < elements.length; ++i) { + fullArray.set(elements[i], fullArrayOffset); + fullArrayOffset += elements[i].length; + } + return fullArray; + } + return readArrayBuffer(length); + case 3: + var utf16data = []; + if (length < 0) { + while ((length = readIndefiniteStringLength(majorType)) >= 0) + appendUtf16data(utf16data, length); + } else + appendUtf16data(utf16data, length); + return String.fromCharCode.apply(null, utf16data); + case 4: + var retArray; + if (length < 0) { + retArray = []; + while (!readBreak()) + retArray.push(decodeItem()); + } else { + retArray = new Array(length); + for (i = 0; i < length; ++i) + retArray[i] = decodeItem(); + } + return retArray; + case 5: + var retObject = {}; + for (i = 0; i < length || length < 0 && !readBreak(); ++i) { + var key = decodeItem(); + retObject[key] = decodeItem(); + } + return retObject; + case 6: + return tagger(decodeItem(), length); + case 7: + switch (length) { + case 20: + return false; + case 21: + return true; + case 22: + return null; + case 23: + return undefined; + default: + return simpleValue(length); + } + } + } + + var ret = decodeItem(); + if (offset !== data.byteLength) + throw "Remaining bytes"; + return ret; +} + +var obj = { encode: encode, decode: decode }; + +if (typeof define === "function" && define.amd) + define("cbor/cbor", obj); +else if (typeof module !== 'undefined' && module.exports) + module.exports = obj; +else if (!global.CBOR) + global.CBOR = obj; + +})(this); },{}],6:[function(require,module,exports){ 'use strict'; @@ -10996,8 +10996,8 @@ var CURRENCIES = [{ }, { name: 'DigiByte', symbol: 'dgb', - addressTypes: { prod: ['1e'], testnet: [] }, - bech32Hrp: { prod: ['dgb', 'S'], testnet: [] }, + addressTypes: { prod: ['1e', '3f'], testnet: [] }, + bech32Hrp: { prod: ['dgb'], testnet: [] }, validator: BTCValidator }, { name: 'Tether', diff --git a/dist/wallet-address-validator.min.js b/dist/wallet-address-validator.min.js index 6f15c71a..f3fdb6aa 100644 --- a/dist/wallet-address-validator.min.js +++ b/dist/wallet-address-validator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,x=i,E=new g(y);if(!w)return m.toS();for(h=E.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?E:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=x,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:N(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),x=0;for(i=0;i=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){var n,i;n=this,i=function(){"use strict";var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)},e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function r(t,e,r,n){var i,o,a,s=e||[0],u=(r=r||0)>>>3,f=-1===n?3:0;for(i=0;i>>2,s.length<=o&&s.push(0),s[o]|=t[i]<<8*(f+n*(a%4));return{value:s,binLen:8*t.length+r}}function n(t,n,i){switch(n){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,r,n){var i,o,a,s;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");var u=e||[0],f=(r=r||0)>>>3,c=-1===n?3:0;for(i=0;i>>1)+f)>>>2;u.length<=a;)u.push(0);u[a]|=o<<8*(c+n*(s%4))}return{value:u,binLen:4*t.length+r}}(t,e,r,i)};case"TEXT":return function(t,e,r){return function(t,e,r,n,i){var o,a,s,u,f,c,l,h,d=0,p=r||[0],v=(n=n||0)>>>3;if("UTF8"===e)for(l=-1===i?3:0,s=0;s(o=t.charCodeAt(s))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(s)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),u=0;u>>2;p.length<=f;)p.push(0);p[f]|=a[u]<<8*(l+i*(c%4)),d+=1}else for(l=-1===i?2:0,h="UTF16LE"===e&&1!==i||"UTF16LE"!==e&&1===i,s=0;s>>8),f=(c=d+v)>>>2;p.length<=f;)p.push(0);p[f]|=o<<8*(l+i*(c%4)),d+=2}return{value:p,binLen:8*d+n}}(t,n,e,r,i)};case"B64":return function(t,r,n){return function(t,r,n,i){var o,a,s,u,f,c,l=0,h=r||[0],d=(n=n||0)>>>3,p=-1===i?3:0,v=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==v&&v=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var v=n.allocUnsafe(i+(a-p));v.fill(0,0,i);for(var y=i;p!==a;)v[y++]=c[p++];return v}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var v=f-i;v!==f&&0===l[v];)v++;for(var y=u.repeat(r);v0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,o,a=[],s=e;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){(function(t){var r,n=20,i=4,o=-7,a=21,s=-1e9,u=1e9,f=!0,c=parseInt,l=g.prototype,h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",d=0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=g(1);function g(t,e){var o,a,c,l,y,w,_=this;if(!(_ instanceof g))return new g(t,e);if(t instanceof g){if(d=0,e===o)return _.s=t.s,_.e=t.e,void(_.c=(t=t.c)?t.slice():t);t+=""}if("string"!=typeof t&&(t=(c="number"==typeof t||"[object Number]"==Object.prototype.toString.call(t))&&0===t&&1/t<0?"-0":t+""),w=t,e===o&&p.test(t))_.s="-"==t.charAt(0)?(t=t.slice(1),-1):1;else{if(10==e)return x(t,n,i);if(t=v.call(t).replace(/^\+(?!-)/,""),_.s="-"==t.charAt(0)?(t=t.replace(/^-(?!-)/,""),-1):1,null!=e?e!=(0|e)&&f||(r=!(e>=2&&e<65))?(b(e,2),y=p.test(t)):(l="["+h.slice(0,e|=0)+"]+",t=t.replace(/\.$/,"").replace(/^\./,"0."),(y=new RegExp("^"+l+"(?:\\."+l+")?$",e<37?"i":"").test(t))?(c&&(t.replace(/^0\.0*|\./,"").length>15&&b(w,0),c=!c),t=m(t,10,e,_.s)):"Infinity"!=t&&"NaN"!=t&&(b(w,1,e),t="NaN")):y=p.test(t),!y)return _.c=_.e=null,"Infinity"!=t&&("NaN"!=t&&b(w,3),_.s=null),void(d=0)}for((o=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(o<0&&(o=a),o+=+t.slice(a+1),t=t.substring(0,a)):o<0&&(o=t.length),a=0;"0"==t.charAt(a);a++);if(e=t.length,c&&e>15&&t.slice(a).length>15&&b(w,0),d=0,(o-=a+1)>u)_.c=_.e=null;else if(a==e||oe-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/e^0,u[i]%=e)}return u.reverse()}function l(t){for(var e=0,r=t.length,n="";e-1)if(i=t.length-i-1,o=c(new g(r).pow(i).toF(),10),a=c((s=t.split("."))[1]),s=c(s[0]),u=(f=w(a,o,a.length-o.length,n,e,1&s[s.length-1])).c,i=f.e){for(;++i;u.unshift(0));t=l(s)+"."+l(u)}else u[0]?s[i=s.length-1]w?1:-1;else for(d=-1,h=0;++dm[d]?1:-1;break}if(!(h<0))break;for(c=w==f?e:p;w;){if(m[--w]B&&A(_,n,o,a,null!=m[0]),_.e>u?_.c=_.e=null:_.e++e&&A(t,n,10),n=0==i[0]?n+1:r?e:t.e+n+1;i.length1?(i.splice(1,0,"."),i.join("")):i[0])+(n<0?"e":"e+")+n:t.toS()}function A(t,e,r,n,o){var a=t.c,s=t.s<0,u=r/2,f=t.e+e+1,c=a[f],l=o||f<0||null!=a[f+1];if(o=i<4?(null!=c||l)&&(0==i||2==i&&!s||3==i&&s):c>u||c==u&&(4==i||l||6==i&&(1&a[f-1]||!e&&n)||7==i&&!s||8==i&&s),f<1||!a[0])return a.length=0,a.push(0),o?(a[0]=1,t.e=-e):t.e=0,t;if(a.length=f--,o)for(--r;++a[f]>r;)a[f]=0,f--||(++t.e,a.unshift(1));for(f=a.length;!a[--f];a.pop());return t}function x(t,e,r){var n=i;return i=r,(t=new g(t)).c&&A(t,e,10),i=n,t}g.ROUND_UP=0,g.ROUND_DOWN=1,g.ROUND_CEIL=2,g.ROUND_FLOOR=3,g.ROUND_HALF_UP=4,g.ROUND_HALF_DOWN=5,g.ROUND_HALF_EVEN=6,g.ROUND_HALF_CEIL=7,g.ROUND_HALF_FLOOR=8,g.fromBuffer=function(t,e){e||(e={});var r={1:"big","-1":"little"}[e.endian]||e.endian||"big",n="auto"===e.size?Math.ceil(t.length):e.size||1;if(t.length%n!=0)throw new RangeError("Buffer length ("+t.length+") must be a multiple of size ("+n+")");for(var i=[],o=0;on)||c(t)!=t&&0!==t)},m=v&&"object"==typeof v?function(){if(v.hasOwnProperty(e))return null!=(t=v[e])}:function(){if(p.length>l)return null!=(t=p[l++])};return m(e="DECIMAL_PLACES")&&(g(t,0,1e9)?n=0|t:b(t,e,y)),h[e]=n,m(e="ROUNDING_MODE")&&(g(t,0,8)?i=0|t:b(t,e,y)),h[e]=i,m(e="EXPONENTIAL_AT")&&(g(t,-1e9,1e9)?o=-(a=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,0)&&g(t[1],0,1e9)?(o=~~t[0],a=~~t[1]):b(t,e,y,1)),h[e]=[o,a],m(e="RANGE")&&(g(t,-1e9,1e9)&&~~t?s=-(u=~~(t<0?-t:+t)):!r&&t&&g(t[0],-1e9,-1)&&g(t[1],1,1e9)?(s=~~t[0],u=~~t[1]):b(t,e,y,1,1)),h[e]=[s,u],m(e="ERRORS")&&(t===!!t||1===t||0===t?(r=d=0,c=(f=!!t)?parseInt:parseFloat):b(t,e,y,0,0,1)),h[e]=f,h},l.abs=l.absoluteValue=function(){var t=new g(this);return t.s<0&&(t.s=1),t},l.bitLength=function(){return this.toString(2).length},l.ceil=function(){return x(this,0,2)},l.comparedTo=l.cmp=function(t,e){var r,n=this,i=n.c,o=(d=-d,t=new g(t,e)).c,a=n.s,s=t.s,u=n.e,f=t.e;if(!a||!s)return null;if(r=i&&!i[0],e=o&&!o[0],r||e)return r?e?0:-s:a;if(a!=s)return a;if(r=a<0,e=u==f,!i||!o)return e?0:!i^r?1:-1;if(!e)return u>f^r?1:-1;for(a=-1,s=(u=i.length)<(f=o.length)?u:f;++ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1},l.dividedBy=l.div=function(t,e){var r=this.c,n=this.e,i=this.s,o=(d=2,t=new g(t,e)).c,a=t.e,s=t.s,u=i==s?1:-1;return(n||r&&r[0])&&(a||o&&o[0])?w(r,o,n-a,u,10):new g(i&&s&&(r?!o||r[0]!=o[0]:o)?r&&0==r[0]||!o?0*u:u/0:NaN)},l.equals=l.eq=function(t,e){return d=3,0===this.cmp(t,e)},l.floor=function(){return x(this,0,3)},l.greaterThan=l.gt=function(t,e){return d=4,this.cmp(t,e)>0},l.greaterThanOrEqualTo=l.gte=l.gt=function(t,e){return d=5,1==(e=this.cmp(t,e))||0===e},l.isFinite=l.isF=function(){return!!this.c},l.isNaN=function(){return!this.s},l.isNegative=l.isNeg=function(){return this.s<0},l.isZero=l.isZ=function(){return!!this.c&&0==this.c[0]},l.lessThan=l.lt=function(t,e){return d=6,this.cmp(t,e)<0},l.lessThanOrEqualTo=l.lte=l.le=function(t,e){return d=7,-1==(e=this.cmp(t,e))||0===e},l.minus=l.sub=function(t,e){var r,n,o,a,u=this,f=u.s;if(e=(d=8,t=new g(t,e)).s,!f||!e)return new g(NaN);if(f!=e)return t.s=-e,u.plus(t);var c=u.c,l=u.e,h=t.c,p=t.e;if(!l||!p){if(!c||!h)return c?(t.s=-e,t):new g(h?u:NaN);if(!c[0]||!h[0])return h[0]?(t.s=-e,t):new g(c[0]?u:3==i?-0:0)}if(c=c.slice(),f=l-p){for((r=(a=f<0)?(f=-f,c):(p=l,h)).reverse(),e=f;e--;r.push(0));r.reverse()}else for(o=((a=c.length0)for(;e--;c[o++]=0);for(e=h.length;e>f;){if(c[--e]0?(s=o,f):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for(a.length-f.length<0&&(r=f,f=a,a=r),i=f.length,e=0;i;e=(a[--i]=a[i]+f[i]+e)/10^0,a[i]%=10);for(e&&(a.unshift(e),++s>u&&(a=s=null)),i=a.length;0==a[--i];a.pop());return t.c=a,t.e=s,t},l.toPower=l.pow=function(t){var e=0*t==0?0|t:t,n=new g(this),i=new g(y);if(((r=t<-1e6||t>1e6)&&(e=1*t/0)||c(t)!=t&&0!==t&&!(e=NaN))&&!b(t,"exponent","pow")||!e)return new g(Math.pow(n.toS(),e));for(e=e<0?-e:e;1&e&&(i=i.times(n)),e>>=1;)n=n.times(n);return t<0?y.div(i):i},l.powm=function(t,e){return this.pow(t).mod(e)},l.round=function(t,e){return x(this,t=null==t||((r=t<0||t>1e9)||c(t)!=t)&&!b(t,"decimal places","round")?0:0|t,e=null==e||((r=e<0||e>8)||c(e)!=e&&0!==e)&&!b(e,"mode","round")?i:0|e)},l.squareRoot=l.sqrt=function(){var t,e,r,o,a=this,s=a.c,u=a.s,f=a.e,c=n,l=i,h=new g("0.5");if(1!==u||!s||!s[0])return new g(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(u=Math.sqrt(a.toS()),i=1,0==u||u==1/0?((t=s.join("")).length+f&1||(t+="0"),(e=new g(Math.sqrt(t)+"")).c||(e.c=[1]),e.e=((f+1)/2|0)-(f<0||1&f)):e=new g(t=u.toString()),(u=(r=e.e)+(n+=4))<3&&(u=0),f=u;;)if(o=e,e=h.times(o.plus(a.div(o))),o.c.slice(0,u).join("")===e.c.slice(0,u).join("")){if(9!=(s=e.c)[u-=t&&e.ef-2&&(s.length=f-2),e.times(e).eq(a)))){for(;s.length-1;a--){for(e=0,f=c+a;f>a;e=r[f]+o[a]*i[f-a-1]+e,r[f--]=e%10|0,e=e/10|0);e&&(r[f]=(r[f]+e)%10)}for(e&&++t.e,!r[0]&&r.shift(),f=r.length;!r[--f];r.pop());return t.c=t.e>u?t.e=null:t.e0&&c.copy(i,4+(128&c[0]?1:0)),128&c[0]&&(i[4]=0),i[0]=n&255<<24,i[1]=n&255<<16,i[2]=65280&n,i[3]=255&n;var o=this.lt(0);if(o)for(var a=4;a0}).forEach(function(t,e){for(var r=0;r1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toE"))&&this.c?this.c.length-1:0|t,1)},l.toFixed=l.toF=function(t){var e,n,i,s=this;return null==t||((r=t<0||t>1e9)||c(t)!=t&&0!==t)&&!b(t,"decimal places","toF")||(i=s.e+(0|t)),e=o,t=a,o=-(a=1/0),i==n?n=s.toS():(n=_(s,i),s.s<0&&s.c&&(s.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),o=e,a=t,n},l.toFraction=l.toFr=function(t){var e,o,a,s,c,l,h,p=s=new g(y),v=a=new g("0"),m=this,w=m.c,_=u,A=n,x=i,E=new g(y);if(!w)return m.toS();for(h=E.e=w.length-m.e-1,(null==t||(!(d=12,l=new g(t)).s||(r=l.cmp(p)<0||!l.c)||f&&l.e0)&&(t=h>0?E:p),u=1/0,l=new g(w.join("")),n=0,i=1;e=l.div(E),1!=(c=s.plus(e.times(v))).cmp(t);)s=v,v=c,p=a.plus(e.times(c=p)),a=c,E=l.minus(e.times(c=E)),l=c;return c=t.minus(s).div(v),a=a.plus(c.times(p)),s=s.plus(c.times(v)),a.s=p.s=m.s,n=2*h,i=x,o=p.div(v).minus(m).abs().cmp(a.div(s).minus(m).abs())<1?[p.toS(),v.toS()]:[a.toS(),s.toS()],u=_,n=A,o},l.toPrecision=l.toP=function(t){return null==t||((r=t<1||t>1e9)||c(t)!=t)&&!b(t,"precision","toP")?this.toS():_(this,0|--t,2)},l.toString=l.toS=function(t){var e,n,i,s=this,u=s.e;if(null===u)n=s.s?"Infinity":"NaN";else{if(t===e&&(u<=o||u>=a))return _(s,s.c.length-1,1);if(n=s.c.join(""),u<0){for(;++u;n="0"+n);n="0."+n}else if(i=n.length,u>0)if(++u>i)for(u-=i;u--;n+="0");else u1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((r=!(t>=2&&t<65))||t!=(0|t)&&f)b(t,"base","toS");else if("0"==(n=m(n,0|t,10,s.s)))return n}return s.s<0?"-"+n:n},l.valueOf=function(){return this.toS()},e.exports=g}).call(this,t("buffer").Buffer)},{buffer:4}],4:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:N(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(P(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,u=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,o){return e=+e,r>>>=0,o||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}},{"base64-js":2,ieee754:31}],5:[function(t,e,r){!function(t,r){"use strict";var n=Math.pow(2,-24),i=Math.pow(2,32),o=Math.pow(2,53);var a={encode:function(t){var e,n=new ArrayBuffer(256),a=new DataView(n),s=0;function u(t){for(var r=n.byteLength,i=s+t;r>2,f=0;f>6),i.push(128|63&a)):a<55296?(i.push(224|a>>12),i.push(128|a>>6&63),i.push(128|63&a)):(a=(1023&a)<<10,a|=1023&e.charCodeAt(++n),a+=65536,i.push(240|a>>18),i.push(128|a>>12&63),i.push(128|a>>6&63),i.push(128|63&a))}return h(3,i.length),l(i);default:var d;if(Array.isArray(e))for(h(4,d=e.length),n=0;n>5!==t)throw"Invalid indefinite length element";return r}function y(t,e){for(var r=0;r>10),t.push(56320|1023&n))}}"function"!=typeof e&&(e=function(t){return t}),"function"!=typeof o&&(o=function(){return r});var g=function t(){var i,h,g=c(),b=g>>5,m=31&g;if(7===b)switch(m){case 25:return function(){var t=new ArrayBuffer(4),e=new DataView(t),r=l(),i=32768&r,o=31744&r,a=1023&r;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==a)return a*n;return e.setUint32(0,i<<16|o<<13|a<<13),e.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=p(m))<0&&(b<2||6=0;)_+=h,w.push(f(h));var A=new Uint8Array(_),x=0;for(i=0;i=0;)y(E,h);else y(E,h);return String.fromCharCode.apply(null,E);case 4:var B;if(h<0)for(B=[];!d();)B.push(t());else for(B=new Array(h),i=0;i>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],19:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("ccitt",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584,6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743,28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("kermit",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-16-modbus",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:65535,o=0;o>8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=o(t("./create_buffer"));function o(t){return t&&t.__esModule?t:{default:t}}var a=(0,o(t("./define_crc")).default)("xmodem",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:0,o=0;o>>8&255;a^=255&t[o],r=r<<8&65535,r^=a^=a>>>4,r^=a=a<<5&65535,r^=a=a<<7&65535}return r});r.default=a},{"./create_buffer":28,"./define_crc":29,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536,5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104,11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303,1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419,12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-24",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=void 0!==e?~~e:11994318,o=0;o>16^a)]^r<<8)}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],24:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-32",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:-1^~~e,o=0;o>>8}return-1^r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],25:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=a(t("./create_buffer")),o=a(t("./define_crc"));function a(t){return t&&t.__esModule?t:{default:t}}var s=[0,7,14,9,28,27,18,21,56,63,54,49,36,35,42,45,112,119,126,121,108,107,98,101,72,79,70,65,84,83,90,93,224,231,238,233,252,251,242,245,216,223,214,209,196,195,202,205,144,151,158,153,140,139,130,133,168,175,166,161,180,179,186,189,199,192,201,206,219,220,213,210,255,248,241,246,227,228,237,234,183,176,185,190,171,172,165,162,143,136,129,134,147,148,157,154,39,32,41,46,59,60,53,50,31,24,17,22,3,4,13,10,87,80,89,94,75,76,69,66,111,104,97,102,115,116,125,122,137,142,135,128,149,146,155,156,177,182,191,184,173,170,163,164,249,254,247,240,229,226,235,236,193,198,207,200,221,218,211,212,105,110,103,96,117,114,123,124,81,86,95,88,77,74,67,68,25,30,23,16,5,2,11,12,33,38,47,40,61,58,51,52,78,73,64,71,82,85,92,91,118,113,120,127,106,109,100,99,62,57,48,55,34,37,44,43,6,1,8,15,26,29,20,19,174,169,160,167,178,181,188,187,150,145,152,159,138,141,132,131,222,217,208,215,194,197,204,203,230,225,232,239,250,253,244,243];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,o.default)("crc-8",function(t,e){n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=~~e,o=0;o1&&void 0!==arguments[1]?arguments[1]:-1;n.Buffer.isBuffer(t)||(t=(0,i.default)(t));for(var r=0===e?0:~~e,o=0;o>>8}return r});r.default=u},{"./create_buffer":28,"./define_crc":29,buffer:4}],28:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("buffer"),i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:function(t){return new n.Buffer(t)};r.default=i},{buffer:4}],29:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e){var r=function(t,r){return e(t,r)>>>0};return r.signed=e,r.unsigned=r,r.model=t,r}},{}],30:[function(t,e,r){"use strict";e.exports={crc1:t("./crc1"),crc8:t("./crc8"),crc81wire:t("./crc8_1wire"),crc16:t("./crc16"),crc16ccitt:t("./crc16_ccitt"),crc16modbus:t("./crc16_modbus"),crc16xmodem:t("./crc16_xmodem"),crc16kermit:t("./crc16_kermit"),crc24:t("./crc24"),crc32:t("./crc32"),crcjam:t("./crcjam")}},{"./crc1":6,"./crc16":7,"./crc16_ccitt":8,"./crc16_kermit":9,"./crc16_modbus":10,"./crc16_xmodem":11,"./crc24":12,"./crc32":13,"./crc8":14,"./crc8_1wire":15,"./crcjam":16}],31:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[r+d]=255&a,d+=p,a/=256,f-=8);t[r+d-p]|=128*v}},{}],32:[function(t,e,r){var n,i;n=this,i=function(){"use strict";var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)},e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function r(t,e,r,n){var i,o,a,s=e||[0],u=(r=r||0)>>>3,f=-1===n?3:0;for(i=0;i>>2,s.length<=o&&s.push(0),s[o]|=t[i]<<8*(f+n*(a%4));return{value:s,binLen:8*t.length+r}}function n(t,n,i){switch(n){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,r,n){var i,o,a,s;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");var u=e||[0],f=(r=r||0)>>>3,c=-1===n?3:0;for(i=0;i>>1)+f)>>>2;u.length<=a;)u.push(0);u[a]|=o<<8*(c+n*(s%4))}return{value:u,binLen:4*t.length+r}}(t,e,r,i)};case"TEXT":return function(t,e,r){return function(t,e,r,n,i){var o,a,s,u,f,c,l,h,d=0,p=r||[0],v=(n=n||0)>>>3;if("UTF8"===e)for(l=-1===i?3:0,s=0;s(o=t.charCodeAt(s))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(s)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),u=0;u>>2;p.length<=f;)p.push(0);p[f]|=a[u]<<8*(l+i*(c%4)),d+=1}else for(l=-1===i?2:0,h="UTF16LE"===e&&1!==i||"UTF16LE"!==e&&1===i,s=0;s>>8),f=(c=d+v)>>>2;p.length<=f;)p.push(0);p[f]|=o<<8*(l+i*(c%4)),d+=2}return{value:p,binLen:8*d+n}}(t,n,e,r,i)};case"B64":return function(t,r,n){return function(t,r,n,i){var o,a,s,u,f,c,l=0,h=r||[0],d=(n=n||0)>>>3,p=-1===i?3:0,v=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==v&&v Date: Fri, 27 Nov 2020 15:30:55 +0100 Subject: [PATCH 108/108] Add Ravencoin --- src/currencies.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/currencies.js b/src/currencies.js index c25561f9..2d41f978 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -191,6 +191,11 @@ var CURRENCIES = [{ addressTypes: { prod: ['1e', '3f'], testnet: [] }, bech32Hrp: { prod: ['dgb'], testnet: [] }, validator: BTCValidator + }, { + name: 'Ravencoin', + symbol: 'rvn', + addressTypes: { prod: ['3c'], testnet: [] }, + validator: BTCValidator }, { name: 'Tether', symbol: 'usdt', @@ -517,5 +522,3 @@ var CURRENCIES = [{ // CURRENCIES // .sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1) // .forEach(c => console.log(`"${c.name}","${c.symbol}",`)); - -