From 4724c6aad669375020a85485ad921afa623eb133 Mon Sep 17 00:00:00 2001 From: Kevin Davis Date: Fri, 19 Oct 2018 16:54:53 -0400 Subject: [PATCH 1/3] Use javascript files for build --- .gitignore | 5 +- package-lock.json | 29 +++--- package.json | 12 +-- src/extensions/express.d.ts | 3 + src/extensions/express.js | 28 ++++++ src/extensions/express.js.map | 1 + src/index.d.ts | 19 ++++ src/index.js | 115 ++++++++++++++++++++++ src/index.js.map | 1 + src/index.ts | 176 ---------------------------------- src/lib/invoice.d.ts | 53 ++++++++++ src/lib/invoice.js | 144 ++++++++++++++++++++++++++++ src/lib/invoice.js.map | 1 + src/lib/plugin.d.ts | 19 ++++ src/lib/plugin.js | 3 + src/lib/plugin.js.map | 1 + src/lib/promise.d.ts | 9 ++ src/lib/promise.js | 21 ++++ src/lib/promise.js.map | 1 + src/lib/receipt.d.ts | 13 +++ src/lib/receipt.js | 3 + src/lib/receipt.js.map | 1 + src/lib/spsp.d.ts | 29 ++++++ src/lib/spsp.js | 101 +++++++++++++++++++ src/lib/spsp.js.map | 1 + 25 files changed, 592 insertions(+), 197 deletions(-) create mode 100644 src/extensions/express.d.ts create mode 100644 src/extensions/express.js create mode 100644 src/extensions/express.js.map create mode 100644 src/index.d.ts create mode 100644 src/index.js create mode 100644 src/index.js.map delete mode 100644 src/index.ts create mode 100644 src/lib/invoice.d.ts create mode 100644 src/lib/invoice.js create mode 100644 src/lib/invoice.js.map create mode 100644 src/lib/plugin.d.ts create mode 100644 src/lib/plugin.js create mode 100644 src/lib/plugin.js.map create mode 100644 src/lib/promise.d.ts create mode 100644 src/lib/promise.js create mode 100644 src/lib/promise.js.map create mode 100644 src/lib/receipt.d.ts create mode 100644 src/lib/receipt.js create mode 100644 src/lib/receipt.js.map create mode 100644 src/lib/spsp.d.ts create mode 100644 src/lib/spsp.js create mode 100644 src/lib/spsp.js.map diff --git a/.gitignore b/.gitignore index a4f43e2..097b26e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ /node_modules/ /.nyc_output/ /coverage/ -**/*.js -**/*.js.map -**/*.d.ts +src/*.ts +!*.d.ts !example.js !typedoc.js !scripts/* diff --git a/package-lock.json b/package-lock.json index 8cff45e..033086b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -985,6 +985,18 @@ "git-branch": "^0.3.0", "node-fetch": "^1.6.3", "rimraf": "^2.5.4" + }, + "dependencies": { + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "dev": true, + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + } } }, "flat-cache": { @@ -1613,14 +1625,9 @@ "dev": true }, "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "dev": true, - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz", + "integrity": "sha512-OayFWziIxiHY8bCUyLX6sTpDH8Jsbp4FfYd1j1f7vZyfgkcOnAyM4oQR16f8a0s7Gl/viMGRey8eScYk4V4EZA==" }, "node-version": { "version": "1.2.0", @@ -2261,9 +2268,9 @@ "dev": true }, "typescript": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.3.tgz", - "integrity": "sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.1.tgz", + "integrity": "sha512-Veu0w4dTc/9wlWNf2jeRInNodKlcdLgemvPsrNpfu5Pq39sgfFjvIIgTsvUHCoLBnMhPoUA+tFxsXjU6VexVRQ==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index 2d6334f..32bf344 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,6 @@ "description": "ILP client library for sending and receiving payments", "main": "src/index.js", "scripts": { - "postinstall": "npm run build", "build": "tsc --project .", "lint": "tslint --project .", "lint:fix": "tslint --fix --project .", @@ -42,7 +41,8 @@ "ilp-packet": "^3.0.0", "ilp-plugin-btp": "^1.2.1", "ilp-protocol-ildcp": "^2.0.0", - "ilp-protocol-stream": "^1.8.0" + "ilp-protocol-stream": "^1.8.0", + "node-fetch": "^2.2.0" }, "devDependencies": { "chai": "^4.1.2", @@ -57,7 +57,7 @@ "mocha": "^5.2.0", "tslint": "^5.11.0", "tslint-config-standard": "^7.1.0", - "typescript": "^3.0.3" + "typescript": "^3.1.1" }, "config": { "five-bells-integration-test-loader": { @@ -72,10 +72,8 @@ "functions": 80, "branches": 80, "include": [ - "src/**/*.js" - ], - "exclude": [ - "test/**/*.js" + "src/**/*.js", + "src/**/*/d.ts" ], "reporter": [ "lcov", diff --git a/src/extensions/express.d.ts b/src/extensions/express.d.ts new file mode 100644 index 0000000..445b8b2 --- /dev/null +++ b/src/extensions/express.d.ts @@ -0,0 +1,3 @@ +import { JsonInvoice, PluginApi } from '..'; +import { RequestHandler } from 'express'; +export declare function createMiddleware(responseTemplate?: JsonInvoice, plugin?: PluginApi.PluginV2): Promise; diff --git a/src/extensions/express.js b/src/extensions/express.js new file mode 100644 index 0000000..4f47d51 --- /dev/null +++ b/src/extensions/express.js @@ -0,0 +1,28 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const __1 = require(".."); +const invoice_1 = require("../lib/invoice"); +function createMiddleware(responseTemplate, plugin = __1.createPlugin()) { + return __awaiter(this, void 0, void 0, function* () { + const server = yield __1.STREAM.createServer({ plugin }); + return (req, rsp) => { + const reference = req.query.reference || undefined; + const payee = (req.query.amount && !isNaN(+req.query.amount)) + ? new __1.InvoiceReceiver(+req.query.amount, reference, server) + : server.generateAddressAndSecret(reference); + const jsonPayee = invoice_1.serializePayee(payee); + rsp.set('Content-Type', __1.SPSP.CONTENT_TYPE); + rsp.send(Object.assign({}, responseTemplate, jsonPayee)); + }; + }); +} +exports.createMiddleware = createMiddleware; +//# sourceMappingURL=express.js.map \ No newline at end of file diff --git a/src/extensions/express.js.map b/src/extensions/express.js.map new file mode 100644 index 0000000..80fb715 --- /dev/null +++ b/src/extensions/express.js.map @@ -0,0 +1 @@ +{"version":3,"file":"express.js","sourceRoot":"","sources":["express.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,0BAAiG;AAEjG,4CAA+C;AA8B/C,SAAsB,gBAAgB,CACpC,gBAA8B,EAC9B,SAA6B,gBAAY,EAAE;;QAE3C,MAAM,MAAM,GAAG,MAAM,UAAM,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAEpD,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAElB,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,SAAS,CAAA;YAElD,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBAC3D,CAAC,CAAC,IAAI,mBAAe,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC;gBAC3D,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAA;YAE9C,MAAM,SAAS,GAAG,wBAAc,CAAC,KAAK,CAAC,CAAA;YAEvC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,QAAI,CAAC,YAAY,CAAC,CAAA;YAC1C,GAAG,CAAC,IAAI,mBACH,gBAAgB,EAChB,SAAS,EACZ,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CAAA;AAtBD,4CAsBC","sourcesContent":["import { createPlugin, JsonInvoice, PluginApi, STREAM, SPSP, receive, InvoiceReceiver } from '..'\nimport { RequestHandler } from 'express'\nimport { serializePayee } from '../lib/invoice'\n\n/**\n * Get a simple middleware function that will return an SPSP response to any request.\n *\n * The function creates a STREAM server using the provided plugin and each time the middleware is called it\n * generates a new address and secret and adds these to the default response.\n *\n * If the middleware is called with a `receiveAmount` then the balance property is set.\n *\n * The `destination_account` and `shared_secret` should not be set on the\n * `defaultResponse` as these will be overwritten.\n *\n * Example: To use with express\n *\n * ```js\n * const ilp = require('ilp')\n * const app = require('express')()\n * ilp.createMiddleware({receiver_info:{name: 'Bob Smith'}}).then(spsp => {\n * app.get('/.well-known/pay', (req, resp) => {\n * const {contentType, body} = spsp()\n * resp.set('Content-Type', contentType)\n * resp.send(body)\n * })\n * app.listen(3000)\n * })\n * ```\n * @param {*} responseTemplate The object that will be returned in the SPSP response.\n * @param {*} plugin The plugin to use to receive payments\n */\nexport async function createMiddleware (\n responseTemplate?: JsonInvoice,\n plugin: PluginApi.PluginV2 = createPlugin()): Promise {\n\n const server = await STREAM.createServer({ plugin })\n\n return (req, rsp) => {\n\n const reference = req.query.reference || undefined\n\n const payee = (req.query.amount && !isNaN(+req.query.amount))\n ? new InvoiceReceiver(+req.query.amount, reference, server)\n : server.generateAddressAndSecret(reference)\n\n const jsonPayee = serializePayee(payee)\n\n rsp.set('Content-Type', SPSP.CONTENT_TYPE)\n rsp.send({\n ...responseTemplate,\n ...jsonPayee\n })\n }\n}\n"]} \ No newline at end of file diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..6ffa03d --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,19 @@ +import BigNumber from 'bignumber.js'; +import * as ILDCP from 'ilp-protocol-ildcp'; +import * as SPSP from './lib/spsp'; +import * as STREAM from 'ilp-protocol-stream'; +import * as express from './extensions/express'; +import { JsonInvoice, InvoiceReceiver, Invoice } from './lib/invoice'; +import * as PluginApi from './lib/plugin'; +import { Receipt } from './lib/receipt'; +declare const createLogger: any; +export declare const DEFAULT_PLUGIN_MODULE = "ilp-plugin-btp"; +declare function createPlugin(pluginOptions?: any, pluginModuleName?: string): PluginApi.PluginV2; +declare function fetchConfig(plugin: PluginApi.PluginV2): Promise; +declare function receive(amount: BigNumber.Value, reference: string, pluginOrServer?: PluginApi.PluginV2 | STREAM.Server): Promise; +declare type PaymentPointerAndAmount = { + amount: BigNumber.Value; + paymentPointer: string; +}; +declare function pay(payee: PaymentPointerAndAmount | Invoice, plugin?: PluginApi.PluginV2): Promise; +export { ILDCP, STREAM, SPSP, PluginApi, express, InvoiceReceiver, JsonInvoice, Receipt, createLogger, createPlugin, fetchConfig, receive, pay }; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..e3a1891 --- /dev/null +++ b/src/index.js @@ -0,0 +1,115 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const bignumber_js_1 = require("bignumber.js"); +const crypto = require("crypto"); +const ILDCP = require("ilp-protocol-ildcp"); +exports.ILDCP = ILDCP; +const SPSP = require("./lib/spsp"); +exports.SPSP = SPSP; +const STREAM = require("ilp-protocol-stream"); +exports.STREAM = STREAM; +const express = require("./extensions/express"); +exports.express = express; +const invoice_1 = require("./lib/invoice"); +exports.InvoiceReceiver = invoice_1.InvoiceReceiver; +const PluginApi = require("./lib/plugin"); +exports.PluginApi = PluginApi; +const createLogger = require('ilp-logger'); +exports.createLogger = createLogger; +const log = createLogger('ilp'); +exports.DEFAULT_PLUGIN_MODULE = 'ilp-plugin-btp'; +function createPlugin(pluginOptions, pluginModuleName = exports.DEFAULT_PLUGIN_MODULE) { + const envModuleName = process.env.ILP_PLUGIN || exports.DEFAULT_PLUGIN_MODULE; + const envOptions = process.env.ILP_PLUGIN_OPTIONS || process.env.ILP_CREDENTIALS; + const moduleName = pluginModuleName || envModuleName; + let options = envOptions ? JSON.parse(envOptions) : {}; + if (process.env.ILP_CREDENTIALS && !process.env.ILP_PLUGIN_OPTIONS) { + log.warn(`Loading options from environment var ILP_CREDENTIALS is deprecated, use ILP_PLUGIN_OPTIONS instead.`); + } + if (moduleName === 'ilp-plugin-btp') { + const name = (pluginOptions && pluginOptions.name) || ''; + if (name) { + log.warn(`'pluginOptions.name' is deprecated. ` + + `Please provide the correct options for the plugin. ` + + `Example: '{ "server" : "btp+ws://:@localhost:7768" }'`); + } + else { + if (pluginOptions) { + options = pluginOptions; + } + } + if (Object.keys(options).length === 0) { + options.server = `btp+ws://${name}:${crypto.randomBytes(16).toString('hex')}@localhost:7768`; + } + } + else { + options = pluginOptions; + } + const Plugin = require(moduleName); + return new Plugin(options); +} +exports.createPlugin = createPlugin; +function fetchConfig(plugin) { + return __awaiter(this, void 0, void 0, function* () { + if (!plugin.isConnected) { + throw Error('Plugin must be connected to get config.'); + } + return ILDCP.fetch(plugin.sendData.bind(plugin)); + }); +} +exports.fetchConfig = fetchConfig; +function receive(amount, reference, pluginOrServer = createPlugin()) { + return __awaiter(this, void 0, void 0, function* () { + const server = (pluginOrServer instanceof STREAM.Server) + ? pluginOrServer + : yield STREAM.createServer({ plugin: pluginOrServer }); + return new invoice_1.InvoiceReceiver(amount, reference, server); + }); +} +exports.receive = receive; +function pay(payee, plugin = createPlugin()) { + return __awaiter(this, void 0, void 0, function* () { + const paymentPointerReceiver = payee; + if (paymentPointerReceiver.paymentPointer) { + return SPSP.pay(plugin, { + receiver: paymentPointerReceiver.paymentPointer, + sourceAmount: paymentPointerReceiver.amount + }); + } + else { + const { destinationAccount, sharedSecret, amount } = payee; + const connection = yield STREAM.createConnection({ + destinationAccount, + plugin, + sharedSecret + }); + const stream = connection.createStream(); + yield stream.sendTotal(amount); + yield connection.end(); + return { + sourceAccount: connection.sourceAccount, + destinationAccount: destinationAccount, + sent: { + amount: new bignumber_js_1.default(connection.totalSent), + assetCode: connection.sourceAssetCode, + assetScale: connection.sourceAssetScale + }, + received: { + amount: new bignumber_js_1.default(connection.totalDelivered), + assetCode: connection.destinationAssetCode, + assetScale: connection.destinationAssetScale + } + }; + } + }); +} +exports.pay = pay; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/index.js.map b/src/index.js.map new file mode 100644 index 0000000..6321b26 --- /dev/null +++ b/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,+CAAoC;AACpC,iCAAgC;AAChC,4CAA2C;AAgKzC,sBAAK;AA/JP,mCAAkC;AAiKhC,oBAAI;AAhKN,8CAA6C;AA+J3C,wBAAM;AA9JR,gDAA+C;AAiK7C,0BAAO;AAhKT,2CAAqE;AAiKnE,0BAjKoB,yBAAe,CAiKpB;AAhKjB,0CAAyC;AA8JvC,8BAAS;AA5JX,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAiKxC,oCAAY;AAhKd,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAA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AAC,SAAS,CAAC,MAAM,CAAC,CAAA;YAC9B,MAAM,UAAU,CAAC,GAAG,EAAE,CAAA;YACtB,OAAO;gBACL,aAAa,EAAE,UAAU,CAAC,aAAa;gBACvC,kBAAkB,EAAE,kBAAkB;gBACtC,IAAI,EAAE;oBACJ,MAAM,EAAE,IAAI,sBAAS,CAAC,UAAU,CAAC,SAAS,CAAC;oBAC3C,SAAS,EAAE,UAAU,CAAC,eAAe;oBACrC,UAAU,EAAE,UAAU,CAAC,gBAAgB;iBACxC;gBACD,QAAQ,EAAE;oBACR,MAAM,EAAE,IAAI,sBAAS,CAAC,UAAU,CAAC,cAAc,CAAC;oBAChD,SAAS,EAAE,UAAU,CAAC,oBAAoB;oBAC1C,UAAU,EAAE,UAAU,CAAC,qBAAqB;iBAC7C;aACF,CAAA;SACF;IACH,CAAC;CAAA;AAeC,kBAAG","sourcesContent":["import BigNumber from 'bignumber.js'\nimport * as crypto from 'crypto'\nimport * as ILDCP from 'ilp-protocol-ildcp'\nimport * as SPSP from './lib/spsp'\nimport * as STREAM from 'ilp-protocol-stream'\nimport * as express from './extensions/express'\nimport { JsonInvoice, InvoiceReceiver, Invoice } from './lib/invoice'\nimport * as PluginApi from './lib/plugin'\nimport { Receipt } from './lib/receipt'\nconst createLogger = require('ilp-logger')\nconst log = createLogger('ilp')\n\nexport const DEFAULT_PLUGIN_MODULE = 'ilp-plugin-btp'\n\n/**\n * Create an instance of an ILP plugin\n *\n * This functions loads an instance of an ILP plugin.\n *\n * The constructor options and module name can be passed to the function as parameters.\n * If no parameters are provided then it willattempt to find the config in environment variables.\n * If these are not found it will load a plugin connected to a local moneyd instance on port 7768.\n *\n * The Environment variables that can be set are:\n * - ILP_PLUGIN : The name/path of the plugin module\n * - ILP_PLUGIN_OPTIONS : The options passed to the constructor, serialized as a JSON object.\n *\n * This function replaces the module 'ilp-plugin' which has been deprecated.\n *\n * Example 1: Explicit config\n *\n * ```js\n * const plugin = createPlugin({ \"server\" : \"btp+ws://myname:0a0cfd180fb5a5d32ebdf5344ce9c076@localhost:7768\" })\n * ```\n *\n * Example 2: Config from env\n *\n * ```sh\n * $ ILP_PLUGIN=\"ilp-plugin-btp\" \\\n * ILP_PLUGIN_OPTIONS=\"{\\\"server\\\":\\\"btp+ws://myname:0a0cfd180fb5a5d32ebdf5344ce9c076@localhost:7768\\\"}\" \\\n * node app.js\n * ```\n *\n * Where `app.js` has the following:\n *\n * ```js\n * const plugin = createPlugin()\n * ```\n * @param {*} pluginOptions The options passed to the plugin constructor\n * @param {*} pluginModuleName The module name of the plugin, defaults to `ilp.DEFAULT_PLUGIN_MODULE`\n */\nfunction createPlugin (pluginOptions?: any, pluginModuleName: string = DEFAULT_PLUGIN_MODULE): PluginApi.PluginV2 {\n const envModuleName = process.env.ILP_PLUGIN || DEFAULT_PLUGIN_MODULE\n const envOptions = process.env.ILP_PLUGIN_OPTIONS || process.env.ILP_CREDENTIALS\n\n const moduleName = pluginModuleName || envModuleName\n let options = envOptions ? JSON.parse(envOptions) : {}\n\n // TODO: Deprecated behaviour can be removed in future\n if (process.env.ILP_CREDENTIALS && !process.env.ILP_PLUGIN_OPTIONS) {\n log.warn(`Loading options from environment var ILP_CREDENTIALS is deprecated, use ILP_PLUGIN_OPTIONS instead.`)\n }\n\n // Replicate behaviour of 'ilp-module' for backwards compatability\n // TODO: Deprecated behaviour can be removed in future\n if (moduleName === 'ilp-plugin-btp') {\n const name = (pluginOptions && pluginOptions.name) || ''\n if (name) {\n log.warn(`'pluginOptions.name' is deprecated. ` +\n `Please provide the correct options for the plugin. ` +\n `Example: '{ \"server\" : \"btp+ws://:@localhost:7768\" }'`)\n } else {\n if (pluginOptions) {\n options = pluginOptions\n }\n }\n if (Object.keys(options).length === 0) {\n options.server = `btp+ws://${name}:${crypto.randomBytes(16).toString('hex')}@localhost:7768`\n }\n } else {\n options = pluginOptions\n }\n\n const Plugin = require(moduleName)\n return new Plugin(options) as PluginApi.PluginV2\n}\n\n/**\n * Get the dynamic configuration provided for a plugin from the upstream server\n *\n * @param plugin The plugin used to connect to the upstream service\n */\nasync function fetchConfig (plugin: PluginApi.PluginV2): Promise {\n if (!plugin.isConnected) {\n throw Error('Plugin must be connected to get config.')\n }\n return ILDCP.fetch(plugin.sendData.bind(plugin))\n}\n\n/**\n * Create a new `Invoice` that is paid when a specific amount is received.\n *\n * This will create or use a STREAM Server to generate an ILP Address and secret for the sender to use.\n * These are returned as properties of the `Invoice`.\n *\n * Calling `receivePayment()` on the invoice returns a promise that will resolve with the actual amount received,\n * or reject if it times out.\n *\n * @param {*} amount The amount to receive\n * @param {*} reference The payment reference\n * @param {*} pluginOrServer The plugin to use to receive payments or an existing STREAM server to use\n */\nasync function receive (amount: BigNumber.Value, reference: string, pluginOrServer: PluginApi.PluginV2 | STREAM.Server = createPlugin()) {\n\n const server = (pluginOrServer instanceof STREAM.Server)\n ? pluginOrServer\n : await STREAM.createServer({ plugin : pluginOrServer })\n\n return new InvoiceReceiver(amount, reference, server)\n}\n\ntype PaymentPointerAndAmount = { amount: BigNumber.Value, paymentPointer: string }\n\n/**\n */\nasync function pay (payee: PaymentPointerAndAmount | Invoice, plugin: PluginApi.PluginV2 = createPlugin()): Promise {\n\n const paymentPointerReceiver = payee as PaymentPointerAndAmount\n if (paymentPointerReceiver.paymentPointer) {\n return SPSP.pay(plugin, {\n receiver: paymentPointerReceiver.paymentPointer,\n sourceAmount: paymentPointerReceiver.amount\n })\n } else {\n const { destinationAccount, sharedSecret, amount } = payee as Invoice\n const connection = await STREAM.createConnection({\n destinationAccount,\n plugin,\n sharedSecret\n })\n\n const stream = connection.createStream()\n await stream.sendTotal(amount)\n await connection.end()\n return {\n sourceAccount: connection.sourceAccount,\n destinationAccount: destinationAccount,\n sent: {\n amount: new BigNumber(connection.totalSent),\n assetCode: connection.sourceAssetCode,\n assetScale: connection.sourceAssetScale\n },\n received: {\n amount: new BigNumber(connection.totalDelivered),\n assetCode: connection.destinationAssetCode,\n assetScale: connection.destinationAssetScale\n }\n }\n }\n}\n\nexport {\n ILDCP, // ILDCP Protocol module\n STREAM, // STREAM Protocol module\n SPSP, // SPSP Protocol module\n PluginApi, // Plugin API types\n express, // express extensions\n InvoiceReceiver, // a receiver invoice\n JsonInvoice, // JSON serialized invoice (used in SPSP response)\n Receipt, // a receipt with the details of a completed payment\n createLogger, // utility logging function\n createPlugin, // utility plugin initializer\n fetchConfig, // Use ILDCP to get the config for a plugin\n receive, // receive a payment (creates an invoice)\n pay // make a payment\n}\n"]} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 7b6213d..0000000 --- a/src/index.ts +++ /dev/null @@ -1,176 +0,0 @@ -import BigNumber from 'bignumber.js' -import * as crypto from 'crypto' -import * as ILDCP from 'ilp-protocol-ildcp' -import * as SPSP from './lib/spsp' -import * as STREAM from 'ilp-protocol-stream' -import * as express from './extensions/express' -import { JsonInvoice, InvoiceReceiver, Invoice } from './lib/invoice' -import * as PluginApi from './lib/plugin' -import { Receipt } from './lib/receipt' -const createLogger = require('ilp-logger') -const log = createLogger('ilp') - -export const DEFAULT_PLUGIN_MODULE = 'ilp-plugin-btp' - -/** - * Create an instance of an ILP plugin - * - * This functions loads an instance of an ILP plugin. - * - * The constructor options and module name can be passed to the function as parameters. - * If no parameters are provided then it willattempt to find the config in environment variables. - * If these are not found it will load a plugin connected to a local moneyd instance on port 7768. - * - * The Environment variables that can be set are: - * - ILP_PLUGIN : The name/path of the plugin module - * - ILP_PLUGIN_OPTIONS : The options passed to the constructor, serialized as a JSON object. - * - * This function replaces the module 'ilp-plugin' which has been deprecated. - * - * Example 1: Explicit config - * - * ```js - * const plugin = createPlugin({ "server" : "btp+ws://myname:0a0cfd180fb5a5d32ebdf5344ce9c076@localhost:7768" }) - * ``` - * - * Example 2: Config from env - * - * ```sh - * $ ILP_PLUGIN="ilp-plugin-btp" \ - * ILP_PLUGIN_OPTIONS="{\"server\":\"btp+ws://myname:0a0cfd180fb5a5d32ebdf5344ce9c076@localhost:7768\"}" \ - * node app.js - * ``` - * - * Where `app.js` has the following: - * - * ```js - * const plugin = createPlugin() - * ``` - * @param {*} pluginOptions The options passed to the plugin constructor - * @param {*} pluginModuleName The module name of the plugin, defaults to `ilp.DEFAULT_PLUGIN_MODULE` - */ -function createPlugin (pluginOptions?: any, pluginModuleName: string = DEFAULT_PLUGIN_MODULE): PluginApi.PluginV2 { - const envModuleName = process.env.ILP_PLUGIN || DEFAULT_PLUGIN_MODULE - const envOptions = process.env.ILP_PLUGIN_OPTIONS || process.env.ILP_CREDENTIALS - - const moduleName = pluginModuleName || envModuleName - let options = envOptions ? JSON.parse(envOptions) : {} - - // TODO: Deprecated behaviour can be removed in future - if (process.env.ILP_CREDENTIALS && !process.env.ILP_PLUGIN_OPTIONS) { - log.warn(`Loading options from environment var ILP_CREDENTIALS is deprecated, use ILP_PLUGIN_OPTIONS instead.`) - } - - // Replicate behaviour of 'ilp-module' for backwards compatability - // TODO: Deprecated behaviour can be removed in future - if (moduleName === 'ilp-plugin-btp') { - const name = (pluginOptions && pluginOptions.name) || '' - if (name) { - log.warn(`'pluginOptions.name' is deprecated. ` + - `Please provide the correct options for the plugin. ` + - `Example: '{ "server" : "btp+ws://:@localhost:7768" }'`) - } else { - if (pluginOptions) { - options = pluginOptions - } - } - if (Object.keys(options).length === 0) { - options.server = `btp+ws://${name}:${crypto.randomBytes(16).toString('hex')}@localhost:7768` - } - } else { - options = pluginOptions - } - - const Plugin = require(moduleName) - return new Plugin(options) as PluginApi.PluginV2 -} - -/** - * Get the dynamic configuration provided for a plugin from the upstream server - * - * @param plugin The plugin used to connect to the upstream service - */ -async function fetchConfig (plugin: PluginApi.PluginV2): Promise { - if (!plugin.isConnected) { - throw Error('Plugin must be connected to get config.') - } - return ILDCP.fetch(plugin.sendData.bind(plugin)) -} - -/** - * Create a new `Invoice` that is paid when a specific amount is received. - * - * This will create or use a STREAM Server to generate an ILP Address and secret for the sender to use. - * These are returned as properties of the `Invoice`. - * - * Calling `receivePayment()` on the invoice returns a promise that will resolve with the actual amount received, - * or reject if it times out. - * - * @param {*} amount The amount to receive - * @param {*} reference The payment reference - * @param {*} pluginOrServer The plugin to use to receive payments or an existing STREAM server to use - */ -async function receive (amount: BigNumber.Value, reference: string, pluginOrServer: PluginApi.PluginV2 | STREAM.Server = createPlugin()) { - - const server = (pluginOrServer instanceof STREAM.Server) - ? pluginOrServer - : await STREAM.createServer({ plugin : pluginOrServer }) - - return new InvoiceReceiver(amount, reference, server) -} - -type PaymentPointerAndAmount = { amount: BigNumber.Value, paymentPointer: string } - -/** - */ -async function pay (payee: PaymentPointerAndAmount | Invoice, plugin: PluginApi.PluginV2 = createPlugin()): Promise { - - const paymentPointerReceiver = payee as PaymentPointerAndAmount - if (paymentPointerReceiver.paymentPointer) { - return SPSP.pay(plugin, { - receiver: paymentPointerReceiver.paymentPointer, - sourceAmount: paymentPointerReceiver.amount - }) - } else { - const { destinationAccount, sharedSecret, amount } = payee as Invoice - const connection = await STREAM.createConnection({ - destinationAccount, - plugin, - sharedSecret - }) - - const stream = connection.createStream() - await stream.sendTotal(amount) - await connection.end() - return { - sourceAccount: connection.sourceAccount, - destinationAccount: destinationAccount, - sent: { - amount: new BigNumber(connection.totalSent), - assetCode: connection.sourceAssetCode, - assetScale: connection.sourceAssetScale - }, - received: { - amount: new BigNumber(connection.totalDelivered), - assetCode: connection.destinationAssetCode, - assetScale: connection.destinationAssetScale - } - } - } -} - -export { - ILDCP, // ILDCP Protocol module - STREAM, // STREAM Protocol module - SPSP, // SPSP Protocol module - PluginApi, // Plugin API types - express, // express extensions - InvoiceReceiver, // a receiver invoice - JsonInvoice, // JSON serialized invoice (used in SPSP response) - Receipt, // a receipt with the details of a completed payment - createLogger, // utility logging function - createPlugin, // utility plugin initializer - fetchConfig, // Use ILDCP to get the config for a plugin - receive, // receive a payment (creates an invoice) - pay // make a payment -} diff --git a/src/lib/invoice.d.ts b/src/lib/invoice.d.ts new file mode 100644 index 0000000..d3397c3 --- /dev/null +++ b/src/lib/invoice.d.ts @@ -0,0 +1,53 @@ +/// +import BigNumber from 'bignumber.js'; +import { STREAM, Receipt } from '..'; +export interface JsonInvoice { + destination_account: string; + shared_secret: string; + balance?: { + maximum: string; + current: string; + }; + asset_info?: { + code: string; + scale: number; + }; + receiver_info?: { + name?: string; + image_url?: string; + }; +} +export interface Payee { + destinationAccount: string; + sharedSecret: Buffer; +} +export interface Invoice extends Payee { + amount: BigNumber; + assetScale?: number; + assetCode?: string; +} +export declare class InvoiceReceiver implements Invoice { + private _expectedAmount; + private _assetScale; + private _assetCode; + private _destinationAccount; + private _sharedSecret; + private _connectionTag; + private _receivedData; + private _paymentPromise; + private _dataPromise; + private _timer?; + private _streamConnection?; + constructor(amount: BigNumber.Value, reference: string | undefined, streamServer: STREAM.Server); + readonly destinationAccount: string; + readonly sharedSecret: Buffer; + readonly amount: BigNumber; + readonly assetScale: number; + readonly assetCode: string; + toJSON(): JsonInvoice; + receiveData(): Promise; + receivePayment(timeout?: number): Promise; + private _complete; + private _timeout; +} +export declare function serializePayee(receiver: Invoice | Payee): JsonInvoice; diff --git a/src/lib/invoice.js b/src/lib/invoice.js new file mode 100644 index 0000000..819c3d2 --- /dev/null +++ b/src/lib/invoice.js @@ -0,0 +1,144 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const bignumber_js_1 = require("bignumber.js"); +const crypto = require("crypto"); +const promise_1 = require("./promise"); +const assert = require("assert"); +const createLogger = require('ilp-logger'); +const log = createLogger('invoice'); +class InvoiceReceiver { + constructor(amount, reference = crypto.randomBytes(16).toString('hex'), streamServer) { + assert(/^[A-Za-z0-9~_-]*$/.test(reference), 'Reference can only contain valid ILP Address characters.'); + this._connectionTag = reference; + const { destinationAccount, sharedSecret } = streamServer.generateAddressAndSecret(this._connectionTag); + this._expectedAmount = new bignumber_js_1.default(amount); + this._assetCode = streamServer.assetCode; + this._assetScale = streamServer.assetScale; + this._destinationAccount = destinationAccount; + this._sharedSecret = sharedSecret; + this._receivedData = Buffer.alloc(0); + this._dataPromise = new promise_1.UnwrappedPromise(); + this._paymentPromise = new promise_1.UnwrappedPromise(); + streamServer.on('connection', (connection) => { + if (connection.connectionTag === this._connectionTag) { + log.debug(`connection opened`); + this._streamConnection = connection; + connection.on('stream', (stream) => { + log.debug(`stream created`); + stream.setReceiveMax(this._expectedAmount); + stream.on('money', (amountReceived) => { + log.trace(`${amountReceived} received`); + if (new bignumber_js_1.default(connection.totalReceived).isGreaterThanOrEqualTo(this._expectedAmount)) { + this._complete(); + } + }); + stream.on('data', (dataReceived) => { + log.trace(`${dataReceived.byteLength} bytes of data received`); + this._receivedData = Buffer.concat([this._receivedData, dataReceived]); + }); + stream.on('end', () => { + log.debug(`stream ended`); + this._complete(); + }); + }); + } + }); + } + get destinationAccount() { + return this._destinationAccount; + } + get sharedSecret() { + return this._sharedSecret; + } + get amount() { + return this._expectedAmount; + } + get assetScale() { + return this._assetScale; + } + get assetCode() { + return this._assetCode; + } + toJSON() { + return serializePayee(this); + } + receiveData() { + return this._dataPromise.promise; + } + receivePayment(timeout) { + if (timeout) { + this._timer = setTimeout(() => { + this._timeout(); + }, timeout); + } + return this._paymentPromise.promise; + } + _complete() { + if (this._timer) { + clearTimeout(this._timer); + } + if (this._streamConnection) { + this._paymentPromise.resolve({ + sourceAccount: this._streamConnection.destinationAccount, + destinationAccount: this._streamConnection.sourceAccount, + received: { + amount: this._streamConnection.totalReceived, + assetCode: this._streamConnection.sourceAssetCode, + assetScale: this._streamConnection.sourceAssetScale + }, + requested: { + amount: this._expectedAmount, + assetCode: this._streamConnection.sourceAssetCode, + assetScale: this._streamConnection.sourceAssetScale + } + }); + this._dataPromise.resolve(this._receivedData); + this._streamConnection.end().catch(e => { + log.error('Error closing connection after payment was completed.', e); + }); + } + else { + const error = new Error('No incoming STREAM connection.'); + this._paymentPromise.reject(error); + this._dataPromise.reject(error); + } + } + _timeout() { + const error = (this._streamConnection) + ? new Error(`Timed out waiting for payment. ` + + `Received ${this._streamConnection.totalReceived} payment ` + + `and ${this._receivedData.byteLength} bytes of data so far.`) + : new Error(`Timed out waiting for connection. `); + this._paymentPromise.reject(error); + this._dataPromise.reject(error); + if (this._streamConnection) { + this._streamConnection.end().catch(e => { + log.error('Error closing connection after payment timed out.', e); + }); + } + } +} +exports.InvoiceReceiver = InvoiceReceiver; +function serializePayee(receiver) { + const invoice = receiver; + const balance = (invoice.amount) + ? { + current: '0', + maximum: invoice.amount.toString() + } + : undefined; + const asset_info = (invoice.assetCode && invoice.assetScale) + ? { + code: invoice.assetCode, + scale: invoice.assetScale + } + : undefined; + return { + destination_account: invoice.destinationAccount, + shared_secret: invoice.sharedSecret.toString('base64'), + balance, + asset_info + }; +} +exports.serializePayee = serializePayee; +//# sourceMappingURL=invoice.js.map \ No newline at end of file diff --git a/src/lib/invoice.js.map b/src/lib/invoice.js.map new file mode 100644 index 0000000..28288ef --- /dev/null +++ b/src/lib/invoice.js.map @@ -0,0 +1 @@ +{"version":3,"file":"invoice.js","sourceRoot":"","sources":["invoice.ts"],"names":[],"mappings":";;AAAA,+CAAoC;AACpC,iCAAgC;AAEhC,uCAA4C;AAC5C,iCAAgC;AAChC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAC1C,MAAM,GAAG,GAAG,YAAY,CAAC,SAAS,CAAC,CAAA;AA8BnC,MAAa,eAAe;IAc1B,YAAa,MAAuB,EAAE,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,YAA2B;QACnH,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,0DAA0D,CAAC,CAAA;QACvG,IAAI,CAAC,cAAc,GAAG,SAAS,CAAA;QAC/B,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC,wBAAwB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QACvG,IAAI,CAAC,eAAe,GAAG,IAAI,sBAAS,CAAC,MAAM,C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,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;QAEjD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAClC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC/B,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1B,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;gBACrC,GAAG,CAAC,KAAK,CAAC,mDAAmD,EAAE,CAAC,CAAC,CAAA;YACnE,CAAC,CAAC,CAAA;SACH;IACH,CAAC;CAEF;AAvID,0CAuIC;AAED,SAAgB,cAAc,CAAE,QAAyB;IAEvD,MAAM,OAAO,GAAG,QAAmB,CAAA;IACnC,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;QAC9B,CAAC,CAAC;YACA,OAAO,EAAE,GAAG;YACZ,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE;SACnC;QACD,CAAC,CAAC,SAAS,CAAA;IAGb,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC;QAC1D,CAAC,CAAC;YACA,IAAI,EAAE,OAAO,CAAC,SAAS;YACvB,KAAK,EAAE,OAAO,CAAC,UAAU;SAC1B;QACD,CAAC,CAAC,SAAS,CAAA;IAEb,OAAO;QACL,mBAAmB,EAAE,OAAO,CAAC,kBAAkB;QAC/C,aAAa,EAAE,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACtD,OAAO;QACP,UAAU;KACX,CAAA;AACH,CAAC;AAxBD,wCAwBC","sourcesContent":["import BigNumber from 'bignumber.js'\nimport * as crypto from 'crypto'\nimport { STREAM, Receipt } from '..'\nimport { UnwrappedPromise } from './promise'\nimport * as assert from 'assert'\nconst createLogger = require('ilp-logger')\nconst log = createLogger('invoice')\n\nexport interface JsonInvoice {\n destination_account: string\n shared_secret: string\n balance?: {\n maximum: string,\n current: string\n }\n asset_info?: {\n code: string,\n scale: number\n }\n receiver_info?: {\n name?: string,\n image_url?: string\n }\n}\n\nexport interface Payee {\n destinationAccount: string,\n sharedSecret: Buffer,\n}\n\nexport interface Invoice extends Payee {\n amount: BigNumber,\n assetScale?: number,\n assetCode?: string\n}\n\nexport class InvoiceReceiver implements Invoice {\n\n private _expectedAmount: BigNumber\n private _assetScale: number\n private _assetCode: string\n private _destinationAccount: string\n private _sharedSecret: Buffer\n private _connectionTag: string\n private _receivedData: Buffer\n private _paymentPromise: UnwrappedPromise\n private _dataPromise: UnwrappedPromise\n private _timer?: NodeJS.Timer\n private _streamConnection?: STREAM.Connection\n\n constructor (amount: BigNumber.Value, reference = crypto.randomBytes(16).toString('hex'), streamServer: STREAM.Server) {\n assert(/^[A-Za-z0-9~_-]*$/.test(reference), 'Reference can only contain valid ILP Address characters.')\n this._connectionTag = reference\n const { destinationAccount, sharedSecret } = streamServer.generateAddressAndSecret(this._connectionTag)\n this._expectedAmount = new BigNumber(amount)\n this._assetCode = streamServer.assetCode\n this._assetScale = streamServer.assetScale\n this._destinationAccount = destinationAccount\n this._sharedSecret = sharedSecret\n this._receivedData = Buffer.alloc(0)\n this._dataPromise = new UnwrappedPromise()\n this._paymentPromise = new UnwrappedPromise()\n\n streamServer.on('connection', (connection: STREAM.Connection) => {\n if (connection.connectionTag === this._connectionTag) {\n log.debug(`connection opened`)\n this._streamConnection = connection\n connection.on('stream', (stream: STREAM.DataAndMoneyStream) => {\n log.debug(`stream created`)\n stream.setReceiveMax(this._expectedAmount)\n stream.on('money', (amountReceived) => {\n log.trace(`${amountReceived} received`)\n if (new BigNumber(connection.totalReceived).isGreaterThanOrEqualTo(this._expectedAmount)) {\n this._complete()\n }\n })\n stream.on('data', (dataReceived) => {\n log.trace(`${(dataReceived as Buffer).byteLength} bytes of data received`)\n this._receivedData = Buffer.concat([this._receivedData, dataReceived as Buffer])\n })\n stream.on('end', () => {\n log.debug(`stream ended`)\n this._complete()\n })\n })\n }\n })\n }\n\n public get destinationAccount (): string {\n return this._destinationAccount\n }\n\n public get sharedSecret (): Buffer {\n return this._sharedSecret\n }\n\n public get amount (): BigNumber {\n return this._expectedAmount\n }\n\n public get assetScale (): number {\n return this._assetScale\n }\n public get assetCode (): string {\n return this._assetCode\n }\n\n public toJSON (): JsonInvoice {\n return serializePayee(this)\n }\n\n public receiveData (): Promise {\n return this._dataPromise.promise\n }\n\n public receivePayment (timeout?: number): Promise {\n if (timeout) {\n this._timer = setTimeout(() => {\n this._timeout()\n }, timeout)\n }\n return this._paymentPromise.promise\n }\n\n private _complete () {\n if (this._timer) {\n clearTimeout(this._timer)\n }\n if (this._streamConnection) {\n this._paymentPromise.resolve({\n sourceAccount: this._streamConnection.destinationAccount,\n destinationAccount: this._streamConnection.sourceAccount,\n received: {\n amount: this._streamConnection.totalReceived,\n assetCode: this._streamConnection.sourceAssetCode,\n assetScale: this._streamConnection.sourceAssetScale\n },\n requested: {\n amount: this._expectedAmount,\n assetCode: this._streamConnection.sourceAssetCode,\n assetScale: this._streamConnection.sourceAssetScale\n }\n } as Receipt)\n this._dataPromise.resolve(this._receivedData)\n this._streamConnection.end().catch(e => {\n log.error('Error closing connection after payment was completed.', e)\n })\n } else {\n const error = new Error('No incoming STREAM connection.')\n this._paymentPromise.reject(error)\n this._dataPromise.reject(error)\n }\n }\n\n private _timeout () {\n const error = (this._streamConnection)\n ? new Error(`Timed out waiting for payment. ` +\n `Received ${this._streamConnection.totalReceived} payment ` +\n `and ${this._receivedData.byteLength} bytes of data so far.`)\n : new Error(`Timed out waiting for connection. `)\n\n this._paymentPromise.reject(error)\n this._dataPromise.reject(error)\n if (this._streamConnection) {\n this._streamConnection.end().catch(e => {\n log.error('Error closing connection after payment timed out.', e)\n })\n }\n }\n\n}\n\nexport function serializePayee (receiver: Invoice | Payee): JsonInvoice {\n\n const invoice = receiver as Invoice\n const balance = (invoice.amount)\n ? {\n current: '0',\n maximum: invoice.amount.toString()\n }\n : undefined\n\n // tslint:disable-next-line:variable-name\n const asset_info = (invoice.assetCode && invoice.assetScale)\n ? {\n code: invoice.assetCode,\n scale: invoice.assetScale\n }\n : undefined\n\n return {\n destination_account: invoice.destinationAccount,\n shared_secret: invoice.sharedSecret.toString('base64'),\n balance,\n asset_info\n }\n}\n"]} \ No newline at end of file diff --git a/src/lib/plugin.d.ts b/src/lib/plugin.d.ts new file mode 100644 index 0000000..90c36ee --- /dev/null +++ b/src/lib/plugin.d.ts @@ -0,0 +1,19 @@ +/// +import { EventEmitter } from 'events'; +export interface FunctionWithVersion extends Function { + version?: number; +} +export declare type DataHandler = (data: Buffer) => Promise; +export declare type MoneyHandler = (amount: string) => Promise; +export interface PluginV2 extends EventEmitter { + constructor: FunctionWithVersion; + connect: () => Promise; + disconnect: () => Promise; + isConnected: () => boolean; + sendData: DataHandler; + sendMoney: MoneyHandler; + registerDataHandler: (handler: DataHandler) => void; + deregisterDataHandler: () => void; + registerMoneyHandler: (handler: MoneyHandler) => void; + deregisterMoneyHandler: () => void; +} diff --git a/src/lib/plugin.js b/src/lib/plugin.js new file mode 100644 index 0000000..518604c --- /dev/null +++ b/src/lib/plugin.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=plugin.js.map \ No newline at end of file diff --git a/src/lib/plugin.js.map b/src/lib/plugin.js.map new file mode 100644 index 0000000..fae9d70 --- /dev/null +++ b/src/lib/plugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"plugin.js","sourceRoot":"","sources":["plugin.ts"],"names":[],"mappings":"","sourcesContent":["\nimport { EventEmitter } from 'events'\nexport interface FunctionWithVersion extends Function {\n version?: number\n}\n\nexport type DataHandler = (data: Buffer) => Promise\n\nexport type MoneyHandler = (amount: string) => Promise\n\nexport interface PluginV2 extends EventEmitter {\n constructor: FunctionWithVersion\n connect: () => Promise\n disconnect: () => Promise\n isConnected: () => boolean\n sendData: DataHandler\n sendMoney: MoneyHandler\n registerDataHandler: (handler: DataHandler) => void\n deregisterDataHandler: () => void\n registerMoneyHandler: (handler: MoneyHandler) => void\n deregisterMoneyHandler: () => void\n}\n"]} \ No newline at end of file diff --git a/src/lib/promise.d.ts b/src/lib/promise.d.ts new file mode 100644 index 0000000..bbc86fe --- /dev/null +++ b/src/lib/promise.d.ts @@ -0,0 +1,9 @@ +export declare class UnwrappedPromise { + private innerPromise; + private resolveCallback?; + private rejectCallback?; + constructor(); + readonly promise: Promise; + resolve(value?: T | PromiseLike): void; + reject(reason?: any): void; +} diff --git a/src/lib/promise.js b/src/lib/promise.js new file mode 100644 index 0000000..95392b0 --- /dev/null +++ b/src/lib/promise.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +class UnwrappedPromise { + constructor() { + this.innerPromise = new Promise((resolve, reject) => { + this.resolveCallback = resolve; + this.rejectCallback = reject; + }); + } + get promise() { + return this.innerPromise; + } + resolve(value) { + return this.resolveCallback ? this.resolveCallback(value) : undefined; + } + reject(reason) { + return this.rejectCallback ? this.rejectCallback(reason) : undefined; + } +} +exports.UnwrappedPromise = UnwrappedPromise; +//# sourceMappingURL=promise.js.map \ No newline at end of file diff --git a/src/lib/promise.js.map b/src/lib/promise.js.map new file mode 100644 index 0000000..cfd2f82 --- /dev/null +++ b/src/lib/promise.js.map @@ -0,0 +1 @@ +{"version":3,"file":"promise.js","sourceRoot":"","sources":["promise.ts"],"names":[],"mappings":";;AAAA,MAAa,gBAAgB;IAM3B;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAA;YAC9B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAA;QAC9B,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAEM,OAAO,CAAE,KAA0B;QACxC,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACvE,CAAC;IAEM,MAAM,CAAE,MAAY;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACtE,CAAC;CAEF;AAzBD,4CAyBC","sourcesContent":["export class UnwrappedPromise {\n\n private innerPromise: Promise\n private resolveCallback?: (value?: T | PromiseLike) => void\n private rejectCallback?: (reason?: any) => void\n\n constructor () {\n this.innerPromise = new Promise((resolve, reject) => {\n this.resolveCallback = resolve\n this.rejectCallback = reject\n })\n }\n\n public get promise (): Promise {\n return this.innerPromise\n }\n\n public resolve (value?: T | PromiseLike) {\n return this.resolveCallback ? this.resolveCallback(value) : undefined\n }\n\n public reject (reason?: any) {\n return this.rejectCallback ? this.rejectCallback(reason) : undefined\n }\n\n}\n"]} \ No newline at end of file diff --git a/src/lib/receipt.d.ts b/src/lib/receipt.d.ts new file mode 100644 index 0000000..c466a20 --- /dev/null +++ b/src/lib/receipt.d.ts @@ -0,0 +1,13 @@ +import BigNumber from 'bignumber.js'; +export interface AssetAmount { + amount: BigNumber.Value; + assetCode?: string; + assetScale?: number; +} +export interface Receipt { + destinationAccount: string; + sourceAccount: string; + received: AssetAmount; + sent?: AssetAmount; + requested?: AssetAmount; +} diff --git a/src/lib/receipt.js b/src/lib/receipt.js new file mode 100644 index 0000000..a63c21b --- /dev/null +++ b/src/lib/receipt.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=receipt.js.map \ No newline at end of file diff --git a/src/lib/receipt.js.map b/src/lib/receipt.js.map new file mode 100644 index 0000000..547e36e --- /dev/null +++ b/src/lib/receipt.js.map @@ -0,0 +1 @@ +{"version":3,"file":"receipt.js","sourceRoot":"","sources":["receipt.ts"],"names":[],"mappings":"","sourcesContent":["import BigNumber from 'bignumber.js'\n\nexport interface AssetAmount {\n amount: BigNumber.Value,\n assetCode?: string,\n assetScale?: number\n}\n\nexport interface Receipt {\n destinationAccount: string,\n sourceAccount: string,\n received: AssetAmount\n sent?: AssetAmount,\n requested?: AssetAmount\n}\n"]} \ No newline at end of file diff --git a/src/lib/spsp.d.ts b/src/lib/spsp.d.ts new file mode 100644 index 0000000..d0c0009 --- /dev/null +++ b/src/lib/spsp.d.ts @@ -0,0 +1,29 @@ +/// +import BigNumber from 'bignumber.js'; +import { PluginV2 } from './plugin'; +import { Receipt } from './receipt'; +export declare const CONTENT_TYPE = "application/spsp4+json"; +export interface SpspResponse { + destinationAccount: string; + sharedSecret: Buffer; + balance?: { + maximum: string; + current: string; + }; + assetInfo?: { + code: string; + scale: number; + }; + receiverInfo?: { + name?: string; + imageUrl?: string; + }; + contentType: string; +} +export declare function query(receiver: string): Promise; +export interface PayOptions { + receiver: string; + sourceAmount: BigNumber.Value; + data?: Buffer; +} +export declare function pay(plugin: PluginV2, options: PayOptions): Promise; diff --git a/src/lib/spsp.js b/src/lib/spsp.js new file mode 100644 index 0000000..6d6c5a8 --- /dev/null +++ b/src/lib/spsp.js @@ -0,0 +1,101 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const ilp_protocol_stream_1 = require("ilp-protocol-stream"); +const url_1 = require("url"); +const node_fetch_1 = require("node-fetch"); +const bignumber_js_1 = require("bignumber.js"); +exports.CONTENT_TYPE = 'application/spsp4+json'; +function query(receiver) { + return __awaiter(this, void 0, void 0, function* () { + const endpoint = new url_1.URL(receiver.startsWith('$') + ? 'https://' + receiver.substring(1) + : receiver); + endpoint.pathname = (endpoint.pathname === '/') + ? '/.well-known/pay' + : endpoint.pathname; + const response = yield node_fetch_1.default(endpoint.href, { + headers: { accept: exports.CONTENT_TYPE } + }); + if (response.status !== 200) { + throw new Error('Got error response from spsp receiver.' + + ' endpoint="' + endpoint.href + '"' + + ' status=' + response.status + + ' message="' + (yield response.text()) + '"'); + } + const json = yield response.json(); + return { + destinationAccount: json.destination_account, + sharedSecret: Buffer.from(json.shared_secret, 'base64'), + balance: json.balance, + assetInfo: json.asset_info, + receiverInfo: json.receiver_info, + contentType: response.headers.get('Content-Type') + }; + }); +} +exports.query = query; +function pay(plugin, options) { + return __awaiter(this, void 0, void 0, function* () { + const { receiver, sourceAmount, data } = options; + const pluginWasConnected = plugin.isConnected; + const [response] = yield Promise.all([ + query(receiver), + plugin.connect() + ]); + const { destinationAccount, sharedSecret, contentType, balance } = response; + if (contentType.indexOf(exports.CONTENT_TYPE) !== -1) { + const streamConnection = yield ilp_protocol_stream_1.createConnection({ + plugin, + destinationAccount, + sharedSecret + }); + const stream = streamConnection.createStream(); + if (data) { + stream.write(data); + } + yield Promise.race([ + stream.sendTotal(sourceAmount).then(() => stream.end()), + new Promise(resolve => stream.on('end', resolve)) + ]); + const requestedAmount = (balance) + ? new bignumber_js_1.default(balance.maximum).minus(new bignumber_js_1.default(balance.current)) + : undefined; + yield streamConnection.end(); + if (!pluginWasConnected) { + yield plugin.disconnect(); + } + return { + sourceAccount: streamConnection.sourceAccount, + destinationAccount, + sent: { + amount: new bignumber_js_1.default(streamConnection.totalSent), + assetCode: streamConnection.sourceAssetCode, + assetScale: streamConnection.sourceAssetScale + }, + received: { + amount: new bignumber_js_1.default(streamConnection.totalDelivered), + assetCode: streamConnection.destinationAssetCode, + assetScale: streamConnection.destinationAssetScale + }, + requested: (requestedAmount) ? { + amount: requestedAmount, + assetCode: streamConnection.destinationAssetCode, + assetScale: streamConnection.destinationAssetScale + } : undefined + }; + } + else { + throw new Error(`Unable to send to ${receiver} as it does not support the STREAM protocol.`); + } + }); +} +exports.pay = pay; +//# sourceMappingURL=spsp.js.map \ No newline at end of file diff --git a/src/lib/spsp.js.map b/src/lib/spsp.js.map new file mode 100644 index 0000000..78f79c7 --- /dev/null +++ b/src/lib/spsp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"spsp.js","sourceRoot":"","sources":["spsp.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,6DAAsD;AACtD,6BAAyB;AACzB,2CAA8B;AAC9B,+CAAoC;AAKvB,QAAA,YAAY,GAAG,wBAAwB,CAAA;AAoBpD,SAAsB,KAAK,CAAE,QAAgB;;QAG3C,MAAM,QAAQ,GAAG,IAAI,SAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;YAC/C,CAAC,CAAC,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;YACpC,CAAC,CAAC,QAAQ,CAAC,CAAA;QAEb,QAAQ,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,QAAQ,KAAK,GAAG,CAAC;YAC7C,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAA;QAIrB,MAAM,QAAQ,GAAG,MAAM,oBAAK,CAAC,QAAQ,CAAC,IAAI,EAAE;YAC1C,OAAO,EAAE,EAAE,MAAM,EAAE,oBAAY,EAAE;SAClC,CAAC,CAAA;QAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,wCAAwC;gBACtD,aAAa,GAAG,QAAQ,CAAC,IAAI,GAAG,GAAG;gBACnC,UAAU,GAAG,QAAQ,CAAC,MAAM;gBAC5B,YAAY,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,CAAA;SAChD;QAED,MA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BA2DC","sourcesContent":["import { createConnection } from 'ilp-protocol-stream'\nimport { URL } from 'url'\nimport fetch from 'node-fetch'\nimport BigNumber from 'bignumber.js'\nimport { PluginV2 } from './plugin'\nimport { Receipt } from './receipt'\nimport { JsonInvoice } from './invoice'\n\nexport const CONTENT_TYPE = 'application/spsp4+json'\n\nexport interface SpspResponse {\n destinationAccount: string\n sharedSecret: Buffer\n balance?: {\n maximum: string,\n current: string\n }\n assetInfo?: {\n code: string,\n scale: number\n }\n receiverInfo?: {\n name?: string,\n imageUrl?: string\n }\n contentType: string\n}\n\nexport async function query (receiver: string): Promise {\n\n // TODO: further validation required on payment-pointer?\n const endpoint = new URL(receiver.startsWith('$')\n ? 'https://' + receiver.substring(1)\n : receiver)\n\n endpoint.pathname = (endpoint.pathname === '/')\n ? '/.well-known/pay'\n : endpoint.pathname\n\n // TODO: make sure that this fetch can never crash this node process. because\n // this could be called from autonomous code, that would pose big problems.\n const response = await fetch(endpoint.href, {\n headers: { accept: CONTENT_TYPE }\n })\n\n if (response.status !== 200) {\n throw new Error('Got error response from spsp receiver.' +\n ' endpoint=\"' + endpoint.href + '\"' +\n ' status=' + response.status +\n ' message=\"' + (await response.text()) + '\"')\n }\n\n const json = await response.json() as JsonInvoice\n\n return {\n destinationAccount: json.destination_account,\n sharedSecret: Buffer.from(json.shared_secret, 'base64'),\n balance: json.balance,\n assetInfo: json.asset_info,\n receiverInfo: json.receiver_info,\n contentType: response.headers.get('Content-Type') as string\n }\n}\n\nexport interface PayOptions {\n receiver: string,\n sourceAmount: BigNumber.Value,\n data?: Buffer\n}\n\nexport async function pay (plugin: PluginV2, options: PayOptions): Promise {\n const { receiver, sourceAmount, data } = options\n const pluginWasConnected = plugin.isConnected\n const [ response ] = await Promise.all([\n query(receiver),\n plugin.connect()\n ])\n\n const { destinationAccount, sharedSecret, contentType, balance } = response\n\n if (contentType.indexOf(CONTENT_TYPE) !== -1) {\n\n const streamConnection = await createConnection({\n plugin,\n destinationAccount,\n sharedSecret\n })\n\n const stream = streamConnection.createStream()\n if (data) {\n stream.write(data)\n }\n await Promise.race([\n stream.sendTotal(sourceAmount).then(() => stream.end()),\n new Promise(resolve => stream.on('end', resolve))\n ])\n\n const requestedAmount = (balance)\n ? new BigNumber(balance.maximum).minus(new BigNumber(balance.current))\n : undefined\n\n await streamConnection.end()\n\n if (!pluginWasConnected) {\n await plugin.disconnect()\n }\n\n return {\n sourceAccount: streamConnection.sourceAccount,\n destinationAccount,\n sent: {\n amount: new BigNumber(streamConnection.totalSent),\n assetCode: streamConnection.sourceAssetCode,\n assetScale: streamConnection.sourceAssetScale\n },\n received: {\n amount: new BigNumber(streamConnection.totalDelivered),\n assetCode: streamConnection.destinationAssetCode,\n assetScale: streamConnection.destinationAssetScale\n },\n requested: (requestedAmount) ? {\n amount: requestedAmount,\n assetCode: streamConnection.destinationAssetCode,\n assetScale: streamConnection.destinationAssetScale\n } : undefined\n }\n } else {\n throw new Error(`Unable to send to ${receiver} as it does not support the STREAM protocol.`)\n }\n}\n"]} \ No newline at end of file From 02226a1d4cdea5eff788951028db9fad0964c838 Mon Sep 17 00:00:00 2001 From: Kevin Davis Date: Fri, 19 Oct 2018 16:59:47 -0400 Subject: [PATCH 2/3] Update packages --- package-lock.json | 455 +++++++++++++++++++--------------------------- 1 file changed, 185 insertions(+), 270 deletions(-) diff --git a/package-lock.json b/package-lock.json index 033086b..5e1fe26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ }, "@types/events": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", "integrity": "sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA==" }, "@types/express": { @@ -72,9 +72,9 @@ } }, "@types/lodash": { - "version": "4.14.116", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.116.tgz", - "integrity": "sha512-lRnAtKnxMXcYYXqOiotTmJd74uawNWuPnsnPrrO7HiFuE3npE2iQhfABatbYDyxTNqZNuXzcKGhw37R7RjBFLg==" + "version": "4.14.117", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.117.tgz", + "integrity": "sha512-xyf2m6tRbz8qQKcxYZa7PA4SllYcay+eh25DN3jmNYY6gSTL7Htc/bttVdkqj2wfJGbeWlQiX8pIyJpKU+tubw==" }, "@types/lodash.camelcase": { "version": "4.3.4", @@ -90,9 +90,9 @@ "integrity": "sha512-A2TAGbTFdBw9azHbpVd+/FkdW2T6msN1uct1O9bH3vTerEHKZhTXJUQXy+hNq1B0RagfU8U+KBdqiZpxjhOUQA==" }, "@types/node": { - "version": "10.9.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz", - "integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw==" + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", + "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" }, "@types/node-fetch": { "version": "2.1.2", @@ -117,9 +117,9 @@ } }, "@types/ws": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-6.0.0.tgz", - "integrity": "sha512-i/dVaSjmTM92EFFFhmGL6AmHzvJ70XpAXmMLvNKh3JrRTGOiXvejfxe5+OSxcJK0paGOYHDaRLS8nXW6/FxSxg==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-6.0.1.tgz", + "integrity": "sha512-EzH8k1gyZ4xih/MaZTXwT2xOkPiIMSrhQ9b8wrlX88L0T02eYsddatQlwVFlEPyEqV0ChpdpNnE51QPH6NVT4Q==", "requires": { "@types/events": "*", "@types/node": "*" @@ -132,9 +132,9 @@ "dev": true }, "acorn": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.2.tgz", - "integrity": "sha512-cJrKCNcr2kv8dlDnbw+JPUGjHZzo4myaxOLmpOX8a+rgX94YeTcTMv/LFJUSByRpc+i4GgVnnhLxvMu/2Y+rqw==", + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", "dev": true }, "acorn-jsx": { @@ -147,9 +147,9 @@ } }, "ajv": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.3.tgz", - "integrity": "sha512-LqZ9wY+fx3UMiiPd741yB2pj3hhil+hQc8taf4o2QGRFpWgZ2V5C8HA165DY9sS3fJwsk7uT7ZlFEyC3Ig3lLg==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", + "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", @@ -158,28 +158,12 @@ "uri-js": "^4.2.2" } }, - "ajv-keywords": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.2.0.tgz", - "integrity": "sha1-6GuBnGAs+IIa1jdBNpjx3sAhhHo=", - "dev": true - }, - "align-text": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", - "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", - "dev": true, - "requires": { - "kind-of": "^3.0.2", - "longest": "^1.0.1", - "repeat-string": "^1.5.2" - } - }, "amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "dev": true + "dev": true, + "optional": true }, "ansi-escapes": { "version": "3.1.0", @@ -240,7 +224,7 @@ }, "async": { "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "resolved": "http://registry.npmjs.org/async/-/async-1.5.2.tgz", "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, @@ -293,7 +277,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -377,36 +361,18 @@ "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", "dev": true }, - "camelcase": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", - "dev": true, - "optional": true - }, - "center-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", - "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", - "dev": true, - "optional": true, - "requires": { - "align-text": "^0.1.3", - "lazy-cache": "^1.0.3" - } - }, "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", "dev": true, "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^3.0.0", + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", "get-func-name": "^2.0.0", - "pathval": "^1.0.0", - "type-detect": "^4.0.0" + "pathval": "^1.1.0", + "type-detect": "^4.0.5" } }, "chalk": { @@ -476,27 +442,6 @@ "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true }, - "cliui": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", - "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", - "dev": true, - "optional": true, - "requires": { - "center-align": "^0.1.1", - "right-align": "^0.1.1", - "wordwrap": "0.0.2" - }, - "dependencies": { - "wordwrap": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", - "dev": true, - "optional": true - } - } - }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -513,9 +458,9 @@ "dev": true }, "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", "dev": true }, "concat-map": { @@ -549,20 +494,13 @@ "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==" }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", + "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true, - "optional": true - }, "deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", @@ -670,16 +608,16 @@ } }, "eslint": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.5.0.tgz", - "integrity": "sha512-m+az4vYehIJgl1Z0gb25KnFXeqQRdNreYsei1jdvkd9bB+UNQD3fsuiC2AWSQ56P+/t++kFSINZXFbfai+krOw==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.7.0.tgz", + "integrity": "sha512-zYCeFQahsxffGl87U2aJ7DPyH8CbWgxBC213Y8+TCanhUTf2gEvfq3EKpHmEcozTLyPmGe9LZdMAwC/CpJBM5A==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "ajv": "^6.5.3", "chalk": "^2.1.0", "cross-spawn": "^6.0.5", - "debug": "^3.1.0", + "debug": "^4.0.1", "doctrine": "^2.1.0", "eslint-scope": "^4.0.0", "eslint-utils": "^1.3.1", @@ -706,12 +644,12 @@ "path-is-inside": "^1.0.2", "pluralize": "^7.0.0", "progress": "^2.0.0", - "regexpp": "^2.0.0", + "regexpp": "^2.0.1", "require-uncached": "^1.0.3", "semver": "^5.5.1", "strip-ansi": "^4.0.0", "strip-json-comments": "^2.0.1", - "table": "^4.0.3", + "table": "^5.0.2", "text-table": "^0.2.0" } }, @@ -739,6 +677,12 @@ "requires": { "ms": "2.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, @@ -760,6 +704,12 @@ "requires": { "ms": "2.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, @@ -809,6 +759,12 @@ "esutils": "^2.0.2", "isarray": "^1.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, @@ -827,9 +783,9 @@ } }, "eslint-plugin-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.0.0.tgz", - "integrity": "sha512-3on8creJifkmNHvT425jCWSuVK0DG0Quf3H75ENZFqvHl6/s2xme8z6bfxww13XwqfELYWKxc/N3AtBXyV1hdg==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.0.1.tgz", + "integrity": "sha512-Si16O0+Hqz1gDHsys6RtFRrW7cCTB6P7p3OJmKp3Y3dxpQE2qwOA7d3xnV+0mBmrPoi0RBnxlCKvqu70te6wjg==", "dev": true }, "eslint-plugin-standard": { @@ -1056,9 +1012,9 @@ } }, "globals": { - "version": "11.7.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.7.0.tgz", - "integrity": "sha512-K8BNSPySfeShBQXsahYB/AbbWruVOTyVpgoIDnl8odPpeSfP2J5QO2oLFFdl2j7GfDCtZj2bMKar2T49itTPCg==", + "version": "11.8.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.8.0.tgz", + "integrity": "sha512-io6LkyPVuzCHBSQV9fmOwxZkUk6nIaGmxheLDgmuFv89j0fm2aqDbIXKAGfzCMHqz3HLF2Zf8WSG6VqMh2qFmA==", "dev": true }, "globby": { @@ -1088,24 +1044,24 @@ "dev": true }, "handlebars": { - "version": "4.0.11", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", - "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", + "version": "4.0.12", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.12.tgz", + "integrity": "sha512-RhmTekP+FZL+XNhwS1Wf+bTTZpdLougwt5pcgA1tuz6Jcx0fpH/7z0qd71RKnZHBCxIRBHfBOnio4gViPemNzA==", "dev": true, "requires": { - "async": "^1.4.0", + "async": "^2.5.0", "optimist": "^0.6.1", - "source-map": "^0.4.4", - "uglify-js": "^2.6" + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" }, "dependencies": { - "source-map": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", - "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", + "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", "dev": true, "requires": { - "amdefine": ">=0.0.4" + "lodash": "^4.17.10" } } } @@ -1139,8 +1095,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, "he": { "version": "1.1.1", @@ -1170,11 +1125,14 @@ "dev": true }, "ilp-logger": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/ilp-logger/-/ilp-logger-1.0.2.tgz", - "integrity": "sha512-4L+aA1Au3eTr13i4EEXqOL/JJ2jIG29r89hlcIeYKQPA1pyYjUluIatZ1Ibp9GUgpQB+GEaJveMSxoQdyhkofw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ilp-logger/-/ilp-logger-1.1.2.tgz", + "integrity": "sha512-LTPA2cwtBGOSiHuspdESKRXQT8CCoGVIUQAeHlNKDz132qwtwwd7KPVWAbGkZer7EQaLW1Cwa9vGR61sSYINww==", "requires": { - "debug": "^3.1.0" + "@types/debug": "^0.0.30", + "debug": "^4.0.0", + "source-map-support": "^0.5.9", + "supports-color": "^5.5.0" } }, "ilp-packet": { @@ -1189,9 +1147,9 @@ } }, "ilp-plugin-btp": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ilp-plugin-btp/-/ilp-plugin-btp-1.2.1.tgz", - "integrity": "sha512-1kA8ORDfbImfHi3HqgI11S3TW+KHh/+4UeNXIbFDT1+BiMuKMVZqGbvsyH3/dsDZNAkC99DwM6XHiBuXkvgENw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/ilp-plugin-btp/-/ilp-plugin-btp-1.3.2.tgz", + "integrity": "sha512-EkEeGAghQ1hZt4VFlvtbP3mR/FgbgJ1/WbwaPdvXMyxQCEhU8lObi/r/X0Ksspnw+u0nK0I7Kl6PgXhEVfMp5w==", "requires": { "@types/debug": "0.0.30", "@types/node": "^10.7.1", @@ -1201,6 +1159,16 @@ "eventemitter2": "^5.0.0", "ilp-logger": "^1.0.2", "ws": "^6.0.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + } } }, "ilp-protocol-ildcp": { @@ -1211,17 +1179,27 @@ "debug": "^3.1.0", "ilp-packet": "^3.0.0", "oer-utils": "^3.0.1" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + } } }, "ilp-protocol-stream": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/ilp-protocol-stream/-/ilp-protocol-stream-1.8.0.tgz", - "integrity": "sha512-U1JRB3oFC6TEJOVbA14LjnEYVlflXZkxlN/1mJCqpKZMk51MF7vCIZ2UVKLoZuYZWTxfwZtU3ehG5xq7o5rnRg==", + "version": "1.8.4", + "resolved": "https://registry.npmjs.org/ilp-protocol-stream/-/ilp-protocol-stream-1.8.4.tgz", + "integrity": "sha512-+iqtznhpJLPpJrLI+ogV6xW2wJuFL1LbbK7QFRRyumNm3iQMvdbTj4BUjuQIMWlaUvwL80805A3bF+vWO4XEHA==", "requires": { "@types/node": "^10.7.1", "bignumber.js": "^7.2.1", - "debug": "^3.1.0", - "ilp-logger": "^1.0.2", + "debug": "^4.0.0", + "ilp-logger": "^1.1.2", "ilp-packet": "^3.0.0", "ilp-protocol-ildcp": "^2.0.0", "oer-utils": "^3.0.1", @@ -1277,15 +1255,9 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, "is-builtin-module": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { @@ -1444,22 +1416,6 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - }, - "lazy-cache": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", - "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", - "dev": true, - "optional": true - }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -1472,7 +1428,7 @@ }, "load-json-file": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { @@ -1501,9 +1457,9 @@ } }, "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, "long": { @@ -1511,12 +1467,6 @@ "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" }, - "longest": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", - "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true - }, "lru-cache": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", @@ -1576,6 +1526,21 @@ "supports-color": "5.4.0" }, "dependencies": { + "commander": { + "version": "2.15.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -1590,6 +1555,12 @@ "path-is-absolute": "^1.0.0" } }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, "supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", @@ -1602,9 +1573,9 @@ } }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, "mute-stream": { "version": "0.0.7", @@ -1663,9 +1634,9 @@ "dev": true }, "oer-utils": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/oer-utils/-/oer-utils-3.0.1.tgz", - "integrity": "sha512-cyVlY/pP3zhfb9cpv/lcMlVejaVSLJo4Y5ExP39dEcTYP8JwCReWbglOhFNnxLJT3PFQi+6IHHfOWuDmjW9LyA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/oer-utils/-/oer-utils-3.1.1.tgz", + "integrity": "sha512-Y6+hgPB/yNWJx7WRb4XKin96sTBSAqYPx5p+73X+cAGFuJYupnkwHGTyZvcXPpxGj9rC2oC5uIWDZU8Qdb+Jlw==", "requires": { "bignumber.js": "^7.2.1" } @@ -1850,9 +1821,9 @@ "dev": true }, "progress": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", - "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.1.tgz", + "integrity": "sha512-OE+a6vzqazc+K6LxJrX5UPyKFvGnL5CYmq2jFGNIBWHpc4QyE49/YOumcrpQFJpfejmvRtbJzgO1zPmMCqlbBg==", "dev": true }, "promise-polyfill": { @@ -1906,15 +1877,9 @@ } }, "regexpp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.0.tgz", - "integrity": "sha512-g2FAVtR8Uh8GO1Nv5wpxW7VFVwHcCEr4wyA8/MHiRkO8uHoR5ntAA8Uq3P1vvMTX/BeQiRVSpDGLd+Wn5HNOTA==", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true }, "require-uncached": { @@ -1952,16 +1917,6 @@ "signal-exit": "^3.0.2" } }, - "right-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", - "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", - "dev": true, - "optional": true, - "requires": { - "align-text": "^0.1.1" - } - }, "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", @@ -1981,9 +1936,9 @@ } }, "rxjs": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.1.tgz", - "integrity": "sha512-hRVfb1Mcf8rLXq1AZEjYpzBnQbO7Duveu1APXkWRTvqzhmkoQ40Pl2F9Btacx+gJCOqsMiugCGG4I2HPQgJRtA==", + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", + "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", "dev": true, "requires": { "tslib": "^1.9.0" @@ -1996,9 +1951,9 @@ "dev": true }, "semver": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", - "integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true }, "shebang-command": { @@ -2046,9 +2001,9 @@ } }, "spdx-correct": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.2.tgz", + "integrity": "sha512-q9hedtzyXHr5S0A1vEPoK/7l8NpfkFYTq6iCY+Pno2ZbdZR6WexZFtqeVGkGxW3TEJMN914Z55EnAGMmenlIQQ==", "dev": true, "requires": { "spdx-expression-parse": "^3.0.0", @@ -2056,9 +2011,9 @@ } }, "spdx-exceptions": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", "dev": true }, "spdx-expression-parse": { @@ -2072,9 +2027,9 @@ } }, "spdx-license-ids": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.1.tgz", + "integrity": "sha512-TfOfPcYGBB5sDuPn3deByxPhmfegAhpDYKSOXZQN81Oyrrif8ZCodOLzK3AesELnCx03kikhyDwh0pfvvQvF8w==", "dev": true }, "sprintf-js": { @@ -2118,21 +2073,18 @@ "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" } }, "table": { - "version": "4.0.3", - "resolved": "http://registry.npmjs.org/table/-/table-4.0.3.tgz", - "integrity": "sha512-S7rnFITmBH1EnyKcvxBh1LjYeQMmnZtCXSEbHcH6S0NoKit24ZuFO/T1vDcLdYsLQkM188PVVhQmzKIuThNkKg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/table/-/table-5.1.0.tgz", + "integrity": "sha512-e542in22ZLhD/fOIuXs/8yDZ9W61ltF8daM88rkRNtgTIct+vI2fTnAyu/Db2TCfEcI8i7mjZz6meLq0nW7TYg==", "dev": true, "requires": { - "ajv": "^6.0.1", - "ajv-keywords": "^3.0.0", - "chalk": "^2.1.0", - "lodash": "^4.17.4", + "ajv": "^6.5.3", + "lodash": "^4.17.10", "slice-ansi": "1.0.0", "string-width": "^2.1.1" } @@ -2145,7 +2097,7 @@ }, "through": { "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, @@ -2233,9 +2185,9 @@ "dev": true }, "tsutils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.0.0.tgz", - "integrity": "sha512-LjHBWR0vWAUHWdIAoTjoqi56Kz+FDKBgVEuL+gVPG/Pv7QW5IdaDDeK9Txlr6U0Cmckp5EgCIq1T25qe3J6hyw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.1.0.tgz", + "integrity": "sha512-rmGhespW+nZMtdkc4JJefYSjux2uCDZxCTLU+nu8gvm+gM+YT0W5XAygHxaeOwRAHZ+SoPdrovZmAlZ2a0KSlw==", "dev": true, "requires": { "tslib": "^1.8.1" @@ -2268,39 +2220,22 @@ "dev": true }, "typescript": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.1.tgz", - "integrity": "sha512-Veu0w4dTc/9wlWNf2jeRInNodKlcdLgemvPsrNpfu5Pq39sgfFjvIIgTsvUHCoLBnMhPoUA+tFxsXjU6VexVRQ==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.3.tgz", + "integrity": "sha512-+81MUSyX+BaSo+u2RbozuQk/UWx6hfG0a5gHu4ANEM4sU96XbuIyAB+rWBW1u70c6a5QuZfuYICn3s2UjuHUpA==", "dev": true }, "uglify-js": { - "version": "2.8.29", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", - "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "version": "3.4.9", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz", + "integrity": "sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==", "dev": true, "optional": true, "requires": { - "source-map": "~0.5.1", - "uglify-to-browserify": "~1.0.0", - "yargs": "~3.10.0" - }, - "dependencies": { - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "optional": true - } + "commander": "~2.17.1", + "source-map": "~0.6.1" } }, - "uglify-to-browserify": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", - "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", - "dev": true, - "optional": true - }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -2329,13 +2264,6 @@ "isexe": "^2.0.0" } }, - "window-size": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", - "dev": true, - "optional": true - }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", @@ -2358,9 +2286,9 @@ } }, "ws": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz", - "integrity": "sha512-c2UlYcAZp1VS8AORtpq6y4RJIkJ9dQz18W32SpR/qXGfLDZ2jU4y4wKvvZwqbi7U6gxFQTeE+urMbXU/tsDy4w==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.0.tgz", + "integrity": "sha512-H3dGVdGvW2H8bnYpIDc3u3LH8Wue3Qh+Zto6aXXFzvESkTVT6rAfKR6tR/+coaUvxs8yHtmNV0uioBF62ZGSTg==", "requires": { "async-limiter": "~1.0.0" } @@ -2370,19 +2298,6 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", "dev": true - }, - "yargs": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", - "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", - "dev": true, - "optional": true, - "requires": { - "camelcase": "^1.0.2", - "cliui": "^2.1.0", - "decamelize": "^1.0.0", - "window-size": "0.1.0" - } } } } From 33131639d1c49ec70b8fb8fb872947835f9e7ba2 Mon Sep 17 00:00:00 2001 From: Kevin Davis Date: Fri, 19 Oct 2018 16:59:50 -0400 Subject: [PATCH 3/3] 14.1.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5e1fe26..f1ecd58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ilp", - "version": "14.0.0", + "version": "14.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 32bf344..b46d8e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ilp", - "version": "14.0.0", + "version": "14.1.0", "description": "ILP client library for sending and receiving payments", "main": "src/index.js", "scripts": {