summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile')
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/_rules.js28
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/equal.js45
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/formats.js164
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/index.js390
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/resolve.js267
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/rules.js40
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/schema_obj.js9
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/ucs2length.js20
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/util.js257
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/validation_error.js14
10 files changed, 1234 insertions, 0 deletions
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/_rules.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/_rules.js
new file mode 100644
index 0000000000..c98610e41a
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/_rules.js
@@ -0,0 +1,28 @@
+'use strict';
+
+//all requires must be explicit because browserify won't work with dynamic requires
+module.exports = {
+ '$ref': require('../dotjs/ref'),
+ allOf: require('../dotjs/allOf'),
+ anyOf: require('../dotjs/anyOf'),
+ dependencies: require('../dotjs/dependencies'),
+ 'enum': require('../dotjs/enum'),
+ format: require('../dotjs/format'),
+ items: require('../dotjs/items'),
+ maximum: require('../dotjs/_limit'),
+ minimum: require('../dotjs/_limit'),
+ maxItems: require('../dotjs/_limitItems'),
+ minItems: require('../dotjs/_limitItems'),
+ maxLength: require('../dotjs/_limitLength'),
+ minLength: require('../dotjs/_limitLength'),
+ maxProperties: require('../dotjs/_limitProperties'),
+ minProperties: require('../dotjs/_limitProperties'),
+ multipleOf: require('../dotjs/multipleOf'),
+ not: require('../dotjs/not'),
+ oneOf: require('../dotjs/oneOf'),
+ pattern: require('../dotjs/pattern'),
+ properties: require('../dotjs/properties'),
+ required: require('../dotjs/required'),
+ uniqueItems: require('../dotjs/uniqueItems'),
+ validate: require('../dotjs/validate')
+};
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/equal.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/equal.js
new file mode 100644
index 0000000000..2a918746c2
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/equal.js
@@ -0,0 +1,45 @@
+'use strict';
+
+/*eslint complexity: 0*/
+
+module.exports = function equal(a, b) {
+ if (a === b) return true;
+
+ var arrA = Array.isArray(a)
+ , arrB = Array.isArray(b)
+ , i;
+
+ if (arrA && arrB) {
+ if (a.length != b.length) return false;
+ for (i = 0; i < a.length; i++)
+ if (!equal(a[i], b[i])) return false;
+ return true;
+ }
+
+ if (arrA != arrB) return false;
+
+ if (a && b && typeof a === 'object' && typeof b === 'object') {
+ var keys = Object.keys(a);
+ if (keys.length !== Object.keys(b).length) return false;
+
+ var dateA = a instanceof Date
+ , dateB = b instanceof Date;
+ if (dateA && dateB) return a.getTime() == b.getTime();
+ if (dateA != dateB) return false;
+
+ var regexpA = a instanceof RegExp
+ , regexpB = b instanceof RegExp;
+ if (regexpA && regexpB) return a.toString() == b.toString();
+ if (regexpA != regexpB) return false;
+
+ for (i = 0; i < keys.length; i++)
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
+
+ for (i = 0; i < keys.length; i++)
+ if(!equal(a[keys[i]], b[keys[i]])) return false;
+
+ return true;
+ }
+
+ return false;
+};
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/formats.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/formats.js
new file mode 100644
index 0000000000..415389efe0
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/formats.js
@@ -0,0 +1,164 @@
+'use strict';
+
+var util = require('./util');
+
+var DATE = /^\d\d\d\d-(\d\d)-(\d\d)$/;
+var DAYS = [0,31,29,31,30,31,30,31,31,30,31,30,31];
+var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i;
+var HOSTNAME = /^[0-9a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?(\.[0-9a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?)*$/i;
+var URI = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9a-f]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9a-f]{2})*)?$/i;
+var UUID = /^(?:urn\:uuid\:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
+var JSON_POINTER = /^(?:\/(?:[^~\/]|~0|~1)*)*$|^\#(?:\/(?:[a-z0-9_\-\.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
+var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:\#|(?:\/(?:[^~\/]|~0|~1)*)*)$/;
+
+
+module.exports = formats;
+
+function formats(mode) {
+ mode = mode == 'full' ? 'full' : 'fast';
+ var formatDefs = util.copy(formats[mode]);
+ for (var fName in formats.compare) {
+ formatDefs[fName] = {
+ validate: formatDefs[fName],
+ compare: formats.compare[fName]
+ };
+ }
+ return formatDefs;
+}
+
+
+formats.fast = {
+ // date: http://tools.ietf.org/html/rfc3339#section-5.6
+ date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
+ // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
+ time: /^[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i,
+ 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s][0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i,
+ // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
+ uri: /^(?:[a-z][a-z0-9+-.]*)?(?:\:|\/)\/?[^\s]*$/i,
+ // email (sources from jsen validator):
+ // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
+ // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
+ email: /^[a-z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
+ hostname: HOSTNAME,
+ // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
+ ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
+ // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
+ ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
+ regex: regex,
+ // uuid: http://tools.ietf.org/html/rfc4122
+ uuid: UUID,
+ // JSON-pointer: https://tools.ietf.org/html/rfc6901
+ // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
+ 'json-pointer': JSON_POINTER,
+ // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
+ 'relative-json-pointer': RELATIVE_JSON_POINTER
+};
+
+
+formats.full = {
+ date: date,
+ time: time,
+ 'date-time': date_time,
+ uri: uri,
+ email: /^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&''*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
+ hostname: hostname,
+ ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
+ ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
+ regex: regex,
+ uuid: UUID,
+ 'json-pointer': JSON_POINTER,
+ 'relative-json-pointer': RELATIVE_JSON_POINTER
+};
+
+
+formats.compare = {
+ date: compareDate,
+ time: compareTime,
+ 'date-time': compareDateTime
+};
+
+
+function date(str) {
+ // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
+ var matches = str.match(DATE);
+ if (!matches) return false;
+
+ var month = +matches[1];
+ var day = +matches[2];
+ return month >= 1 && month <= 12 && day >= 1 && day <= DAYS[month];
+}
+
+
+function time(str, full) {
+ var matches = str.match(TIME);
+ if (!matches) return false;
+
+ var hour = matches[1];
+ var minute = matches[2];
+ var second = matches[3];
+ var timeZone = matches[5];
+ return hour <= 23 && minute <= 59 && second <= 59 && (!full || timeZone);
+}
+
+
+var DATE_TIME_SEPARATOR = /t|\s/i;
+function date_time(str) {
+ // http://tools.ietf.org/html/rfc3339#section-5.6
+ var dateTime = str.split(DATE_TIME_SEPARATOR);
+ return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
+}
+
+
+function hostname(str) {
+ // https://tools.ietf.org/html/rfc1034#section-3.5
+ // https://tools.ietf.org/html/rfc1123#section-2
+ return str.length <= 255 && HOSTNAME.test(str);
+}
+
+
+var NOT_URI_FRAGMENT = /\/|\:/;
+function uri(str) {
+ // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
+ return NOT_URI_FRAGMENT.test(str) && URI.test(str);
+}
+
+
+function regex(str) {
+ try {
+ new RegExp(str);
+ return true;
+ } catch(e) {
+ return false;
+ }
+}
+
+
+function compareDate(d1, d2) {
+ if (!(d1 && d2)) return;
+ if (d1 > d2) return 1;
+ if (d1 < d2) return -1;
+ if (d1 === d2) return 0;
+}
+
+
+function compareTime(t1, t2) {
+ if (!(t1 && t2)) return;
+ t1 = t1.match(TIME);
+ t2 = t2.match(TIME);
+ if (!(t1 && t2)) return;
+ t1 = t1[1] + t1[2] + t1[3] + (t1[4]||'');
+ t2 = t2[1] + t2[2] + t2[3] + (t2[4]||'');
+ if (t1 > t2) return 1;
+ if (t1 < t2) return -1;
+ if (t1 === t2) return 0;
+}
+
+
+function compareDateTime(dt1, dt2) {
+ if (!(dt1 && dt2)) return;
+ dt1 = dt1.split(DATE_TIME_SEPARATOR);
+ dt2 = dt2.split(DATE_TIME_SEPARATOR);
+ var res = compareDate(dt1[0], dt2[0]);
+ if (res === undefined) return;
+ return res || compareTime(dt1[1], dt2[1]);
+}
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/index.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/index.js
new file mode 100644
index 0000000000..c9c6730f8a
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/index.js
@@ -0,0 +1,390 @@
+'use strict';
+
+var resolve = require('./resolve')
+ , util = require('./util')
+ , stableStringify = require('json-stable-stringify')
+ , async = require('../async');
+
+var beautify;
+
+function loadBeautify(){
+ if (beautify === undefined) {
+ var name = 'js-beautify';
+ try { beautify = require(name).js_beautify; }
+ catch(e) { beautify = false; }
+ }
+}
+
+var validateGenerator = require('../dotjs/validate');
+
+/**
+ * Functions below are used inside compiled validations function
+ */
+
+var co = require('co');
+var ucs2length = util.ucs2length;
+var equal = require('./equal');
+
+// this error is thrown by async schemas to return validation errors via exception
+var ValidationError = require('./validation_error');
+
+module.exports = compile;
+
+
+/**
+ * Compiles schema to validation function
+ * @this Ajv
+ * @param {Object} schema schema object
+ * @param {Object} root object with information about the root schema for this schema
+ * @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
+ * @param {String} baseId base ID for IDs in the schema
+ * @return {Function} validation function
+ */
+function compile(schema, root, localRefs, baseId) {
+ /* jshint validthis: true, evil: true */
+ /* eslint no-shadow: 0 */
+ var self = this
+ , opts = this._opts
+ , refVal = [ undefined ]
+ , refs = {}
+ , patterns = []
+ , patternsHash = {}
+ , defaults = []
+ , defaultsHash = {}
+ , customRules = []
+ , keepSourceCode = opts.sourceCode !== false;
+
+ root = root || { schema: schema, refVal: refVal, refs: refs };
+
+ var c = checkCompiling.call(this, schema, root, baseId);
+ var compilation = this._compilations[c.index];
+ if (c.compiling) return (compilation.callValidate = callValidate);
+
+ var formats = this._formats;
+ var RULES = this.RULES;
+
+ try {
+ var v = localCompile(schema, root, localRefs, baseId);
+ compilation.validate = v;
+ var cv = compilation.callValidate;
+ if (cv) {
+ cv.schema = v.schema;
+ cv.errors = null;
+ cv.refs = v.refs;
+ cv.refVal = v.refVal;
+ cv.root = v.root;
+ cv.$async = v.$async;
+ if (keepSourceCode) cv.sourceCode = v.sourceCode;
+ }
+ return v;
+ } finally {
+ endCompiling.call(this, schema, root, baseId);
+ }
+
+ function callValidate() {
+ var validate = compilation.validate;
+ var result = validate.apply(null, arguments);
+ callValidate.errors = validate.errors;
+ return result;
+ }
+
+ function localCompile(_schema, _root, localRefs, baseId) {
+ var isRoot = !_root || (_root && _root.schema == _schema);
+ if (_root.schema != root.schema)
+ return compile.call(self, _schema, _root, localRefs, baseId);
+
+ var $async = _schema.$async === true;
+ if ($async && !opts.transpile) async.setup(opts);
+
+ var sourceCode = validateGenerator({
+ isTop: true,
+ schema: _schema,
+ isRoot: isRoot,
+ baseId: baseId,
+ root: _root,
+ schemaPath: '',
+ errSchemaPath: '#',
+ errorPath: '""',
+ RULES: RULES,
+ validate: validateGenerator,
+ util: util,
+ resolve: resolve,
+ resolveRef: resolveRef,
+ usePattern: usePattern,
+ useDefault: useDefault,
+ useCustomRule: useCustomRule,
+ opts: opts,
+ formats: formats,
+ self: self
+ });
+
+ sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode)
+ + vars(defaults, defaultCode) + vars(customRules, customRuleCode)
+ + sourceCode;
+
+ if (opts.beautify) {
+ loadBeautify();
+ /* istanbul ignore else */
+ if (beautify) sourceCode = beautify(sourceCode, opts.beautify);
+ else console.error('"npm install js-beautify" to use beautify option');
+ }
+ // console.log('\n\n\n *** \n', sourceCode);
+ var validate, validateCode
+ , transpile = opts._transpileFunc;
+ try {
+ validateCode = $async && transpile
+ ? transpile(sourceCode)
+ : sourceCode;
+
+ var makeValidate = new Function(
+ 'self',
+ 'RULES',
+ 'formats',
+ 'root',
+ 'refVal',
+ 'defaults',
+ 'customRules',
+ 'co',
+ 'equal',
+ 'ucs2length',
+ 'ValidationError',
+ validateCode
+ );
+
+ validate = makeValidate(
+ self,
+ RULES,
+ formats,
+ root,
+ refVal,
+ defaults,
+ customRules,
+ co,
+ equal,
+ ucs2length,
+ ValidationError
+ );
+
+ refVal[0] = validate;
+ } catch(e) {
+ console.error('Error compiling schema, function code:', validateCode);
+ throw e;
+ }
+
+ validate.schema = _schema;
+ validate.errors = null;
+ validate.refs = refs;
+ validate.refVal = refVal;
+ validate.root = isRoot ? validate : _root;
+ if ($async) validate.$async = true;
+ if (keepSourceCode) validate.sourceCode = sourceCode;
+ if (opts.sourceCode === true) {
+ validate.source = {
+ patterns: patterns,
+ defaults: defaults
+ };
+ }
+
+ return validate;
+ }
+
+ function resolveRef(baseId, ref, isRoot) {
+ ref = resolve.url(baseId, ref);
+ var refIndex = refs[ref];
+ var _refVal, refCode;
+ if (refIndex !== undefined) {
+ _refVal = refVal[refIndex];
+ refCode = 'refVal[' + refIndex + ']';
+ return resolvedRef(_refVal, refCode);
+ }
+ if (!isRoot && root.refs) {
+ var rootRefId = root.refs[ref];
+ if (rootRefId !== undefined) {
+ _refVal = root.refVal[rootRefId];
+ refCode = addLocalRef(ref, _refVal);
+ return resolvedRef(_refVal, refCode);
+ }
+ }
+
+ refCode = addLocalRef(ref);
+ var v = resolve.call(self, localCompile, root, ref);
+ if (!v) {
+ var localSchema = localRefs && localRefs[ref];
+ if (localSchema) {
+ v = resolve.inlineRef(localSchema, opts.inlineRefs)
+ ? localSchema
+ : compile.call(self, localSchema, root, localRefs, baseId);
+ }
+ }
+
+ if (v) {
+ replaceLocalRef(ref, v);
+ return resolvedRef(v, refCode);
+ }
+ }
+
+ function addLocalRef(ref, v) {
+ var refId = refVal.length;
+ refVal[refId] = v;
+ refs[ref] = refId;
+ return 'refVal' + refId;
+ }
+
+ function replaceLocalRef(ref, v) {
+ var refId = refs[ref];
+ refVal[refId] = v;
+ }
+
+ function resolvedRef(refVal, code) {
+ return typeof refVal == 'object'
+ ? { code: code, schema: refVal, inline: true }
+ : { code: code, $async: refVal && refVal.$async };
+ }
+
+ function usePattern(regexStr) {
+ var index = patternsHash[regexStr];
+ if (index === undefined) {
+ index = patternsHash[regexStr] = patterns.length;
+ patterns[index] = regexStr;
+ }
+ return 'pattern' + index;
+ }
+
+ function useDefault(value) {
+ switch (typeof value) {
+ case 'boolean':
+ case 'number':
+ return '' + value;
+ case 'string':
+ return util.toQuotedString(value);
+ case 'object':
+ if (value === null) return 'null';
+ var valueStr = stableStringify(value);
+ var index = defaultsHash[valueStr];
+ if (index === undefined) {
+ index = defaultsHash[valueStr] = defaults.length;
+ defaults[index] = value;
+ }
+ return 'default' + index;
+ }
+ }
+
+ function useCustomRule(rule, schema, parentSchema, it) {
+ var validateSchema = rule.definition.validateSchema;
+ if (validateSchema && self._opts.validateSchema !== false) {
+ var valid = validateSchema(schema);
+ if (!valid) {
+ var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
+ if (self._opts.validateSchema == 'log') console.error(message);
+ else throw new Error(message);
+ }
+ }
+
+ var compile = rule.definition.compile
+ , inline = rule.definition.inline
+ , macro = rule.definition.macro;
+
+ var validate;
+ if (compile) {
+ validate = compile.call(self, schema, parentSchema, it);
+ } else if (macro) {
+ validate = macro.call(self, schema, parentSchema, it);
+ if (opts.validateSchema !== false) self.validateSchema(validate, true);
+ } else if (inline) {
+ validate = inline.call(self, it, rule.keyword, schema, parentSchema);
+ } else {
+ validate = rule.definition.validate;
+ }
+
+ var index = customRules.length;
+ customRules[index] = validate;
+
+ return {
+ code: 'customRule' + index,
+ validate: validate
+ };
+ }
+}
+
+
+/**
+ * Checks if the schema is currently compiled
+ * @this Ajv
+ * @param {Object} schema schema to compile
+ * @param {Object} root root object
+ * @param {String} baseId base schema ID
+ * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
+ */
+function checkCompiling(schema, root, baseId) {
+ /* jshint validthis: true */
+ var index = compIndex.call(this, schema, root, baseId);
+ if (index >= 0) return { index: index, compiling: true };
+ index = this._compilations.length;
+ this._compilations[index] = {
+ schema: schema,
+ root: root,
+ baseId: baseId
+ };
+ return { index: index, compiling: false };
+}
+
+
+/**
+ * Removes the schema from the currently compiled list
+ * @this Ajv
+ * @param {Object} schema schema to compile
+ * @param {Object} root root object
+ * @param {String} baseId base schema ID
+ */
+function endCompiling(schema, root, baseId) {
+ /* jshint validthis: true */
+ var i = compIndex.call(this, schema, root, baseId);
+ if (i >= 0) this._compilations.splice(i, 1);
+}
+
+
+/**
+ * Index of schema compilation in the currently compiled list
+ * @this Ajv
+ * @param {Object} schema schema to compile
+ * @param {Object} root root object
+ * @param {String} baseId base schema ID
+ * @return {Integer} compilation index
+ */
+function compIndex(schema, root, baseId) {
+ /* jshint validthis: true */
+ for (var i=0; i<this._compilations.length; i++) {
+ var c = this._compilations[i];
+ if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
+ }
+ return -1;
+}
+
+
+function patternCode(i, patterns) {
+ return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
+}
+
+
+function defaultCode(i) {
+ return 'var default' + i + ' = defaults[' + i + '];';
+}
+
+
+function refValCode(i, refVal) {
+ return refVal[i] ? 'var refVal' + i + ' = refVal[' + i + '];' : '';
+}
+
+
+function customRuleCode(i) {
+ return 'var customRule' + i + ' = customRules[' + i + '];';
+}
+
+
+function vars(arr, statement) {
+ if (!arr.length) return '';
+ var code = '';
+ for (var i=0; i<arr.length; i++)
+ code += statement(i, arr);
+ return code;
+}
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/resolve.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/resolve.js
new file mode 100644
index 0000000000..db2b91fbf1
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/resolve.js
@@ -0,0 +1,267 @@
+'use strict';
+
+var url = require('url')
+ , equal = require('./equal')
+ , util = require('./util')
+ , SchemaObject = require('./schema_obj');
+
+module.exports = resolve;
+
+resolve.normalizeId = normalizeId;
+resolve.fullPath = getFullPath;
+resolve.url = resolveUrl;
+resolve.ids = resolveIds;
+resolve.inlineRef = inlineRef;
+resolve.schema = resolveSchema;
+
+/**
+ * [resolve and compile the references ($ref)]
+ * @this Ajv
+ * @param {Function} compile reference to schema compilation funciton (localCompile)
+ * @param {Object} root object with information about the root schema for the current schema
+ * @param {String} ref reference to resolve
+ * @return {Object|Function} schema object (if the schema can be inlined) or validation function
+ */
+function resolve(compile, root, ref) {
+ /* jshint validthis: true */
+ var refVal = this._refs[ref];
+ if (typeof refVal == 'string') {
+ if (this._refs[refVal]) refVal = this._refs[refVal];
+ else return resolve.call(this, compile, root, refVal);
+ }
+
+ refVal = refVal || this._schemas[ref];
+ if (refVal instanceof SchemaObject) {
+ return inlineRef(refVal.schema, this._opts.inlineRefs)
+ ? refVal.schema
+ : refVal.validate || this._compile(refVal);
+ }
+
+ var res = resolveSchema.call(this, root, ref);
+ var schema, v, baseId;
+ if (res) {
+ schema = res.schema;
+ root = res.root;
+ baseId = res.baseId;
+ }
+
+ if (schema instanceof SchemaObject) {
+ v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
+ } else if (schema) {
+ v = inlineRef(schema, this._opts.inlineRefs)
+ ? schema
+ : compile.call(this, schema, root, undefined, baseId);
+ }
+
+ return v;
+}
+
+
+/**
+ * Resolve schema, its root and baseId
+ * @this Ajv
+ * @param {Object} root root object with properties schema, refVal, refs
+ * @param {String} ref reference to resolve
+ * @return {Object} object with properties schema, root, baseId
+ */
+function resolveSchema(root, ref) {
+ /* jshint validthis: true */
+ var p = url.parse(ref, false, true)
+ , refPath = _getFullPath(p)
+ , baseId = getFullPath(root.schema.id);
+ if (refPath !== baseId) {
+ var id = normalizeId(refPath);
+ var refVal = this._refs[id];
+ if (typeof refVal == 'string') {
+ return resolveRecursive.call(this, root, refVal, p);
+ } else if (refVal instanceof SchemaObject) {
+ if (!refVal.validate) this._compile(refVal);
+ root = refVal;
+ } else {
+ refVal = this._schemas[id];
+ if (refVal instanceof SchemaObject) {
+ if (!refVal.validate) this._compile(refVal);
+ if (id == normalizeId(ref))
+ return { schema: refVal, root: root, baseId: baseId };
+ root = refVal;
+ } else {
+ return;
+ }
+ }
+ if (!root.schema) return;
+ baseId = getFullPath(root.schema.id);
+ }
+ return getJsonPointer.call(this, p, baseId, root.schema, root);
+}
+
+
+/* @this Ajv */
+function resolveRecursive(root, ref, parsedRef) {
+ /* jshint validthis: true */
+ var res = resolveSchema.call(this, root, ref);
+ if (res) {
+ var schema = res.schema;
+ var baseId = res.baseId;
+ root = res.root;
+ if (schema.id) baseId = resolveUrl(baseId, schema.id);
+ return getJsonPointer.call(this, parsedRef, baseId, schema, root);
+ }
+}
+
+
+var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
+/* @this Ajv */
+function getJsonPointer(parsedRef, baseId, schema, root) {
+ /* jshint validthis: true */
+ parsedRef.hash = parsedRef.hash || '';
+ if (parsedRef.hash.slice(0,2) != '#/') return;
+ var parts = parsedRef.hash.split('/');
+
+ for (var i = 1; i < parts.length; i++) {
+ var part = parts[i];
+ if (part) {
+ part = util.unescapeFragment(part);
+ schema = schema[part];
+ if (!schema) break;
+ if (schema.id && !PREVENT_SCOPE_CHANGE[part]) baseId = resolveUrl(baseId, schema.id);
+ if (schema.$ref) {
+ var $ref = resolveUrl(baseId, schema.$ref);
+ var res = resolveSchema.call(this, root, $ref);
+ if (res) {
+ schema = res.schema;
+ root = res.root;
+ baseId = res.baseId;
+ }
+ }
+ }
+ }
+ if (schema && schema != root.schema)
+ return { schema: schema, root: root, baseId: baseId };
+}
+
+
+var SIMPLE_INLINED = util.toHash([
+ 'type', 'format', 'pattern',
+ 'maxLength', 'minLength',
+ 'maxProperties', 'minProperties',
+ 'maxItems', 'minItems',
+ 'maximum', 'minimum',
+ 'uniqueItems', 'multipleOf',
+ 'required', 'enum'
+]);
+function inlineRef(schema, limit) {
+ if (limit === false) return false;
+ if (limit === undefined || limit === true) return checkNoRef(schema);
+ else if (limit) return countKeys(schema) <= limit;
+}
+
+
+function checkNoRef(schema) {
+ var item;
+ if (Array.isArray(schema)) {
+ for (var i=0; i<schema.length; i++) {
+ item = schema[i];
+ if (typeof item == 'object' && !checkNoRef(item)) return false;
+ }
+ } else {
+ for (var key in schema) {
+ if (key == '$ref') return false;
+ item = schema[key];
+ if (typeof item == 'object' && !checkNoRef(item)) return false;
+ }
+ }
+ return true;
+}
+
+
+function countKeys(schema) {
+ var count = 0, item;
+ if (Array.isArray(schema)) {
+ for (var i=0; i<schema.length; i++) {
+ item = schema[i];
+ if (typeof item == 'object') count += countKeys(item);
+ if (count == Infinity) return Infinity;
+ }
+ } else {
+ for (var key in schema) {
+ if (key == '$ref') return Infinity;
+ if (SIMPLE_INLINED[key]) {
+ count++;
+ } else {
+ item = schema[key];
+ if (typeof item == 'object') count += countKeys(item) + 1;
+ if (count == Infinity) return Infinity;
+ }
+ }
+ }
+ return count;
+}
+
+
+function getFullPath(id, normalize) {
+ if (normalize !== false) id = normalizeId(id);
+ var p = url.parse(id, false, true);
+ return _getFullPath(p);
+}
+
+
+function _getFullPath(p) {
+ var protocolSeparator = p.protocol || p.href.slice(0,2) == '//' ? '//' : '';
+ return (p.protocol||'') + protocolSeparator + (p.host||'') + (p.path||'') + '#';
+}
+
+
+var TRAILING_SLASH_HASH = /#\/?$/;
+function normalizeId(id) {
+ return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
+}
+
+
+function resolveUrl(baseId, id) {
+ id = normalizeId(id);
+ return url.resolve(baseId, id);
+}
+
+
+/* @this Ajv */
+function resolveIds(schema) {
+ /* eslint no-shadow: 0 */
+ /* jshint validthis: true */
+ var id = normalizeId(schema.id);
+ var localRefs = {};
+ _resolveIds.call(this, schema, getFullPath(id, false), id);
+ return localRefs;
+
+ /* @this Ajv */
+ function _resolveIds(schema, fullPath, baseId) {
+ /* jshint validthis: true */
+ if (Array.isArray(schema)) {
+ for (var i=0; i<schema.length; i++)
+ _resolveIds.call(this, schema[i], fullPath+'/'+i, baseId);
+ } else if (schema && typeof schema == 'object') {
+ if (typeof schema.id == 'string') {
+ var id = baseId = baseId
+ ? url.resolve(baseId, schema.id)
+ : schema.id;
+ id = normalizeId(id);
+
+ var refVal = this._refs[id];
+ if (typeof refVal == 'string') refVal = this._refs[refVal];
+ if (refVal && refVal.schema) {
+ if (!equal(schema, refVal.schema))
+ throw new Error('id "' + id + '" resolves to more than one schema');
+ } else if (id != normalizeId(fullPath)) {
+ if (id[0] == '#') {
+ if (localRefs[id] && !equal(schema, localRefs[id]))
+ throw new Error('id "' + id + '" resolves to more than one schema');
+ localRefs[id] = schema;
+ } else {
+ this._refs[id] = fullPath;
+ }
+ }
+ }
+ for (var key in schema)
+ _resolveIds.call(this, schema[key], fullPath+'/'+util.escapeFragment(key), baseId);
+ }
+ }
+}
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/rules.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/rules.js
new file mode 100644
index 0000000000..39b1708d96
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/rules.js
@@ -0,0 +1,40 @@
+'use strict';
+
+var ruleModules = require('./_rules')
+ , toHash = require('./util').toHash;
+
+module.exports = function rules() {
+ var RULES = [
+ { type: 'number',
+ rules: [ 'maximum', 'minimum', 'multipleOf'] },
+ { type: 'string',
+ rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
+ { type: 'array',
+ rules: [ 'maxItems', 'minItems', 'uniqueItems', 'items' ] },
+ { type: 'object',
+ rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'properties' ] },
+ { rules: [ '$ref', 'enum', 'not', 'anyOf', 'oneOf', 'allOf' ] }
+ ];
+
+ var ALL = [ 'type', 'additionalProperties', 'patternProperties' ];
+ var KEYWORDS = [ 'additionalItems', '$schema', 'id', 'title', 'description', 'default' ];
+ var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
+ RULES.all = toHash(ALL);
+
+ RULES.forEach(function (group) {
+ group.rules = group.rules.map(function (keyword) {
+ ALL.push(keyword);
+ var rule = RULES.all[keyword] = {
+ keyword: keyword,
+ code: ruleModules[keyword]
+ };
+ return rule;
+ });
+ });
+
+ RULES.keywords = toHash(ALL.concat(KEYWORDS));
+ RULES.types = toHash(TYPES);
+ RULES.custom = {};
+
+ return RULES;
+};
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/schema_obj.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/schema_obj.js
new file mode 100644
index 0000000000..e7903b0f46
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/schema_obj.js
@@ -0,0 +1,9 @@
+'use strict';
+
+var util = require('./util');
+
+module.exports = SchemaObject;
+
+function SchemaObject(obj) {
+ util.copy(obj, this);
+}
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/ucs2length.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/ucs2length.js
new file mode 100644
index 0000000000..d193fb1700
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/ucs2length.js
@@ -0,0 +1,20 @@
+'use strict';
+
+// https://mathiasbynens.be/notes/javascript-encoding
+// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
+module.exports = function ucs2length(str) {
+ var length = 0
+ , len = str.length
+ , pos = 0
+ , value;
+ while (pos < len) {
+ length++;
+ value = str.charCodeAt(pos++);
+ if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
+ // high surrogate, and there is a next character
+ value = str.charCodeAt(pos);
+ if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
+ }
+ }
+ return length;
+};
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/util.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/util.js
new file mode 100644
index 0000000000..8451f83ae2
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/util.js
@@ -0,0 +1,257 @@
+'use strict';
+
+
+module.exports = {
+ copy: copy,
+ checkDataType: checkDataType,
+ checkDataTypes: checkDataTypes,
+ coerceToTypes: coerceToTypes,
+ toHash: toHash,
+ getProperty: getProperty,
+ escapeQuotes: escapeQuotes,
+ ucs2length: require('./ucs2length'),
+ varOccurences: varOccurences,
+ varReplace: varReplace,
+ cleanUpCode: cleanUpCode,
+ cleanUpVarErrors: cleanUpVarErrors,
+ schemaHasRules: schemaHasRules,
+ schemaHasRulesExcept: schemaHasRulesExcept,
+ stableStringify: require('json-stable-stringify'),
+ toQuotedString: toQuotedString,
+ getPathExpr: getPathExpr,
+ getPath: getPath,
+ getData: getData,
+ unescapeFragment: unescapeFragment,
+ escapeFragment: escapeFragment,
+ escapeJsonPointer: escapeJsonPointer
+};
+
+
+function copy(o, to) {
+ to = to || {};
+ for (var key in o) to[key] = o[key];
+ return to;
+}
+
+
+function checkDataType(dataType, data, negate) {
+ var EQUAL = negate ? ' !== ' : ' === '
+ , AND = negate ? ' || ' : ' && '
+ , OK = negate ? '!' : ''
+ , NOT = negate ? '' : '!';
+ switch (dataType) {
+ case 'null': return data + EQUAL + 'null';
+ case 'array': return OK + 'Array.isArray(' + data + ')';
+ case 'object': return '(' + OK + data + AND +
+ 'typeof ' + data + EQUAL + '"object"' + AND +
+ NOT + 'Array.isArray(' + data + '))';
+ case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
+ NOT + '(' + data + ' % 1)' +
+ AND + data + EQUAL + data + ')';
+ default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
+ }
+}
+
+
+function checkDataTypes(dataTypes, data) {
+ switch (dataTypes.length) {
+ case 1: return checkDataType(dataTypes[0], data, true);
+ default:
+ var code = '';
+ var types = toHash(dataTypes);
+ if (types.array && types.object) {
+ code = types.null ? '(': '(!' + data + ' || ';
+ code += 'typeof ' + data + ' !== "object")';
+ delete types.null;
+ delete types.array;
+ delete types.object;
+ }
+ if (types.number) delete types.integer;
+ for (var t in types)
+ code += (code ? ' && ' : '' ) + checkDataType(t, data, true);
+
+ return code;
+ }
+}
+
+
+var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
+function coerceToTypes(optionCoerceTypes, dataTypes) {
+ if (Array.isArray(dataTypes)) {
+ var types = [];
+ for (var i=0; i<dataTypes.length; i++) {
+ var t = dataTypes[i];
+ if (COERCE_TO_TYPES[t]) types[types.length] = t;
+ else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
+ }
+ if (types.length) return types;
+ } else if (COERCE_TO_TYPES[dataTypes]) {
+ return [dataTypes];
+ } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
+ return ['array'];
+ }
+}
+
+
+function toHash(arr) {
+ var hash = {};
+ for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
+ return hash;
+}
+
+
+var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
+var SINGLE_QUOTE = /'|\\/g;
+function getProperty(key) {
+ return typeof key == 'number'
+ ? '[' + key + ']'
+ : IDENTIFIER.test(key)
+ ? '.' + key
+ : "['" + escapeQuotes(key) + "']";
+}
+
+
+function escapeQuotes(str) {
+ return str.replace(SINGLE_QUOTE, '\\$&')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r')
+ .replace(/\f/g, '\\f')
+ .replace(/\t/g, '\\t');
+}
+
+
+function varOccurences(str, dataVar) {
+ dataVar += '[^0-9]';
+ var matches = str.match(new RegExp(dataVar, 'g'));
+ return matches ? matches.length : 0;
+}
+
+
+function varReplace(str, dataVar, expr) {
+ dataVar += '([^0-9])';
+ expr = expr.replace(/\$/g, '$$$$');
+ return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
+}
+
+
+var EMPTY_ELSE = /else\s*{\s*}/g
+ , EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
+ , EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
+function cleanUpCode(out) {
+ return out.replace(EMPTY_ELSE, '')
+ .replace(EMPTY_IF_NO_ELSE, '')
+ .replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
+}
+
+
+var ERRORS_REGEXP = /[^v\.]errors/g
+ , REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
+ , REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
+ , RETURN_VALID = 'return errors === 0;'
+ , RETURN_TRUE = 'validate.errors = null; return true;'
+ , RETURN_ASYNC = /if \(errors === 0\) return true;\s*else throw new ValidationError\(vErrors\);/
+ , RETURN_TRUE_ASYNC = 'return true;';
+
+function cleanUpVarErrors(out, async) {
+ var matches = out.match(ERRORS_REGEXP);
+ if (!matches || matches.length !== 2) return out;
+ return async
+ ? out.replace(REMOVE_ERRORS_ASYNC, '')
+ .replace(RETURN_ASYNC, RETURN_TRUE_ASYNC)
+ : out.replace(REMOVE_ERRORS, '')
+ .replace(RETURN_VALID, RETURN_TRUE);
+}
+
+
+function schemaHasRules(schema, rules) {
+ for (var key in schema) if (rules[key]) return true;
+}
+
+
+function schemaHasRulesExcept(schema, rules, exceptKeyword) {
+ for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
+}
+
+
+function toQuotedString(str) {
+ return '\'' + escapeQuotes(str) + '\'';
+}
+
+
+function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
+ var path = jsonPointers // false by default
+ ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
+ : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
+ return joinPaths(currentPath, path);
+}
+
+
+function getPath(currentPath, prop, jsonPointers) {
+ var path = jsonPointers // false by default
+ ? toQuotedString('/' + escapeJsonPointer(prop))
+ : toQuotedString(getProperty(prop));
+ return joinPaths(currentPath, path);
+}
+
+
+var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
+var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
+function getData($data, lvl, paths) {
+ var up, jsonPointer, data, matches;
+ if ($data === '') return 'rootData';
+ if ($data[0] == '/') {
+ if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
+ jsonPointer = $data;
+ data = 'rootData';
+ } else {
+ matches = $data.match(RELATIVE_JSON_POINTER);
+ if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
+ up = +matches[1];
+ jsonPointer = matches[2];
+ if (jsonPointer == '#') {
+ if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
+ return paths[lvl - up];
+ }
+
+ if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
+ data = 'data' + ((lvl - up) || '');
+ if (!jsonPointer) return data;
+ }
+
+ var expr = data;
+ var segments = jsonPointer.split('/');
+ for (var i=0; i<segments.length; i++) {
+ var segment = segments[i];
+ if (segment) {
+ data += getProperty(unescapeJsonPointer(segment));
+ expr += ' && ' + data;
+ }
+ }
+ return expr;
+}
+
+
+function joinPaths (a, b) {
+ if (a == '""') return b;
+ return (a + ' + ' + b).replace(/' \+ '/g, '');
+}
+
+
+function unescapeFragment(str) {
+ return unescapeJsonPointer(decodeURIComponent(str));
+}
+
+
+function escapeFragment(str) {
+ return encodeURIComponent(escapeJsonPointer(str));
+}
+
+
+function escapeJsonPointer(str) {
+ return str.replace(/~/g, '~0').replace(/\//g, '~1');
+}
+
+
+function unescapeJsonPointer(str) {
+ return str.replace(/~1/g, '/').replace(/~0/g, '~');
+}
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/validation_error.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/validation_error.js
new file mode 100644
index 0000000000..3c5c59478c
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/compile/validation_error.js
@@ -0,0 +1,14 @@
+'use strict';
+
+module.exports = ValidationError;
+
+
+function ValidationError(errors) {
+ this.message = 'validation failed';
+ this.errors = errors;
+ this.ajv = this.validation = true;
+}
+
+
+ValidationError.prototype = Object.create(Error.prototype);
+ValidationError.prototype.constructor = ValidationError;