From f1f5364d07a0d87fd478555ed8151d10e5be18fc Mon Sep 17 00:00:00 2001 From: Brad Chase Date: Wed, 3 May 2017 20:17:31 -0400 Subject: [PATCH 1/2] Switch to jsonschema --- npm-shrinkwrap.json | 412 +-------------------------------- package.json | 3 +- src/common/schema-validator.js | 40 +++- 3 files changed, 36 insertions(+), 419 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 7be4ce8e..e0450eeb 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -7,143 +7,16 @@ "from": "agent-base@>=2.0.0 <3.0.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.0.1.tgz" }, - "ajv": { - "version": "4.1.5", - "from": "ajv@>=4.0.5 <5.0.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.1.5.tgz" - }, - "ajv-i18n": { - "version": "1.2.0", - "from": "ajv-i18n@>=1.2.0 <2.0.0", - "resolved": "https://registry.npmjs.org/ajv-i18n/-/ajv-i18n-1.2.0.tgz" - }, - "amdefine": { - "version": "1.0.0", - "from": "amdefine@>=0.0.4", - "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.0.tgz" - }, - "ansi-regex": { - "version": "2.0.0", - "from": "ansi-regex@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz" - }, - "ansi-styles": { - "version": "2.2.1", - "from": "ansi-styles@>=2.1.0 <3.0.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz" - }, - "babel-code-frame": { - "version": "6.11.0", - "from": "babel-code-frame@>=6.8.0 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.11.0.tgz" - }, - "babel-core": { - "version": "6.10.4", - "from": "babel-core@>=6.4.0 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.10.4.tgz", - "dependencies": { - "lodash": { - "version": "4.13.1", - "from": "lodash@>=4.2.0 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz" - } - } - }, - "babel-generator": { - "version": "6.11.0", - "from": "babel-generator@>=6.9.0 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.11.0.tgz", - "dependencies": { - "lodash": { - "version": "4.13.1", - "from": "lodash@>=4.2.0 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz" - } - } - }, - "babel-helpers": { - "version": "6.8.0", - "from": "babel-helpers@>=6.8.0 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.8.0.tgz" - }, - "babel-messages": { - "version": "6.8.0", - "from": "babel-messages@>=6.8.0 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.8.0.tgz" - }, - "babel-plugin-syntax-flow": { - "version": "6.8.0", - "from": "babel-plugin-syntax-flow@>=6.3.13 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.8.0.tgz" - }, "babel-polyfill": { "version": "6.9.1", "from": "babel-polyfill@>=6.3.14 <7.0.0", "resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.9.1.tgz" }, - "babel-register": { - "version": "6.9.0", - "from": "babel-register@>=6.3.13 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.9.0.tgz", - "dependencies": { - "lodash": { - "version": "4.13.1", - "from": "lodash@>=4.2.0 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz" - } - } - }, "babel-runtime": { "version": "6.9.2", "from": "babel-runtime@>=6.3.19 <7.0.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.9.2.tgz" }, - "babel-template": { - "version": "6.9.0", - "from": "babel-template@>=6.9.0 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.9.0.tgz", - "dependencies": { - "lodash": { - "version": "4.13.1", - "from": "lodash@>=4.2.0 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz" - } - } - }, - "babel-traverse": { - "version": "6.10.4", - "from": "babel-traverse@>=6.10.4 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.10.4.tgz", - "dependencies": { - "lodash": { - "version": "4.13.1", - "from": "lodash@>=4.2.0 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz" - } - } - }, - "babel-types": { - "version": "6.11.1", - "from": "babel-types@>=6.9.1 <7.0.0", - "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.11.1.tgz", - "dependencies": { - "lodash": { - "version": "4.13.1", - "from": "lodash@>=4.2.0 <5.0.0", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz" - } - } - }, - "babylon": { - "version": "6.8.4", - "from": "babylon@>=6.7.0 <7.0.0", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.8.4.tgz" - }, - "balanced-match": { - "version": "0.4.1", - "from": "balanced-match@>=0.4.1 <0.5.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.1.tgz" - }, "base-x": { "version": "1.0.4", "from": "base-x@>=1.0.1 <2.0.0", @@ -159,46 +32,21 @@ "from": "bn.js@>=4.11.3 <5.0.0", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz" }, - "brace-expansion": { - "version": "1.1.5", - "from": "brace-expansion@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.5.tgz" - }, "brorand": { "version": "1.0.5", "from": "brorand@>=1.0.5 <2.0.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.0.5.tgz" }, - "chalk": { - "version": "1.1.1", - "from": "chalk@1.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.1.tgz" - }, "cipher-base": { "version": "1.0.2", "from": "cipher-base@>=1.0.1 <2.0.0", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.2.tgz" }, - "co": { - "version": "4.6.0", - "from": "co@>=4.6.0 <5.0.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz" - }, "commander": { "version": "1.3.2", "from": "commander@1.3.2", "resolved": "https://registry.npmjs.org/commander/-/commander-1.3.2.tgz" }, - "concat-map": { - "version": "0.0.1", - "from": "concat-map@0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - }, - "convert-source-map": { - "version": "1.2.0", - "from": "convert-source-map@>=1.1.0 <2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.2.0.tgz" - }, "core-js": { "version": "2.4.0", "from": "core-js@>=2.4.0 <3.0.0", @@ -219,16 +67,6 @@ "from": "decimal.js@>=5.0.8 <6.0.0", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-5.0.8.tgz" }, - "detect-indent": { - "version": "3.0.1", - "from": "detect-indent@>=3.0.1 <4.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-3.0.1.tgz" - }, - "diff": { - "version": "1.4.0", - "from": "diff@1.4.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz" - }, "elliptic": { "version": "5.2.1", "from": "elliptic@>=5.1.0 <6.0.0", @@ -241,16 +79,6 @@ } } }, - "escape-string-regexp": { - "version": "1.0.5", - "from": "escape-string-regexp@>=1.0.2 <2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" - }, - "esutils": { - "version": "2.0.2", - "from": "esutils@>=2.0.2 <3.0.0", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz" - }, "extend": { "version": "3.0.0", "from": "extend@>=3.0.0 <4.0.0", @@ -261,41 +89,11 @@ "from": "eyes@0.1.8", "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz" }, - "get-stdin": { - "version": "4.0.1", - "from": "get-stdin@>=4.0.1 <5.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz" - }, - "globals": { - "version": "8.18.0", - "from": "globals@>=8.3.0 <9.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-8.18.0.tgz" - }, - "growl": { - "version": "1.9.2", - "from": "growl@1.9.2", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz" - }, - "gulp-rename": { - "version": "1.2.2", - "from": "gulp-rename@>=1.2.0 <2.0.0", - "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.2.2.tgz" - }, - "has-ansi": { - "version": "2.0.0", - "from": "has-ansi@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz" - }, "hash.js": { "version": "1.0.3", "from": "hash.js@>=1.0.3 <2.0.0", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz" }, - "home-or-tmp": { - "version": "1.0.0", - "from": "home-or-tmp@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-1.0.0.tgz" - }, "https-proxy-agent": { "version": "1.0.0", "from": "https-proxy-agent@>=1.0.0 <2.0.0", @@ -306,33 +104,6 @@ "from": "inherits@>=2.0.1 <3.0.0", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" }, - "invariant": { - "version": "2.2.1", - "from": "invariant@>=2.2.0 <3.0.0", - "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.1.tgz" - }, - "is-finite": { - "version": "1.0.1", - "from": "is-finite@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.1.tgz" - }, - "jade": { - "version": "0.26.3", - "from": "jade@0.26.3", - "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", - "dependencies": { - "commander": { - "version": "0.6.1", - "from": "commander@0.6.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz" - }, - "mkdirp": { - "version": "0.3.0", - "from": "mkdirp@0.3.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz" - } - } - }, "jayson": { "version": "1.2.2", "from": "jayson@>=1.2.2 <2.0.0", @@ -345,31 +116,16 @@ } } }, - "js-tokens": { - "version": "2.0.0", - "from": "js-tokens@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-2.0.0.tgz" - }, - "json-stable-stringify": { - "version": "1.0.1", - "from": "json-stable-stringify@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz" - }, - "json5": { - "version": "0.4.0", - "from": "json5@>=0.4.0 <0.5.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.4.0.tgz" - }, - "jsonify": { - "version": "0.0.0", - "from": "jsonify@>=0.0.0 <0.1.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz" - }, "jsonparse": { "version": "1.0.0", "from": "jsonparse@>=1.0.0 <1.1.0", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.0.0.tgz" }, + "jsonschema": { + "version": "1.1.1", + "from": "jsonschema@latest", + "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.1.1.tgz" + }, "JSONStream": { "version": "1.0.3", "from": "JSONStream@1.0.3", @@ -385,122 +141,21 @@ "from": "lodash@>=3.1.0 <4.0.0", "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" }, - "loose-envify": { - "version": "1.2.0", - "from": "loose-envify@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.2.0.tgz", - "dependencies": { - "js-tokens": { - "version": "1.0.3", - "from": "js-tokens@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.3.tgz" - } - } - }, - "lru-cache": { - "version": "2.7.3", - "from": "lru-cache@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz" - }, - "minimatch": { - "version": "3.0.2", - "from": "minimatch@>=3.0.2 <4.0.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.2.tgz" - }, - "minimist": { - "version": "1.2.0", - "from": "minimist@>=1.1.0 <2.0.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz" - }, - "mkdirp": { - "version": "0.5.1", - "from": "mkdirp@>=0.5.1 <0.6.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "dependencies": { - "minimist": { - "version": "0.0.8", - "from": "minimist@0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" - } - } - }, - "mocha": { - "version": "2.5.3", - "from": "mocha@>=2.1.0 <3.0.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", - "dependencies": { - "commander": { - "version": "2.3.0", - "from": "commander@2.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz" - }, - "escape-string-regexp": { - "version": "1.0.2", - "from": "escape-string-regexp@1.0.2", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz" - }, - "glob": { - "version": "3.2.11", - "from": "glob@3.2.11", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz" - }, - "minimatch": { - "version": "0.3.0", - "from": "minimatch@>=0.3.0 <0.4.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz" - }, - "supports-color": { - "version": "1.2.0", - "from": "supports-color@1.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz" - } - } - }, "ms": { "version": "0.7.1", "from": "ms@0.7.1", "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" }, - "number-is-nan": { - "version": "1.0.0", - "from": "number-is-nan@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.0.tgz" - }, "options": { "version": "0.0.6", "from": "options@>=0.0.5", "resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz" }, - "os-tmpdir": { - "version": "1.0.1", - "from": "os-tmpdir@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.1.tgz" - }, - "path-exists": { - "version": "1.0.0", - "from": "path-exists@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-1.0.0.tgz" - }, - "path-is-absolute": { - "version": "1.0.0", - "from": "path-is-absolute@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" - }, - "private": { - "version": "0.1.6", - "from": "private@>=0.1.6 <0.2.0", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.6.tgz" - }, "regenerator-runtime": { "version": "0.9.5", "from": "regenerator-runtime@>=0.9.5 <0.10.0", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.9.5.tgz" }, - "repeating": { - "version": "1.1.3", - "from": "repeating@>=1.1.0 <2.0.0", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-1.1.3.tgz" - }, "ripemd160": { "version": "1.0.1", "from": "ripemd160@>=1.0.0 <2.0.0", @@ -565,73 +220,16 @@ "from": "sha.js@>=2.3.6 <3.0.0", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.5.tgz" }, - "shebang-regex": { - "version": "1.0.0", - "from": "shebang-regex@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz" - }, - "sigmund": { - "version": "1.0.1", - "from": "sigmund@>=1.0.0 <1.1.0", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz" - }, - "slash": { - "version": "1.0.0", - "from": "slash@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz" - }, - "source-map": { - "version": "0.5.6", - "from": "source-map@>=0.5.0 <0.6.0", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz" - }, - "source-map-support": { - "version": "0.2.10", - "from": "source-map-support@>=0.2.10 <0.3.0", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.2.10.tgz", - "dependencies": { - "source-map": { - "version": "0.1.32", - "from": "source-map@0.1.32", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.32.tgz" - } - } - }, - "strip-ansi": { - "version": "3.0.1", - "from": "strip-ansi@>=3.0.0 <4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz" - }, - "supports-color": { - "version": "2.0.0", - "from": "supports-color@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - }, "through": { "version": "2.3.8", "from": "through@>=2.2.7 <3.0.0", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" }, - "to-fast-properties": { - "version": "1.0.2", - "from": "to-fast-properties@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.2.tgz" - }, - "to-iso-string": { - "version": "0.0.2", - "from": "to-iso-string@0.0.2", - "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz" - }, "ultron": { "version": "1.0.2", "from": "ultron@>=1.0.0 <1.1.0", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz" }, - "user-home": { - "version": "1.1.1", - "from": "user-home@>=1.1.1 <2.0.0", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz" - }, "ws": { "version": "1.1.1", "from": "ws@>=1.0.1 <2.0.0", diff --git a/package.json b/package.json index 89bbaee0..75c5d3b8 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,12 @@ "test": "test" }, "dependencies": { - "ajv": "^4.0.5", - "ajv-i18n": "^1.2.0", "babel-polyfill": "^6.3.14", "babel-runtime": "^6.3.19", "bignumber.js": "^2.0.3", "https-proxy-agent": "^1.0.0", "jayson": "^1.2.2", + "jsonschema": "^1.1.1", "lodash": "^3.1.0", "ripple-address-codec": "^2.0.1", "ripple-binary-codec": "^0.1.10", diff --git a/src/common/schema-validator.js b/src/common/schema-validator.js index 93f717ad..1ad314ff 100644 --- a/src/common/schema-validator.js +++ b/src/common/schema-validator.js @@ -3,7 +3,7 @@ 'use strict' // eslint-disable-line strict const _ = require('lodash') const assert = require('assert') -const Ajv = require('ajv') +const Validator = require('jsonschema').Validator const ValidationError = require('./errors').ValidationError const {isValidAddress} = require('ripple-address-codec') const {isValidSecret} = require('./utils') @@ -114,19 +114,39 @@ function loadSchemas() { const titles = _.map(schemas, schema => schema.title) const duplicates = _.keys(_.pick(_.countBy(titles), count => count > 1)) assert(duplicates.length === 0, 'Duplicate schemas for: ' + duplicates) - const ajv = new Ajv() - _.forEach(schemas, schema => ajv.addSchema(schema, schema.title)) - ajv.addFormat('address', isValidAddress) - ajv.addFormat('secret', isValidSecret) - return ajv + const v = new Validator() + // Register custom format validators that ignore undefined instances + // since jsonschema will still call the format validator on a missing + // (optional) property + v.customFormats.address = function(instance) { + if (instance === undefined) { + return true + } + return isValidAddress(instance) + } + v.customFormats.secret = function(instance) { + if (instance === undefined) { + return true + } + return isValidSecret(instance) + } + + // Register under the root URI '/' + _.forEach(schemas, schema => v.addSchema(schema, '/' + schema.title)) + return v } -const ajv = loadSchemas() +const v = loadSchemas() function schemaValidate(schemaName: string, object: any): void { - const isValid = ajv.validate(schemaName, object) - if (!isValid) { - throw new ValidationError(ajv.errorsText()) + // Lookup under the root URI '/' + const schema = v.getSchema('/' + schemaName) + if (schema === undefined) { + throw new ValidationError('no schema for ' + schemaName) + } + const result = v.validate(object, schema) + if (!result.valid) { + throw new ValidationError(result.errors.join()) } } From f175966816a0e55b706dd674f7b62f95b75ebaf3 Mon Sep 17 00:00:00 2001 From: Brad Chase Date: Fri, 5 May 2017 14:59:15 -0400 Subject: [PATCH 2/2] Make http server dev only --- npm-shrinkwrap.json | 42 ----------------------- package.json | 2 +- scripts/http.js | 6 ++-- src/index.js | 4 +-- test/integration/http-integration-test.js | 2 +- 5 files changed, 6 insertions(+), 50 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index e0450eeb..e2e6c0cd 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -42,11 +42,6 @@ "from": "cipher-base@>=1.0.1 <2.0.0", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.2.tgz" }, - "commander": { - "version": "1.3.2", - "from": "commander@1.3.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-1.3.2.tgz" - }, "core-js": { "version": "2.4.0", "from": "core-js@>=2.4.0 <3.0.0", @@ -84,11 +79,6 @@ "from": "extend@>=3.0.0 <4.0.0", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz" }, - "eyes": { - "version": "0.1.8", - "from": "eyes@0.1.8", - "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz" - }, "hash.js": { "version": "1.0.3", "from": "hash.js@>=1.0.3 <2.0.0", @@ -104,38 +94,11 @@ "from": "inherits@>=2.0.1 <3.0.0", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" }, - "jayson": { - "version": "1.2.2", - "from": "jayson@>=1.2.2 <2.0.0", - "resolved": "https://registry.npmjs.org/jayson/-/jayson-1.2.2.tgz", - "dependencies": { - "lodash": { - "version": "3.6.0", - "from": "lodash@3.6.0", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.6.0.tgz" - } - } - }, - "jsonparse": { - "version": "1.0.0", - "from": "jsonparse@>=1.0.0 <1.1.0", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.0.0.tgz" - }, "jsonschema": { "version": "1.1.1", "from": "jsonschema@latest", "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.1.1.tgz" }, - "JSONStream": { - "version": "1.0.3", - "from": "JSONStream@1.0.3", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.0.3.tgz" - }, - "keypress": { - "version": "0.1.0", - "from": "keypress@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz" - }, "lodash": { "version": "3.10.1", "from": "lodash@>=3.1.0 <4.0.0", @@ -220,11 +183,6 @@ "from": "sha.js@>=2.3.6 <3.0.0", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.5.tgz" }, - "through": { - "version": "2.3.8", - "from": "through@>=2.2.7 <3.0.0", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" - }, "ultron": { "version": "1.0.2", "from": "ultron@>=1.0.0 <1.1.0", diff --git a/package.json b/package.json index 75c5d3b8..2d86286c 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "babel-runtime": "^6.3.19", "bignumber.js": "^2.0.3", "https-proxy-agent": "^1.0.0", - "jayson": "^1.2.2", "jsonschema": "^1.1.1", "lodash": "^3.1.0", "ripple-address-codec": "^2.0.1", @@ -51,6 +50,7 @@ "gulp-uglify": "^1.1.0", "http-server": "^0.8.5", "istanbul": "^1.1.0-alpha.1", + "jayson": "^1.2.2", "json-loader": "^0.5.2", "json-schema-to-markdown-table": "^0.4.0", "mocha": "^2.1.0", diff --git a/scripts/http.js b/scripts/http.js index 1edd8038..9e281d38 100644 --- a/scripts/http.js +++ b/scripts/http.js @@ -1,6 +1,6 @@ -'use strict'; - -const createHTTPServer = require('../src/index').createHTTPServer; +'use strict'; + +const createHTTPServer = require('../src/http').createHTTPServer; const port = 5990; const serverUrl = 'wss://s1.ripple.com'; diff --git a/src/index.js b/src/index.js index cb6abe2c..081de235 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,5 @@ module.exports = { RippleAPI: require('./api').RippleAPI, // Broadcast api is experimental - RippleAPIBroadcast: require('./broadcast').RippleAPIBroadcast, - // HTTP server is experimental - createHTTPServer: require('./http').createHTTPServer + RippleAPIBroadcast: require('./broadcast').RippleAPIBroadcast } diff --git a/test/integration/http-integration-test.js b/test/integration/http-integration-test.js index 55fc797c..3c1b7657 100644 --- a/test/integration/http-integration-test.js +++ b/test/integration/http-integration-test.js @@ -5,7 +5,7 @@ const _ = require('lodash'); const jayson = require('jayson'); const RippleAPI = require('../../src').RippleAPI; -const createHTTPServer = require('../../src/index').createHTTPServer; +const createHTTPServer = require('../../src/http').createHTTPServer; const {payTo, ledgerAccept} = require('./utils'); const apiFixtures = require('../fixtures');