diff --git a/README.md b/README.md index 1d3a826..9fc954c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,72 @@ +# About This Fork + +This fork contains several changes from unwriter's original version. + +## 1. Axios insight implementation + +The `connect` method can now be used to create an axios instance which will be +used for retrieving utxo's and broadcasting raw transactions. + +This is an example of using BitIndex's testnet endpoint, with an api key. + +``` +datapay.connect({ + baseURL: "https://api.bitindex.network/api/v3/test", + headers: { api_key: "myapikey" } +}); +``` + +## 2. Promises + +Both build and send now return promises which can be used with async/await. + +``` +const tx = await datapay.build({ + data: ["using promises with datapay"], + pay: { + key: "" + } +}); + +const txid = await datapay.send({ tx }); +``` + +## 3. Fees + +This fork is using bsv 0.30.0 which has a fixed implementation of fee +estimation. The default fee is set to 1 sat/byte. This means the fee paid should +be exact, or only a sat or two over exact. + +## 4. Filtering + +The mingo filtering has been removed in favour of using a plain javascript +function. + +``` +const tx = await datapay.build({ + data: ["using promises with datapay"], + pay: { + key: "", + filter: utxos => utxos.filter(utxo => utxo.confirmations > 5) + } +}); +``` + +## 5. Genesis defaults + +`OP_FALSE OP_RETURN` is now used by default and the `safe: true` option has been removed. + +# Using This Fork + +The api here is still evolving so I recommend using the package-lock file or installing a specific commit. + +``` +npm install git+https://github.com/Breavyn/datapay.git# + +# e.g. +npm install git+https://github.com/Breavyn/datapay.git#8fa2715d28ddd16c8efa0c61ec99700fc7674408 +``` + # Datapay Datapay is the simplest library for building and broadcasting data transactions to the **Bitcoin SV blockchain**. @@ -8,7 +77,7 @@ Datapay is the simplest library for building and broadcasting data transactions # Preview -Post to the blockchain with just 4 lines of code. +Post to the blockchain with just 4 lines of code. ![code](code.png) @@ -32,7 +101,6 @@ Post to both Memo.cash and Blockpress with a single interface. --- - # Install ## 1. In node.js @@ -62,7 +130,6 @@ const datapay = require('datapay') Send `"Hello from datapay"` to [memo.cash](https://memo.cash) in 5 lines of code. - ``` const privateKey = [YOUR PRIVATE KEY HERE]; datapay.send({ @@ -163,21 +230,18 @@ The first argument--a declarative JSON object--can contain the following attribu - `pay`: For describing everything related to actually sending money - `tx`: For importing previously "built" transactions - ### A. data The `data` attribute is used to construct human readable/processable data to post to the blockchain. - #### 1. Buid from push data array - ``` const tx = { safe: true, data: ["0x6d02", "hello world"] } -datapay.build(tx, function(err, tx) { +datapay.build(tx, function(err, tx) { /** * res contains the generated transaction object, powered by bsv * You can check it out at https://github.com/moneybutton/bsv/blob/master/lib/transaction/transaction.js @@ -194,7 +258,7 @@ datapay.build(tx, function(err, tx) { 2. a hex string 3. Binary data ([Buffer](https://nodejs.org/api/buffer.html) in node.js, and [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) in browser) -**To use hex string, simply prefix the string with "0x"**. +**To use hex string, simply prefix the string with "0x"**. **To use Buffer types, just pass the Buffer (or ArrayBuffer) object as push data.** @@ -202,7 +266,6 @@ datapay.build(tx, function(err, tx) { In above example, we can see that the first item is `"0x6d02"`. Datapay will automatically recognize this as a hex string and interpret as a hex string (while discarding the 0x prefix before the interpretation) - #### 2. Build from Binary Data + String In Node.js (Buffer) @@ -212,7 +275,7 @@ const tx = { safe: true, data: ["0x6d02", Buffer.from("Abc"), "hello world"] } -datapay.build(tx, function(err, tx) { +datapay.build(tx, function(err, tx) { /** * res contains the generated transaction object, powered by bsv * You can check it out at https://github.com/moneybutton/bsv/blob/master/lib/transaction/transaction.js @@ -296,10 +359,9 @@ datapay.build(tx, function(err, tx) { }) ``` - #### 2. `rpc` -The `rpc` attribute is used to manually set the JSON-RPC endpoint you wish to broadcast through. +The `rpc` attribute is used to manually set the JSON-RPC endpoint you wish to broadcast through. - default: `https://api.bitindex.network` @@ -410,7 +472,6 @@ But sometimes you want more fine-grained control over which UTXOs to use for a t For this feature, datapay uses [Bitquery](https://docs.bitdb.network/docs/query_v3) as a filter to describe the UTXOs to filter out. - ``` const tx = { safe: true, @@ -470,7 +531,6 @@ datapay.build({ Notice how in addition to the `tx` attribute we've added the `pay.key` attribute. This will import the unsigned transaction and sign it. - #### 3. Importing and sending a signed transaction from exported hex string If you already have a signed transaction object, you can simply send it away without any additional steps. @@ -533,7 +593,6 @@ datapay.send({ This time since the exported transaction is already signed, no need for additional `pay.key` attriute when sending later - ``` // Build and export an unsigned transaction for later usage var exportedSignedTxHex = ""; @@ -598,7 +657,7 @@ datapay.connect().getUnspentUtxos("14xMz8rKm4L83RuZdmsHXD2jvENZbv72vR", function if (err) { console.log("Error: ", err) } else { - console.log(utxos) + console.log(utxos) } }) ``` @@ -610,7 +669,7 @@ datapay.connect('https://api.bitindex.network').getUnspentUtxos("14xMz8rKm4L83Ru if (err) { console.log("Error: ", err) } else { - console.log(utxos) + console.log(utxos) } }); ``` diff --git a/index.js b/index.js index 8e76ec5..073b9b4 100644 --- a/index.js +++ b/index.js @@ -1,154 +1,108 @@ -const mingo = require("mingo") -const _Buffer = require('buffer/') -const bitcoin = require('bsv'); -const explorer = require('bitcore-explorers'); -const defaults = { - rpc: "https://api.bitindex.network", - fee: 400, - feeb: 1.4 -} -// The end goal of 'build' is to create a hex formated transaction object -// therefore this function must end with _tx() for all cases -// and return a hex formatted string of either a tranaction or a script -var build = function(options, callback) { - let script = null; - let rpcaddr = (options.pay && options.pay.rpc) ? options.pay.rpc : defaults.rpc; - if (options.tx) { - // if tx exists, check to see if it's already been signed. - // if it's a signed transaction - // and the request is trying to override using 'data' or 'pay', - // we should throw an error - let tx = new bitcoin.Transaction(options.tx) - // transaction is already signed - if (tx.inputs.length > 0 && tx.inputs[0].script) { - if (options.pay || options.data) { - callback(new Error("the transaction is already signed and cannot be modified")) - return; - } - } - } else { - // construct script only if transaction doesn't exist - // if a 'transaction' attribute exists, the 'data' should be ignored to avoid confusion - if (options.data) { - script = _script(options) +const axios = require("axios"); +const bsv = require("bsv"); + +const callbackWrapper = func => { + return async (options, callback) => { + try { + result = await func(options); + if (callback) callback(null, result); + else return result; + } catch (err) { + if (callback) callback(err); + else throw err; } + }; +}; + +let insight; + +module.exports.connect = options => { + insight = axios.create(options); +}; + +module.exports.connect({ baseURL: "https://api.mattercloud.net/api/v3/main" }); + +module.exports.getUTXOs = async address => { + try { + const res = await insight.post("/addrs/utxo", { + addrs: address.toString() + }); + return res.data; + } catch (err) { + throw new Error(`Failed to retrieve utxo's for ${address}: ${err.message}`); } - // Instantiate pay - if (options.pay && options.pay.key) { - // key exists => create a signed transaction - let key = options.pay.key; - const privateKey = new bitcoin.PrivateKey(key); - const address = privateKey.toAddress(); - const insight = new explorer.Insight(rpcaddr) - insight.getUnspentUtxos(address, function (err, res) { - if (err) { - callback(err); - return; - } - - if (options.pay.filter && options.pay.filter.q && options.pay.filter.q.find) { - let f = new mingo.Query(options.pay.filter.q.find) - res = res.filter(function(item) { - return f.test(item) - }) - } - let tx = new bitcoin.Transaction(options.tx).from(res); - - if (script) { - tx.addOutput(new bitcoin.Transaction.Output({ script: script, satoshis: 0 })); - } - if (options.pay.to && Array.isArray(options.pay.to)) { - options.pay.to.forEach(function(receiver) { - tx.to(receiver.address, receiver.value) - }) - } - - tx.fee(defaults.fee).change(address); - let opt_pay = options.pay || {}; - let myfee = opt_pay.fee || Math.ceil(tx._estimateSize()* (opt_pay.feeb || defaults.feeb)); - tx.fee(myfee); - - //Check all the outputs for dust - for(var i=0;i0 && tx.outputs[i]._satoshis<546){ - tx.outputs.splice(i,1); - i--; - } - } - let transaction = tx.sign(privateKey); - callback(null, transaction); - }) - } else { - // key doesn't exist => create an unsigned transaction - let fee = (options.pay && options.pay.fee) ? options.pay.fee : defaults.fee; - let tx = new bitcoin.Transaction(options.tx).fee(fee); - if (script) { - tx.addOutput(new bitcoin.Transaction.Output({ script: script, satoshis: 0 })); - } - callback(null, tx) +}; + +module.exports.broadcast = async rawtx => { + try { + const res = await insight.post("/tx/send", { rawtx }); + return res.data ? res.data.txid : null; + } catch (err) { + throw new Error(`Failed to broadcast transaction: ${err.message}`); + } +}; + +module.exports.build = callbackWrapper(async ({ data, pay }) => { + const tx = new bsv.Transaction(); + + if (data && data.length) { + const script = module.exports.createDataScript(data); + tx.addOutput(new bsv.Transaction.Output({ script, satoshis: 0 })); } -} -var send = function(options, callback) { - if (!callback) { - callback = function() {}; + + if (pay) { + const { fee, feeb = 1.0, key, to = [], filter } = pay; + + if (fee) tx.fee(fee); + else tx.feePerKb(feeb * 1000); + + to.forEach(receiver => tx.to(receiver.address, receiver.value)); + + if (key) { + const privateKey = new bsv.PrivateKey(key); + const address = privateKey.toAddress(); + tx.change(address); + + let utxos = await module.exports.getUTXOs(address); + if (filter) utxos = filter(utxos); + tx.from(utxos); + + tx.sign(privateKey); + } } - build(options, function(err, tx) { - if (err) { - callback(err); + return tx; +}); + +module.exports.send = callbackWrapper(async options => { + const tx = options.tx || (await module.exports.build(options)); + return await module.exports.broadcast(tx.serialize()); +}); + +module.exports.createDataScript = data => { + if (typeof data === "string") return bsv.Script.fromHex(data); + + const s = new bsv.Script(); + + // Add OP_RETURN + s.add(bsv.Opcode.OP_FALSE); + s.add(bsv.Opcode.OP_RETURN); + + // Add data + data.forEach(item => { + if (typeof item === "object" && item.hasOwnProperty("op")) { + s.add({ opcodenum: item.op }); return; } - let rpcaddr = (options.pay && options.pay.rpc) ? options.pay.rpc : defaults.rpc; - const insight = new explorer.Insight(rpcaddr) - insight.broadcast(tx.toString(), callback) - }) -} -// compose script -var _script = function(options) { - var s = null; - if (options.data) { - if (Array.isArray(options.data)) { - s = new bitcoin.Script(); - if (options.safe) { - s.add(bitcoin.Opcode.OP_FALSE); - } - // Add op_return - s.add(bitcoin.Opcode.OP_RETURN); - options.data.forEach(function(item) { - // add push data - if (item.constructor.name === 'ArrayBuffer') { - let buffer = _Buffer.Buffer.from(item) - s.add(buffer) - } else if (item.constructor.name === 'Buffer') { - s.add(item) - } else if (typeof item === 'string') { - if (/^0x/i.test(item)) { - // ex: 0x6d02 - s.add(Buffer.from(item.slice(2), "hex")) - } else { - // ex: "hello" - s.add(Buffer.from(item)) - } - } else if (typeof item === 'object' && item.hasOwnProperty('op')) { - s.add({ opcodenum: item.op }) - } - }) - } else if (typeof options.data === 'string') { - // Exported transaction - s = bitcoin.Script.fromHex(options.data); + if (typeof item === "string" && /^0x/i.test(item)) { + // e.g. 0x6d02 + s.add(Buffer.from(item.slice(2), "hex")); + return; } - } - return s; -} -var connect = function(endpoint) { - var rpc = endpoint ? endpoint : defaults.rpc; - return new explorer.Insight(rpc); -} -module.exports = { - build: build, - send: send, - bsv: bitcoin, - connect: connect, -} + s.add(Buffer.from(item)); + }); + + return s; +}; diff --git a/package-lock.json b/package-lock.json index 095478e..b07f2d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,143 +1,136 @@ { "name": "datapay", - "version": "0.0.15", + "version": "0.0.18", "lockfileVersion": 1, "requires": true, "dependencies": { - "ajv": { - "version": "6.6.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.2.tgz", - "integrity": "sha512-FBHEW6Jf5TB9MGBgUUA9XHkTbjXYfAUjY43ACMfmdMRHniyoMHjHjzD50OK8LGDWQwp4rWEsIq5kEqq7rvIM1g==", + "@sinonjs/commons": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.1.tgz", + "integrity": "sha512-Debi3Baff1Qu1Unc3mjJ96MgpbwTn43S1+9yJ0llWygPwDNu2aaWBD6yc9y/Z8XDRNhx7U+u2UDg2OGQXkclUQ==", + "dev": true, "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" + "type-detect": "4.0.8" } }, - "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "@sinonjs/fake-timers": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.0.tgz", + "integrity": "sha512-atR1J/jRXvQAb47gfzSK8zavXy7BcpnYq21ALon0U99etu99vsir0trzIO3wpeLtW+LLVY6X7EkfVTbjGSH8Ww==", + "dev": true, "requires": { - "safer-buffer": "~2.1.0" + "@sinonjs/commons": "^1.7.0" } }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + "@sinonjs/formatio": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-5.0.1.tgz", + "integrity": "sha512-KaiQ5pBf1MpS09MuA0kp6KBQt2JUOQycqVG1NZXvzeaXe5LGFqAKueIS0bw4w0P9r7KuBSVdUk5QjXsUdu2CxQ==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1", + "@sinonjs/samsam": "^5.0.2" + } }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + "@sinonjs/samsam": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.0.2.tgz", + "integrity": "sha512-p3yrEVB5F/1wI+835n+X8llOGRgV8+jw5BHQ/cJoLBUXXZ5U8Tr5ApwPc4L4av/vjla48kVPoN0t6dykQm+Rvg==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.6.0", + "@sinonjs/formatio": "^5.0.0", + "lodash.get": "^4.4.2", + "type-detect": "^4.0.8" + } }, - "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=" + "@sinonjs/text-encoding": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", + "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", + "dev": true }, - "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + "aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", + "dev": true }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", "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==" + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "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=", + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, "requires": { - "tweetnacl": "^0.14.3" + "color-convert": "^1.9.0" } }, - "bitcore-explorers": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bitcore-explorers/-/bitcore-explorers-1.0.1.tgz", - "integrity": "sha1-0Lw0u9cSlmSh+5uklwkRtdEOlNU=", + "anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, "requires": { - "bitcore-lib": "^0.13.7", - "browser-request": "^0.3.3", - "request": "^2.51.0" + "sprintf-js": "~1.0.2" } }, - "bitcore-lib": { - "version": "0.13.19", - "resolved": "https://registry.npmjs.org/bitcore-lib/-/bitcore-lib-0.13.19.tgz", - "integrity": "sha1-SK8em9oQBnwasWJjRyta3SAA89w=", + "axios": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", "requires": { - "bn.js": "=2.0.4", - "bs58": "=2.0.0", - "buffer-compare": "=1.0.0", - "elliptic": "=3.0.3", - "inherits": "=2.0.1", - "lodash": "=3.10.1" - }, - "dependencies": { - "bn.js": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-2.0.4.tgz", - "integrity": "sha1-Igp81nf38b+pNif/QZN3b+eBlIA=" - }, - "bs58": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-2.0.0.tgz", - "integrity": "sha1-crcTvtIjoKxRi72g484/SBfznrU=" - }, - "buffer-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-compare/-/buffer-compare-1.0.0.tgz", - "integrity": "sha1-rKp6lm6Y7un64Usxw5pfFY+zxKI=" - }, - "elliptic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-3.0.3.tgz", - "integrity": "sha1-hlybQgv75VAGuflp+XoNLESWZZU=", - "requires": { - "bn.js": "^2.0.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "inherits": "^2.0.1" - }, - "dependencies": { - "brorand": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.0.5.tgz", - "integrity": "sha1-B7VMowKGq9Fxig4qgwgD79yb+gQ=" - }, - "hash.js": { - "version": "1.0.3", - "resolved": "http://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz", - "integrity": "sha1-EzL/ABVsCg/92CNgE9B7d6BFFXM=", - "requires": { - "inherits": "^2.0.1" - } - } - } - }, - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" - }, - "lodash": { - "version": "3.10.1", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=" - } + "follow-redirects": "1.5.10" } }, + "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-x": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz", + "integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "binary-extensions": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", + "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", + "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 + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -148,10 +141,20 @@ "concat-map": "0.0.1" } }, - "browser-request": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/browser-request/-/browser-request-0.3.3.tgz", - "integrity": "sha1-ns5bWsqJopkyJC4Yv5M975h2zBc=" + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "dev": true }, "browser-stdout": { "version": "1.3.1", @@ -159,32 +162,138 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", - "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", + "bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", + "dev": true, + "requires": { + "base-x": "^3.0.2" + } + }, + "bsv": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/bsv/-/bsv-1.3.0.tgz", + "integrity": "sha512-/mguDGAgpvzF6mtBFN3kuAGmoCr3ciesJCWDqvcAflvtvGsJyR0lSR4xfage7QfHWrHn/Y4iyPCshbsH6gI0jQ==", + "dev": true, + "requires": { + "aes-js": "^3.1.2", + "bn.js": "=4.11.8", + "bs58": "=4.0.1", + "clone-deep": "^4.0.1", + "elliptic": "6.4.1", + "hash.js": "^1.1.7", + "inherits": "2.0.3", + "unorm": "1.4.1" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "chokidar": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", + "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", + "dev": true, "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.1", + "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" } }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } }, - "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "clone-deep": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", + "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", + "dev": true, "requires": { - "delayed-stream": "~1.0.0" + "is-plain-object": "^2.0.4", + "kind-of": "^6.0.2", + "shallow-clone": "^3.0.0" } }, - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, "concat-map": { @@ -193,23 +302,28 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "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=" - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "requires": { - "assert-plus": "^1.0.0" + "ms": "2.0.0" } }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } }, "diff": { "version": "3.5.0", @@ -217,19 +331,55 @@ "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, - "dotenv": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.2.0.tgz", - "integrity": "sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==", + "elliptic": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", + "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", + "dev": true, + "requires": { + "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" + } + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, - "ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "es-abstract": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, "requires": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" } }, "escape-string-regexp": { @@ -238,39 +388,45 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } }, - "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=" + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + } }, - "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" + "debug": "=3.1.0" } }, "fs.realpath": { @@ -279,18 +435,29 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "requires": { - "assert-plus": "^1.0.0" - } + "fsevents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", + "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", + "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 + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -301,24 +468,28 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, "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=" - }, - "har-validator": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", - "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "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": { - "ajv": "^6.5.5", - "har-schema": "^2.0.0" + "function-bind": "^1.1.1" } }, "has-flag": { @@ -327,26 +498,38 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", "dev": true }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" } }, - "ieee754": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", - "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==" + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "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.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } }, "inflight": { "version": "1.0.6", @@ -359,69 +542,174 @@ } }, "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" - }, - "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=" + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "is-buffer": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", + "dev": true + }, + "is-callable": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", + "dev": true + }, + "is-date-object": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", + "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-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "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-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "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 + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "just-extend": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.1.0.tgz", + "integrity": "sha512-ApcjaOdVTJ7y4r08xI5wIqpvwS48Q0PBG4DJROcEkH1f8MdAiNFyFxz3xoL0LWAVwjrwPYZdVHHxhRHcx/uGLA==", + "dev": true + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" } }, - "mime-db": { - "version": "1.37.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", - "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true }, - "mime-types": { - "version": "2.1.21", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", - "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "log-symbols": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", + "integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==", + "dev": true, "requires": { - "mime-db": "~1.37.0" + "chalk": "^2.4.2" } }, - "mingo": { - "version": "2.2.8", - "resolved": "https://registry.npmjs.org/mingo/-/mingo-2.2.8.tgz", - "integrity": "sha512-61ET/PK45Jm1yWfoiYL/9KBs/+66s4ctLJeMCnKgYJlrD46oqbIVnfm5RbDyqo9Gl19mzUUi4DDvTlMzirzKVw==" + "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", @@ -434,13 +722,13 @@ }, "minimist": { "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -448,45 +736,122 @@ } }, "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.1.0.tgz", + "integrity": "sha512-MymHK8UkU0K15Q/zX7uflZgVoRWiTjy0fXE/QjKts6mowUvGxOdPhZ2qj3b0iZdUrNZlW9LAIMFHB4IW+2b3EQ==", "dev": true, "requires": { + "ansi-colors": "3.2.3", "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", + "chokidar": "3.3.0", + "debug": "3.2.6", "diff": "3.5.0", "escape-string-regexp": "1.0.5", - "glob": "7.1.2", + "find-up": "3.0.0", + "glob": "7.1.3", "growl": "1.10.5", - "he": "1.1.1", + "he": "1.2.0", + "js-yaml": "3.13.1", + "log-symbols": "3.0.0", "minimatch": "3.0.4", "mkdirp": "0.5.1", - "supports-color": "5.4.0" + "ms": "2.1.1", + "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": "13.3.0", + "yargs-parser": "13.1.1", + "yargs-unparser": "1.6.0" }, "dependencies": { "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true } } }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "nise": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/nise/-/nise-4.0.2.tgz", + "integrity": "sha512-ALDnm0pTTyeGdbg5FCpWGd58Nmp3qO8d8x+dU2Fw8lApeJTEBSjkBZZM4S8t6GpKh+czxkfM/TKxpRMroZzwOg==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0", + "@sinonjs/fake-timers": "^6.0.0", + "@sinonjs/formatio": "^5.0.1", + "@sinonjs/text-encoding": "^0.7.1", + "just-extend": "^4.0.2", + "path-to-regexp": "^1.7.0" + } + }, + "node-environment-flags": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.6.tgz", + "integrity": "sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw==", + "dev": true, + "requires": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.getownpropertydescriptors": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz", + "integrity": "sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + } }, "once": { "version": "1.4.0", @@ -497,68 +862,142 @@ "wrappy": "1" } }, + "p-limit": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz", + "integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + "path-to-regexp": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", + "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", + "dev": true, + "requires": { + "isarray": "0.0.1" + } }, - "psl": { - "version": "1.1.31", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", - "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" + "picomatch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", + "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==", + "dev": true }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" - }, - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" - }, - "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", - "requires": { - "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" + "readdirp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", + "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", + "dev": true, + "requires": { + "picomatch": "^2.0.4" } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "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==" + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", + "dev": true }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "shallow-clone": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", + "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", + "dev": true, + "requires": { + "kind-of": "^6.0.2" + } + }, + "sinon": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.0.tgz", + "integrity": "sha512-c4bREcvuK5VuEGyMW/Oim9I3Rq49Vzb0aMdxouFaA44QCFpilc5LJOugrX+mkrvikbqCimxuK+4cnHVNnLR41g==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0", + "@sinonjs/fake-timers": "^6.0.0", + "@sinonjs/formatio": "^5.0.0", + "@sinonjs/samsam": "^5.0.1", + "diff": "^4.0.2", + "nise": "^4.0.1", + "supports-color": "^7.1.0" + }, + "dependencies": { + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } }, "source-map": { "version": "0.6.1", @@ -566,59 +1005,80 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, - "sshpk": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.0.tgz", - "integrity": "sha512-Zhev35/y7hRMcID/upReIvRse+I9SVhyVre/KTJSJQWMz3C3+G+HpO7m1wK/yckEtujKZ7dS4hkVxAnmHaIGVQ==", + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, "requires": { - "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" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.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==", + "string.prototype.trimleft": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", + "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" } }, - "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "string.prototype.trimright": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", + "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", + "dev": true, "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" - }, - "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" - } + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" } }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, "requires": { - "safe-buffer": "^5.0.1" + "ansi-regex": "^3.0.0" } }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.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 }, "uglify-es": { "version": "3.3.9", @@ -638,27 +1098,73 @@ } } }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "unorm": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/unorm/-/unorm-1.4.1.tgz", + "integrity": "sha1-NkIA1fE2RsqLzURJAnEzVhR5IwA=", + "dev": true + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, "requires": { - "punycode": "^2.1.0" + "isexe": "^2.0.0" } }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" + "string-width": "^1.0.2 || 2" + } + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } } }, "wrappy": { @@ -666,6 +1172,79 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz", + "integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==", + "dev": true, + "requires": { + "flat": "^4.1.0", + "lodash": "^4.17.15", + "yargs": "^13.3.0" + } } } } diff --git a/package.json b/package.json index ba435c8..22f959b 100644 --- a/package.json +++ b/package.json @@ -18,19 +18,18 @@ "license": "MIT", "unpkg": "dist/datapay.min.js", "dependencies": { - "bitcore-explorers": "^1.0.1", - "buffer": "^5.2.1", - "mingo": "^2.2.4" + "axios": "^0.19.2" }, "peerDependencies": { - "bsv": "0.27.1" + "bsv": "^1.3.0" }, "files": [ "dist" ], "devDependencies": { - "dotenv": "^6.2.0", - "mocha": "^5.1.1", + "bsv": "^1.3.0", + "mocha": "^7.1.0", + "sinon": "^9.0.0", "uglify-es": "^3.3.9" } } diff --git a/test/test.js b/test/test.js index f1f9460..d431776 100644 --- a/test/test.js +++ b/test/test.js @@ -1,607 +1,318 @@ -require('dotenv').config() -const assert = require('assert'); -const bitcoin = require('bsv') -const datapay = require('../index'); - -// Private Key for Demo Purpose Only -const privKey = process.env.privKey - -var utxoSize; -describe('datapay', function() { - beforeEach(function(done) { - const address = new bitcoin.PrivateKey(privKey).toAddress() - datapay.connect().getUnspentUtxos(address, function(err, utxos) { - if (err) { - console.log("Error: ", err) - } else { - utxoSize = utxos.length - done() - } - }) - }) - describe('build', function() { - describe('data only', function() { - it('opcode', function(done) { - const options = { - data: [{op: 78}, "hello world"] - } - datapay.build(options, function(err, tx) { - let generated = tx.toObject() - let s = new bitcoin.Script(generated.outputs[0].script).toString() - assert(s.startsWith("OP_RETURN OP_PUSHDATA4 1818585099")) - done() - }); - }) - it('opcode 2', function(done) { - const options = { - data: ["0x6d02", "hello world", {op: 78}, "blah blah blah * 10^100"] - } - datapay.build(options, function(err, tx) { - let generated = tx.toObject() - let s = new bitcoin.Script(generated.outputs[0].script).toString() - assert(s.startsWith("OP_RETURN 2 0x6d02 11 0x68656c6c6f20776f726c64 OP_PUSHDATA4 1634492951")) - done() - }); - }) - it('push data array', function(done) { - const options = { - data: ["0x6d02", "hello world"] - } - datapay.build(options, function(err, tx) { - let generated = tx.toObject(); - // no input (since no one has signed yet) - assert.equal(generated.inputs.length, 0) - // output has one item (only OP_RETURN) - assert.equal(generated.outputs.length, 1) - // the only existing output is a script - assert(generated.outputs[0].script); - // uses the default fee of 400 - assert(generated.fee <= 400) - - done() - }); - }) - it('hex string that represents script', function(done) { - const options = { - data: "6a04366430320b68656c6c6f20776f726c64" - } - datapay.build(options, function(err, tx) { - let generated = tx.toObject(); - // no input (since no one has signed yet) - assert.equal(generated.inputs.length, 0) - // output has one item (only OP_RETURN) - assert.equal(generated.outputs.length, 1) - // the only existing output is a script - assert(generated.outputs[0].script); - // uses the default fee of 400 - assert(generated.fee <= 400) - - done() - }); - }) - it('Buffer', function(done) { - const options = { - data: [Buffer.from("abc"), "hello world"] - } - datapay.build(options, function(err, tx) { - let generated = tx.toObject(); - // no input (since no one has signed yet) - assert.equal(generated.inputs.length, 0) - // output has one item (only OP_RETURN) - assert.equal(generated.outputs.length, 1) - // the only existing output is a script - assert(generated.outputs[0].script); - // uses the default fee of 400 - assert(generated.fee <= 400) - - done() - }); - }) - }) - describe('pay only', function() { - it('to', function(done) { - const address = new bitcoin.PrivateKey(privKey).toAddress() - const options = { - pay: { - key: privKey, - to: [{ address: address, value: 100 }] +const assert = require("assert"); +const sinon = require("sinon"); +const bsv = require("bsv"); +const datapay = require("../index"); + +const sandbox = sinon.createSandbox(); + +// fake input data +const toAddress1 = "1DnFt3kHih4jkAbGYsF8wPhoisuM3vkWLN"; +const toAddress2 = "1LTLNv4SCF9pjj73t5ZEt5fYrWWadwfMFB"; +const privateKey = "Ky1WGEzN2Jn6CezPWdYMqTJzcBTJuFaMhna6wBpycg1wzVBUXcHC"; +const privateKeyRedeem = "76a914ee305aa2a75dbeff6f8f960eb1b7b16eb1d3b2df88ac"; +const utxos = [ + { + txid: "8a06f5d5449c0f68291171ad1a7cc427db9bef5abb93998b40c999f5e933eb89", + vout: 2, + amount: 0.045, + script: privateKeyRedeem + }, + { + txid: "23cad3adb933c194b57b9d8db22a977b281f7279f040c319a9552c3378a70f5a", + vout: 4, + satoshis: 10000, + scriptPubKey: privateKeyRedeem + } +]; + +describe("datapay", function() { + afterEach(function() { + sandbox.restore(); + }); + + describe("#createDataScript()", function() { + describe("with a pushdata array", function() { + it("should add an opcode", function() { + const script = datapay.createDataScript([{ op: 78 }, "hello world"]); + assert.equal( + script.toASM(), + "0 OP_RETURN OP_PUSHDATA4 68656c6c6f20776f726c64" + ); + }); + + it("should add a buffer", function() { + const script = datapay.createDataScript([ + Buffer.from("abc"), + "hello world" + ]); + + assert.equal( + script.toASM(), + "0 OP_RETURN 616263 68656c6c6f20776f726c64" + ); + }); + + it("should add a utf-8 string", function() { + const script = datapay.createDataScript(["hello world"]); + assert.equal(script.toASM(), "0 OP_RETURN 68656c6c6f20776f726c64"); + }); + + it("should add a hex string", function() { + const script = datapay.createDataScript(["0x6d02", "hello world"]); + assert.equal(script.toASM(), "0 OP_RETURN 6d02 68656c6c6f20776f726c64"); + }); + }); + + it("should build from a hex string", function() { + const script = datapay.createDataScript( + "6a04366430320b68656c6c6f20776f726c64" + ); + + assert.equal(script.toASM(), "OP_RETURN 36643032 68656c6c6f20776f726c64"); + }); + }); + + describe("#build()", function() { + describe("with data", function() { + it("should add a data output", async function() { + const options = { data: ["hello world"] }; + const tx = await datapay.build(options); + assert.equal(tx.outputs.length, 1); + assert.equal( + tx.outputs[0].script.toASM(), + "0 OP_RETURN 68656c6c6f20776f726c64" + ); + }); + }); + + describe("with callback", function() { + it("should build a transaction", function(done) { + sandbox.stub(datapay, "getUTXOs").resolves(utxos); + + const options = { pay: { key: privateKey } }; + datapay.build(options, (err, tx) => { + try { + assert(tx, "a transaction was not returned in the callback"); + done(); + } catch (err) { + done(err); } - } - datapay.build(options, function(err, tx) { - // If only 'key' is included, it will use the default values for - // rest of the pay attributes - // and make a transaction that sends money to oneself - // (since no receiver is specified) - let generated = tx.toObject(); - done() - }) - }) - it('pay.key only', function(done) { - const options = { - pay: { - key: privKey - } - } - datapay.build(options, function(err, tx) { - // If only 'key' is included, it will use the default values for - // rest of the pay attributes - // and make a transaction that sends money to oneself - // (since no receiver is specified) - let generated = tx.toObject(); - - // input length utxoSize => from the user specifiec by the private key - assert.equal(generated.inputs.length, utxoSize) - // contains a 'changeScript' - assert(generated.changeScript) - - // output length 1 => the output points to the sender by default - assert.equal(generated.outputs.length, 1) - // script is a pubkeyhashout - let s = new bitcoin.Script(generated.outputs[0].script) - assert(s.isPublicKeyHashOut()) - - // script sends the money to the same address as the sender - // specified by the private key - const address = new bitcoin.PrivateKey(privKey).toAddress() - assert.equal(address.toString(), s.toAddress().toString()) - - done() }); - }) - it('pay.fee only', function(done) { - const options = { - pay: { - fee: 100 + }); + + it("should handle getUTXOs error", function(done) { + sandbox.stub(datapay, "getUTXOs").rejects(); + + const options = { pay: { key: privateKey } }; + datapay.build(options, (err, tx) => { + try { + assert(err, "an error was not returned in the callback"); + done(); + } catch (err) { + done(err); } - } - datapay.build(options, function(err, tx) { - // if no key is included, - // empty input (since no sender) - // empty output (since nothing else is specified) - let generated = tx.toObject(); - assert.equal(generated.inputs.length, 0) - assert.equal(generated.outputs.length, 0) - assert.equal(generated.fee, 100) - done() - }) - }) - it('pay.key and pay.fee', function(done) { - const options = { - pay: { - key: privKey, - fee: 100 - } - } - datapay.build(options, function(err, tx) { - let generated = tx.toObject(); - assert.equal(generated.fee, 100) - done() - }) - }) - - /** - - pay.rpc TBD - - **/ - - }) - describe('data and pay', function() { - it('both data and pay', function(done) { - const options = { - data: ["0x6d02", "hello world"], - pay: { - key: privKey - } - } - datapay.build(options, function(err, tx) { - let generated = tx.toObject(); - - // input length 1 => from the user specifiec by the private key - assert.equal(generated.inputs.length, utxoSize) - // contains a 'changeScript' - assert(generated.changeScript) - - // must have two outputs - assert.equal(generated.outputs.length, 2) - - let s1 = new bitcoin.Script(generated.outputs[0].script) - - // the first output is OP_RETURN - assert(s1.chunks[0].opcodenum, bitcoin.Opcode.OP_RETURN) - - // the second script is a pubkeyhashout (change address) - let s2 = new bitcoin.Script(generated.outputs[1].script) - assert(s2.isPublicKeyHashOut()) - - // script sends the money to the same address as the sender - // specified by the private key - const address = new bitcoin.PrivateKey(privKey).toAddress() - assert.equal(address.toString(), s2.toAddress().toString()) - - done() - }) - }) - /* - it('pay.filter', function(done) { - const options = { - data: ["0x6d02", "hello world"], - pay: { - key: privKey, - filter: { - v: 3, - q: { - find: { - } - } - } - } - } - datapay.build(options, function(err, tx) { - let generated = tx.toObject(); - - // input length 1 => from the user specifiec by the private key - assert.equal(generated.inputs.length, 5) - // contains a 'changeScript' - assert(generated.changeScript) - - // must have two outputs - assert.equal(generated.outputs.length, 2) - - let s1 = new bitcoin.Script(generated.outputs[0].script) - - // the first output is OP_RETURN - assert(s1.chunks[0].opcodenum, bitcoin.Opcode.OP_RETURN) - - // the second script is a pubkeyhashout (change address) - let s2 = new bitcoin.Script(generated.outputs[1].script) - assert(s2.isPublicKeyHashOut()) - - // script sends the money to the same address as the sender - // specified by the private key - const address = new bitcoin.PrivateKey(privKey).toAddress() - assert.equal(address.toString(), s2.toAddress().toString()) - - done() - }) - - }) - */ - }) - describe('attach coins to data', function() { - it('paying tip to 1 user', function(done) { - // send to myself - const receiver = new bitcoin.PrivateKey(privKey).toAddress() + }); + }); + }); - const options = { - data: ["0x6d02", "hello world"], - pay: { - key: privKey, - to: [{ - address: receiver, - value: 1000 - }] - } - } - datapay.build(options, function(err, tx) { - // output has 3 items - assert.equal(tx.outputs.length, 3) - - // 1. OP_RETURN - let s1 = new bitcoin.Script(tx.outputs[0].script) - assert(s1.chunks[0].opcodenum, bitcoin.Opcode.OP_RETURN) - // 2. Manual transaction output - // the second script is a pubkeyhashout (change address) - let s2 = new bitcoin.Script(tx.outputs[1].script) - assert(s2.isPublicKeyHashOut()) - // the value sent is 1000 - assert.equal(tx.outputs[1].satoshis, 1000) - // the receiver address is the address specified in pay.to - assert.equal(s2.toAddress().toString(), bitcoin.Address(receiver).toString()) - - // 3. Change address transaction output - let s3 = new bitcoin.Script(tx.outputs[2].script) - assert(s3.isPublicKeyHashOut()) - done() - }) - }) - it('paying tip to 2 users', function(done) { - // send to myself - const receiver = new bitcoin.PrivateKey(privKey).toAddress() + describe("with async/await", function() { + it("should build a transaction", async function() { + sandbox.stub(datapay, "getUTXOs").resolves(utxos); const options = { - data: ["0x6d02", "hello world"], - pay: { - key: privKey, - to: [{ - address: receiver, - value: 1000 - }, { - address: receiver, - value: 2000 - }] - } + pay: { key: privateKey, to: [{ address: toAddress1, value: 5000 }] }, + data: ["async", "await"] + }; + const tx = await datapay.build(options); + assert(tx.inputs.length, 2); + assert(tx.outputs.length, 3); + assert(tx.isFullySigned()); + }); + + it("should handle getUTXOs error", async function() { + sandbox.stub(datapay, "getUTXOs").rejects(); + + const options = { pay: { key: privateKey } }; + await assert.rejects(async () => await datapay.build(options)); + }); + }); + + it("should send output to address", async function() { + const options = { pay: { to: [{ address: toAddress1, value: 100000 }] } }; + const tx = await datapay.build(options); + assert.equal(tx.outputs.length, 1); + assert.equal(tx.outputs[0].satoshis, 100000); + assert.equal( + tx.outputs[0].script.toHex(), + "76a9148c30a62437626c504205900ed6def906b0b0b3fd88ac" + ); + }); + + it("should add change output", async function() { + sandbox.stub(datapay, "getUTXOs").resolves(utxos); + + const options = { pay: { key: privateKey } }; + const tx = await datapay.build(options); + const changeOutput = tx.getChangeOutput(); + assert(changeOutput); + assert.equal(changeOutput.script.toHex(), privateKeyRedeem); + }); + + it("should apply fixed fee", async function() { + sandbox.stub(datapay, "getUTXOs").resolves(utxos); + + const options = { pay: { key: privateKey, fee: 500 } }; + const tx = await datapay.build(options); + assert.equal(tx.getFee(), 500); + }); + + it("should apply custom fee rate", async function() { + sandbox.stub(datapay, "getUTXOs").resolves(utxos); + + const options = { pay: { key: privateKey, feeb: 5.0 } }; + const tx = await datapay.build(options); + assert.equal(tx._feePerKb, 5000); + }); + + it("should filter utxo's", async function() { + sandbox.stub(datapay, "getUTXOs").resolves(utxos); + + const prevTxId = + "8a06f5d5449c0f68291171ad1a7cc427db9bef5abb93998b40c999f5e933eb89"; + const options = { + pay: { + key: privateKey, + filter: utxos => utxos.filter(utxo => utxo.txid === prevTxId) } - datapay.build(options, function(err, tx) { - // output has 4 items - assert.equal(tx.outputs.length, 4) - - // 1. OP_RETURN - let s1 = new bitcoin.Script(tx.outputs[0].script) - assert(s1.chunks[0].opcodenum, bitcoin.Opcode.OP_RETURN) - // 2. Manual transaction output - // the second script is a pubkeyhashout (change address) - let s2 = new bitcoin.Script(tx.outputs[1].script) - assert(s2.isPublicKeyHashOut()) - // the value sent is 1000 - assert.equal(tx.outputs[1].satoshis, 1000) - // the receiver address is the address specified in pay.to - assert.equal(s2.toAddress().toString(), bitcoin.Address(receiver).toString()) - - // 3. Manual transaction output - // the third script is a pubkeyhashout (change address) - let s3 = new bitcoin.Script(tx.outputs[2].script) - assert(s3.isPublicKeyHashOut()) - // the value sent is 1000 - assert.equal(tx.outputs[2].satoshis, 2000) - // the receiver address is the address specified in pay.to - assert.equal(s3.toAddress().toString(), bitcoin.Address(receiver).toString()) - - // 3. Change address transaction output - let s4 = new bitcoin.Script(tx.outputs[3].script) - assert(s4.isPublicKeyHashOut()) - done() - }) - }) - }) - describe('tx', function() { - describe('importing unsigned tx', function() { - it('tx only', function(done) { - // 1. build - const options = { - data: ["0x6d02", "hello world"] - } - datapay.build(options, function(err, original_tx) { - // 2. export - let exportedTx = original_tx.toString() - // exported transaction is string - assert.equal(typeof exportedTx, "string") - // 3. re-import - datapay.build({ - tx: exportedTx - }, function(err, imported_tx) { - // the imported transaction should equal the original transaction - assert.equal(imported_tx.toString(), original_tx.toString()) - done() - }) - }) - }) - it('tx + data', function(done) { - // if there's a 'tx' attribute, it should ignore 'data' to avoid confusion - const options1 = { - data: ["0x6d02", "hello world"] - } - // 1. build initial transaction - datapay.build(options1, function(err, tx1) { - let exported_tx1 = tx1.toString(); - // 2. build a new transaction using the exported transaction + new data - let options2 = { - tx: exported_tx1, - data: ["0x6d02", "bye world"] - } - datapay.build(options2, function(err, tx2) { - assert.equal(tx1.toString(), tx2.toString()) - done() - }) - }) - }) - it('tx + pay', function(done) { - // tx1 is an unsigned transaction - // and we create a signed version by adding the 'pay' attribute - const options1 = { - data: ["0x6d02", "hello world"] + }; + const tx = await datapay.build(options); + assert.equal(tx.inputs.length, 1); + assert.equal(tx.inputs[0].prevTxId.toString("hex"), prevTxId); + }); + }); + + describe("#send()", function() { + const tx = bsv + .Transaction() + .from(utxos) + .change(toAddress2) + .to(toAddress1, 5000) + .sign(privateKey); + + describe("with callback", function() { + it("should broadcast a transaction", function(done) { + const broadcastFake = sandbox.fake.resolves(tx.hash); + sandbox.replace(datapay, "broadcast", broadcastFake); + + datapay.send({ tx }, (err, txid) => { + try { + assert(broadcastFake.called, "transaction was not broadcast"); + assert.equal(txid, tx.hash); + done(); + } catch (err) { + done(err); } - // 1. build initial transaction - datapay.build(options1, function(err, tx1) { - let exported_tx1 = tx1.toString(); - // 2. build a new transaction using the exported transaction + new data - let options2 = { - tx: exported_tx1, - pay: { - key: privKey - } - } - datapay.build(options2, function(err, tx2) { - - // tx1's input should be empty - assert.equal(tx1.inputs.length, 0) - // tx2's input should now have as many as the utxoSize - assert.equal(tx2.inputs.length, utxoSize) - - // tx1's output should have one item - assert.equal(tx1.outputs.length, 1) - // and it should be an OP_RETURN - let script1 = new bitcoin.Script(tx1.outputs[0].script) - assert(script1.chunks[0].opcodenum, bitcoin.Opcode.OP_RETURN) - - // tx2's output should have two items - assert.equal(tx2.outputs.length, 2) - let script2 = [ - new bitcoin.Script(tx2.outputs[0].script), - new bitcoin.Script(tx2.outputs[1].script) - ] - // the first should be OP_RETURN - assert(script2[0].chunks[0].opcodenum, bitcoin.Opcode.OP_RETURN) - // the second script is a pubkeyhashout (change address) - assert(script2[1].isPublicKeyHashOut()) - done() - }) - }) - }) - it('tx + pay + data', function(done) { - // tx1 is an unsigned transaction - // and we create a signed version by adding the 'pay' attribute - // but this time we also try to sneak in 'data' - // the 'data' should be ignored - const options1 = { - data: ["0x6d02", "hello world"] - } - // 1. build initial transaction - datapay.build(options1, function(err, tx1) { - let exported_tx1 = tx1.toString(); - // 2. build a new transaction using the exported transaction + new data - let options2 = { - tx: exported_tx1, - data: ["0x6d02", "bye world"], // trying to sneak in 'data' - pay: { - key: privKey - } - } - datapay.build(options2, function(err, tx2) { - - // tx2's input should now have as many as the utxoSize - assert.equal(tx2.inputs.length, utxoSize) - - // tx2's output should have two items - assert.equal(tx2.outputs.length, 2) - let script2 = [ - new bitcoin.Script(tx2.outputs[0].script), - new bitcoin.Script(tx2.outputs[1].script) - ] - // the first should be OP_RETURN - assert(script2[0].chunks[0].opcodenum, bitcoin.Opcode.OP_RETURN) - // the second script is a pubkeyhashout (change address) - assert(script2[1].isPublicKeyHashOut()) - - // the script for the original OP_RETURN - // should match the new OP_RETURN script - // because the 'data' attribute was ignored - let script1 = new bitcoin.Script(tx1.outputs[0].script) - assert.equal(script1.toString(), script2[0].toString()) - done() - }) - }) - }) - }) - describe('importing signed tx', function() { - it('tx only', function(done) { - const options1 = { - data: ["0x6d02", "hello world"], - pay: { key: privKey } - } - // 1. build initial transaction - datapay.build(options1, function(err, tx1) { - let exported_tx1 = tx1.toString(); - // 2. import transaction - datapay.build({ tx: exported_tx1 }, function(err, tx2) { - // the imported transaction should have as many as the utxoSize - assert.equal(tx2.inputs.length, utxoSize) - // the input should have 'script' property - assert(tx2.inputs[0].script) - // the script should be public key hash in - let script = new bitcoin.Script(tx2.inputs[0].script) - assert(script.isPublicKeyHashIn()) - // the imported transaction's input script address should match - // the address corresponding to the originally imported private key - const address = new bitcoin.PrivateKey(privKey).toAddress() - assert.equal(address.toString(), script.toAddress().toString()) - done() - }) - }) - }) - it('tx + data', function(done) { - // the transaction has already been signed - // the data should be ignored - // Better yet, this shouldn't be used - const options1 = { - data: ["0x6d02", "hello world"], - pay: { key: privKey } + }); + }); + + it("should propagate a build error", function(done) { + sandbox.stub(datapay, "build").rejects(); + + const options = { pay: { key: privateKey } }; + datapay.send(options, (err, txid) => { + try { + assert(err, "an error was not returned in the callback"); + done(); + } catch (err) { + done(err); } - // 1. build initial transaction - datapay.build(options1, function(err, tx1) { - let exported_tx1 = tx1.toString(); - // 2. import transaction - datapay.build({ - tx: exported_tx1, - data: ["0x6d02", "bye world"] - }, function(err, tx2) { - assert(err.toString(), "the transaction is already signed and cannot be modified") - assert.equal(tx2, undefined) - done() - }) - }) - }) - it('tx+ pay', function(done) { - // the transaction has already been signed - // the pay attribute should be ignored - // and throw and error - const options1 = { - data: ["0x6d02", "hello world"], - pay: { key: privKey } + }); + }); + + it("should propagate a broadcast error", function(done) { + sandbox.stub(datapay, "getUTXOs").resolves(utxos); + sandbox.stub(datapay, "broadcast").rejects(); + + const options = { pay: { key: privateKey } }; + datapay.send(options, (err, txid) => { + try { + assert(err, "an error was not returned in the callback"); + done(); + } catch (err) { + done(err); } - // 1. build initial transaction - datapay.build(options1, function(err, tx1) { - let exported_tx1 = tx1.toString(); - // 2. import transaction - // But this time, we're updating the key attribute. - // This should re-sign the transaction - datapay.build({ - tx: exported_tx1, - pay: { - key: privKey - } - }, function(err, tx2) { - assert(err.toString(), "the transaction is already signed and cannot be modified") - assert.equal(tx2, undefined) - done() - }) - }) - }) - it('tx + pay + data', function(done) { - const options1 = { - data: ["0x6d02", "hello world"], - pay: { key: privKey } + }); + }); + + it("should propagate a serialization error", function(done) { + // sending an unsigned transaction + const tx = bsv + .Transaction() + .from(utxos) + .change(toAddress1); + + datapay.send({ tx }, (err, txid) => { + try { + assert(err, "an error was not returned in the callback"); + done(); + } catch (err) { + done(err); } - // 1. build initial transaction - datapay.build(options1, function(err, tx1) { - let exported_tx1 = tx1.toString(); - // 2. import transaction - // But this time, we're updating the key attribute. - // This should re-sign the transaction - datapay.build({ - tx: exported_tx1, - data: ["0x6d02", "bye world"], - pay: { - key: privKey - } - }, function(err, tx2) { - assert(err.toString(), "the transaction is already signed and cannot be modified") - assert.equal(tx2, undefined) - done() - }) - }) - }) - }) - }) - }) - describe('advanced', function() { - describe('bitcoin', function() { - it('exposes bitcoin', function() { - assert(datapay.bsv.Networks) - assert(datapay.bsv.Opcode) - }) - }) - describe('connect', function() { - it('default', function() { - var insight = datapay.connect(); - assert.equal(insight.constructor.name, "Insight") - assert.equal(insight.url, 'https://api.bitindex.network') - }) - it('connect with url', function() { - var insight = datapay.connect('https://api.bitindex.network'); - assert.equal(insight.constructor.name, "Insight") - assert.equal(insight.url, 'https://api.bitindex.network') - }) - }) - }) -}) + }); + }); + }); + + describe("with async/await", function() { + it("should broadcast a transaction", async function() { + const broadcastFake = sandbox.fake.resolves(tx.hash); + sandbox.replace(datapay, "broadcast", broadcastFake); + + const txid = await datapay.send({ tx }); + assert(broadcastFake.called, "transaction was not broadcast"); + assert.equal(txid, tx.hash); + }); + + it("should propagate a build error", async function() { + sandbox.stub(datapay, "build").rejects(); + + const options = { pay: { key: privateKey } }; + assert.rejects(datapay.send(options)); + }); + + it("should propagate a broadcast error", async function() { + sandbox.stub(datapay, "getUTXOs").resolves(utxos); + sandbox.stub(datapay, "broadcast").rejects(); + + const options = { pay: { key: privateKey } }; + assert.rejects(datapay.send(options)); + }); + + it("should propagate a serialization error", async function() { + // sending an unsigned transaction + const tx = bsv + .Transaction() + .from(utxos) + .change(toAddress1); + + assert.rejects(datapay.send({ tx })); + }); + }); + + it("should build a transaction if not supplied", async function() { + const broadcastFake = sandbox.fake.resolves("faketxid"); + const buildFake = sandbox.fake.resolves(tx); + sandbox.replace(datapay, "broadcast", broadcastFake); + sandbox.replace(datapay, "build", buildFake); + sandbox.stub(datapay, "getUTXOs").resolves(utxos); + + const options = { + pay: { key: privateKey, to: [{ address: toAddress1, value: 5000 }] } + }; + const txid = await datapay.send(options); + + assert.equal(txid, "faketxid", "transaction was not broadcast"); + assert(buildFake.calledWith(options)); + assert(broadcastFake.calledWith(tx.serialize())); + }); + }); +});