diff --git a/CHANGELOG b/CHANGELOG index dd3df59631..8d463fe74e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ v3.4.0-rc.5 (XXXX-XX-XX) ------------------------ +* Updated joi library (Web UI), improved foxx mount path validation + * disable startup warning for Linux kernel variable `vm.overcommit_memory` settings values of 0 or 1. Effectively `overcommit_memory` settings value of 0 or 1 fix two memory-allocation diff --git a/js/apps/system/_admin/aardvark/APP/GruntFile.js b/js/apps/system/_admin/aardvark/APP/GruntFile.js index 9c0886e113..b928615b81 100644 --- a/js/apps/system/_admin/aardvark/APP/GruntFile.js +++ b/js/apps/system/_admin/aardvark/APP/GruntFile.js @@ -92,7 +92,7 @@ "frontend/js/lib/bootstrap-pagination.min.js", "frontend/js/lib/jqconsole.min.js", "frontend/js/lib/highlight.js", - "frontend/js/lib/joi.browser.js", + "frontend/js/lib/joi-browser.min.js", "frontend/js/lib/md5.min.js", "frontend/js/lib/pretty-bytes.js", "frontend/js/lib/marked.min.js", diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js b/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js index 473acd2b38..a9f6269aa8 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js @@ -1233,8 +1233,8 @@ validateInput: function () { return [ { - rule: Joi.string().regex(/^(\/(APP[^\/]+|(?!APP)[a-zA-Z0-9_\-\/]+))+$/i), - msg: 'May not contain /APP' + rule: Joi.string().regex(/(\/|^)APP(\/|$)/i, {invert: true}), + msg: 'May not contain APP' }, { rule: Joi.string().regex(/^([a-zA-Z0-9_\-\/]+)+$/), diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/lib/joi-browser.min.js b/js/apps/system/_admin/aardvark/APP/frontend/js/lib/joi-browser.min.js new file mode 100644 index 0000000000..7a3f36acb4 --- /dev/null +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/lib/joi-browser.min.js @@ -0,0 +1,6 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Joi",[],t):"object"==typeof exports?exports.Joi=t():e.Joi=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=32)}([function(e,t,r){"use strict";(function(e,n){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(17),a=r(15),s=r(37),u=r(16),c=r(18),l={};t.clone=function(r,n){if("object"!==(void 0===r?"undefined":i(r))||null===r)return r;n=n||new Map;var o=n.get(r);if(o)return o;var a=void 0,s=!1;if(Array.isArray(r))a=[],s=!0;else if(e.isBuffer(r))a=e.from(r);else if(r instanceof Date)a=new Date(r.getTime());else if(r instanceof RegExp)a=new RegExp(r);else{var u=Object.getPrototypeOf(r);u&&u.isImmutable?a=r:(a=Object.create(u),s=!0)}if(n.set(r,a),s)for(var c=Object.getOwnPropertyNames(r),l=0;l1||!n.part&&!f[j])return!1;return(!n.only||!l)&&A},t.flatten=function(e,r){for(var n=r||[],i=0;i1?r-1:0),i=1;i\?@\[\]\^`\{\|\}~\"\\]*$/.test(e),"Bad attribute value ("+e+")"),e.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')},t.escapeHtml=function(e){return c.escapeHtml(e)},t.escapeJavaScript=function(e){return c.escapeJavaScript(e)},t.escapeJson=function(e){return c.escapeJson(e)},t.once=function(e){if(e._hoekOnce)return e;var t=!1,r=function(){if(!t){t=!0;for(var r=arguments.length,n=Array(r),i=0;i1;)d=p.shift(),g[d]||(g[d]={}),g=g[d];d=p.shift(),g[d]=t.reach(e,h,n)}return u},t.uniqueFilename=function(e,t){t=t?"."!==t[0]?"."+t:t:"",e=s.resolve(e);var r=[Date.now(),n.pid,a.randomBytes(8).toString("hex")].join("-")+t;return s.join(e,r)},t.stringify=function(){try{for(var e=arguments.length,t=Array(e),r=0;r4&&void 0!==arguments[4]?arguments[4]:this._flags;return c.create(e,t,r,n,i)},e.prototype.createOverrideError=function(e,t,r,n,i,o){return c.create(e,t,r,n,this._flags,i,o)},e.prototype.checkOptions=function(e){var t=r(21),n=t.options.validate(e);if(n.error)throw new Error(n.error.details[0].message)},e.prototype.clone=function(){var e=Object.create(Object.getPrototypeOf(this));e.isJoi=!0,e._currentJoi=this._currentJoi,e._type=this._type,e._settings=this._settings,e._baseType=this._baseType,e._valids=this._valids.slice(),e._invalids=this._invalids.slice(),e._tests=this._tests.slice(),e._refs=this._refs.slice(),e._flags=a.clone(this._flags),e._description=this._description,e._unit=this._unit,e._notes=this._notes.slice(),e._tags=this._tags.slice(),e._examples=this._examples.slice(),e._meta=this._meta.slice(),e._inner={};for(var t=Object.keys(this._inner),r=0;r=0?h[d[v]]={key:v,schema:h[d[v]].schema.concat(f[y].schema)}:h.push(f[y])}}else t._inner[l]=t._inner[l].concat(f);else t._inner[l]=f.slice()}}return t},e.prototype._test=function(e,t,r,n){var i=this.clone();return i._tests.push({func:r,name:e,arg:t,options:n}),i},e.prototype.options=function(e){a.assert(!e.context,"Cannot override context"),this.checkOptions(e);var t=this.clone();return t._settings=s.concat(t._settings,e),t},e.prototype.strict=function(e){var t=this.clone(),r=void 0!==e&&!e;return t._settings=s.concat(t._settings,{convert:r}),t},e.prototype.raw=function(e){var t=void 0===e||e;if(this._flags.raw===t)return this;var r=this.clone();return r._flags.raw=t,r},e.prototype.error=function(e){a.assert(e&&(e instanceof Error||"function"==typeof e),"Must provide a valid Error object or a function");var t=this.clone();return t._flags.error=e,t},e.prototype.allow=function(){for(var e=arguments.length,t=Array(e),r=0;r0,"description must be provided when default value is a function"));var r=this.clone();return r._flags.default=e,u.push(r._refs,e),r},e.prototype.empty=function(e){var t=this.clone();return void 0===e?delete t._flags.empty:t._flags.empty=f.schema(this._currentJoi,e),t},e.prototype.when=function(e,t){a.assert(t&&"object"===(void 0===t?"undefined":i(t)),"Invalid options"),a.assert(void 0!==t.then||void 0!==t.otherwise,'options must have at least one of "then" or "otherwise"');var n=t.hasOwnProperty("then")?this.concat(f.schema(this._currentJoi,t.then)):void 0,o=t.hasOwnProperty("otherwise")?this.concat(f.schema(this._currentJoi,t.otherwise)):void 0;l=l||r(10);var s={then:n,otherwise:o};Object.prototype.hasOwnProperty.call(t,"is")&&(s.is=t.is);var u=l.when(e,s);return u._flags.presence="ignore",u._baseType=this,u},e.prototype.description=function(e){a.assert(e&&"string"==typeof e,"Description must be a non-empty string");var t=this.clone();return t._description=e,t},e.prototype.notes=function(e){a.assert(e&&("string"==typeof e||Array.isArray(e)),"Notes must be a non-empty string or array");var t=this.clone();return t._notes=t._notes.concat(e),t},e.prototype.tags=function(e){a.assert(e&&("string"==typeof e||Array.isArray(e)),"Tags must be a non-empty string or array");var t=this.clone();return t._tags=t._tags.concat(e),t},e.prototype.meta=function(e){a.assert(void 0!==e,"Meta cannot be undefined");var t=this.clone();return t._meta=t._meta.concat(e),t},e.prototype.example=function(){a.assert(1===arguments.length,"Missing example");var e=arguments.length<=0?void 0:arguments[0],t=this.clone();return t._examples.push(e),t},e.prototype.unit=function(e){a.assert(e&&"string"==typeof e,"Unit name must be a non-empty string");var t=this.clone();return t._unit=e,t},e.prototype._prepareEmptyValue=function(e){return"string"==typeof e&&this._flags.trim?e.trim():e},e.prototype._validate=function(e,t,r,n){var i=this,o=e;t=t||{key:"",path:[],parent:null,reference:n},this._settings&&(r=s.concat(r,this._settings));var l=[],f=function(){var n=void 0;if(void 0!==e)n=i._flags.raw?o:e;else if(r.noDefaults)n=e;else if(u.isRef(i._flags.default))n=i._flags.default(t.parent,r);else if("function"!=typeof i._flags.default||i._flags.func&&!i._flags.default.description)n=a.clone(i._flags.default);else{var s=void 0;null!==t.parent&&i._flags.default.length>0&&(s=[a.clone(t.parent),r]);var c=p._try(i._flags.default,s);n=c.value,c.error&&l.push(i.createError("any.default",{error:c.error},t,r))}if(l.length&&"function"==typeof i._flags.error){var f=i._flags.error.call(i,l);l="string"==typeof f?[i.createOverrideError("override",{reason:l},t,r,f)]:[].concat(f).map(function(e){return e instanceof Error?e:i.createOverrideError(e.type||"override",e.context,t,r,e.message,e.template)})}return{value:i._flags.strip?void 0:n,finalValue:n,errors:l.length?l:null}};if(this._coerce){var h=this._coerce.call(this,e,t,r);if(h.errors)return e=h.value,l=l.concat(h.errors),f();e=h.value}this._flags.empty&&!this._flags.empty._validate(this._prepareEmptyValue(e),null,p.defaults).errors&&(e=void 0);var d=this._flags.presence||r.presence;if("optional"===d){if(void 0===e){var g=this._flags.hasOwnProperty("default")&&void 0===this._flags.default;if(!g||"object"!==this._type)return f();e={}}}else{if("required"===d&&void 0===e)return l.push(this.createError("any.required",null,t,r)),f();if("forbidden"===d)return void 0===e?f():(l.push(this.createError("any.unknown",null,t,r)),f())}if(this._valids.has(e,t,r,this._flags.insensitive))return f();if(this._invalids.has(e,t,r,this._flags.insensitive)&&(l.push(this.createError(""===e?"any.empty":"any.invalid",{value:e,invalids:this._invalids.values({stripUndefined:!0})},t,r)),r.abortEarly||void 0===e))return f();if(this._base){var y=this._base.call(this,e,t,r);if(y.errors)return e=y.value,l=l.concat(y.errors),f();if(y.value!==e){if(e=y.value,this._valids.has(e,t,r,this._flags.insensitive))return f();if(this._invalids.has(e,t,r,this._flags.insensitive)&&(l.push(this.createError(""===e?"any.empty":"any.invalid",{value:e,invalids:this._invalids.values({stripUndefined:!0})},t,r)),r.abortEarly))return f()}}if(this._flags.allowOnly&&(l.push(this.createError("any.allowOnly",{value:e,valids:this._valids.values({stripUndefined:!0})},t,r)),r.abortEarly))return f();for(var v=0;v=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function g(e){return+e!=e&&(e=0),o.alloc(+e)}function y(e,t){if(o.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return J(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Z(e).length;default:if(n)return J(e).length;t=(""+t).toLowerCase(),n=!0}}function v(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return T(this,t,r);case"latin1":case"binary":return R(this,t,r);case"base64":return O(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=o.from(t,n)),o.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,i);if("number"==typeof t)return t&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _(e,t,r,n,i){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}var c;if(i){var l=-1;for(c=r;cs&&(r=s-u),c=r;c>=0;c--){for(var f=!0,p=0;pi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a239?4:o>223?3:o>191?2:1;if(i+s<=r){var u,c,l,f;switch(s){case 1:o<128&&(a=o);break;case 2:u=e[i+1],128==(192&u)&&(f=(31&o)<<6|63&u)>127&&(a=f);break;case 3:u=e[i+1],c=e[i+2],128==(192&u)&&128==(192&c)&&(f=(15&o)<<12|(63&u)<<6|63&c)>2047&&(f<55296||f>57343)&&(a=f);break;case 4:u=e[i+1],c=e[i+2],l=e[i+3],128==(192&u)&&128==(192&c)&&128==(192&l)&&(f=(15&o)<<18|(63&u)<<12|(63&c)<<6|63&l)>65535&&f<1114112&&(a=f)}}null===a?(a=65533,s=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=s}return P(n)}function P(e){var t=e.length;if(t<=K)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function L(e,t,r,n,i,a){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function N(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function F(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(e,t,r,n,i){return i||F(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(e,t,r,n,23,4),r+4}function z(e,t,r,n,i){return i||F(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(e,t,r,n,52,8),r+8}function q(e){if(e=W(e).replace(ee,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function W(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function M(e){return e<16?"0"+e.toString(16):e.toString(16)}function J(e,t){t=t||1/0;for(var r,n=e.length,i=null,o=[],a=0;a55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function $(e){for(var t=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function Z(e){return H.toByteArray(q(e))}function V(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Q(e){return e!==e}var H=r(33),X=r(34),G=r(35);t.Buffer=o,t.SlowBuffer=g,t.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=n(),o.poolSize=8192,o._augment=function(e){return e.__proto__=o.prototype,e},o.from=function(e,t,r){return a(null,e,t,r)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(e,t,r){return u(null,e,t,r)},o.allocUnsafe=function(e){return c(null,e)},o.allocUnsafeSlow=function(e){return c(null,e)},o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},o.prototype.compare=function(e,t,r,n,i){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var a=i-n,s=r-t,u=Math.min(a,s),c=this.slice(n,i),l=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":return x(this,e,t,r);case"latin1":case"binary":return A(this,e,t,r);case"base64":return j(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var K=4096;o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(i*=256);)n+=this[e+--t]*i;return n},o.prototype.readUInt8=function(e,t){return t||I(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||I(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||I(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||I(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||I(e,t,this.length);for(var n=this[e],i=1,o=0;++o=i&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||I(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return t||I(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||I(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(e,t){t||I(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(e,t){return t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||I(e,4,this.length),X.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||I(e,4,this.length),X.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||I(e,8,this.length),X.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||I(e,8,this.length),X.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t|=0,r|=0,!n){L(this,e,t,r,Math.pow(2,8*r)-1,0)}var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);L(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);L(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return z(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return z(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(a<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var a;if("number"==typeof e)for(a=t;a2&&"!"===t[0]&&"!"===t[1];if(c&&(t=t.slice(2)),!u&&!c){var l=o.reach(r,"key");t="string"==typeof l?l+t:o.reach(a.errors,"key")+t}return t.replace(/\{\{(\!?)([^}]+)\}\}/g,function(t,r,i){var a=o.reach(e.context,i),u=s.stringify(a,n);return r&&e.options.escapeHtml?o.escapeHtml(u):u})},e}(),t.create=function(e,r,n,i,o,a,s){return new t.Err(e,r,n,i,o,a,s)},t.process=function(e,t){if(!e||!e.length)return null;var r="",n=[],i=function e(t,i){for(var o=0;o0){var a=t.indexOf(this);~a?(t.length=a+1,e.length=a+1,e[a]=n):(t.push(this),e.push(n)),~t.indexOf(o)&&(o=r.call(this,n,o))}else t.push(o);if(o){var u=o[s.annotations];if(u){if(Array.isArray(o)){for(var c=[],l=0;l=0;--u)for(var c=u+1,l=this.details[u],f=l.path,p=a,h=0;;++h){var d=f[h];if(p.isImmutable&&(p=p.clone()),!(h+11)for(var r=1;r0,"You need to provide at least one extension"),this.assert(d,t.extensionsSchema);var m=Object.create(this.any());c(m,this);for(var b=0;bi.length)throw new Error("Unexpected number of arguments");for(var a=!1,s={},u=0;u0&&void 0!==arguments[0]?arguments[0]:"javascript",t=["javascript","unix"];if(c.assert(t.includes(e),'"type" must be one of "'+t.join('", "')+'"'),this._flags.timestamp===e)return this;var r=this.clone();return r._flags.timestamp=e,r._flags.multiplier="unix"===e?1e3:1,r},t.prototype._isIsoDate=function(e){return l.isoDate.test(e)},t}(s),l.compare=function(e,t){return function(r){var n="now"===r,i=u.isRef(r);return n||i||(r=l.Date.toDate(r)),c.assert(r,"Invalid date format"),this._test(e,r,function(o,a,s){var u=void 0;if(n)u=Date.now();else if(i){if(!(u=l.Date.toDate(r(a.reference||a.parent,s))))return this.createError("date.ref",{ref:r.key},a,s);u=u.getTime()}else u=r.getTime();return t(o.getTime(),u)?o:this.createError("date."+e,{limit:new Date(u)},a,s)})}},l.Date.prototype.min=l.compare("min",function(e,t){return e>=t}),l.Date.prototype.max=l.compare("max",function(e,t){return e<=t}),l.Date.prototype.greater=l.compare("greater",function(e,t){return e>t}),l.Date.prototype.less=l.compare("less",function(e,t){return e=0,"limit must be a positive integer"),this._test("length",e,function(t,r,n){return Object.keys(t).length===e?t:this.createError("object.length",{limit:e},r,n)})},t.prototype.min=function(e){return u.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("min",e,function(t,r,n){return Object.keys(t).length>=e?t:this.createError("object.min",{limit:e},r,n)})},t.prototype.max=function(e){return u.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("max",e,function(t,r,n){return Object.keys(t).length<=e?t:this.createError("object.max",{limit:e},r,n)})},t.prototype.pattern=function(e,t){var r=e instanceof RegExp;u.assert(r||e instanceof l,"pattern must be a regex or schema"),u.assert(void 0!==t,"Invalid rule"),r&&(e=new RegExp(e.source,e.ignoreCase?"i":void 0));try{t=p.schema(this._currentJoi,t)}catch(e){throw e.hasOwnProperty("path")&&(e.message=e.message+"("+e.path+")"),e}var n=this.clone();return r?n._inner.patterns.push({regex:e,rule:t}):n._inner.patterns.push({schema:e,rule:t}),n},t.prototype.schema=function(){return this._test("schema",null,function(e,t,r){return e instanceof l?e:this.createError("object.schema",null,t,r)})},t.prototype.with=function(e,t){return u.assert(2===arguments.length,"Invalid number of arguments, expected 2."),this._dependency("with",e,t)},t.prototype.without=function(e,t){return u.assert(2===arguments.length,"Invalid number of arguments, expected 2."),this._dependency("without",e,t)},t.prototype.xor=function(){for(var e=arguments.length,t=Array(e),r=0;r0,"expected at least one children");var i=h.groupChildren(e),o=void 0;if(""in i?(o=this[t].apply(this,r),delete i[""]):o=this.clone(),o._inner.children){n=n?n+".":"";for(var a=0;a0&&(t.renames=u.clone(this._inner.renames)),t},t.prototype.assert=function(e,t,r){e=p.ref(e),u.assert(e.isContext||e.depth>1,"Cannot use assertions for root level references - use direct key rules instead"),r=r||"pass the assertion test";try{t=p.schema(this._currentJoi,t)}catch(e){throw e.hasOwnProperty("path")&&(e.message=e.message+"("+e.path+")"),e}var n=e.path[e.path.length-1],i=e.path.join(".");return this._test("assert",{schema:t,ref:e},function(o,a,s){if(!t._validate(e(o),null,s,o).errors)return o;var c=u.merge({},a);return c.key=n,c.path=e.path,this.createError("object.assert",{ref:i,message:r},c,s)})},t.prototype.type=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.name;u.assert("function"==typeof e,"type must be a constructor function");var r={name:t,ctor:e};return this._test("type",r,function(t,n,i){return t instanceof e?t:this.createError("object.type",{type:r.name},n,i)})},t}(l),h.safeParse=function(e){try{return JSON.parse(e)}catch(e){}return e},h.renameDefaults={alias:!1,multiple:!1,override:!1},h.groupChildren=function(e){e.sort();for(var t={},r=0;r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(r)?n.showHidden=r:r&&t._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,e,n.depth)}function o(e,t){var r=i.styles[t];return r?"["+i.colors[r][0]+"m"+e+"["+i.colors[r][1]+"m":e}function a(e,t){return e}function s(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function u(e,r,n){if(e.customInspect&&r&&S(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return b(i)||(i=u(e,i,n)),i}var o=c(e,r);if(o)return o;var a=Object.keys(r),g=s(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(r)),j(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(r);if(0===a.length){if(S(r)){var y=r.name?": "+r.name:"";return e.stylize("[Function"+y+"]","special")}if(E(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(A(r))return e.stylize(Date.prototype.toString.call(r),"date");if(j(r))return l(r)}var v="",m=!1,_=["{","}"];if(d(r)&&(m=!0,_=["[","]"]),S(r)){v=" [Function"+(r.name?": "+r.name:"")+"]"}if(E(r)&&(v=" "+RegExp.prototype.toString.call(r)),A(r)&&(v=" "+Date.prototype.toUTCString.call(r)),j(r)&&(v=" "+l(r)),0===a.length&&(!m||0==r.length))return _[0]+v+_[1];if(n<0)return E(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special");e.seen.push(r);var w;return w=m?f(e,r,n,g,a):a.map(function(t){return p(e,r,n,g,t,m)}),e.seen.pop(),h(w,v,_)}function c(e,t){if(w(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return m(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):y(t)?e.stylize("null","null"):void 0}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,r,n,i){for(var o=[],a=0,s=t.length;a-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n"))):s=e.stylize("[Circular]","special")),w(a)){if(o&&i.match(/^\d+$/))return s;a=JSON.stringify(""+i),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function h(e,t,r){var n=0;return e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function d(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function y(e){return null===e}function v(e){return null==e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function _(e){return"symbol"==typeof e}function w(e){return void 0===e}function E(e){return x(e)&&"[object RegExp]"===k(e)}function x(e){return"object"==typeof e&&null!==e}function A(e){return x(e)&&"[object Date]"===k(e)}function j(e){return x(e)&&("[object Error]"===k(e)||e instanceof Error)}function S(e){return"function"==typeof e}function O(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function k(e){return Object.prototype.toString.call(e)}function P(e){return e<10?"0"+e.toString(10):e.toString(10)}function T(){var e=new Date,t=[P(e.getHours()),P(e.getMinutes()),P(e.getSeconds())].join(":");return[e.getDate(),L[e.getMonth()],t].join(" ")}function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var C=/%[sdj%]/g;t.format=function(e){if(!b(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),s=n[r];r=0;s--)if(u[s]!==c[s])return!1;for(s=u.length-1;s>=0;s--)if(a=u[s],!h(e[a],t[a],r,n))return!1;return!0}function y(e,t,r){h(e,t,!0)&&f(e,t,r,"notDeepStrictEqual",y)}function v(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function m(e){var t;try{e()}catch(e){t=e}return t}function b(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=m(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&f(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!e&&_.isError(i),s=!e&&i&&!r;if((a&&o&&v(i,r)||s)&&f(i,r,"Got unwanted exception"+n),e&&i&&r&&!v(i,r)||!e&&i)throw i}var _=r(16),w=Object.prototype.hasOwnProperty,E=Array.prototype.slice,x=function(){return"foo"===function(){}.name}(),A=e.exports=p,j=/\s*function\s+([^\(\s]*)\s*/;A.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=l(this),this.generatedMessage=!0);var t=e.stackStartFunction||f;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=s(t),o=n.indexOf("\n"+i);if(o>=0){var a=n.indexOf("\n",o+1);n=n.substring(a+1)}this.stack=n}}},_.inherits(A.AssertionError,Error),A.fail=f,A.ok=p,A.equal=function(e,t,r){e!=t&&f(e,t,r,"==",A.equal)},A.notEqual=function(e,t,r){e==t&&f(e,t,r,"!=",A.notEqual)},A.deepEqual=function(e,t,r){h(e,t,!1)||f(e,t,r,"deepEqual",A.deepEqual)},A.deepStrictEqual=function(e,t,r){h(e,t,!0)||f(e,t,r,"deepStrictEqual",A.deepStrictEqual)},A.notDeepEqual=function(e,t,r){h(e,t,!1)&&f(e,t,r,"notDeepEqual",A.notDeepEqual)},A.notDeepStrictEqual=y,A.strictEqual=function(e,t,r){e!==t&&f(e,t,r,"===",A.strictEqual)},A.notStrictEqual=function(e,t,r){e===t&&f(e,t,r,"!==",A.notStrictEqual)},A.throws=function(e,t,r){b(!0,e,t,r)},A.doesNotThrow=function(e,t,r){b(!1,e,t,r)},A.ifError=function(e){if(e)throw e};var S=Object.keys||function(e){var t=[];for(var r in e)w.call(e,r)&&t.push(r);return t}}).call(t,r(5))},function(e,t,r){"use strict";(function(e){var r={};t.escapeJavaScript=function(e){if(!e)return"";for(var t="",n=0;n&\u2028\u2029]/g,function(e){return t=e.charCodeAt(0),60===t?"\\u003c":62===t?"\\u003e":38===t?"\\u0026":8232===t?"\\u2028":"\\u2029"})},r.escapeJavaScriptChar=function(t){if(t>=256)return"\\u"+r.padLeft(""+t,4);var n=e.from(String.fromCharCode(t),"ascii").toString("hex");return"\\x"+r.padLeft(n,2)},r.escapeHtmlChar=function(t){var n=r.namedHtml[t];if(void 0!==n)return n;if(t>=256)return"&#"+t+";";var i=e.from(String.fromCharCode(t),"ascii").toString("hex");return"&#x"+r.padLeft(i,2)+";"},r.padLeft=function(e,t){for(;e.length=97||t>=65&&t<=90||t>=48&&t<=57||32===t||46===t||44===t||45===t||58===t||95===t)&&(e[t]=null);return e}()}).call(t,r(3).Buffer)},function(e,t,r){"use strict";(function(e){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(38),o={hasOwn:Object.prototype.hasOwnProperty,indexOf:Array.prototype.indexOf,defaultThreshold:16,maxIPv6Groups:8,categories:{valid:1,dnsWarn:7,rfc5321:15,cfws:31,deprecated:63,rfc5322:127,error:255},diagnoses:{valid:0,rfc5321TLD:9,rfc5321TLDNumeric:10,rfc5321QuotedString:11,rfc5321AddressLiteral:12,cfwsComment:17,cfwsFWS:18,undesiredNonAscii:25,deprecatedLocalPart:33,deprecatedFWS:34,deprecatedQTEXT:35,deprecatedQP:36,deprecatedComment:37,deprecatedCTEXT:38,deprecatedIPv6:39,deprecatedCFWSNearAt:49,rfc5322Domain:65,rfc5322TooLong:66,rfc5322LocalTooLong:67,rfc5322DomainTooLong:68,rfc5322LabelTooLong:69,rfc5322DomainLiteral:70,rfc5322DomainLiteralOBSDText:71,rfc5322IPv6GroupCount:72,rfc5322IPv62x2xColon:73,rfc5322IPv6BadCharacter:74,rfc5322IPv6MaxGroups:75,rfc5322IPv6ColonStart:76,rfc5322IPv6ColonEnd:77,errExpectingDTEXT:129,errNoLocalPart:130,errNoDomain:131,errConsecutiveDots:132,errATEXTAfterCFWS:133,errATEXTAfterQS:134,errATEXTAfterDomainLiteral:135,errExpectingQPair:136,errExpectingATEXT:137,errExpectingQTEXT:138,errExpectingCTEXT:139,errBackslashEnd:140,errDotStart:141,errDotEnd:142,errDomainHyphenStart:143,errDomainHyphenEnd:144,errUnclosedQuotedString:145,errUnclosedComment:146,errUnclosedDomainLiteral:147,errFWSCRLFx2:148,errFWSCRLFEnd:149,errCRNoLF:150,errUnknownTLD:160,errDomainTooShort:161},components:{localpart:0,domain:1,literal:2,contextComment:3,contextFWS:4,contextQuotedString:5,contextQuotedPair:6}};o.specials=function(){var e='()<>[]:;@\\,."',t=new Array(256);t.fill(!1);for(var r=0;r=0?o.nulNormalize(e):e.normalize("NFC")},o.checkIpV6=function(e){return e.every(function(e){return o.regex.ipV6.test(e)})},o.validDomain=function(e,t){return t.tldBlacklist?Array.isArray(t.tldBlacklist)?-1===o.indexOf.call(t.tldBlacklist,e):!o.hasOwn.call(t.tldBlacklist,e):Array.isArray(t.tldWhitelist)?-1!==o.indexOf.call(t.tldWhitelist,e):o.hasOwn.call(t.tldWhitelist,e)},t.validate=o.validate=function(t,r,a){r=r||{},t=o.normalize(t),"function"==typeof r&&(a=r,r={}),"function"!=typeof a&&(a=null);var s=void 0,u=void 0;if("number"==typeof r.errorLevel?(s=!0,u=r.errorLevel):(s=!!r.errorLevel,u=o.diagnoses.valid),r.tldWhitelist)if("string"==typeof r.tldWhitelist)r.tldWhitelist=[r.tldWhitelist];else if("object"!==n(r.tldWhitelist))throw new TypeError("expected array or object tldWhitelist");if(r.tldBlacklist)if("string"==typeof r.tldBlacklist)r.tldBlacklist=[r.tldBlacklist];else if("object"!==n(r.tldBlacklist))throw new TypeError("expected array or object tldBlacklist");if(r.minDomainAtoms&&(r.minDomainAtoms!==(0|+r.minDomainAtoms)||r.minDomainAtoms<0))throw new TypeError("expected positive integer minDomainAtoms");var c=o.diagnoses.valid,l=function(e){e>c&&(c=e)};!(void 0===r.allowUnicode||!!r.allowUnicode)&&/[^\x00-\x7f]/.test(t)&&l(o.diagnoses.undesiredNonAscii);for(var f={now:o.components.localpart,prev:o.components.localpart,stack:[o.components.localpart]},p="",h={local:"",domain:""},d={locals:[""],domains:[""]},g=0,y=0,v=0,m=void 0,b=!1,_=!1,w=t.length,E=void 0,x=0;x64?l(o.diagnoses.rfc5322LocalTooLong):f.prev!==o.components.contextComment&&f.prev!==o.components.contextFWS||l(o.diagnoses.deprecatedCFWSNearAt),f.now=o.components.domain,f.stack[0]=o.components.domain,g=0,y=0,_=!1;break;default:if(_)switch(f.prev){case o.components.contextComment:case o.components.contextFWS:l(o.diagnoses.errATEXTAfterCFWS);break;case o.components.contextQuotedString:l(o.diagnoses.errATEXTAfterQS);break;default:throw new Error("more atext found where none is allowed, but unrecognized prev context: "+f.prev)}else f.prev=f.now,m=E.codePointAt(0),(o.specials(m)||o.c0Controls(m)||o.c1Controls(m))&&l(o.diagnoses.errExpectingATEXT),h.local+=E,d.locals[g]+=E,y+=e.byteLength(E,"utf8")}break;case o.components.domain:switch(E){case"(":0===y?l(0===g?o.diagnoses.deprecatedCFWSNearAt:o.diagnoses.deprecatedComment):(_=!0,l(o.diagnoses.cfwsComment)),f.stack.push(f.now),f.now=o.components.contextComment;break;case".":var A=i.encode(d.domains[g]).length;0===y?l(0===g?o.diagnoses.errDotStart:o.diagnoses.errConsecutiveDots):b?l(o.diagnoses.errDomainHyphenEnd):A>63&&l(o.diagnoses.rfc5322LabelTooLong),_=!1,y=0,++g,d.domains[g]="",h.domain+=E;break;case"[":0===h.domain.length?(_=!0,y+=e.byteLength(E,"utf8"),f.stack.push(f.now),f.now=o.components.literal,h.domain+=E,d.domains[g]+=E,h.literal=""):l(o.diagnoses.errExpectingATEXT);break;case"\r":if(w===++x||"\n"!==t[x]){l(o.diagnoses.errCRNoLF);break}case" ":case"\t":0===y?l(0===g?o.diagnoses.deprecatedCFWSNearAt:o.diagnoses.deprecatedFWS):(l(o.diagnoses.cfwsFWS),_=!0),f.stack.push(f.now),f.now=o.components.contextFWS,p=E;break;default:if(_)switch(f.prev){case o.components.contextComment:case o.components.contextFWS:l(o.diagnoses.errATEXTAfterCFWS);break;case o.components.literal:l(o.diagnoses.errATEXTAfterDomainLiteral);break;default:throw new Error("more atext found where none is allowed, but unrecognized prev context: "+f.prev)}m=E.codePointAt(0),b=!1,o.specials(m)||o.c0Controls(m)||o.c1Controls(m)?l(o.diagnoses.errExpectingATEXT):"-"===E?(0===y&&l(o.diagnoses.errDomainHyphenStart),b=!0):(m<48||m>122&&m<192||m>57&&m<65||m>90&&m<97)&&l(o.diagnoses.rfc5322Domain),h.domain+=E,d.domains[g]+=E,y+=e.byteLength(E,"utf8")}break;case o.components.literal:switch(E){case"]":if(cP?l(o.diagnoses.rfc5322IPv6MaxGroups):T.length===P&&l(o.diagnoses.deprecatedIPv6)):T.length!==P&&l(o.diagnoses.rfc5322IPv6GroupCount),l(":"===k[0]&&":"!==k[1]?o.diagnoses.rfc5322IPv6ColonStart:":"===k[k.length-1]&&":"!==k[k.length-2]?o.diagnoses.rfc5322IPv6ColonEnd:o.checkIpV6(T)?o.diagnoses.rfc5321AddressLiteral:o.diagnoses.rfc5322IPv6BadCharacter)}}else l(o.diagnoses.rfc5322DomainLiteral);h.domain+=E,d.domains[g]+=E,y+=e.byteLength(E,"utf8"),f.prev=f.now,f.now=f.stack.pop();break;case"\\":l(o.diagnoses.rfc5322DomainLiteralOBSDText),f.stack.push(f.now),f.now=o.components.contextQuotedPair;break;case"\r":if(w===++x||"\n"!==t[x]){l(o.diagnoses.errCRNoLF);break}case" ":case"\t":l(o.diagnoses.cfwsFWS),f.stack.push(f.now),f.now=o.components.contextFWS,p=E;break;default:if(127!==(m=E.codePointAt(0))&&o.c1Controls(m)||0===m||"["===E){l(o.diagnoses.errExpectingDTEXT);break}(o.c0Controls(m)||127===m)&&l(o.diagnoses.rfc5322DomainLiteralOBSDText),h.literal+=E,h.domain+=E,d.domains[g]+=E,y+=e.byteLength(E,"utf8")}break;case o.components.contextQuotedString:switch(E){case"\\":f.stack.push(f.now),f.now=o.components.contextQuotedPair;break;case"\r":if(w===++x||"\n"!==t[x]){l(o.diagnoses.errCRNoLF);break}case"\t":h.local+=" ",d.locals[g]+=" ",y+=e.byteLength(E,"utf8"),l(o.diagnoses.cfwsFWS),f.stack.push(f.now),f.now=o.components.contextFWS,p=E;break;case'"':h.local+=E,d.locals[g]+=E,y+=e.byteLength(E,"utf8"),f.prev=f.now,f.now=f.stack.pop();break;default:m=E.codePointAt(0),127!==m&&o.c1Controls(m)||0===m||10===m?l(o.diagnoses.errExpectingQTEXT):(o.c0Controls(m)||127===m)&&l(o.diagnoses.deprecatedQTEXT),h.local+=E,d.locals[g]+=E,y+=e.byteLength(E,"utf8")}break;case o.components.contextQuotedPair:m=E.codePointAt(0),127!==m&&o.c1Controls(m)?l(o.diagnoses.errExpectingQPair):(m<31&&9!==m||127===m)&&l(o.diagnoses.deprecatedQP),f.prev=f.now,f.now=f.stack.pop();var R="\\"+E;switch(f.now){case o.components.contextComment:break;case o.components.contextQuotedString:h.local+=R,d.locals[g]+=R,y+=2;break;case o.components.literal:h.domain+=R,d.domains[g]+=R,y+=2;break;default:throw new Error("quoted pair logic invoked in an invalid context: "+f.now)}break;case o.components.contextComment:switch(E){case"(":f.stack.push(f.now),f.now=o.components.contextComment;break;case")":f.prev=f.now,f.now=f.stack.pop();break;case"\\":f.stack.push(f.now),f.now=o.components.contextQuotedPair;break;case"\r":if(w===++x||"\n"!==t[x]){l(o.diagnoses.errCRNoLF);break}case" ":case"\t":l(o.diagnoses.cfwsFWS),f.stack.push(f.now),f.now=o.components.contextFWS,p=E;break;default:if(0===(m=E.codePointAt(0))||10===m||127!==m&&o.c1Controls(m)){l(o.diagnoses.errExpectingCTEXT);break}(o.c0Controls(m)||127===m)&&l(o.diagnoses.deprecatedCTEXT)}break;case o.components.contextFWS:if("\r"===p){if("\r"===E){l(o.diagnoses.errFWSCRLFx2);break}++v>1?l(o.diagnoses.deprecatedFWS):v=1}switch(E){case"\r":w!==++x&&"\n"===t[x]||l(o.diagnoses.errCRNoLF);break;case" ":case"\t":break;default:"\r"===p&&l(o.diagnoses.errFWSCRLFEnd),v=0,f.prev=f.now,f.now=f.stack.pop(),--x}p=E;break;default:throw new Error("unknown context: "+f.now)}if(c>o.categories.rfc5322)break}if(c255)l(o.diagnoses.rfc5322DomainTooLong);else if(e.byteLength(h.local,"utf8")+C+1>254)l(o.diagnoses.rfc5322TooLong);else if(y>63)l(o.diagnoses.rfc5322LabelTooLong);else if(r.minDomainAtoms&&d.domains.length0){var b=s.shift();if(v=b._validate(f,y,n),v.errors){if(i.push(this.createError("array.ordered",{pos:l,reason:v.errors,value:f},{key:r.key,path:y.path},n)),n.abortEarly)return i}else if(b._flags.strip)p.fastSplice(e,l),--l,--c;else{if(!this._flags.sparse&&void 0===v.value){if(i.push(this.createError("array.sparse",null,{key:r.key,path:y.path,pos:l},n)),n.abortEarly)return i;continue}e[l]=v.value}continue}if(!this._inner.items.length){if(i.push(this.createError("array.orderedLength",{pos:l,limit:this._inner.ordereds.length},{key:r.key,path:y.path},n)),n.abortEarly)return i;continue}}for(var _=[],w=a.length,E=0;E=0||t,"limit must be a positive integer or reference"),this._test("min",e,function(r,n,i){var o=void 0;if(t){if(o=e(n.reference||n.parent,i),!(Number.isSafeInteger(o)&&o>=0))return this.createError("array.ref",{ref:e.key},n,i)}else o=e;return r.length>=o?r:this.createError("array.min",{limit:e,value:r},n,i)})},t.prototype.max=function(e){var t=l.isRef(e);return f.assert(Number.isSafeInteger(e)&&e>=0||t,"limit must be a positive integer or reference"),this._test("max",e,function(r,n,i){var o=void 0;if(t){if(o=e(n.reference||n.parent,i),!(Number.isSafeInteger(o)&&o>=0))return this.createError("array.ref",{ref:e.key},n,i)}else o=e;return r.length<=o?r:this.createError("array.max",{limit:e,value:r},n,i)})},t.prototype.length=function(e){var t=l.isRef(e);return f.assert(Number.isSafeInteger(e)&&e>=0||t,"limit must be a positive integer or reference"),this._test("length",e,function(r,n,i){var o=void 0;if(t){if(o=e(n.reference||n.parent,i),!(Number.isSafeInteger(o)&&o>=0))return this.createError("array.ref",{ref:e.key},n,i)}else o=e;return r.length===o?r:this.createError("array.length",{limit:e,value:r},n,i)})},t.prototype.unique=function(e){f.assert(void 0===e||"function"==typeof e||"string"==typeof e,"comparator must be a function or a string");var t={};return"string"==typeof e?t.path=e:"function"==typeof e&&(t.comparator=e),this._test("unique",t,function(e,r,n){for(var i={string:Object.create(null),number:Object.create(null),undefined:Object.create(null),boolean:Object.create(null),object:new Map,function:new Map,custom:new Map},o=t.comparator||f.deepEqual,a=0;a=0,"limit must be a positive integer"),this._test("min",e,function(t,r,n){return t.length>=e?t:this.createError("binary.min",{limit:e,value:t},r,n)})},r.prototype.max=function(e){return u.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("max",e,function(t,r,n){return t.length<=e?t:this.createError("binary.max",{limit:e,value:t},r,n)})},r.prototype.length=function(e){return u.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("length",e,function(t,r,n){return t.length===e?t:this.createError("binary.length",{limit:e,value:t},r,n)})},r}(s),e.exports=new c.Binary}).call(t,r(3).Buffer)},function(e,t,r){"use strict";function n(e,t){for(var r=Object.getOwnPropertyNames(t),n=0;n=0,"n must be a positive integer"),this._test("arity",e,function(t,r,n){return t.length===e?t:this.createError("function.arity",{n:e},r,n)})},t.prototype.minArity=function(e){return s.assert(Number.isSafeInteger(e)&&e>0,"n must be a strict positive integer"),this._test("minArity",e,function(t,r,n){return t.length>=e?t:this.createError("function.minArity",{n:e},r,n)})},t.prototype.maxArity=function(e){return s.assert(Number.isSafeInteger(e)&&e>=0,"n must be a positive integer"),this._test("maxArity",e,function(t,r,n){return t.length<=e?t:this.createError("function.maxArity",{n:e},r,n)})},t.prototype.ref=function(){return this._test("ref",null,function(e,t,r){return c.isRef(e)?e:this.createError("function.ref",null,t,r)})},t.prototype.class=function(){return this._test("class",null,function(e,t,r){return/^\s*class\s/.test(e.toString())?e:this.createError("function.class",null,t,r)})},t}(u.constructor),e.exports=new l.Func},function(e,t,r){"use strict";function n(e,t){for(var r=Object.getOwnPropertyNames(t),n=0;n0,"multiple must be greater than 0")),this._test("multiple",e,function(r,n,i){var o=t?e(n.reference||n.parent,i):e;return!t||"number"==typeof o&&isFinite(o)?r%o==0?r:this.createError("number.multiple",{multiple:e,value:r},n,i):this.createError("number.ref",{ref:e.key},n,i)})},t.prototype.integer=function(){return this._test("integer",void 0,function(e,t,r){return Number.isSafeInteger(e)?e:this.createError("number.integer",{value:e},t,r)})},t.prototype.negative=function(){return this._test("negative",void 0,function(e,t,r){return e<0?e:this.createError("number.negative",{value:e},t,r)})},t.prototype.positive=function(){return this._test("positive",void 0,function(e,t,r){return e>0?e:this.createError("number.positive",{value:e},t,r)})},t.prototype.precision=function(e){c.assert(Number.isSafeInteger(e),"limit must be an integer"),c.assert(!("precision"in this._flags),"precision already set");var t=this._test("precision",e,function(t,r,n){var i=t.toString().match(l.precisionRx);return Math.max((i[1]?i[1].length:0)-(i[2]?parseInt(i[2],10):0),0)<=e?t:this.createError("number.precision",{limit:e,value:t},r,n)});return t._flags.precision=e,t},t.prototype.port=function(){return this._test("port",void 0,function(e,t,r){return!Number.isSafeInteger(e)||e<0||e>65535?this.createError("number.port",{value:e},t,r):e})},t}(s),l.compare=function(e,t){return function(r){var n=u.isRef(r),i="number"==typeof r&&!isNaN(r);return c.assert(i||n,"limit must be a number or reference"),this._test(e,r,function(i,o,a){var s=void 0;if(n){if("number"!=typeof(s=r(o.reference||o.parent,a))||isNaN(s))return this.createError("number.ref",{ref:r.key},o,a)}else s=r;return t(i,s)?i:this.createError("number."+e,{limit:s,value:i},o,a)})}},l.Number.prototype.min=l.compare("min",function(e,t){return e>=t}),l.Number.prototype.max=l.compare("max",function(e,t){return e<=t}),l.Number.prototype.greater=l.compare("greater",function(e,t){return e>t}),l.Number.prototype.less=l.compare("less",function(e,t){return e9),o^=3}return i%10==0&&i>0?e:this.createError("string.creditCard",{value:e},t,r)})},t.prototype.regex=function(e,t){c.assert(e instanceof RegExp,"pattern must be a RegExp");var r={pattern:new RegExp(e.source,e.ignoreCase?"i":void 0)};"string"==typeof t?r.name=t:"object"===(void 0===t?"undefined":s(t))&&(r.invert=!!t.invert,t.name&&(r.name=t.name));var n=["string.regex",r.invert?".invert":"",r.name?".name":".base"].join("");return this._test("regex",r,function(e,t,i){return r.pattern.test(e)^r.invert?e:this.createError(n,{name:r.name,pattern:r.pattern,value:e},t,i)})},t.prototype.alphanum=function(){return this._test("alphanum",void 0,function(e,t,r){return/^[a-zA-Z0-9]+$/.test(e)?e:this.createError("string.alphanum",{value:e},t,r)})},t.prototype.token=function(){return this._test("token",void 0,function(e,t,r){return/^\w+$/.test(e)?e:this.createError("string.token",{value:e},t,r)})},t.prototype.email=function(e){return e&&(c.assert("object"===(void 0===e?"undefined":s(e)),"email options must be an object"),c.assert(void 0===e.checkDNS,"checkDNS option is not supported"),c.assert(void 0===e.tldWhitelist||"object"===s(e.tldWhitelist),"tldWhitelist must be an array or object"),c.assert(void 0===e.minDomainAtoms||Number.isSafeInteger(e.minDomainAtoms)&&e.minDomainAtoms>0,"minDomainAtoms must be a positive integer"),c.assert(void 0===e.errorLevel||"boolean"==typeof e.errorLevel||Number.isSafeInteger(e.errorLevel)&&e.errorLevel>=0,"errorLevel must be a non-negative integer or boolean")),this._test("email",e,function(t,n,i){l=l||r(19);try{var o=l.validate(t,e);if(!0===o||0===o)return t}catch(e){}return this.createError("string.email",{value:t},n,i)})},t.prototype.ip=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=y.ipRegex;c.assert("object"===(void 0===e?"undefined":s(e)),"options must be an object"),e.cidr?(c.assert("string"==typeof e.cidr,"cidr must be a string"),e.cidr=e.cidr.toLowerCase(),c.assert(c.contain(y.cidrPresences,e.cidr),"cidr must be one of "+y.cidrPresences.join(", ")),e.version||"optional"===e.cidr||(t=g.createIpRegex(["ipv4","ipv6","ipvfuture"],e.cidr))):e.cidr="optional";var r=void 0;if(e.version){Array.isArray(e.version)||(e.version=[e.version]),c.assert(e.version.length>=1,"version must have at least 1 version specified"),r=[];for(var n=0;n=1,"scheme must have at least 1 scheme specified");for(var o=0;o=1,"version must have at least 1 valid version specified");for(var r=new Set,n=0;n0&&void 0!==arguments[0]?arguments[0]:{};c.assert("object"===(void 0===e?"undefined":s(e)),"hex options must be an object"),c.assert(void 0===e.byteAligned||"boolean"==typeof e.byteAligned,"byteAligned must be boolean");var t=!0===e.byteAligned,r=/^[a-f0-9]+$/i,n=this._test("hex",r,function(e,n,i){return r.test(e)?t&&e.length%2!=0?this.createError("string.hexAlign",{value:e},n,i):e:this.createError("string.hex",{value:e},n,i)});return t&&(n._flags.byteAligned=!0),n},t.prototype.base64=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c.assert("object"===(void 0===e?"undefined":s(e)),"base64 options must be an object"),c.assert(void 0===e.paddingRequired||"boolean"==typeof e.paddingRequired,"paddingRequired must be boolean");var t=!1===e.paddingRequired?e.paddingRequired:e.paddingRequired||!0,r=t?/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/:/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/;return this._test("base64",r,function(e,t,n){return r.test(e)?e:this.createError("string.base64",{value:e},t,n)})},t.prototype.hostname=function(){var e=/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/;return this._test("hostname",void 0,function(t,r,n){return t.length<=255&&e.test(t)||u.isIPv6(t)?t:this.createError("string.hostname",{value:t},r,n)})},t.prototype.normalize=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NFC";c.assert(c.contain(y.normalizationForms,e),"normalization form must be one of "+y.normalizationForms.join(", "));var t=this._test("normalize",e,function(t,r,n){return n.convert||t===t.normalize(e)?t:this.createError("string.normalize",{value:t,form:e},r,n)});return t._flags.normalize=e,t},t.prototype.lowercase=function(){var e=this._test("lowercase",void 0,function(e,t,r){return r.convert||e===e.toLocaleLowerCase()?e:this.createError("string.lowercase",{value:e},t,r)});return e._flags.case="lower",e},t.prototype.uppercase=function(){var e=this._test("uppercase",void 0,function(e,t,r){return r.convert||e===e.toLocaleUpperCase()?e:this.createError("string.uppercase",{value:e},t,r)});return e._flags.case="upper",e},t.prototype.trim=function(){var e=this._test("trim",void 0,function(e,t,r){return r.convert||e===e.trim()?e:this.createError("string.trim",{value:e},t,r)});return e._flags.trim=!0,e},t.prototype.replace=function(e,t){"string"==typeof e&&(e=new RegExp(c.escapeRegex(e),"g")),c.assert(e instanceof RegExp,"pattern must be a RegExp"),c.assert("string"==typeof t,"replacement must be a String");var r=this.clone();return r._inner.replacements||(r._inner.replacements=[]),r._inner.replacements.push({pattern:e,replacement:t}),r},t.prototype.truncate=function(e){var t=void 0===e||!!e;if(this._flags.truncate===t)return this;var r=this.clone();return r._flags.truncate=t,r},t}(f),y.compare=function(e,r){return function(n,i){var o=p.isRef(n);return c.assert(Number.isSafeInteger(n)&&n>=0||o,"limit must be a positive integer or reference"),c.assert(!i||t.isEncoding(i),"Invalid encoding:",i),this._test(e,n,function(t,a,s){var u=void 0;if(o){if(u=n(a.reference||a.parent,s),!Number.isSafeInteger(u))return this.createError("string.ref",{ref:n.key},a,s)}else u=n;return r(t,u,i)?t:this.createError("string."+e,{limit:u,value:t,encoding:i},a,s)})}},y.String.prototype.min=y.compare("min",function(e,r,n){return(n?t.byteLength(e,n):e.length)>=r}),y.String.prototype.max=y.compare("max",function(e,r,n){return(n?t.byteLength(e,n):e.length)<=r}),y.String.prototype.length=y.compare("length",function(e,r,n){return(n?t.byteLength(e,n):e.length)===r}),y.String.prototype.uuid=y.String.prototype.guid,e.exports=new y.String}).call(t,r(3).Buffer)},function(e,t,r){"use strict";var n=r(14),i={Ip:{cidrs:{ipv4:{required:"\\/(?:"+n.ipv4Cidr+")",optional:"(?:\\/(?:"+n.ipv4Cidr+"))?",forbidden:""},ipv6:{required:"\\/"+n.ipv6Cidr,optional:"(?:\\/"+n.ipv6Cidr+")?",forbidden:""},ipvfuture:{required:"\\/"+n.ipv6Cidr,optional:"(?:\\/"+n.ipv6Cidr+")?",forbidden:""}},versions:{ipv4:n.IPv4address,ipv6:n.IPv6address,ipvfuture:n.IPvFuture}}};i.Ip.createIpRegex=function(e,t){for(var r=void 0,n=0;n0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function i(e){return 3*e.length/4-n(e)}function o(e){var t,r,i,o,a,s=e.length;o=n(e),a=new f(3*s/4-o),r=o>0?s-4:s;var u=0;for(t=0;t>16&255,a[u++]=i>>8&255,a[u++]=255&i;return 2===o?(i=l[e.charCodeAt(t)]<<2|l[e.charCodeAt(t+1)]>>4,a[u++]=255&i):1===o&&(i=l[e.charCodeAt(t)]<<10|l[e.charCodeAt(t+1)]<<4|l[e.charCodeAt(t+2)]>>2,a[u++]=i>>8&255,a[u++]=255&i),a}function a(e){return c[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}function s(e,t,r){for(var n,i=[],o=t;ou?u:a+16383));return 1===n?(t=e[r-1],i+=c[t>>2],i+=c[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=c[t>>10],i+=c[t>>4&63],i+=c[t<<2&63],i+="="),o.push(i),o.join("")}t.byteLength=i,t.toByteArray=o,t.fromByteArray=u;for(var c=[],l=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,d=p.length;h>1,l=-7,f=r?i-1:0,p=r?-1:1,h=e[t+f];for(f+=p,o=h&(1<<-l)-1,h>>=-l,l+=s;l>0;o=256*o+e[t+f],f+=p,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+e[t+f],f+=p,l-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,n),o-=c}return(h?-1:1)*a*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,l=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,d=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),t+=a+f>=1?p/u:p*Math.pow(2,1-f),t*u>=2&&(a++,u/=2),a+f>=l?(s=0,a=l):a+f>=1?(s=(t*u-1)*Math.pow(2,i),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;e[r+h]=255&s,h+=d,s/=256,i-=8);for(a=a<0;e[r+h]=255&a,h+=d,a/=256,c-=8);e[r+h-d]|=128*g}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t){e.exports={_args:[["joi@13.4.0","/Users/hkernbach/Git/joi-browser"]],_development:!0,_from:"joi@13.4.0",_id:"joi@13.4.0",_inBundle:!1,_integrity:"sha512-JuK4GjEu6j7zr9FuVe2MAseZ6si/8/HaY0qMAejfDFHp7jcH4OKE937mIHM5VT4xDS0q7lpQbszbxKV9rm0yUg==",_location:"/joi",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"joi@13.4.0",name:"joi",escapedName:"joi",rawSpec:"13.4.0",saveSpec:null,fetchSpec:"13.4.0"},_requiredBy:["#DEV:/"],_resolved:"https://registry.npmjs.org/joi/-/joi-13.4.0.tgz",_spec:"13.4.0",_where:"/Users/hkernbach/Git/joi-browser",bugs:{url:"https://github.com/hapijs/joi/issues"},dependencies:{hoek:"5.x.x",isemail:"3.x.x",topo:"3.x.x"},description:"Object schema validation",devDependencies:{code:"5.x.x",hapitoc:"1.x.x",lab:"15.x.x"},engines:{node:">=8.9.0"},homepage:"https://github.com/hapijs/joi",keywords:["hapi","schema","validation"],license:"BSD-3-Clause",main:"lib/index.js",name:"joi",repository:{type:"git",url:"git://github.com/hapijs/joi.git"},scripts:{test:"lab -t 100 -a code -L","test-cov-html":"lab -r html -o coverage.html -a code","test-debug":"lab -a code",toc:"hapitoc",version:"npm run toc && git add API.md README.md"},version:"13.4.0"}},function(e,t,r){(function(e){function r(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function n(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n=-1&&!i;o--){var a=o>=0?arguments[o]:e.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(t=a+"/"+t,i="/"===a.charAt(0))}return t=r(n(t.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+t||"."},t.normalize=function(e){var i=t.isAbsolute(e),o="/"===a(e,-1);return e=r(n(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&o&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(n(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,r){function n(e){for(var t=0;t=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var i=n(e.split("/")),o=n(r.split("/")),a=Math.min(i.length,o.length),s=a,u=0;u1&&(n=r[0]+"@",e=r[1]),e=e.replace(R,"."),n+s(e.split("."),t).join(".")}function c(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(e-=65536,t+=L(e>>>10&1023|55296),e=56320|1023&e),t+=L(e)}).join("")}function f(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:w}function p(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function h(e,t,r){var n=0;for(e=r?I(e/j):e>>1, +e+=I(e/t);e>D*x>>1;n+=w)e=I(e/D);return I(n+(D+1)*e/(e+A))}function d(e){var t,r,n,i,o,s,u,c,p,d,g=[],y=e.length,v=0,m=O,b=S;for(r=e.lastIndexOf(k),r<0&&(r=0),n=0;n=128&&a("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=y&&a("invalid-input"),c=f(e.charCodeAt(i++)),(c>=w||c>I((_-v)/s))&&a("overflow"),v+=c*s,p=u<=b?E:u>=b+x?x:u-b,!(cI(_/d)&&a("overflow"),s*=d;t=g.length+1,b=h(v-o,t,0==o),I(v/t)>_-m&&a("overflow"),m+=I(v/t),v%=t,g.splice(v++,0,m)}return l(g)}function g(e){var t,r,n,i,o,s,u,l,f,d,g,y,v,m,b,A=[];for(e=c(e),y=e.length,t=O,r=0,o=S,s=0;s=t&&gI((_-r)/v)&&a("overflow"),r+=(u-t)*v,t=u,s=0;s_&&a("overflow"),g==t){for(l=r,f=w;d=f<=o?E:f>=o+x?x:f-o,!(l= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=w-E,I=Math.floor,L=String.fromCharCode;b={version:"1.4.1",ucs2:{decode:c,encode:l},decode:d,encode:g,toASCII:v,toUnicode:y},void 0!==(i=function(){return b}.call(t,r,t,e))&&(e.exports=i)}()}).call(t,r(41)(e),r(5))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}}])}); diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/lib/joi.browser.js b/js/apps/system/_admin/aardvark/APP/frontend/js/lib/joi.browser.js deleted file mode 100644 index acf063be84..0000000000 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/lib/joi.browser.js +++ /dev/null @@ -1,7189 +0,0 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Joi=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0, 'limit must be a positive integer'); - - return this._test('min', limit, function (value, state, options) { - - if (value.length >= limit) { - return null; - } - - return Errors.create('array.min', { limit: limit }, state, options); - }); -}; - - -internals.Array.prototype.max = function (limit) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - - return this._test('max', limit, function (value, state, options) { - - if (value.length <= limit) { - return null; - } - - return Errors.create('array.max', { limit: limit }, state, options); - }); -}; - - -internals.Array.prototype.length = function (limit) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - - return this._test('length', limit, function (value, state, options) { - - if (value.length === limit) { - return null; - } - - return Errors.create('array.length', { limit: limit }, state, options); - }); -}; - - -module.exports = new internals.Array(); - -},{"./any":2,"./cast":6,"./errors":8,"hoek":16}],4:[function(require,module,exports){ -(function (Buffer){ -// Load modules - -var Any = require('./any'); -var Errors = require('./errors'); -var Hoek = require('hoek'); - - -// Declare internals - -var internals = {}; - - -internals.Binary = function () { - - Any.call(this); - this._type = 'binary'; -}; - -Hoek.inherits(internals.Binary, Any); - - -internals.Binary.prototype._base = function (value, state, options) { - - var result = { - value: value - }; - - if (typeof value === 'string' && - options.convert) { - - try { - var converted = new Buffer(value, this._flags.encoding); - result.value = converted; - } - catch (e) { } - } - - result.errors = Buffer.isBuffer(result.value) ? null : Errors.create('binary.base', null, state, options); - return result; -}; - - -internals.Binary.prototype.encoding = function (encoding) { - - Hoek.assert(Buffer.isEncoding(encoding), 'Invalid encoding:', encoding); - - var obj = this.clone(); - obj._flags.encoding = encoding; - return obj; -}; - - -internals.Binary.prototype.min = function (limit) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - - return this._test('min', limit, function (value, state, options) { - - if (value.length >= limit) { - return null; - } - - return Errors.create('binary.min', { limit: limit }, state, options); - }); -}; - - -internals.Binary.prototype.max = function (limit) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - - return this._test('max', limit, function (value, state, options) { - - if (value.length <= limit) { - return null; - } - - return Errors.create('binary.max', { limit: limit }, state, options); - }); -}; - - -internals.Binary.prototype.length = function (limit) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - - return this._test('length', limit, function (value, state, options) { - - if (value.length === limit) { - return null; - } - - return Errors.create('binary.length', { limit: limit }, state, options); - }); -}; - - -module.exports = new internals.Binary(); -}).call(this,require("buffer").Buffer) -},{"./any":2,"./errors":8,"buffer":24,"hoek":16}],5:[function(require,module,exports){ -// Load modules - -var Any = require('./any'); -var Errors = require('./errors'); -var Hoek = require('hoek'); - - -// Declare internals - -var internals = {}; - - -internals.Boolean = function () { - - Any.call(this); - this._type = 'boolean'; -}; - -Hoek.inherits(internals.Boolean, Any); - - -internals.Boolean.prototype._base = function (value, state, options) { - - var result = { - value: value - }; - - if (typeof value === 'string' && - options.convert) { - - var lower = value.toLowerCase(); - result.value = (lower === 'true' || lower === 'yes' || lower === 'on' ? true - : (lower === 'false' || lower === 'no' || lower === 'off' ? false : value)); - } - - result.errors = (typeof result.value === 'boolean') ? null : Errors.create('boolean.base', null, state, options); - return result; -}; - - -module.exports = new internals.Boolean(); -},{"./any":2,"./errors":8,"hoek":16}],6:[function(require,module,exports){ -// Load modules - -var Hoek = require('hoek'); -var Ref = require('./ref'); -// Type modules are delay-loaded to prevent circular dependencies - - -// Declare internals - -var internals = { - any: null, - date: require('./date'), - string: require('./string'), - number: require('./number'), - boolean: require('./boolean'), - alt: null, - object: null -}; - - -exports.schema = function (config) { - - internals.any = internals.any || new (require('./any'))(); - internals.alt = internals.alt || require('./alternatives'); - internals.object = internals.object || require('./object'); - - if (config && - typeof config === 'object') { - - if (config.isJoi) { - return config; - } - - if (Array.isArray(config)) { - return internals.alt.try(config); - } - - if (config instanceof RegExp) { - return internals.string.regex(config); - } - - if (config instanceof Date) { - return internals.date.valid(config); - } - - return internals.object.keys(config); - } - - if (typeof config === 'string') { - return internals.string.valid(config); - } - - if (typeof config === 'number') { - return internals.number.valid(config); - } - - if (typeof config === 'boolean') { - return internals.boolean.valid(config); - } - - if (Ref.isRef(config)) { - return internals.any.valid(config); - } - - Hoek.assert(config === null, 'Invalid schema content:', config); - - return internals.any.valid(null); -}; - - -exports.ref = function (id) { - - return Ref.isRef(id) ? id : Ref.create(id); -}; -},{"./alternatives":1,"./any":2,"./boolean":5,"./date":7,"./number":12,"./object":13,"./ref":14,"./string":15,"hoek":16}],7:[function(require,module,exports){ -// Load modules - -var Any = require('./any'); -var Errors = require('./errors'); -var Hoek = require('hoek'); - - -// Declare internals - -var internals = {}; - - -internals.Date = function () { - - Any.call(this); - this._type = 'date'; -}; - -Hoek.inherits(internals.Date, Any); - - -internals.Date.prototype._base = function (value, state, options) { - - var result = { - value: (options.convert && internals.toDate(value)) || value - }; - - result.errors = (result.value instanceof Date && !isNaN(result.value.getTime())) ? null : Errors.create('date.base', null, state, options); - return result; -}; - - -internals.toDate = function (value) { - - if (value instanceof Date) { - return value; - } - - if (typeof value === 'string' || - Hoek.isInteger(value)) { - - if (typeof value === 'string' && - /^\d+$/.test(value)) { - - value = parseInt(value, 10); - } - - var date = new Date(value); - if (!isNaN(date.getTime())) { - return date; - } - } - - return null; -}; - - -internals.Date.prototype.min = function (date) { - - date = internals.toDate(date); - Hoek.assert(date, 'Invalid date format'); - - return this._test('min', date, function (value, state, options) { - - if (value.getTime() >= date.getTime()) { - return null; - } - - return Errors.create('date.min', { limit: date }, state, options); - }); -}; - - -internals.Date.prototype.max = function (date) { - - date = internals.toDate(date); - Hoek.assert(date, 'Invalid date format'); - - return this._test('max', date, function (value, state, options) { - - if (value.getTime() <= date.getTime()) { - return null; - } - - return Errors.create('date.max', { limit: date }, state, options); - }); -}; - - -module.exports = new internals.Date(); - -},{"./any":2,"./errors":8,"hoek":16}],8:[function(require,module,exports){ -// Load modules - -var Hoek = require('hoek'); -var Language = require('./language'); - - -// Declare internals - -var internals = {}; - - -internals.Err = function (type, context, state, options) { - - this.type = type; - this.context = context || {}; - this.context.key = state.key; - this.path = state.path; - this.options = options; -}; - - -internals.Err.prototype.toString = function () { - - var self = this; - - var localized = this.options.language; - this.context.key = this.context.key || localized.root || Language.errors.root; - - var format = Hoek.reach(localized, this.type) || Hoek.reach(Language.errors, this.type); - var hasKey = /\{\{\!?key\}\}/.test(format); - format = (hasKey ? format : '{{!key}} ' + format); - var message = format.replace(/\{\{(\!?)([^}]+)\}\}/g, function ($0, isSecure, name) { - - var value = Hoek.reach(self.context, name); - var normalized = Array.isArray(value) ? value.join(', ') : value.toString(); - return (isSecure ? Hoek.escapeHtml(normalized) : normalized); - }); - - return message; -}; - - -exports.create = function (type, context, state, options) { - - return new internals.Err(type, context, state, options); -}; - - -exports.process = function (errors, object) { - - if (!errors || !errors.length) { - return null; - } - - var details = []; - for (var i = 0, il = errors.length; i < il; ++i) { - var item = errors[i]; - details.push({ - message: item.toString(), - path: item.path || item.context.key, - type: item.type - }); - } - - // Construct error - - var message = ''; - details.forEach(function (error) { - - message += (message ? '. ' : '') + error.message; - }); - - var error = new Error(message); - error.name = 'ValidationError'; - error.details = details; - error._object = object; - error.annotate = internals.annotate; - return error; -}; - - -internals.annotate = function () { - - var obj = Hoek.clone(this._object || {}); - - var lookup = {}; - var el = this.details.length; - for (var e = el - 1; e >= 0; --e) { // Reverse order to process deepest child first - var pos = el - e; - var error = this.details[e]; - var path = error.path.split('.'); - var ref = obj; - for (var i = 0, il = path.length; i < il && ref; ++i) { - var seg = path[i]; - if (i + 1 < il) { - ref = ref[seg]; - } - else { - var value = ref[seg]; - if (value !== undefined) { - delete ref[seg]; - var label = seg + '_$key$_' + pos + '_$end$_'; - ref[label] = value; - lookup[error.path] = label; - } - else if (lookup[error.path]) { - var replacement = lookup[error.path]; - var appended = replacement.replace('_$end$_', ', ' + pos + '_$end$_'); - ref[appended] = ref[replacement]; - lookup[error.path] = appended; - delete ref[replacement]; - } - else { - ref['_$miss$_' + seg + '|' + pos + '_$end$_'] = '__missing__'; - } - } - } - } - - var annotated = JSON.stringify(obj, null, 2); - - annotated = annotated.replace(/_\$key\$_([, \d]+)_\$end\$_\"/g, function ($0, $1) { - - return '" \u001b[31m[' + $1 + ']\u001b[0m'; - }); - - var message = annotated.replace(/\"_\$miss\$_([^\|]+)\|(\d+)_\$end\$_\"\: \"__missing__\"/g, function ($0, $1, $2) { - - return '\u001b[41m"' + $1 + '"\u001b[0m\u001b[31m [' + $2 + ']: -- missing --\u001b[0m'; - }); - - message += '\n\u001b[31m'; - - for (e = 0; e < el; ++e) { - message += '\n[' + (e + 1) + '] ' + this.details[e].message; - } - - message += '\u001b[0m'; - - return message; -}; - - -},{"./language":11,"hoek":16}],9:[function(require,module,exports){ -// Load modules - -var Any = require('./any'); -var Errors = require('./errors'); -var Hoek = require('hoek'); - - -// Declare internals - -var internals = {}; - - -internals.Function = function () { - - Any.call(this); - this._type = 'func'; -}; - -Hoek.inherits(internals.Function, Any); - - -internals.Function.prototype._base = function (value, state, options) { - - return { - value: value, - errors: (typeof value === 'function') ? null : Errors.create('function.base', null, state, options) - }; -}; - - -module.exports = new internals.Function(); -},{"./any":2,"./errors":8,"hoek":16}],10:[function(require,module,exports){ -// Load modules - -var Hoek = require('hoek'); -var Any = require('./any'); -var Cast = require('./cast'); -var Ref = require('./ref'); - - -// Declare internals - -var internals = { - alternatives: require('./alternatives'), - array: require('./array'), - boolean: require('./boolean'), - binary: require('./binary'), - date: require('./date'), - func: require('./function'), - number: require('./number'), - object: require('./object'), - string: require('./string') -}; - - -internals.root = function () { - - var any = new Any(); - - var root = any.clone(); - root.any = function () { - - return any; - }; - - root.alternatives = root.alt = function () { - - return arguments.length ? internals.alternatives.try.apply(internals.alternatives, arguments) : internals.alternatives; - }; - - root.array = function () { - - return internals.array; - }; - - root.boolean = root.bool = function () { - - return internals.boolean; - }; - - root.binary = function () { - - return internals.binary; - }; - - root.date = function () { - - return internals.date; - }; - - root.func = function () { - - return internals.func; - }; - - root.number = function () { - - return internals.number; - }; - - root.object = function () { - - return arguments.length ? internals.object.keys.apply(internals.object, arguments) : internals.object; - }; - - root.string = function () { - - return internals.string; - }; - - root.ref = function () { - - return Ref.create.apply(null, arguments); - }; - - root.isRef = function (ref) { - - return Ref.isRef(ref); - }; - - root.validate = function (value /*, [schema], [options], callback */) { - - var last = arguments[arguments.length - 1]; - var callback = typeof last === 'function' ? last : null; - - var count = arguments.length - (callback ? 1 : 0); - if (count === 1) { - return any.validate(value, callback); - } - - var options = count === 3 ? arguments[2] : {}; - var schema = Cast.schema(arguments[1]); - - return schema._validateWithOptions(value, options, callback); - }; - - root.describe = function () { - - var schema = arguments.length ? Cast.schema(arguments[0]) : any; - return schema.describe(); - }; - - root.compile = function (schema) { - - return Cast.schema(schema); - }; - - root.assert = function (value, schema) { - - var error = root.validate(value, schema).error; - if (error) { - throw new Error(error.annotate()); - } - }; - - return root; -}; - - -module.exports = internals.root(); - -},{"./alternatives":1,"./any":2,"./array":3,"./binary":4,"./boolean":5,"./cast":6,"./date":7,"./function":9,"./number":12,"./object":13,"./ref":14,"./string":15,"hoek":16}],11:[function(require,module,exports){ -// Load modules - - -// Declare internals - -var internals = {}; - - -exports.errors = { - root: 'value', - any: { - unknown: 'is not allowed', - invalid: 'contains an invalid value', - empty: 'is not allowed to be empty', - required: 'is required', - allowOnly: 'must be one of {{valids}}' - }, - alternatives: { - base: 'not matching any of the allowed alternatives' - }, - array: { - base: 'must be an array', - includes: 'position {{pos}} does not match any of the allowed types', - includesOne: 'position {{pos}} fails because {{reason}}', - excludes: 'position {{pos}} contains an excluded value', - min: 'must contain at least {{limit}} items', - max: 'must contain less than or equal to {{limit}} items', - length: 'must contain {{limit}} items' - }, - boolean: { - base: 'must be a boolean' - }, - binary: { - base: 'must be a buffer or a string', - min: 'must be at least {{limit}} bytes', - max: 'must be less than or equal to {{limit}} bytes', - length: 'must be {{limit}} bytes' - }, - date: { - base: 'must be a number of milliseconds or valid date string', - min: 'must be larger than or equal to {{limit}}', - max: 'must be less than or equal to {{limit}}' - }, - function: { - base: 'must be a Function' - }, - object: { - base: 'must be an object', - min: 'must have at least {{limit}} children', - max: 'must have less than or equal to {{limit}} children', - length: 'must have {{limit}} children', - allowUnknown: 'is not allowed', - with: 'missing required peer {{peer}}', - without: 'conflict with forbidden peer {{peer}}', - missing: 'must contain at least one of {{peers}}', - xor: 'contains a conflict between exclusive peers {{peers}}', - or: 'must contain at least one of {{peers}}', - and: 'contains {{present}} without its required peers {{missing}}', - assert: 'validation failed because {{ref}} failed to {{message}}', - rename: { - multiple: 'cannot rename child {{from}} because multiple renames are disabled and another key was already renamed to {{to}}', - override: 'cannot rename child {{from}} because override is disabled and target {{to}} exists' - } - }, - number: { - base: 'must be a number', - min: 'must be larger than or equal to {{limit}}', - max: 'must be less than or equal to {{limit}}', - float: 'must be a float or double', - integer: 'must be an integer', - negative: 'must be a negative number', - positive: 'must be a positive number' - }, - string: { - base: 'must be a string', - min: 'length must be at least {{limit}} characters long', - max: 'length must be less than or equal to {{limit}} characters long', - length: 'length must be {{limit}} characters long', - alphanum: 'must only contain alpha-numeric characters', - token: 'must only contain alpha-numeric and underscore characters', - regex: 'fails to match the required pattern', - email: 'must be a valid email', - isoDate: 'must be a valid ISO 8601 date', - guid: 'must be a valid GUID', - hostname: 'must be a valid hostname', - lowercase: 'must only contain lowercase characters', - uppercase: 'must only contain uppercase characters', - trim: 'must not have leading or trailing whitespace' - } -}; - -},{}],12:[function(require,module,exports){ -// Load modules - -var Any = require('./any'); -var Errors = require('./errors'); -var Hoek = require('hoek'); - - -// Declare internals - -var internals = {}; - - -internals.Number = function () { - - Any.call(this); - this._type = 'number'; -}; - -Hoek.inherits(internals.Number, Any); - - -internals.Number.prototype._base = function (value, state, options) { - - var result = { - errors: null, - value: value - }; - - if (typeof value === 'string' && - options.convert) { - - var number = parseFloat(value); - result.value = (isNaN(number) || !isFinite(value)) ? NaN : number; - } - - result.errors = (typeof result.value === 'number' && !isNaN(result.value)) ? null : Errors.create('number.base', null, state, options); - return result; -}; - - -internals.Number.prototype.min = function (limit) { - - Hoek.assert(Hoek.isInteger(limit), 'limit must be an integer'); - - return this._test('min', limit, function (value, state, options) { - - if (value >= limit) { - return null; - } - - return Errors.create('number.min', { limit: limit }, state, options); - }); -}; - - -internals.Number.prototype.max = function (limit) { - - Hoek.assert(Hoek.isInteger(limit), 'limit must be an integer'); - - return this._test('max', limit, function (value, state, options) { - - if (value <= limit) { - return null; - } - - return Errors.create('number.max', { limit: limit }, state, options); - }); -}; - - -internals.Number.prototype.integer = function () { - - return this._test('integer', undefined, function (value, state, options) { - - return Hoek.isInteger(value) ? null : Errors.create('number.integer', null, state, options); - }); -}; - - -internals.Number.prototype.negative = function () { - - return this._test('negative', undefined, function (value, state, options) { - - if (value < 0) { - return null; - } - - return Errors.create('number.negative', null, state, options); - }); -}; - - -internals.Number.prototype.positive = function () { - - return this._test('positive', undefined, function (value, state, options) { - - if (value > 0) { - return null; - } - - return Errors.create('number.positive', null, state, options); - }); -}; - - -module.exports = new internals.Number(); - -},{"./any":2,"./errors":8,"hoek":16}],13:[function(require,module,exports){ -// Load modules - -var Hoek = require('hoek'); -var Topo = require('topo'); -var Any = require('./any'); -var Cast = require('./cast'); -var Ref = require('./ref'); -var Errors = require('./errors'); - - -// Declare internals - -var internals = {}; - - -internals.Object = function () { - - Any.call(this); - this._type = 'object'; - this._inner.children = null; - this._inner.renames = []; - this._inner.dependencies = []; - this._inner.patterns = []; -}; - -Hoek.inherits(internals.Object, Any); - - -internals.Object.prototype._base = function (value, state, options) { - - var target = value; - var errors = []; - var finish = function () { - - return { - value: target, - errors: errors.length ? errors : null - }; - }; - - if (typeof value === 'string' && - options.convert) { - - try { - value = JSON.parse(value); - } - catch (err) { } - } - - if (!value || - typeof value !== 'object' || - Array.isArray(value)) { - - errors.push(Errors.create('object.base', null, state, options)); - return finish(); - } - - // Ensure target is a local copy (parsed) or shallow copy - - if (target === value) { - target = {}; - target.__proto__ = Object.getPrototypeOf(value); - var valueKeys = Object.keys(value); - for (var t = 0, tl = valueKeys.length; t < tl; ++t) { - target[valueKeys[t]] = value[valueKeys[t]]; - } - } - else { - target = value; - } - - // Rename keys - - var renamed = {}; - for (var r = 0, rl = this._inner.renames.length; r < rl; ++r) { - var item = this._inner.renames[r]; - - if (target[item.from] === undefined) { - continue; - } - - if (!item.options.multiple && - renamed[item.to]) { - - errors.push(Errors.create('object.rename.multiple', { from: item.from, to: item.to }, state, options)); - if (options.abortEarly) { - return finish(); - } - } - - if (target.hasOwnProperty(item.to) && - !item.options.override && - !renamed[item.to]) { - - errors.push(Errors.create('object.rename.override', { from: item.from, to: item.to }, state, options)); - if (options.abortEarly) { - return finish(); - } - } - - target[item.to] = target[item.from]; - renamed[item.to] = true; - - if (!item.options.alias) { - delete target[item.from]; - } - } - - // Validate dependencies - - for (var d = 0, dl = this._inner.dependencies.length; d < dl; ++d) { - var dep = this._inner.dependencies[d]; - var err = internals[dep.type](dep.key !== null && value[dep.key], dep.peers, target, { key: dep.key, path: (state.path ? state.path + '.' : '') + dep.key }, options); - if (err) { - errors.push(err); - if (options.abortEarly) { - return finish(); - } - } - } - - // Validate schema - - if (!this._inner.children && // null allows any keys - !this._inner.patterns.length) { - - return finish(); - } - - var unprocessed = Hoek.mapToObject(Object.keys(target)); - var key; - - if (this._inner.children) { - for (var i = 0, il = this._inner.children.length; i < il; ++i) { - var child = this._inner.children[i]; - var key = child.key; - var item = target[key]; - - delete unprocessed[key]; - - var localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference }; - var result = child.schema._validate(item, localState, options); - if (result.errors) { - errors = errors.concat(result.errors); - if (options.abortEarly) { - return finish(); - } - } - - if (result.value !== undefined) { - target[key] = result.value; - } - } - } - - // Unknown keys - - var unprocessedKeys = Object.keys(unprocessed); - if (unprocessedKeys.length && - this._inner.patterns.length) { - - for (i = 0, il = unprocessedKeys.length; i < il; ++i) { - var key = unprocessedKeys[i]; - - for (var p = 0, pl = this._inner.patterns.length; p < pl; ++p) { - var pattern = this._inner.patterns[p]; - - if (pattern.regex.test(key)) { - delete unprocessed[key]; - - var item = target[key]; - var localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference }; - var result = pattern.rule._validate(item, localState, options); - if (result.errors) { - errors = errors.concat(result.errors); - if (options.abortEarly) { - return finish(); - } - } - - if (result.value !== undefined) { - target[key] = result.value; - } - } - } - } - - unprocessedKeys = Object.keys(unprocessed); - } - - if (unprocessedKeys.length) { - if (options.stripUnknown || - options.skipFunctions) { - - var hasFunctions = false; - for (var k = 0, kl = unprocessedKeys.length; k < kl; ++k) { - key = unprocessedKeys[k]; - - if (options.stripUnknown) { - delete target[key]; - } - else if (typeof target[key] === 'function') { - delete unprocessed[key]; - hasFunctions = true; - } - } - - if (options.stripUnknown) { - return finish(); - } - - if (hasFunctions) { - unprocessedKeys = Object.keys(unprocessed); - } - } - - if (unprocessedKeys.length && - (this._flags.allowUnknown !== undefined ? !this._flags.allowUnknown : !options.allowUnknown)) { - - for (var e = 0, el = unprocessedKeys.length; e < el; ++e) { - errors.push(Errors.create('object.allowUnknown', null, { key: unprocessedKeys[e], path: state.path }, options)); - } - } - } - - return finish(); -}; - - -internals.Object.prototype.keys = function (schema) { - - Hoek.assert(schema === null || schema === undefined || typeof schema === 'object', 'Object schema must be a valid object'); - Hoek.assert(!schema || !schema.isJoi, 'Object schema cannot be a joi schema'); - - var obj = this.clone(); - - if (!schema) { - obj._inner.children = null; - return obj; - } - - var children = Object.keys(schema); - - if (!children.length) { - obj._inner.children = []; - return obj; - } - - var topo = new Topo(); - if (obj._inner.children) { - for (var i = 0, il = obj._inner.children.length; i < il; ++i) { - var child = obj._inner.children[i]; - topo.add(child, { after: child._refs, group: child.key }); - } - } - - for (var c = 0, cl = children.length; c < cl; ++c) { - var key = children[c]; - var child = schema[key]; - var cast = Cast.schema(child); - topo.add({ key: key, schema: cast }, { after: cast._refs, group: key }); - } - - obj._inner.children = topo.nodes; - - return obj; -}; - - -internals.Object.prototype.unknown = function (allow) { - - var obj = this.clone(); - obj._flags.allowUnknown = (allow !== false); - return obj; -}; - - -internals.Object.prototype.length = function (limit) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - - return this._test('length', limit, function (value, state, options) { - - if (Object.keys(value).length === limit) { - return null; - } - - return Errors.create('object.length', { limit: limit }, state, options); - }); -}; - - -internals.Object.prototype.min = function (limit) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - - return this._test('min', limit, function (value, state, options) { - - if (Object.keys(value).length >= limit) { - return null; - } - - return Errors.create('object.min', { limit: limit }, state, options); - }); -}; - - -internals.Object.prototype.max = function (limit) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - - return this._test('max', limit, function (value, state, options) { - - if (Object.keys(value).length <= limit) { - return null; - } - - return Errors.create('object.max', { limit: limit }, state, options); - }); -}; - - -internals.Object.prototype.pattern = function (regex, schema) { - - Hoek.assert(regex instanceof RegExp, 'Invalid regular expression'); - Hoek.assert(schema !== undefined, 'Invalid rule'); - - var obj = this.clone(); - obj._inner.patterns.push({ regex: regex, rule: Cast.schema(schema) }); - return obj; -}; - - -internals.Object.prototype.with = function (key, peers) { - - return this._dependency('with', key, peers); -}; - - -internals.Object.prototype.without = function (key, peers) { - - return this._dependency('without', key, peers); -}; - - -internals.Object.prototype.xor = function () { - - var peers = Hoek.flatten(Array.prototype.slice.call(arguments)); - return this._dependency('xor', null, peers); -}; - - -internals.Object.prototype.or = function () { - - var peers = Hoek.flatten(Array.prototype.slice.call(arguments)); - return this._dependency('or', null, peers); -}; - - -internals.Object.prototype.and = function () { - - var peers = Hoek.flatten(Array.prototype.slice.call(arguments)); - return this._dependency('and', null, peers); -}; - - -internals.renameDefaults = { - alias: false, // Keep old value in place - multiple: false, // Allow renaming multiple keys into the same target - override: false // Overrides an existing key -}; - - -internals.Object.prototype.rename = function (from, to, options) { - - Hoek.assert(typeof from === 'string', 'Rename missing the from argument'); - Hoek.assert(typeof to === 'string', 'Rename missing the to argument'); - Hoek.assert(to !== from, 'Cannot rename key to same name:', from); - - for (var i = 0, il = this._inner.renames.length; i < il; ++i) { - Hoek.assert(this._inner.renames[i].from !== from, 'Cannot rename the same key multiple times'); - } - - var obj = this.clone(); - - obj._inner.renames.push({ - from: from, - to: to, - options: Hoek.applyToDefaults(internals.renameDefaults, options || {}) - }); - - return obj; -}; - - -internals.Object.prototype._dependency = function (type, key, peers) { - - peers = [].concat(peers); - for (var i = 0, li = peers.length; i < li; i++) { - Hoek.assert(typeof peers[i] === 'string', type, 'peers must be a string or array of strings'); - } - - var obj = this.clone(); - obj._inner.dependencies.push({ type: type, key: key, peers: peers }); - return obj; -}; - - -internals.with = function (value, peers, parent, state, options) { - - if (value === undefined) { - return null; - } - - for (var i = 0, il = peers.length; i < il; ++i) { - var peer = peers[i]; - if (!parent.hasOwnProperty(peer) || - parent[peer] === undefined) { - - return Errors.create('object.with', { peer: peer }, state, options); - } - } - - return null; -}; - - -internals.without = function (value, peers, parent, state, options) { - - if (value === undefined) { - return null; - } - - for (var i = 0, il = peers.length; i < il; ++i) { - var peer = peers[i]; - if (parent.hasOwnProperty(peer) && - parent[peer] !== undefined) { - - return Errors.create('object.without', { peer: peer }, state, options); - } - } - - return null; -}; - - -internals.xor = function (value, peers, parent, state, options) { - - var present = []; - for (var i = 0, il = peers.length; i < il; ++i) { - var peer = peers[i]; - if (parent.hasOwnProperty(peer) && - parent[peer] !== undefined) { - - present.push(peer); - } - } - - if (present.length === 1) { - return null; - } - - if (present.length === 0) { - return Errors.create('object.missing', { peers: peers }, state, options); - } - - return Errors.create('object.xor', { peers: peers }, state, options); -}; - - -internals.or = function (value, peers, parent, state, options) { - - for (var i = 0, il = peers.length; i < il; ++i) { - var peer = peers[i]; - if (parent.hasOwnProperty(peer) && - parent[peer] !== undefined) { - return null; - } - } - - return Errors.create('object.missing', { peers: peers }, state, options); -}; - - -internals.and = function (value, peers, parent, state, options) { - - var missing = []; - var present = []; - var count = peers.length; - for (var i = 0; i < count; ++i) { - var peer = peers[i]; - if (!parent.hasOwnProperty(peer) || - parent[peer] === undefined) { - - missing.push(peer); - } - else { - present.push(peer); - } - } - - var aon = (missing.length === count || present.length === count); - return !aon ? Errors.create('object.and', { present: present, missing: missing }, state, options) : null; -}; - - -internals.Object.prototype.describe = function (shallow) { - - var description = Any.prototype.describe.call(this); - - if (this._inner.children && - !shallow) { - - description.children = {}; - for (var i = 0, il = this._inner.children.length; i < il; ++i) { - var child = this._inner.children[i]; - description.children[child.key] = child.schema.describe(); - } - } - - if (this._inner.dependencies.length) { - description.dependencies = Hoek.clone(this._inner.dependencies); - } - - return description; -}; - - -internals.Object.prototype.assert = function (ref, schema, message) { - - ref = Cast.ref(ref); - Hoek.assert(ref.isContext || ref.depth > 1, 'Cannot use assertions for root level references - use direct key rules instead'); - - var cast = Cast.schema(schema); - - return this._test('assert', { cast: cast, ref: ref }, function (value, state, options) { - - var result = cast._validate(ref(value), null, options, value); - if (!result.errors) { - return null; - } - - return Errors.create('object.assert', { ref: ref.path.join('.'), message: message }, state, options); - }); -}; - - -module.exports = new internals.Object(); - -},{"./any":2,"./cast":6,"./errors":8,"./ref":14,"hoek":16,"topo":21}],14:[function(require,module,exports){ -// Load modules - -var Hoek = require('hoek'); - - -// Declare internals - -var internals = {}; - - -exports.create = function (key, options) { - - Hoek.assert(typeof key === 'string', 'Invalid reference key:', key); - - var settings = Hoek.clone(options); // options can be reused and modified - - var ref = function (value, validationOptions) { - - return Hoek.reach(ref.isContext ? validationOptions.context : value, ref.key, settings); - }; - - ref.isContext = (key[0] === ((settings && settings.contextPrefix) || '$')); - ref.key = (ref.isContext ? key.slice(1) : key); - ref.path = ref.key.split((settings && settings.separator) || '.'); - ref.depth = ref.path.length; - ref.root = ref.path[0]; - ref.isJoi = true; - - ref.toString = function () { - - return (ref.isContext ? 'context:' : 'ref:') + ref.key; - }; - - return ref; -}; - - -exports.isRef = function (ref) { - - return typeof ref === 'function' && ref.isJoi; -}; - - -exports.push = function (array, ref) { - - if (exports.isRef(ref) && - !ref.isContext) { - - array.push(ref.root); - } -}; -},{"hoek":16}],15:[function(require,module,exports){ -(function (Buffer){ -// Load modules - -var Net = require('net'); -var Hoek = require('hoek'); -var Isemail = require('isemail'); -var Any = require('./any'); -var Errors = require('./errors'); - - -// Declare internals - -var internals = {}; - - -internals.String = function () { - - Any.call(this); - this._type = 'string'; - this._invalids.add(''); -}; - -Hoek.inherits(internals.String, Any); - - -internals.String.prototype._base = function (value, state, options) { - - if (typeof value === 'string' && - options.convert) { - - if (this._flags.case) { - value = (this._flags.case === 'upper' ? value.toLocaleUpperCase() : value.toLocaleLowerCase()); - } - - if (this._flags.trim) { - value = value.trim(); - } - } - - return { - value: value, - errors: (typeof value === 'string') ? null : Errors.create('string.base', null, state, options) - }; -}; - - -internals.String.prototype.insensitive = function () { - - var obj = this.clone(); - obj._flags.insensitive = true; - return obj; -}; - - -internals.String.prototype.min = function (limit, encoding) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - Hoek.assert(!encoding || Buffer.isEncoding(encoding), 'Invalid encoding:', encoding); - - return this._test('min', limit, function (value, state, options) { - - var length = encoding ? Buffer.byteLength(value, encoding) : value.length; - if (length >= limit) { - return null; - } - - return Errors.create('string.min', { limit: limit }, state, options); - }); -}; - - -internals.String.prototype.max = function (limit, encoding) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - Hoek.assert(!encoding || Buffer.isEncoding(encoding), 'Invalid encoding:', encoding); - - return this._test('max', limit, function (value, state, options) { - - var length = encoding ? Buffer.byteLength(value, encoding) : value.length; - if (length <= limit) { - return null; - } - - return Errors.create('string.max', { limit: limit }, state, options); - }); -}; - - -internals.String.prototype.length = function (limit, encoding) { - - Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer'); - Hoek.assert(!encoding || Buffer.isEncoding(encoding), 'Invalid encoding:', encoding); - - return this._test('length', limit, function (value, state, options) { - - var length = encoding ? Buffer.byteLength(value, encoding) : value.length; - if (length === limit) { - return null; - } - - return Errors.create('string.length', { limit: limit }, state, options); - }); -}; - - -internals.String.prototype.regex = function (pattern) { - - Hoek.assert(pattern instanceof RegExp, 'pattern must be a RegExp'); - - return this._test('regex', pattern, function (value, state, options) { - - if (pattern.test(value)) { - return null; - } - - return Errors.create('string.regex', null, state, options); - }); -}; - - -internals.String.prototype.alphanum = function () { - - return this._test('alphanum', undefined, function (value, state, options) { - - if (/^[a-zA-Z0-9]+$/.test(value)) { - return null; - } - - return Errors.create('string.alphanum', null, state, options); - }); -}; - - -internals.String.prototype.token = function () { - - return this._test('token', undefined, function (value, state, options) { - - if (/^\w+$/.test(value)) { - return null; - } - - return Errors.create('string.token', null, state, options); - }); -}; - - -internals.String.prototype.email = function () { - - return this._test('email', undefined, function (value, state, options) { - - if (Isemail(value)) { - return null; - } - - return Errors.create('string.email', null, state, options); - }); -}; - - -internals.String.prototype.isoDate = function () { - - var regex = /^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/; - - return this._test('isoDate', undefined, function (value, state, options) { - - if (regex.test(value)) { - return null; - } - - return Errors.create('string.isoDate', null, state, options); - }); -}; - - -internals.String.prototype.guid = function () { - - var regex = /^[A-F0-9]{8}(?:-?[A-F0-9]{4}){3}-?[A-F0-9]{12}$/i; - var regex2 = /^\{[A-F0-9]{8}(?:-?[A-F0-9]{4}){3}-?[A-F0-9]{12}\}$/i; - - return this._test('guid', undefined, function (value, state, options) { - - if (regex.test(value) || regex2.test(value)) { - return null; - } - - return Errors.create('string.guid', null, state, options); - }); -}; - - -internals.String.prototype.hostname = function () { - - var regex = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/; - - return this._test('hostname', undefined, function (value, state, options) { - - if ((value.length <= 255 && regex.test(value)) || - Net.isIPv6(value)) { - - return null; - } - - return Errors.create("string.hostname", null, state, options); - }); -}; - - -internals.String.prototype.lowercase = function () { - - var obj = this._test('lowercase', undefined, function (value, state, options) { - - if (options.convert || - value === value.toLocaleLowerCase()) { - - return null; - } - - return Errors.create('string.lowercase', null, state, options); - }); - - obj._flags.case = 'lower'; - return obj; -}; - - -internals.String.prototype.uppercase = function (options) { - - var obj = this._test('uppercase', undefined, function (value, state, options) { - - if (options.convert || - value === value.toLocaleUpperCase()) { - - return null; - } - - return Errors.create('string.uppercase', null, state, options); - }); - - obj._flags.case = 'upper'; - return obj; -}; - - -internals.String.prototype.trim = function () { - - var obj = this._test('trim', undefined, function (value, state, options) { - - if (options.convert || - value === value.trim()) { - - return null; - } - - return Errors.create('string.trim', null, state, options); - }); - - obj._flags.trim = true; - return obj; -}; - - -module.exports = new internals.String(); - -}).call(this,require("buffer").Buffer) -},{"./any":2,"./errors":8,"buffer":24,"hoek":16,"isemail":19,"net":23}],16:[function(require,module,exports){ -module.exports = require('./lib'); -},{"./lib":18}],17:[function(require,module,exports){ -(function (Buffer){ -// Declare internals - -var internals = {}; - - -exports.escapeJavaScript = function (input) { - - if (!input) { - return ''; - } - - var escaped = ''; - - for (var i = 0, il = input.length; i < il; ++i) { - - var charCode = input.charCodeAt(i); - - if (internals.isSafe(charCode)) { - escaped += input[i]; - } - else { - escaped += internals.escapeJavaScriptChar(charCode); - } - } - - return escaped; -}; - - -exports.escapeHtml = function (input) { - - if (!input) { - return ''; - } - - var escaped = ''; - - for (var i = 0, il = input.length; i < il; ++i) { - - var charCode = input.charCodeAt(i); - - if (internals.isSafe(charCode)) { - escaped += input[i]; - } - else { - escaped += internals.escapeHtmlChar(charCode); - } - } - - return escaped; -}; - - -internals.escapeJavaScriptChar = function (charCode) { - - if (charCode >= 256) { - return '\\u' + internals.padLeft('' + charCode, 4); - } - - var hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex'); - return '\\x' + internals.padLeft(hexValue, 2); -}; - - -internals.escapeHtmlChar = function (charCode) { - - var namedEscape = internals.namedHtml[charCode]; - if (typeof namedEscape !== 'undefined') { - return namedEscape; - } - - if (charCode >= 256) { - return '&#' + charCode + ';'; - } - - var hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex'); - return '&#x' + internals.padLeft(hexValue, 2) + ';'; -}; - - -internals.padLeft = function (str, len) { - - while (str.length < len) { - str = '0' + str; - } - - return str; -}; - - -internals.isSafe = function (charCode) { - - return (typeof internals.safeCharCodes[charCode] !== 'undefined'); -}; - - -internals.namedHtml = { - '38': '&', - '60': '<', - '62': '>', - '34': '"', - '160': ' ', - '162': '¢', - '163': '£', - '164': '¤', - '169': '©', - '174': '®' -}; - - -internals.safeCharCodes = (function () { - - var safe = {}; - - for (var i = 32; i < 123; ++i) { - - if ((i >= 97) || // a-z - (i >= 65 && i <= 90) || // A-Z - (i >= 48 && i <= 57) || // 0-9 - i === 32 || // space - i === 46 || // . - i === 44 || // , - i === 45 || // - - i === 58 || // : - i === 95) { // _ - - safe[i] = null; - } - } - - return safe; -}()); -}).call(this,require("buffer").Buffer) -},{"buffer":24}],18:[function(require,module,exports){ -(function (process,Buffer){ -// Load modules - -var Path = require('path'); -var Util = require('util'); -var Escape = require('./escape'); - - -// Declare internals - -var internals = {}; - - -// Clone object or array - -exports.clone = function (obj, seen) { - - if (typeof obj !== 'object' || - obj === null) { - - return obj; - } - - seen = seen || { orig: [], copy: [] }; - - var lookup = seen.orig.indexOf(obj); - if (lookup !== -1) { - return seen.copy[lookup]; - } - - var newObj; - var cloneDeep = false; - - if (!Array.isArray(obj)) { - if (Buffer.isBuffer(obj)) { - newObj = new Buffer(obj); - } - else if (obj instanceof Date) { - newObj = new Date(obj.getTime()); - } - else if (obj instanceof RegExp) { - newObj = new RegExp(obj); - } - else { - var proto = Object.getPrototypeOf(obj); - if (!proto || proto.isImmutable) { - newObj = obj; - } - else { - newObj = {}; - newObj.__proto__ = proto; - cloneDeep = true; - } - } - } - else { - newObj = []; - cloneDeep = true; - } - - seen.orig.push(obj); - seen.copy.push(newObj); - - if (cloneDeep) { - for (var i in obj) { - if (obj.hasOwnProperty(i)) { - newObj[i] = exports.clone(obj[i], seen); - } - } - } - - return newObj; -}; - - -// Merge all the properties of source into target, source wins in conflict, and by default null and undefined from source are applied - -exports.merge = function (target, source, isNullOverride /* = true */, isMergeObjects /* = true */) { - - exports.assert(target && typeof target === 'object', 'Invalid target value: must be an object'); - exports.assert(source === null || source === undefined || typeof source === 'object', 'Invalid source value: must be null, undefined, or an object'); - - if (!source) { - return target; - } - - if (Array.isArray(source)) { - exports.assert(Array.isArray(target), 'Cannot merge array onto an object'); - if (isMergeObjects === false) { // isMergeObjects defaults to true - target.length = 0; // Must not change target assignment - } - - for (var i = 0, il = source.length; i < il; ++i) { - target.push(exports.clone(source[i])); - } - - return target; - } - - var keys = Object.keys(source); - for (var k = 0, kl = keys.length; k < kl; ++k) { - var key = keys[k]; - var value = source[key]; - if (value && - typeof value === 'object') { - - if (!target[key] || - typeof target[key] !== 'object' || - (Array.isArray(target[key]) ^ Array.isArray(value)) || - value instanceof Date || - Buffer.isBuffer(value) || - value instanceof RegExp) { - - target[key] = exports.clone(value); - } - else { - exports.merge(target[key], value, isNullOverride, isMergeObjects); - } - } - else { - if (value !== null && - value !== undefined) { // Explicit to preserve empty strings - - target[key] = value; - } - else if (isNullOverride !== false) { // Defaults to true - target[key] = value; - } - } - } - - return target; -}; - - -// Apply options to a copy of the defaults - -exports.applyToDefaults = function (defaults, options) { - - exports.assert(defaults && typeof defaults === 'object', 'Invalid defaults value: must be an object'); - exports.assert(!options || options === true || typeof options === 'object', 'Invalid options value: must be true, falsy or an object'); - - if (!options) { // If no options, return null - return null; - } - - var copy = exports.clone(defaults); - - if (options === true) { // If options is set to true, use defaults - return copy; - } - - return exports.merge(copy, options, false, false); -}; - - -// Clone an object except for the listed keys which are shallow copied - -exports.cloneWithShallow = function (source, keys) { - - if (!source || - typeof source !== 'object') { - - return source; - } - - return internals.shallow(source, keys, function () { - - return exports.clone(source); - }); -}; - - -// Apply options to defaults except for the listed keys which are shallow copied from option without merging - -exports.applyToDefaultsWithShallow = function (defaults, options, keys) { - - return internals.shallow(options, keys, function () { - - return exports.applyToDefaults(defaults, options); - }); -}; - - -internals.shallow = function (source, keys, clone) { - - // Move shallow copy items to storage - - var storage = {}; - for (var i = 0, il = keys.length; i < il; ++i) { - var key = keys[i]; - if (source.hasOwnProperty(key)) { - storage[key] = source[key]; - source[key] = undefined; - } - } - - // Deep copy the rest - - var copy = clone(); - - // Shallow copy the stored items - - for (i = 0; i < il; ++i) { - var key = keys[i]; - if (storage.hasOwnProperty(key)) { - source[key] = storage[key]; - copy[key] = storage[key]; - } - } - - return copy; -}; - - -// Remove duplicate items from array - -exports.unique = function (array, key) { - - var index = {}; - var result = []; - - for (var i = 0, il = array.length; i < il; ++i) { - var id = (key ? array[i][key] : array[i]); - if (index[id] !== true) { - - result.push(array[i]); - index[id] = true; - } - } - - return result; -}; - - -// Convert array into object - -exports.mapToObject = function (array, key) { - - if (!array) { - return null; - } - - var obj = {}; - for (var i = 0, il = array.length; i < il; ++i) { - if (key) { - if (array[i][key]) { - obj[array[i][key]] = true; - } - } - else { - obj[array[i]] = true; - } - } - - return obj; -}; - - -// Find the common unique items in two arrays - -exports.intersect = function (array1, array2, justFirst) { - - if (!array1 || !array2) { - return []; - } - - var common = []; - var hash = (Array.isArray(array1) ? exports.mapToObject(array1) : array1); - var found = {}; - for (var i = 0, il = array2.length; i < il; ++i) { - if (hash[array2[i]] && !found[array2[i]]) { - if (justFirst) { - return array2[i]; - } - - common.push(array2[i]); - found[array2[i]] = true; - } - } - - return (justFirst ? null : common); -}; - - -// Flatten array - -exports.flatten = function (array, target) { - - var result = target || []; - - for (var i = 0, il = array.length; i < il; ++i) { - if (Array.isArray(array[i])) { - exports.flatten(array[i], result); - } - else { - result.push(array[i]); - } - } - - return result; -}; - - -// Convert an object key chain string ('a.b.c') to reference (object[a][b][c]) - -exports.reach = function (obj, chain, options) { - - options = options || {}; - if (typeof options === 'string') { - options = { separator: options }; - } - - var path = chain.split(options.separator || '.'); - var ref = obj; - for (var i = 0, il = path.length; i < il; ++i) { - if (!ref || - !ref.hasOwnProperty(path[i]) || - (typeof ref !== 'object' && options.functions === false)) { // Only object and function can have properties - - exports.assert(!options.strict || i + 1 === il, 'Missing segment', path[i], 'in reach path ', chain); - exports.assert(typeof ref === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', path[i], 'in reach path ', chain); - ref = options.default || undefined; - break; - } - - ref = ref[path[i]]; - } - - return ref; -}; - - -exports.formatStack = function (stack) { - - var trace = []; - for (var i = 0, il = stack.length; i < il; ++i) { - var item = stack[i]; - trace.push([item.getFileName(), item.getLineNumber(), item.getColumnNumber(), item.getFunctionName(), item.isConstructor()]); - } - - return trace; -}; - - -exports.formatTrace = function (trace) { - - var display = []; - - for (var i = 0, il = trace.length; i < il; ++i) { - var row = trace[i]; - display.push((row[4] ? 'new ' : '') + row[3] + ' (' + row[0] + ':' + row[1] + ':' + row[2] + ')'); - } - - return display; -}; - - -exports.callStack = function (slice) { - - // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi - - var v8 = Error.prepareStackTrace; - Error.prepareStackTrace = function (err, stack) { - - return stack; - }; - - var capture = {}; - Error.captureStackTrace(capture, arguments.callee); - var stack = capture.stack; - - Error.prepareStackTrace = v8; - - var trace = exports.formatStack(stack); - - if (slice) { - return trace.slice(slice); - } - - return trace; -}; - - -exports.displayStack = function (slice) { - - var trace = exports.callStack(slice === undefined ? 1 : slice + 1); - - return exports.formatTrace(trace); -}; - - -exports.abortThrow = false; - - -exports.abort = function (message, hideStack) { - - if (process.env.NODE_ENV === 'test' || exports.abortThrow === true) { - throw new Error(message || 'Unknown error'); - } - - var stack = ''; - if (!hideStack) { - stack = exports.displayStack(1).join('\n\t'); - } - console.log('ABORT: ' + message + '\n\t' + stack); - process.exit(1); -}; - - -exports.assert = function (condition /*, msg1, msg2, msg3 */) { - - if (condition) { - return; - } - - var msgs = []; - for (var i = 1, il = arguments.length; i < il; ++i) { - msgs.push(arguments[i]); // Avoids Array.slice arguments leak, allowing for V8 optimizations - } - - msgs = msgs.map(function (msg) { - - return typeof msg === 'string' ? msg : msg instanceof Error ? msg.message : JSON.stringify(msg); - }); - throw new Error(msgs.join(' ') || 'Unknown error'); -}; - - -exports.Timer = function () { - - this.ts = 0; - this.reset(); -}; - - -exports.Timer.prototype.reset = function () { - - this.ts = Date.now(); -}; - - -exports.Timer.prototype.elapsed = function () { - - return Date.now() - this.ts; -}; - - -exports.Bench = function () { - - this.ts = 0; - this.reset(); -}; - - -exports.Bench.prototype.reset = function () { - - this.ts = exports.Bench.now(); -}; - - -exports.Bench.prototype.elapsed = function () { - - return exports.Bench.now() - this.ts; -}; - - -exports.Bench.now = function () { - - var ts = process.hrtime(); - return (ts[0] * 1e3) + (ts[1] / 1e6); -}; - - -// Escape string for Regex construction - -exports.escapeRegex = function (string) { - - // Escape ^$.*+-?=!:|\/()[]{}, - return string.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g, '\\$&'); -}; - - -// Base64url (RFC 4648) encode - -exports.base64urlEncode = function (value, encoding) { - - var buf = (Buffer.isBuffer(value) ? value : new Buffer(value, encoding || 'binary')); - return buf.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, ''); -}; - - -// Base64url (RFC 4648) decode - -exports.base64urlDecode = function (value, encoding) { - - if (value && - !/^[\w\-]*$/.test(value)) { - - return new Error('Invalid character'); - } - - try { - var buf = new Buffer(value, 'base64'); - return (encoding === 'buffer' ? buf : buf.toString(encoding || 'binary')); - } - catch (err) { - return err; - } -}; - - -// Escape attribute value for use in HTTP header - -exports.escapeHeaderAttribute = function (attribute) { - - // Allowed value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9, \, " - - exports.assert(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~\"\\]*$/.test(attribute), 'Bad attribute value (' + attribute + ')'); - - return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"'); // Escape quotes and slash -}; - - -exports.escapeHtml = function (string) { - - return Escape.escapeHtml(string); -}; - - -exports.escapeJavaScript = function (string) { - - return Escape.escapeJavaScript(string); -}; - - -exports.nextTick = function (callback) { - - return function () { - - var args = arguments; - process.nextTick(function () { - - callback.apply(null, args); - }); - }; -}; - - -exports.once = function (method) { - - if (method._hoekOnce) { - return method; - } - - var once = false; - var wrapped = function () { - - if (!once) { - once = true; - method.apply(null, arguments); - } - }; - - wrapped._hoekOnce = true; - - return wrapped; -}; - - -exports.isAbsolutePath = function (path, platform) { - - if (!path) { - return false; - } - - if (Path.isAbsolute) { // node >= 0.11 - return Path.isAbsolute(path); - } - - platform = platform || process.platform; - - // Unix - - if (platform !== 'win32') { - return path[0] === '/'; - } - - // Windows - - return !!/^(?:[a-zA-Z]:[\\\/])|(?:[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/])/.test(path); // C:\ or \\something\something -}; - - -exports.isInteger = function (value) { - - return (typeof value === 'number' && - parseFloat(value) === parseInt(value, 10) && - !isNaN(value)); -}; - - -exports.ignore = function () { }; - - -exports.inherits = Util.inherits; - - -exports.transform = function (source, transform, options) { - - exports.assert(source == null || typeof source === 'object', 'Invalid source object: must be null, undefined, or an object'); - - var result = {}; - var keys = Object.keys(transform); - - for (var k = 0, kl = keys.length; k < kl; ++k) { - var key = keys[k]; - var path = key.split('.'); - var sourcePath = transform[key]; - - exports.assert(typeof sourcePath === 'string', 'All mappings must be "." delineated strings'); - - var segment; - var res = result; - - while (path.length > 1) { - segment = path.shift(); - if (!res[segment]) { - res[segment] = {}; - } - res = res[segment]; - } - segment = path.shift(); - res[segment] = exports.reach(source, sourcePath, options); - } - - return result; -}; - -}).call(this,require('_process'),require("buffer").Buffer) -},{"./escape":17,"_process":29,"buffer":24,"path":28,"util":31}],19:[function(require,module,exports){ -module.exports = require('./lib/isemail'); - -},{"./lib/isemail":20}],20:[function(require,module,exports){ -(function (process){ -/** - * To validate an email address according to RFCs 5321, 5322 and others - * - * Copyright © 2008-2011, Dominic Sayers - * Test schema documentation Copyright © 2011, Daniel Marschall - * Port for Node.js Copyright © 2013, GlobeSherpa - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Dominic Sayers nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @author Dominic Sayers - * @author Eli Skeggs - * @copyright 2008-2011 Dominic Sayers - * @copyright 2013-2014 GlobeSherpa - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.dominicsayers.com/isemail - * @link https://github.com/globesherpa/isemail - * @version 1.0.1 - Increase test coverage, minor style fixes. - */ - -// lazy-loaded -var dns, HAS_REQUIRE = typeof require !== 'undefined'; - -// categories -var ISEMAIL_VALID_CATEGORY = 1; -var ISEMAIL_DNSWARN = 7; -var ISEMAIL_RFC5321 = 15; -var ISEMAIL_CFWS = 31; -var ISEMAIL_DEPREC = 63; -var ISEMAIL_RFC5322 = 127; -var ISEMAIL_ERR = 255; - -// diagnoses -// address is valid -var ISEMAIL_VALID = 0; -// address is valid but a DNS check was not successful -var ISEMAIL_DNSWARN_NO_MX_RECORD = 5; -var ISEMAIL_DNSWARN_NO_RECORD = 6; -// address is valid for SMTP but has unusual elements -var ISEMAIL_RFC5321_TLD = 9; -var ISEMAIL_RFC5321_TLDNUMERIC = 10; -var ISEMAIL_RFC5321_QUOTEDSTRING = 11; -var ISEMAIL_RFC5321_ADDRESSLITERAL = 12; -var ISEMAIL_RFC5321_IPV6DEPRECATED = 13; -// address is valid within the message but cannot be used unmodified for the envelope -var ISEMAIL_CFWS_COMMENT = 17; -var ISEMAIL_CFWS_FWS = 18; -// address contains deprecated elements but may still be valid in restricted contexts -var ISEMAIL_DEPREC_LOCALPART = 33; -var ISEMAIL_DEPREC_FWS = 34; -var ISEMAIL_DEPREC_QTEXT = 35; -var ISEMAIL_DEPREC_QP = 36; -var ISEMAIL_DEPREC_COMMENT = 37; -var ISEMAIL_DEPREC_CTEXT = 38; -var ISEMAIL_DEPREC_CFWS_NEAR_AT = 49; -// the address is only valid according to the broad definition of RFC 5322, but otherwise invalid -var ISEMAIL_RFC5322_DOMAIN = 65; -var ISEMAIL_RFC5322_TOOLONG = 66; -var ISEMAIL_RFC5322_LOCAL_TOOLONG = 67; -var ISEMAIL_RFC5322_DOMAIN_TOOLONG = 68; -var ISEMAIL_RFC5322_LABEL_TOOLONG = 69; -var ISEMAIL_RFC5322_DOMAINLITERAL = 70; -var ISEMAIL_RFC5322_DOMLIT_OBSDTEXT = 71; -var ISEMAIL_RFC5322_IPV6_GRPCOUNT = 72; -var ISEMAIL_RFC5322_IPV6_2X2XCOLON = 73; -var ISEMAIL_RFC5322_IPV6_BADCHAR = 74; -var ISEMAIL_RFC5322_IPV6_MAXGRPS = 75; -var ISEMAIL_RFC5322_IPV6_COLONSTRT = 76; -var ISEMAIL_RFC5322_IPV6_COLONEND = 77; -// address is invalid for any purpose -var ISEMAIL_ERR_EXPECTING_DTEXT = 129; -var ISEMAIL_ERR_NOLOCALPART = 130; -var ISEMAIL_ERR_NODOMAIN = 131; -var ISEMAIL_ERR_CONSECUTIVEDOTS = 132; -var ISEMAIL_ERR_ATEXT_AFTER_CFWS = 133; -var ISEMAIL_ERR_ATEXT_AFTER_QS = 134; -var ISEMAIL_ERR_ATEXT_AFTER_DOMLIT = 135; -var ISEMAIL_ERR_EXPECTING_QPAIR = 136; -var ISEMAIL_ERR_EXPECTING_ATEXT = 137; -var ISEMAIL_ERR_EXPECTING_QTEXT = 138; -var ISEMAIL_ERR_EXPECTING_CTEXT = 139; -var ISEMAIL_ERR_BACKSLASHEND = 140; -var ISEMAIL_ERR_DOT_START = 141; -var ISEMAIL_ERR_DOT_END = 142; -var ISEMAIL_ERR_DOMAINHYPHENSTART = 143; -var ISEMAIL_ERR_DOMAINHYPHENEND = 144; -var ISEMAIL_ERR_UNCLOSEDQUOTEDSTR = 145; -var ISEMAIL_ERR_UNCLOSEDCOMMENT = 146; -var ISEMAIL_ERR_UNCLOSEDDOMLIT = 147; -var ISEMAIL_ERR_FWS_CRLF_X2 = 148; -var ISEMAIL_ERR_FWS_CRLF_END = 149; -var ISEMAIL_ERR_CR_NO_LF = 150; - -// function control -var ISEMAIL_THRESHOLD = 16; -// email parts -var ISEMAIL_COMPONENT_LOCALPART = 0; -var ISEMAIL_COMPONENT_DOMAIN = 1; -var ISEMAIL_COMPONENT_LITERAL = 2; -var ISEMAIL_CONTEXT_COMMENT = 3; -var ISEMAIL_CONTEXT_FWS = 4; -var ISEMAIL_CONTEXT_QUOTEDSTRING = 5; -var ISEMAIL_CONTEXT_QUOTEDPAIR = 6; -// US-ASCII visible characters not valid for atext (http://tools.ietf.org/html/rfc5322#section-3.2.3) -var SPECIALS = '()<>[]:;@\\,."'; - -// matches valid IPv4 addresses from the end of a string -var IPv4_REGEX = /\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/; - - -// ---- Modification ----- -// Removed for Karma tests -var IPv6_REGEX = /^[a-fA-F\d]{0,4}$/; -var IPv6_REGEX_TEST; -if (!window.hasOwnProperty("TEST_BUILD")) { - IPv6_REGEX_TEST = IPv6_REGEX.test.bind(IPv6_REGEX); -} - -// -// ---- End of Modification ----- - -/** - * Get the largest number in the array. - * - * Returns -Infinity if the array is empty. - * - * @param {Array.} array The array to scan. - * @return {number} The largest number contained. - */ -function maxValue(array) { - var v = -Infinity, i = 0, n = array.length; - - for (; i < n; i++) { - if (array[i] > v) { - v = array[i]; - } - } - - return v; -} - -/** - * Check that an email address conforms to RFCs 5321, 5322 and others - * - * As of Version 3.0, we are now distinguishing clearly between a Mailbox - * as defined by RFC 5321 and an addr-spec as defined by RFC 5322. Depending - * on the context, either can be regarded as a valid email address. The - * RFC 5321 Mailbox specification is more restrictive (comments, white space - * and obsolete forms are not allowed). - * - * @param {string} email The email address to check. - * @param {boolean} checkDNS If true then will check DNS for MX records. If true - * this isEmail _will_ be asynchronous. - * @param {*} errorLevel Determines the boundary between valid and invalid - * addresses. Status codes above this number will be returned as-is, status - * codes below will be returned as ISEMAIL_VALID. Thus the calling program can - * simply look for ISEMAIL_VALID if it is only interested in whether an - * address is valid or not. The errorLevel will determine how "picky" - * isEmail() is about the address. If omitted or passed as false then - * isEmail() will return true or false rather than an integer error or - * warning. NB Note the difference between errorLevel = false and - * errorLevel = 0. - * @return {*} - */ -function isEmail(email, options, callback) { - if (typeof options === 'function') { - callback = options; - options = {}; - } - options || (options = {}); - - var threshold, diagnose; - if (typeof options.errorLevel === 'number') { - diagnose = true; - threshold = options.errorLevel; - } else { - diagnose = !!options.errorLevel; - threshold = ISEMAIL_VALID; - } - - var result = [ISEMAIL_VALID]; - - var context = { - now: ISEMAIL_COMPONENT_LOCALPART, - prev: ISEMAIL_COMPONENT_LOCALPART, - stack: [ISEMAIL_COMPONENT_LOCALPART] - }; - - var token = '', prevToken = '', charCode = 0, parseData = {}, atomList = {}; - parseData[ISEMAIL_COMPONENT_LOCALPART] = ''; - parseData[ISEMAIL_COMPONENT_DOMAIN] = ''; - atomList[ISEMAIL_COMPONENT_LOCALPART] = ['']; - atomList[ISEMAIL_COMPONENT_DOMAIN] = ['']; - - var elementCount = 0, elementLength = 0, hyphenFlag = false, assertEnd = false; - var crlfCount = 0; - - for (var i = 0; i < email.length; i++) { - token = email[i]; - - switch (context.now) { - // local-part - case ISEMAIL_COMPONENT_LOCALPART: - // http://tools.ietf.org/html/rfc5322#section-3.4.1 - // local-part = dot-atom / quoted-string / obs-local-part - // - // dot-atom = [CFWS] dot-atom-text [CFWS] - // - // dot-atom-text = 1*atext *("." 1*atext) - // - // quoted-string = [CFWS] - // DQUOTE *([FWS] qcontent) [FWS] DQUOTE - // [CFWS] - // - // obs-local-part = word *("." word) - // - // word = atom / quoted-string - // - // atom = [CFWS] 1*atext [CFWS] - switch (token) { - // comment - case '(': - if (elementLength === 0) { - // comments are OK at the beginning of an element - result.push(elementCount === 0 ? ISEMAIL_CFWS_COMMENT : ISEMAIL_DEPREC_COMMENT); - } else { - result.push(ISEMAIL_CFWS_COMMENT); - assertEnd = true; // can't start a comment in an element, should be end - } - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_COMMENT; - break; - // next dot-atom element - case '.': - if (elementLength === 0) { - // another dot, already? - result.push(elementCount === 0 ? ISEMAIL_ERR_DOT_START : ISEMAIL_ERR_CONSECUTIVEDOTS); - } else { - // the entire local-part can be a quoted string for RFC 5321 - // if it's just one atom that is quoted then it's an RFC 5322 obsolete form - if (assertEnd) { - result.push(ISEMAIL_DEPREC_LOCALPART); - } - - // CFWS & quoted strings are OK again now we're at the beginning of an element (although they are obsolete forms) - assertEnd = false; - elementLength = 0; - elementCount++; - parseData[ISEMAIL_COMPONENT_LOCALPART] += token; - atomList[ISEMAIL_COMPONENT_LOCALPART][elementCount] = ''; // TODO: push? - } - break; - // quoted string - case '"': - if (elementLength === 0) { - // the entire local-part can be a quoted string for RFC 5321 - // if it's just one atom that is quoted then it's an RFC 5322 obsolete form - result.push(elementCount === 0 ? ISEMAIL_RFC5321_QUOTEDSTRING : ISEMAIL_DEPREC_LOCALPART); - - parseData[ISEMAIL_COMPONENT_LOCALPART] += token; - atomList[ISEMAIL_COMPONENT_LOCALPART][elementCount] += token; - elementLength++; - assertEnd = true; // quoted string must be the entire element - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_QUOTEDSTRING; - } else { - result.push(ISEMAIL_ERR_EXPECTING_ATEXT); - } - break; - // folding white space - case '\r': - case ' ': - case '\t': - if (token === '\r' && ((++i === email.length) || email[i] !== '\n')) { - // fatal error - result.push(ISEMAIL_ERR_CR_NO_LF); - break; - } - if (elementLength === 0) { - result.push(elementCount === 0 ? ISEMAIL_CFWS_FWS : ISEMAIL_DEPREC_FWS); - } else { - // we can't start FWS in the middle of an element, better be end - assertEnd = true; - } - - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_FWS; - prevToken = token; - break; - // @ - case '@': - // at this point we should have a valid local-part - /* istanbul ignore next: logically unreachable */ - if (context.stack.length !== 1) { - throw new Error('unexpected item on context stack'); - } - - if (parseData[ISEMAIL_COMPONENT_LOCALPART].length === 0) { - // fatal error - result.push(ISEMAIL_ERR_NOLOCALPART); - } else if (elementLength === 0) { - // fatal error - result.push(ISEMAIL_ERR_DOT_END); - // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.1 - // the maximum total length of a user name or other local-part is 64 - // octets - } else if (parseData[ISEMAIL_COMPONENT_LOCALPART].length > 64) { - result.push(ISEMAIL_RFC5322_LOCAL_TOOLONG); - // http://tools.ietf.org/html/rfc5322#section-3.4.1 - // comments and folding white space - // SHOULD NOT be used around the "@" in the addr-spec - // - // http://tools.ietf.org/html/rfc2119 - // 4. SHOULD NOT this phrase, or the phrase "NOT RECOMMENDED" mean that - // there may exist valid reasons in particular circumstances when the - // particular behavior is acceptable or even useful, but the full - // implications should be understood and the case carefully weighed - // before implementing any behavior described with this label - } else if ((context.prev === ISEMAIL_CONTEXT_COMMENT) || (context.prev === ISEMAIL_CONTEXT_FWS)) { - result.push(ISEMAIL_DEPREC_CFWS_NEAR_AT); - } - - // clear everything down for the domain parsing - context.now = ISEMAIL_COMPONENT_DOMAIN; // where we are - context.stack = [ISEMAIL_COMPONENT_DOMAIN]; // where we have been - elementCount = 0; - elementLength = 0; - assertEnd = false; // CFWS can only appear at the end of the element - break; - // atext - default: - // http://tools.ietf.org/html/rfc5322#section-3.2.3 - // atext = ALPHA / DIGIT / ; Printable US-ASCII - // "!" / "#" / ; characters not including - // "$" / "%" / ; specials. Used for atoms. - // "&" / "'" / - // "*" / "+" / - // "-" / "/" / - // "=" / "?" / - // "^" / "_" / - // "`" / "{" / - // "|" / "}" / - // "~" - if (assertEnd) { - // we have encountered atext where it is no longer valid - switch (context.prev) { - case ISEMAIL_CONTEXT_COMMENT: - case ISEMAIL_CONTEXT_FWS: - result.push(ISEMAIL_ERR_ATEXT_AFTER_CFWS); - break; - case ISEMAIL_CONTEXT_QUOTEDSTRING: - result.push(ISEMAIL_ERR_ATEXT_AFTER_QS); - break; - /* istanbul ignore next: logically unreachable */ - default: - throw new Error('more atext found where none is allowed, but unrecognized prev context: ' + context.prev); - } - } else { - context.prev = context.now; - charCode = token.charCodeAt(0); - - if (charCode < 33 || charCode > 126 || charCode === 10 || ~SPECIALS.indexOf(token)) { - // fatal error - result.push(ISEMAIL_ERR_EXPECTING_ATEXT); - } - - parseData[ISEMAIL_COMPONENT_LOCALPART] += token; - atomList[ISEMAIL_COMPONENT_LOCALPART][elementCount] += token; - elementLength++; - } - } - break; - case ISEMAIL_COMPONENT_DOMAIN: - // http://tools.ietf.org/html/rfc5322#section-3.4.1 - // domain = dot-atom / domain-literal / obs-domain - // - // dot-atom = [CFWS] dot-atom-text [CFWS] - // - // dot-atom-text = 1*atext *("." 1*atext) - // - // domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS] - // - // dtext = %d33-90 / ; Printable US-ASCII - // %d94-126 / ; characters not including - // obs-dtext ; "[", "]", or "\" - // - // obs-domain = atom *("." atom) - // - // atom = [CFWS] 1*atext [CFWS] - - // http://tools.ietf.org/html/rfc5321#section-4.1.2 - // Mailbox = Local-part "@" ( Domain / address-literal ) - // - // Domain = sub-domain *("." sub-domain) - // - // address-literal = "[" ( IPv4-address-literal / - // IPv6-address-literal / - // General-address-literal ) "]" - // ; See Section 4.1.3 - - // http://tools.ietf.org/html/rfc5322#section-3.4.1 - // Note: A liberal syntax for the domain portion of addr-spec is - // given here. However, the domain portion contains addressing - // information specified by and used in other protocols (e.g., - // [RFC1034], [RFC1035], [RFC1123], [RFC5321]). It is therefore - // incumbent upon implementations to conform to the syntax of - // addresses for the context in which they are used. - // is_email() author's note: it's not clear how to interpret this in - // the context of a general email address validator. The conclusion I - // have reached is this: "addressing information" must comply with - // RFC 5321 (and in turn RFC 1035), anything that is "semantically - // invisible" must comply only with RFC 5322. - switch (token) { - // comment - case '(': - if (elementLength === 0) { - // comments at the start of the domain are deprecated in the text - // comments at the start of a subdomain are obs-domain - // (http://tools.ietf.org/html/rfc5322#section-3.4.1) - result.push(elementCount === 0 ? ISEMAIL_DEPREC_CFWS_NEAR_AT : ISEMAIL_DEPREC_COMMENT); - } else { - result.push(ISEMAIL_CFWS_COMMENT); - assertEnd = true; // can't start a comment mid-element, better be end - } - - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_COMMENT; - break; - // next dot-atom element - case '.': - if (elementLength === 0) { - // another dot, already? - result.push(elementCount === 0 ? ISEMAIL_ERR_DOT_START : ISEMAIL_ERR_CONSECUTIVEDOTS); // fatal error - } else if (hyphenFlag) { - // previous subdomain ended in a hyphen - result.push(ISEMAIL_ERR_DOMAINHYPHENEND); // fatal error - } else if (elementLength > 63) { - // Nowhere in RFC 5321 does it say explicitly that the - // domain part of a Mailbox must be a valid domain according - // to the DNS standards set out in RFC 1035, but this *is* - // implied in several places. For instance, wherever the idea - // of host routing is discussed the RFC says that the domain - // must be looked up in the DNS. This would be nonsense unless - // the domain was designed to be a valid DNS domain. Hence we - // must conclude that the RFC 1035 restriction on label length - // also applies to RFC 5321 domains. - // - // http://tools.ietf.org/html/rfc1035#section-2.3.4 - // labels 63 octets or less - - result.push(ISEMAIL_RFC5322_LABEL_TOOLONG); - } - - // CFWS is OK again now we're at the beginning of an element (although it may be obsolete CFWS) - assertEnd = false; - elementLength = 0; - elementCount++; - atomList[ISEMAIL_COMPONENT_DOMAIN][elementCount] = ''; - parseData[ISEMAIL_COMPONENT_DOMAIN] += token; - - break; - // domain literal - case '[': - if (parseData[ISEMAIL_COMPONENT_DOMAIN].length === 0) { - // domain literal must be the only component - assertEnd = true; - elementLength++; - context.stack.push(context.now); - context.now = ISEMAIL_COMPONENT_LITERAL; - parseData[ISEMAIL_COMPONENT_DOMAIN] += token; - atomList[ISEMAIL_COMPONENT_DOMAIN][elementCount] += token; - parseData[ISEMAIL_COMPONENT_LITERAL] = ''; - } else { - // fatal error - result.push(ISEMAIL_ERR_EXPECTING_ATEXT); - } - break; - // folding white space - case '\r': - case ' ': - case '\t': - if (token === '\r' && ((++i === email.length) || email[i] !== '\n')) { - // fatal error - result.push(ISEMAIL_ERR_CR_NO_LF); - break; - } - - if (elementLength === 0) { - result.push(elementCount === 0 ? ISEMAIL_DEPREC_CFWS_NEAR_AT : ISEMAIL_DEPREC_FWS); - } else { - // We can't start FWS in the middle of an element, so this better be the end - result.push(ISEMAIL_CFWS_FWS); - assertEnd = true; - } - - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_FWS; - prevToken = token; - break; - // atext - default: - // RFC 5322 allows any atext... - // http://tools.ietf.org/html/rfc5322#section-3.2.3 - // atext = ALPHA / DIGIT / ; Printable US-ASCII - // "!" / "#" / ; characters not including - // "$" / "%" / ; specials. Used for atoms. - // "&" / "'" / - // "*" / "+" / - // "-" / "/" / - // "=" / "?" / - // "^" / "_" / - // "`" / "{" / - // "|" / "}" / - // "~" - - // But RFC 5321 only allows letter-digit-hyphen to comply with DNS rules (RFCs 1034 & 1123) - // http://tools.ietf.org/html/rfc5321#section-4.1.2 - // sub-domain = Let-dig [Ldh-str] - // - // Let-dig = ALPHA / DIGIT - // - // Ldh-str = *( ALPHA / DIGIT / "-" ) Let-dig - // - if (assertEnd) { - // we have encountered atext where it is no longer valid - switch (context.prev) { - case ISEMAIL_CONTEXT_COMMENT: - case ISEMAIL_CONTEXT_FWS: - result.push(ISEMAIL_ERR_ATEXT_AFTER_CFWS); - break; - case ISEMAIL_COMPONENT_LITERAL: - result.push(ISEMAIL_ERR_ATEXT_AFTER_DOMLIT); - break; - /* istanbul ignore next: logically unreachable */ - default: - throw new Error('more atext found where none is allowed, but unrecognized prev context: ' + context.prev); - } - } - - charCode = token.charCodeAt(0); - hyphenFlag = false; // assume this token isn't a hyphen unless we discover it is - - if (charCode < 33 || charCode > 126 || ~SPECIALS.indexOf(token)) { - // fatal error - result.push(ISEMAIL_ERR_EXPECTING_ATEXT); - } else if (token === '-') { - if (elementLength === 0) { - // hyphens can't be at the beginning of a subdomain - result.push(ISEMAIL_ERR_DOMAINHYPHENSTART); // fatal error - } - - hyphenFlag = true; - } else if (!((charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123))) { - // not an RFC 5321 subdomain, but still OK by RFC 5322 - result.push(ISEMAIL_RFC5322_DOMAIN); - } - - parseData[ISEMAIL_COMPONENT_DOMAIN] += token; - atomList[ISEMAIL_COMPONENT_DOMAIN][elementCount] += token; - elementLength++; - } - break; - // domain literal - case ISEMAIL_COMPONENT_LITERAL: - // http://tools.ietf.org/html/rfc5322#section-3.4.1 - // domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS] - // - // dtext = %d33-90 / ; Printable US-ASCII - // %d94-126 / ; characters not including - // obs-dtext ; "[", "]", or "\" - // - // obs-dtext = obs-NO-WS-CTL / quoted-pair - switch (token) { - // end of domain literal - case ']': - if (maxValue(result) < ISEMAIL_DEPREC) { - // Could be a valid RFC 5321 address literal, so let's check - - // http://tools.ietf.org/html/rfc5321#section-4.1.2 - // address-literal = "[" ( IPv4-address-literal / - // IPv6-address-literal / - // General-address-literal ) "]" - // ; See Section 4.1.3 - // - // http://tools.ietf.org/html/rfc5321#section-4.1.3 - // IPv4-address-literal = Snum 3("." Snum) - // - // IPv6-address-literal = "IPv6:" IPv6-addr - // - // General-address-literal = Standardized-tag ":" 1*dcontent - // - // Standardized-tag = Ldh-str - // ; Standardized-tag MUST be specified in a - // ; Standards-Track RFC and registered with IANA - // - // dcontent = %d33-90 / ; Printable US-ASCII - // %d94-126 ; excl. "[", "\", "]" - // - // Snum = 1*3DIGIT - // ; representing a decimal integer - // ; value in the range 0 through 255 - // - // IPv6-addr = IPv6-full / IPv6-comp / IPv6v4-full / IPv6v4-comp - // - // IPv6-hex = 1*4HEXDIG - // - // IPv6-full = IPv6-hex 7(":" IPv6-hex) - // - // IPv6-comp = [IPv6-hex *5(":" IPv6-hex)] "::" - // [IPv6-hex *5(":" IPv6-hex)] - // ; The "::" represents at least 2 16-bit groups of - // ; zeros. No more than 6 groups in addition to the - // ; "::" may be present. - // - // IPv6v4-full = IPv6-hex 5(":" IPv6-hex) ":" IPv4-address-literal - // - // IPv6v4-comp = [IPv6-hex *3(":" IPv6-hex)] "::" - // [IPv6-hex *3(":" IPv6-hex) ":"] - // IPv4-address-literal - // ; The "::" represents at least 2 16-bit groups of - // ; zeros. No more than 4 groups in addition to the - // ; "::" and IPv4-address-literal may be present. - // - // is_email() author's note: We can't use ip2long() to validate - // IPv4 addresses because it accepts abbreviated addresses - // (xxx.xxx.xxx), expanding the last group to complete the address. - // filter_var() validates IPv6 address inconsistently (up to PHP 5.3.3 - // at least) -- see http://bugs.php.net/bug.php?id=53236 for example - - // TODO: var here? - var maxGroups = 8, matchesIP, index = false; - var addressLiteral = parseData[ISEMAIL_COMPONENT_LITERAL]; - - // extract IPv4 part from the end of the address-literal (if applicable) - if (matchesIP = IPv4_REGEX.exec(addressLiteral)) { - if ((index = matchesIP.index) !== 0) { - // convert IPv4 part to IPv6 format for futher testing - addressLiteral = addressLiteral.substr(0, matchesIP.index) + '0:0'; - } - } - - if (index === 0) { - // nothing there except a valid IPv4 address, so... - result.push(ISEMAIL_RFC5321_ADDRESSLITERAL); - } else if (addressLiteral.slice(0, 5).toLowerCase() !== 'ipv6:') { - result.push(ISEMAIL_RFC5322_DOMAINLITERAL); - } else { - var match = addressLiteral.substr(5); - matchesIP = match.split(':'); - index = match.indexOf('::'); - - if (!~index) { - // need exactly the right number of groups - if (matchesIP.length !== maxGroups) { - result.push(ISEMAIL_RFC5322_IPV6_GRPCOUNT); - } - } else if (index !== match.lastIndexOf('::')) { - result.push(ISEMAIL_RFC5322_IPV6_2X2XCOLON); - } else { - if (index === 0 || index === match.length - 2) { - // RFC 4291 allows :: at the start or end of an address with 7 other groups in addition - maxGroups++; - } - - if (matchesIP.length > maxGroups) { - result.push(ISEMAIL_RFC5322_IPV6_MAXGRPS); - } else if (matchesIP.length === maxGroups) { - // eliding a single "::" - result.push(ISEMAIL_RFC5321_IPV6DEPRECATED); - } - } - - // IPv6 testing strategy - if (match[0] === ':' && match[1] !== ':') { - result.push(ISEMAIL_RFC5322_IPV6_COLONSTRT); - } else if (match[match.length - 1] === ':' && match[match.length - 2] !== ':') { - result.push(ISEMAIL_RFC5322_IPV6_COLONEND); - } else if (matchesIP.every(IPv6_REGEX_TEST)) { - result.push(ISEMAIL_RFC5321_ADDRESSLITERAL); - } else { - result.push(ISEMAIL_RFC5322_IPV6_BADCHAR); - } - } - } else { - result.push(ISEMAIL_RFC5322_DOMAINLITERAL); - } - - parseData[ISEMAIL_COMPONENT_DOMAIN] += token; - atomList[ISEMAIL_COMPONENT_DOMAIN][elementCount] += token; - elementLength++; - context.prev = context.now; - context.now = context.stack.pop(); - break; - case '\\': - result.push(ISEMAIL_RFC5322_DOMLIT_OBSDTEXT); - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_QUOTEDPAIR; - break; - // folding white space - case '\r': - case ' ': - case '\t': - if (token === '\r' && ((++i === email.length) || email[i] !== '\n')) { - // fatal error - result.push(ISEMAIL_ERR_CR_NO_LF); - break; - } - - result.push(ISEMAIL_CFWS_FWS); - - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_FWS; - prevToken = token; - break; - // dtext - default: - // http://tools.ietf.org/html/rfc5322#section-3.4.1 - // dtext = %d33-90 / ; Printable US-ASCII - // %d94-126 / ; characters not including - // obs-dtext ; "[", "]", or "\" - // - // obs-dtext = obs-NO-WS-CTL / quoted-pair - // - // obs-NO-WS-CTL = %d1-8 / ; US-ASCII control - // %d11 / ; characters that do not - // %d12 / ; include the carriage - // %d14-31 / ; return, line feed, and - // %d127 ; white space characters - charCode = token.charCodeAt(0); - - // CR, LF, SP & HTAB have already been parsed above - if (charCode > 127 || charCode === 0 || token === '[') { - // fatal error - result.push(ISEMAIL_ERR_EXPECTING_DTEXT); - break; - } else if (charCode < 33 || charCode === 127) { - result.push(ISEMAIL_RFC5322_DOMLIT_OBSDTEXT); - } - - parseData[ISEMAIL_COMPONENT_LITERAL] += token; - parseData[ISEMAIL_COMPONENT_DOMAIN] += token; - atomList[ISEMAIL_COMPONENT_DOMAIN][elementCount] += token; - elementLength++; - } - break; - // quoted string - case ISEMAIL_CONTEXT_QUOTEDSTRING: - // http://tools.ietf.org/html/rfc5322#section-3.2.4 - // quoted-string = [CFWS] - // DQUOTE *([FWS] qcontent) [FWS] DQUOTE - // [CFWS] - // - // qcontent = qtext / quoted-pair - switch (token) { - // quoted pair - case '\\': - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_QUOTEDPAIR; - break; - // folding white space - // inside a quoted string, spaces are allowed as regular characters - // it's only FWS if we include HTAB or CRLF - case '\r': - case '\t': - if (token === '\r' && ((++i === email.length) || email[i] !== '\n')) { - // fatal error - result.push(ISEMAIL_ERR_CR_NO_LF); - break; - } - - // http://tools.ietf.org/html/rfc5322#section-3.2.2 - // Runs of FWS, comment, or CFWS that occur between lexical tokens in a - // structured header field are semantically interpreted as a single - // space character. - - // http://tools.ietf.org/html/rfc5322#section-3.2.4 - // the CRLF in any FWS/CFWS that appears within the quoted-string [is] - // semantically "invisible" and therefore not part of the quoted-string - - parseData[ISEMAIL_COMPONENT_LOCALPART] += ' '; - atomList[ISEMAIL_COMPONENT_LOCALPART][elementCount] += ' '; - elementLength++; - - result.push(ISEMAIL_CFWS_FWS); - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_FWS; - prevToken = token; - break; - // end of quoted string - case '"': - parseData[ISEMAIL_COMPONENT_LOCALPART] += token; - atomList[ISEMAIL_COMPONENT_LOCALPART][elementCount] += token; - elementLength++; - context.prev = context.now; - context.now = context.stack.pop(); - break; - // qtext - default: - // http://tools.ietf.org/html/rfc5322#section-3.2.4 - // qtext = %d33 / ; Printable US-ASCII - // %d35-91 / ; characters not including - // %d93-126 / ; "\" or the quote character - // obs-qtext - // - // obs-qtext = obs-NO-WS-CTL - // - // obs-NO-WS-CTL = %d1-8 / ; US-ASCII control - // %d11 / ; characters that do not - // %d12 / ; include the carriage - // %d14-31 / ; return, line feed, and - // %d127 ; white space characters - charCode = token.charCodeAt(0); - - if (charCode > 127 || charCode === 0 || charCode === 10) { - result.push(ISEMAIL_ERR_EXPECTING_QTEXT); - } else if (charCode < 32 || charCode === 127) { - result.push(ISEMAIL_DEPREC_QTEXT); - } - - parseData[ISEMAIL_COMPONENT_LOCALPART] += token; - atomList[ISEMAIL_COMPONENT_LOCALPART][elementCount] += token; - elementLength++; - } - - // http://tools.ietf.org/html/rfc5322#section-3.4.1 - // If the string can be represented as a dot-atom (that is, it contains - // no characters other than atext characters or "." surrounded by atext - // characters), then the dot-atom form SHOULD be used and the quoted- - // string form SHOULD NOT be used. - - break; - // quoted pair - case ISEMAIL_CONTEXT_QUOTEDPAIR: - // http://tools.ietf.org/html/rfc5322#section-3.2.1 - // quoted-pair = ("\" (VCHAR / WSP)) / obs-qp - // - // VCHAR = %d33-126 ; visible (printing) characters - // WSP = SP / HTAB ; white space - // - // obs-qp = "\" (%d0 / obs-NO-WS-CTL / LF / CR) - // - // obs-NO-WS-CTL = %d1-8 / ; US-ASCII control - // %d11 / ; characters that do not - // %d12 / ; include the carriage - // %d14-31 / ; return, line feed, and - // %d127 ; white space characters - // - // i.e. obs-qp = "\" (%d0-8, %d10-31 / %d127) - charCode = token.charCodeAt(0); - - if (charCode > 127) { - // fatal error - result.push(ISEMAIL_ERR_EXPECTING_QPAIR); - } else if ((charCode < 31 && charCode !== 9) || charCode === 127) { - // SP & HTAB are allowed - result.push(ISEMAIL_DEPREC_QP); - } - - // At this point we know where this qpair occurred so - // we could check to see if the character actually - // needed to be quoted at all. - // http://tools.ietf.org/html/rfc5321#section-4.1.2 - // the sending system SHOULD transmit the - // form that uses the minimum quoting possible. - - // To do: check whether the character needs to be quoted (escaped) in this context - - context.prev = context.now; - context.now = context.stack.pop(); // end of qpair - token = '\\' + token; - - switch (context.now) { - case ISEMAIL_CONTEXT_COMMENT: break; - case ISEMAIL_CONTEXT_QUOTEDSTRING: - parseData[ISEMAIL_COMPONENT_LOCALPART] += token; - atomList[ISEMAIL_COMPONENT_LOCALPART][elementCount] += token; - elementLength += 2; // the maximum sizes specified by RFC 5321 are octet counts, so we must include the backslash - break; - case ISEMAIL_COMPONENT_LITERAL: - parseData[ISEMAIL_COMPONENT_DOMAIN] += token; - atomList[ISEMAIL_COMPONENT_DOMAIN][elementCount] += token; - elementLength += 2; // the maximum sizes specified by RFC 5321 are octet counts, so we must include the backslash - break; - /* istanbul ignore next: logically unreachable */ - default: - throw new Error('quoted pair logic invoked in an invalid context: ' + context.now); - } - break; - // comment - case ISEMAIL_CONTEXT_COMMENT: - // http://tools.ietf.org/html/rfc5322#section-3.2.2 - // comment = "(" *([FWS] ccontent) [FWS] ")" - // - // ccontent = ctext / quoted-pair / comment - switch (token) { - // nested comment - case '(': - // nested comments are ok - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_COMMENT; - break; - // end of comment - case ')': - context.prev = context.now; - context.now = context.stack.pop(); - - // http://tools.ietf.org/html/rfc5322#section-3.2.2 - // Runs of FWS, comment, or CFWS that occur between lexical tokens in a - // structured header field are semantically interpreted as a single - // space character. - // - // isEmail() author's note: This *cannot* mean that we must add a - // space to the address wherever CFWS appears. This would result in - // any addr-spec that had CFWS outside a quoted string being invalid - // for RFC 5321. -// if (context.now === ISEMAIL_COMPONENT_LOCALPART || context.now === ISEMAIL_COMPONENT_DOMAIN) { -// parseData[context.now] += ' '; -// atomList[context.now][elementCount] += ' '; -// elementLength++; -// } - - break; - // quoted pair - case '\\': - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_QUOTEDPAIR; - break; - // folding white space - case '\r': - case ' ': - case '\t': - if (token === '\r' && ((++i === email.length) || email[i] !== '\n')) { - // fatal error - result.push(ISEMAIL_ERR_CR_NO_LF); - break; - } - - result.push(ISEMAIL_CFWS_FWS); - - context.stack.push(context.now); - context.now = ISEMAIL_CONTEXT_FWS; - prevToken = token; - break; - // ctext - default: - // http://tools.ietf.org/html/rfc5322#section-3.2.3 - // ctext = %d33-39 / ; Printable US-ASCII - // %d42-91 / ; characters not including - // %d93-126 / ; "(", ")", or "\" - // obs-ctext - // - // obs-ctext = obs-NO-WS-CTL - // - // obs-NO-WS-CTL = %d1-8 / ; US-ASCII control - // %d11 / ; characters that do not - // %d12 / ; include the carriage - // %d14-31 / ; return, line feed, and - // %d127 ; white space characters - charCode = token.charCodeAt(0); - - if (charCode > 127 || charCode === 0 || charCode === 10) { - // fatal error - result.push(ISEMAIL_ERR_EXPECTING_CTEXT); - break; - } else if (charCode < 32 || charCode === 127) { - result.push(ISEMAIL_DEPREC_CTEXT); - } - } - break; - // folding white space - case ISEMAIL_CONTEXT_FWS: - // http://tools.ietf.org/html/rfc5322#section-3.2.2 - // FWS = ([*WSP CRLF] 1*WSP) / obs-FWS - // ; Folding white space - - // But note the erratum: - // http://www.rfc-editor.org/errata_search.php?rfc=5322&eid=1908: - // In the obsolete syntax, any amount of folding white space MAY be - // inserted where the obs-FWS rule is allowed. This creates the - // possibility of having two consecutive "folds" in a line, and - // therefore the possibility that a line which makes up a folded header - // field could be composed entirely of white space. - // - // obs-FWS = 1*([CRLF] WSP) - - if (prevToken === '\r') { - if (token === '\r') { - // fatal error - result.push(ISEMAIL_ERR_FWS_CRLF_X2); - break; - } - - if (++crlfCount > 1) { - // multiple folds = obsolete FWS - result.push(ISEMAIL_DEPREC_FWS); - } else { - crlfCount = 1; - } - } - - switch (token) { - case '\r': - if ((++i === email.length) || email[i] !== '\n') { - // fatal error - result.push(ISEMAIL_ERR_CR_NO_LF); - } - break; - case ' ': - case '\t': - break; - default: - if (prevToken === '\r') { - // fatal error - result.push(ISEMAIL_ERR_FWS_CRLF_END); - } - - crlfCount = 0; - - context.prev = context.now; - context.now = context.stack.pop(); // end of FWS - - // http://tools.ietf.org/html/rfc5322#section-3.2.2 - // Runs of FWS, comment, or CFWS that occur between lexical tokens in a - // structured header field are semantically interpreted as a single - // space character. - // - // isEmail() author's note: This *cannot* mean that we must add a - // space to the address wherever CFWS appears. This would result in - // any addr-spec that had CFWS outside a quoted string being invalid - // for RFC 5321. -// if ((context.now === ISEMAIL_COMPONENT_LOCALPART) || (context.now === ISEMAIL_COMPONENT_DOMAIN)) { -// parseData[context.now] += ' '; -// atomList[context.now][elementCount] += ' '; -// elementLength++; -// } - - i--; // look at this token again in the parent context - } - prevToken = token; - break; - // unexpected context - /* istanbul ignore next: logically unreachable */ - default: - throw new Error('unknown context: ' + context.now); - } // primary state machine - - if (maxValue(result) > ISEMAIL_RFC5322) { - // fatal error, no point continuing - break; - } - } // token loop - - // check for errors - if (maxValue(result) < ISEMAIL_RFC5322) { - // fatal errors - if (context.now === ISEMAIL_CONTEXT_QUOTEDSTRING) result.push(ISEMAIL_ERR_UNCLOSEDQUOTEDSTR); - else if (context.now === ISEMAIL_CONTEXT_QUOTEDPAIR) result.push(ISEMAIL_ERR_BACKSLASHEND); - else if (context.now === ISEMAIL_CONTEXT_COMMENT) result.push(ISEMAIL_ERR_UNCLOSEDCOMMENT); - else if (context.now === ISEMAIL_COMPONENT_LITERAL) result.push(ISEMAIL_ERR_UNCLOSEDDOMLIT); - else if (token === '\r') result.push(ISEMAIL_ERR_FWS_CRLF_END); - else if (parseData[ISEMAIL_COMPONENT_DOMAIN].length === 0) result.push(ISEMAIL_ERR_NODOMAIN); - else if (elementLength === 0) result.push(ISEMAIL_ERR_DOT_END); - else if (hyphenFlag) result.push(ISEMAIL_ERR_DOMAINHYPHENEND); - // other errors - // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.2 - // The maximum total length of a domain name or number is 255 octets. - else if (parseData[ISEMAIL_COMPONENT_DOMAIN].length > 255) { - result.push(ISEMAIL_RFC5322_DOMAIN_TOOLONG); - // http://tools.ietf.org/html/rfc5321#section-4.1.2 - // Forward-path = Path - // - // Path = "<" [ A-d-l ":" ] Mailbox ">" - // - // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3 - // The maximum total length of a reverse-path or forward-path is 256 - // octets (including the punctuation and element separators). - // - // Thus, even without (obsolete) routing information, the Mailbox can - // only be 254 characters long. This is confirmed by this verified - // erratum to RFC 3696: - // - // http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690 - // However, there is a restriction in RFC 2821 on the length of an - // address in MAIL and RCPT commands of 254 characters. Since addresses - // that do not fit in those fields are not normally useful, the upper - // limit on address lengths should normally be considered to be 254. - } else if (parseData[ISEMAIL_COMPONENT_LOCALPART].length + - parseData[ISEMAIL_COMPONENT_DOMAIN].length + - 1 /* '@' symbol */ > 254) { - result.push(ISEMAIL_RFC5322_TOOLONG); - // http://tools.ietf.org/html/rfc1035#section-2.3.4 - // labels 63 octets or less - } else if (elementLength > 63) { - result.push(ISEMAIL_RFC5322_LABEL_TOOLONG); - } - } // check for errors - - var dnsPositive = false; - - if (options.checkDNS && (maxValue(result) < ISEMAIL_DNSWARN) && HAS_REQUIRE) { - dns || (dns = require('dns')); - // http://tools.ietf.org/html/rfc5321#section-2.3.5 - // Names that can - // be resolved to MX RRs or address (i.e., A or AAAA) RRs (as discussed - // in Section 5) are permitted, as are CNAME RRs whose targets can be - // resolved, in turn, to MX or address RRs. - // - // http://tools.ietf.org/html/rfc5321#section-5.1 - // The lookup first attempts to locate an MX record associated with the - // name. If a CNAME record is found, the resulting name is processed as - // if it were the initial name. ... If an empty list of MXs is returned, - // the address is treated as if it was associated with an implicit MX - // RR, with a preference of 0, pointing to that host. - // - // isEmail() author's note: We will regard the existence of a CNAME to be - // sufficient evidence of the domain's existence. For performance reasons - // we will not repeat the DNS lookup for the CNAME's target, but we will - // raise a warning because we didn't immediately find an MX record. - if (elementCount === 0) { - // checking TLD DNS seems to work only if you explicitly check from the root - parseData[ISEMAIL_COMPONENT_DOMAIN] += '.'; - } - - var dnsDomain = parseData[ISEMAIL_COMPONENT_DOMAIN]; - dns.resolveMx(dnsDomain, function(err, records) { - if ((err && err.code !== dns.NODATA) || (!err && !records)) { - result.push(ISEMAIL_DNSWARN_NO_RECORD); - return finish(); - } - if (records && records.length) { - dnsPositive = true; - return finish(); - } - var done = false, count = 3; - result.push(ISEMAIL_DNSWARN_NO_MX_RECORD); - dns.resolveCname(dnsDomain, handleRecords); - dns.resolve4(dnsDomain, handleRecords); - dns.resolve6(dnsDomain, handleRecords); - function handleRecords(err, records) { - if (done) return; - count--; - if (!err && records && records.length) { - done = true; - return finish(); - } - if (count === 0) { - // no usable records for the domain can be found - result.push(ISEMAIL_DNSWARN_NO_RECORD); - done = true; - finish(); - } - } - }); - } else if (options.checkDNS) { - // guarantee asynchronicity - process.nextTick(finish); - } else { - return finish(); - } // checkDNS - - function finish() { - if (!dnsPositive && (maxValue(result) < ISEMAIL_DNSWARN)) { - if (elementCount === 0) { - result.push(ISEMAIL_RFC5321_TLD); - } else { - var charCode = atomList[ISEMAIL_COMPONENT_DOMAIN][elementCount].charCodeAt(0); - if (charCode >= 48 && charCode <= 57) { - result.push(ISEMAIL_RFC5321_TLDNUMERIC); - } - } - } - - // make unique (TODO: how efficient is this?) - var has = {}, index = 0; - while (index < result.length) { - if (has[result[index]]) { - result.splice(index, 1); - } else { - has[result[index]] = true; - index++; - } - } - // TODO: optimize all these Math.max calls! - var finalStatus = maxValue(result); - - if (result.length !== 1) { - // remove redundant ISEMAIL_VALID - result.shift(); - } - - if (finalStatus < threshold) { - finalStatus = ISEMAIL_VALID; - } - - finalStatus = diagnose ? finalStatus : finalStatus < ISEMAIL_THRESHOLD; - callback && callback(finalStatus); - - return finalStatus; - } // finish -} // isEmail - -module.exports = isEmail; - -}).call(this,require('_process')) -},{"_process":29,"dns":23}],21:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./lib":22}],22:[function(require,module,exports){ -// Load modules - -var Hoek = require('hoek'); - - -// Declare internals - -var internals = {}; - - -exports = module.exports = internals.Topo = function () { - - this._items = []; - this.nodes = []; -}; - - -internals.Topo.prototype.add = function (nodes, options) { - - var self = this; - - options = options || {}; - - // Validate rules - - var before = [].concat(options.before || []); - var after = [].concat(options.after || []); - var group = options.group || '?'; - - Hoek.assert(before.indexOf(group) === -1, 'Item cannot come before itself:', group); - Hoek.assert(before.indexOf('?') === -1, 'Item cannot come before unassociated items'); - Hoek.assert(after.indexOf(group) === -1, 'Item cannot come after itself:', group); - Hoek.assert(after.indexOf('?') === -1, 'Item cannot come after unassociated items'); - - ([].concat(nodes)).forEach(function (node, i) { - - var item = { - seq: self._items.length, - before: before, - after: after, - group: group, - node: node - }; - - self._items.push(item); - }); - - // Insert event - - var error = this._sort(); - Hoek.assert(!error, 'item', (group !== '?' ? 'added into group ' + group : ''), 'created a dependencies error'); - - return this.nodes; -}; - - -internals.Topo.prototype._sort = function () { - - // Construct graph - - var groups = {}; - var graph = {}; - var graphAfters = {}; - - for (var i = 0, il = this._items.length; i < il; ++i) { - var item = this._items[i]; - var seq = item.seq; // Unique across all items - var group = item.group; - - // Determine Groups - - groups[group] = groups[group] || []; - groups[group].push(seq); - - // Build intermediary graph using 'before' - - graph[seq] = [item.before]; - - // Build second intermediary graph with 'after' - - var after = item.after; - for (var j = 0, jl = after.length; j < jl; ++j) { - graphAfters[after[j]] = (graphAfters[after[j]] || []).concat(seq); - } - } - - // Expand intermediary graph - - var graphNodes = Object.keys(graph); - for (i = 0, il = graphNodes.length; i < il; ++i) { - var node = graphNodes[i]; - var expandedGroups = []; - - var graphNodeItems = Object.keys(graph[node]); - for (j = 0, jl = graphNodeItems.length; j < jl; ++j) { - var group = graph[node][graphNodeItems[j]]; - groups[group] = groups[group] || []; - groups[group].forEach(function (d) { - - expandedGroups.push(d); - }); - } - graph[node] = expandedGroups; - } - - // Merge intermediary graph using graphAfters into final graph - - var afterNodes = Object.keys(graphAfters); - for (i = 0, il = afterNodes.length; i < il; ++i) { - var group = afterNodes[i]; - - if (groups[group]) { - for (j = 0, jl = groups[group].length; j < jl; ++j) { - var node = groups[group][j]; - graph[node] = graph[node].concat(graphAfters[group]); - } - } - } - - // Compile ancestors - - var ancestors = {}; - graphNodes = Object.keys(graph); - for (i = 0, il = graphNodes.length; i < il; ++i) { - var node = graphNodes[i]; - var children = graph[node]; - - for (j = 0, jl = children.length; j < jl; ++j) { - ancestors[children[j]] = (ancestors[children[j]] || []).concat(node); - } - } - - // Topo sort - - var visited = {}; - var sorted = []; - - for (i = 0, il = this._items.length; i < il; ++i) { - var next = i; - - if (ancestors[i]) { - next = null; - for (j = 0, jl = this._items.length; j < jl; ++j) { - if (visited[j] === true) { - continue; - } - - if (!ancestors[j]) { - ancestors[j] = []; - } - - var shouldSeeCount = ancestors[j].length; - var seenCount = 0; - for (var l = 0, ll = shouldSeeCount; l < ll; ++l) { - if (sorted.indexOf(ancestors[j][l]) >= 0) { - ++seenCount; - } - } - - if (seenCount === shouldSeeCount) { - next = j; - break; - } - } - } - - if (next !== null) { - next = next.toString(); // Normalize to string TODO: replace with seq - visited[next] = true; - sorted.push(next); - } - } - - if (sorted.length !== this._items.length) { - return new Error('Invalid dependencies'); - } - - var seqIndex = {}; - this._items.forEach(function (item) { - - seqIndex[item.seq] = item; - }); - - var sortedNodes = []; - this._items = sorted.map(function (value) { - - var item = seqIndex[value]; - sortedNodes.push(item.node); - return item; - }); - - this.nodes = sortedNodes; -}; - -},{"hoek":16}],23:[function(require,module,exports){ - -},{}],24:[function(require,module,exports){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ - -var base64 = require('base64-js') -var ieee754 = require('ieee754') - -exports.Buffer = Buffer -exports.SlowBuffer = Buffer -exports.INSPECT_MAX_BYTES = 50 -Buffer.poolSize = 8192 - -/** - * If `TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * Note: - * - * - Implementation must support adding new properties to `Uint8Array` instances. - * Firefox 4-29 lacked support, fixed in Firefox 30+. - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - * - * We detect these buggy browsers and set `TYPED_ARRAY_SUPPORT` to `false` so they will - * get the Object implementation, which is slower but will work correctly. - */ -var TYPED_ARRAY_SUPPORT = (function () { - try { - var buf = new ArrayBuffer(0) - var arr = new Uint8Array(buf) - arr.foo = function () { return 42 } - return 42 === arr.foo() && // typed array instances can be augmented - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` - } catch (e) { - return false - } -})() - -/** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. - */ -function Buffer (subject, encoding, noZero) { - if (!(this instanceof Buffer)) - return new Buffer(subject, encoding, noZero) - - var type = typeof subject - - // Find the length - var length - if (type === 'number') - length = subject > 0 ? subject >>> 0 : 0 - else if (type === 'string') { - if (encoding === 'base64') - subject = base64clean(subject) - length = Buffer.byteLength(subject, encoding) - } else if (type === 'object' && subject !== null) { // assume object is array-like - if (subject.type === 'Buffer' && isArray(subject.data)) - subject = subject.data - length = +subject.length > 0 ? Math.floor(+subject.length) : 0 - } else - throw new Error('First argument needs to be a number, array or string.') - - var buf - if (TYPED_ARRAY_SUPPORT) { - // Preferred: Return an augmented `Uint8Array` instance for best performance - buf = Buffer._augment(new Uint8Array(length)) - } else { - // Fallback: Return THIS instance of Buffer (created by `new`) - buf = this - buf.length = length - buf._isBuffer = true - } - - var i - if (TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') { - // Speed optimization -- use set if we're copying from a typed array - buf._set(subject) - } else if (isArrayish(subject)) { - // Treat array-ish objects as a byte array - if (Buffer.isBuffer(subject)) { - for (i = 0; i < length; i++) - buf[i] = subject.readUInt8(i) - } else { - for (i = 0; i < length; i++) - buf[i] = ((subject[i] % 256) + 256) % 256 - } - } else if (type === 'string') { - buf.write(subject, 0, encoding) - } else if (type === 'number' && !TYPED_ARRAY_SUPPORT && !noZero) { - for (i = 0; i < length; i++) { - buf[i] = 0 - } - } - - return buf -} - -// STATIC METHODS -// ============== - -Buffer.isEncoding = function (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'binary': - case 'base64': - case 'raw': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.isBuffer = function (b) { - return !!(b != null && b._isBuffer) -} - -Buffer.byteLength = function (str, encoding) { - var ret - str = str.toString() - switch (encoding || 'utf8') { - case 'hex': - ret = str.length / 2 - break - case 'utf8': - case 'utf-8': - ret = utf8ToBytes(str).length - break - case 'ascii': - case 'binary': - case 'raw': - ret = str.length - break - case 'base64': - ret = base64ToBytes(str).length - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = str.length * 2 - break - default: - throw new Error('Unknown encoding') - } - return ret -} - -Buffer.concat = function (list, totalLength) { - assert(isArray(list), 'Usage: Buffer.concat(list[, length])') - - if (list.length === 0) { - return new Buffer(0) - } else if (list.length === 1) { - return list[0] - } - - var i - if (totalLength === undefined) { - totalLength = 0 - for (i = 0; i < list.length; i++) { - totalLength += list[i].length - } - } - - var buf = new Buffer(totalLength) - var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length - } - return buf -} - -Buffer.compare = function (a, b) { - assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers') - var x = a.length - var y = b.length - for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {} - if (i !== len) { - x = a[i] - y = b[i] - } - if (x < y) { - return -1 - } - if (y < x) { - return 1 - } - return 0 -} - -// BUFFER INSTANCE METHODS -// ======================= - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - // must be an even number of digits - var strLen = string.length - assert(strLen % 2 === 0, 'Invalid hex string') - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; i++) { - var byte = parseInt(string.substr(i * 2, 2), 16) - assert(!isNaN(byte), 'Invalid hex string') - buf[offset + i] = byte - } - return i -} - -function utf8Write (buf, string, offset, length) { - var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length) - return charsWritten -} - -function asciiWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length) - return charsWritten -} - -function binaryWrite (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length) - return charsWritten -} - -function utf16leWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length) - return charsWritten -} - -Buffer.prototype.write = function (string, offset, length, encoding) { - // Support both (string, offset, length, encoding) - // and the legacy (string, encoding, offset, length) - if (isFinite(offset)) { - if (!isFinite(length)) { - encoding = length - length = undefined - } - } else { // legacy - var swap = encoding - encoding = offset - offset = length - length = swap - } - - offset = Number(offset) || 0 - var remaining = this.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - encoding = String(encoding || 'utf8').toLowerCase() - - var ret - switch (encoding) { - case 'hex': - ret = hexWrite(this, string, offset, length) - break - case 'utf8': - case 'utf-8': - ret = utf8Write(this, string, offset, length) - break - case 'ascii': - ret = asciiWrite(this, string, offset, length) - break - case 'binary': - ret = binaryWrite(this, string, offset, length) - break - case 'base64': - ret = base64Write(this, string, offset, length) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = utf16leWrite(this, string, offset, length) - break - default: - throw new Error('Unknown encoding') - } - return ret -} - -Buffer.prototype.toString = function (encoding, start, end) { - var self = this - - encoding = String(encoding || 'utf8').toLowerCase() - start = Number(start) || 0 - end = (end === undefined) ? self.length : Number(end) - - // Fastpath empty strings - if (end === start) - return '' - - var ret - switch (encoding) { - case 'hex': - ret = hexSlice(self, start, end) - break - case 'utf8': - case 'utf-8': - ret = utf8Slice(self, start, end) - break - case 'ascii': - ret = asciiSlice(self, start, end) - break - case 'binary': - ret = binarySlice(self, start, end) - break - case 'base64': - ret = base64Slice(self, start, end) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = utf16leSlice(self, start, end) - break - default: - throw new Error('Unknown encoding') - } - return ret -} - -Buffer.prototype.toJSON = function () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -Buffer.prototype.equals = function (b) { - assert(Buffer.isBuffer(b), 'Argument must be a Buffer') - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.compare = function (b) { - assert(Buffer.isBuffer(b), 'Argument must be a Buffer') - return Buffer.compare(this, b) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function (target, target_start, start, end) { - var source = this - - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (!target_start) target_start = 0 - - // Copy 0 bytes; we're done - if (end === start) return - if (target.length === 0 || source.length === 0) return - - // Fatal error conditions - assert(end >= start, 'sourceEnd < sourceStart') - assert(target_start >= 0 && target_start < target.length, - 'targetStart out of bounds') - assert(start >= 0 && start < source.length, 'sourceStart out of bounds') - assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) - end = this.length - if (target.length - target_start < end - start) - end = target.length - target_start + start - - var len = end - start - - if (len < 100 || !TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < len; i++) { - target[i + target_start] = this[i + start] - } - } else { - target._set(this.subarray(start, start + len), target_start) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - var res = '' - var tmp = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) - tmp = '' - } else { - tmp += '%' + buf[i].toString(16) - } - } - - return res + decodeUtf8Char(tmp) -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function binarySlice (buf, start, end) { - return asciiSlice(buf, start, end) -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; i++) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) - } - return res -} - -Buffer.prototype.slice = function (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len; - if (start < 0) - start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) - end = 0 - } else if (end > len) { - end = len - } - - if (end < start) - end = start - - if (TYPED_ARRAY_SUPPORT) { - return Buffer._augment(this.subarray(start, end)) - } else { - var sliceLen = end - start - var newBuf = new Buffer(sliceLen, undefined, true) - for (var i = 0; i < sliceLen; i++) { - newBuf[i] = this[i + start] - } - return newBuf - } -} - -// `get` will be removed in Node 0.13+ -Buffer.prototype.get = function (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) -} - -// `set` will be removed in Node 0.13+ -Buffer.prototype.set = function (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) -} - -Buffer.prototype.readUInt8 = function (offset, noAssert) { - if (!noAssert) { - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset < this.length, 'Trying to read beyond buffer length') - } - - if (offset >= this.length) - return - - return this[offset] -} - -function readUInt16 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') - } - - var len = buf.length - if (offset >= len) - return - - var val - if (littleEndian) { - val = buf[offset] - if (offset + 1 < len) - val |= buf[offset + 1] << 8 - } else { - val = buf[offset] << 8 - if (offset + 1 < len) - val |= buf[offset + 1] - } - return val -} - -Buffer.prototype.readUInt16LE = function (offset, noAssert) { - return readUInt16(this, offset, true, noAssert) -} - -Buffer.prototype.readUInt16BE = function (offset, noAssert) { - return readUInt16(this, offset, false, noAssert) -} - -function readUInt32 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') - } - - var len = buf.length - if (offset >= len) - return - - var val - if (littleEndian) { - if (offset + 2 < len) - val = buf[offset + 2] << 16 - if (offset + 1 < len) - val |= buf[offset + 1] << 8 - val |= buf[offset] - if (offset + 3 < len) - val = val + (buf[offset + 3] << 24 >>> 0) - } else { - if (offset + 1 < len) - val = buf[offset + 1] << 16 - if (offset + 2 < len) - val |= buf[offset + 2] << 8 - if (offset + 3 < len) - val |= buf[offset + 3] - val = val + (buf[offset] << 24 >>> 0) - } - return val -} - -Buffer.prototype.readUInt32LE = function (offset, noAssert) { - return readUInt32(this, offset, true, noAssert) -} - -Buffer.prototype.readUInt32BE = function (offset, noAssert) { - return readUInt32(this, offset, false, noAssert) -} - -Buffer.prototype.readInt8 = function (offset, noAssert) { - if (!noAssert) { - assert(offset !== undefined && offset !== null, - 'missing offset') - assert(offset < this.length, 'Trying to read beyond buffer length') - } - - if (offset >= this.length) - return - - var neg = this[offset] & 0x80 - if (neg) - return (0xff - this[offset] + 1) * -1 - else - return this[offset] -} - -function readInt16 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') - } - - var len = buf.length - if (offset >= len) - return - - var val = readUInt16(buf, offset, littleEndian, true) - var neg = val & 0x8000 - if (neg) - return (0xffff - val + 1) * -1 - else - return val -} - -Buffer.prototype.readInt16LE = function (offset, noAssert) { - return readInt16(this, offset, true, noAssert) -} - -Buffer.prototype.readInt16BE = function (offset, noAssert) { - return readInt16(this, offset, false, noAssert) -} - -function readInt32 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') - } - - var len = buf.length - if (offset >= len) - return - - var val = readUInt32(buf, offset, littleEndian, true) - var neg = val & 0x80000000 - if (neg) - return (0xffffffff - val + 1) * -1 - else - return val -} - -Buffer.prototype.readInt32LE = function (offset, noAssert) { - return readInt32(this, offset, true, noAssert) -} - -Buffer.prototype.readInt32BE = function (offset, noAssert) { - return readInt32(this, offset, false, noAssert) -} - -function readFloat (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') - } - - return ieee754.read(buf, offset, littleEndian, 23, 4) -} - -Buffer.prototype.readFloatLE = function (offset, noAssert) { - return readFloat(this, offset, true, noAssert) -} - -Buffer.prototype.readFloatBE = function (offset, noAssert) { - return readFloat(this, offset, false, noAssert) -} - -function readDouble (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset + 7 < buf.length, 'Trying to read beyond buffer length') - } - - return ieee754.read(buf, offset, littleEndian, 52, 8) -} - -Buffer.prototype.readDoubleLE = function (offset, noAssert) { - return readDouble(this, offset, true, noAssert) -} - -Buffer.prototype.readDoubleBE = function (offset, noAssert) { - return readDouble(this, offset, false, noAssert) -} - -Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset < this.length, 'trying to write beyond buffer length') - verifuint(value, 0xff) - } - - if (offset >= this.length) return - - this[offset] = value - return offset + 1 -} - -function writeUInt16 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'trying to write beyond buffer length') - verifuint(value, 0xffff) - } - - var len = buf.length - if (offset >= len) - return - - for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) { - buf[offset + i] = - (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } - return offset + 2 -} - -Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) { - return writeUInt16(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) { - return writeUInt16(this, value, offset, false, noAssert) -} - -function writeUInt32 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'trying to write beyond buffer length') - verifuint(value, 0xffffffff) - } - - var len = buf.length - if (offset >= len) - return - - for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) { - buf[offset + i] = - (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } - return offset + 4 -} - -Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) { - return writeUInt32(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) { - return writeUInt32(this, value, offset, false, noAssert) -} - -Buffer.prototype.writeInt8 = function (value, offset, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset < this.length, 'Trying to write beyond buffer length') - verifsint(value, 0x7f, -0x80) - } - - if (offset >= this.length) - return - - if (value >= 0) - this.writeUInt8(value, offset, noAssert) - else - this.writeUInt8(0xff + value + 1, offset, noAssert) - return offset + 1 -} - -function writeInt16 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'Trying to write beyond buffer length') - verifsint(value, 0x7fff, -0x8000) - } - - var len = buf.length - if (offset >= len) - return - - if (value >= 0) - writeUInt16(buf, value, offset, littleEndian, noAssert) - else - writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert) - return offset + 2 -} - -Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { - return writeInt16(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeInt16BE = function (value, offset, noAssert) { - return writeInt16(this, value, offset, false, noAssert) -} - -function writeInt32 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') - verifsint(value, 0x7fffffff, -0x80000000) - } - - var len = buf.length - if (offset >= len) - return - - if (value >= 0) - writeUInt32(buf, value, offset, littleEndian, noAssert) - else - writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert) - return offset + 4 -} - -Buffer.prototype.writeInt32LE = function (value, offset, noAssert) { - return writeInt32(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeInt32BE = function (value, offset, noAssert) { - return writeInt32(this, value, offset, false, noAssert) -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') - verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - - var len = buf.length - if (offset >= len) - return - - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 7 < buf.length, - 'Trying to write beyond buffer length') - verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - - var len = buf.length - if (offset >= len) - return - - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// fill(value, start=0, end=buffer.length) -Buffer.prototype.fill = function (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length - - assert(end >= start, 'end < start') - - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return - - assert(start >= 0 && start < this.length, 'start out of bounds') - assert(end >= 0 && end <= this.length, 'end out of bounds') - - var i - if (typeof value === 'number') { - for (i = start; i < end; i++) { - this[i] = value - } - } else { - var bytes = utf8ToBytes(value.toString()) - var len = bytes.length - for (i = start; i < end; i++) { - this[i] = bytes[i % len] - } - } - - return this -} - -Buffer.prototype.inspect = function () { - var out = [] - var len = this.length - for (var i = 0; i < len; i++) { - out[i] = toHex(this[i]) - if (i === exports.INSPECT_MAX_BYTES) { - out[i + 1] = '...' - break - } - } - return '' -} - -/** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ -Buffer.prototype.toArrayBuffer = function () { - if (typeof Uint8Array !== 'undefined') { - if (TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i] - } - return buf.buffer - } - } else { - throw new Error('Buffer.toArrayBuffer not supported in this browser') - } -} - -// HELPER FUNCTIONS -// ================ - -var BP = Buffer.prototype - -/** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ -Buffer._augment = function (arr) { - arr._isBuffer = true - - // save reference to original Uint8Array get/set methods before overwriting - arr._get = arr.get - arr._set = arr.set - - // deprecated, will be removed in node 0.13+ - arr.get = BP.get - arr.set = BP.set - - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.equals = BP.equals - arr.compare = BP.compare - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer - - return arr -} - -var INVALID_BASE64_RE = /[^+\/0-9A-z]/g - -function base64clean (str) { - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, '') - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') -} - -function isArray (subject) { - return (Array.isArray || function (subject) { - return Object.prototype.toString.call(subject) === '[object Array]' - })(subject) -} - -function isArrayish (subject) { - return isArray(subject) || Buffer.isBuffer(subject) || - subject && typeof subject === 'object' && - typeof subject.length === 'number' -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - var b = str.charCodeAt(i) - if (b <= 0x7F) { - byteArray.push(b) - } else { - var start = i - if (b >= 0xD800 && b <= 0xDFFF) i++ - var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%') - for (var j = 0; j < h.length; j++) { - byteArray.push(parseInt(h[j], 16)) - } - } - } - return byteArray -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; i++) { - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(str) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; i++) { - if ((i + offset >= dst.length) || (i >= src.length)) - break - dst[i + offset] = src[i] - } - return i -} - -function decodeUtf8Char (str) { - try { - return decodeURIComponent(str) - } catch (err) { - return String.fromCharCode(0xFFFD) // UTF 8 invalid char - } -} - -/* - * We have to make sure that the value is a valid integer. This means that it - * is non-negative. It has no fractional component and that it does not - * exceed the maximum allowed value. - */ -function verifuint (value, max) { - assert(typeof value === 'number', 'cannot write a non-number as a number') - assert(value >= 0, 'specified a negative value for writing an unsigned value') - assert(value <= max, 'value is larger than maximum value for type') - assert(Math.floor(value) === value, 'value has a fractional component') -} - -function verifsint (value, max, min) { - assert(typeof value === 'number', 'cannot write a non-number as a number') - assert(value <= max, 'value larger than maximum allowed value') - assert(value >= min, 'value smaller than minimum allowed value') - assert(Math.floor(value) === value, 'value has a fractional component') -} - -function verifIEEE754 (value, max, min) { - assert(typeof value === 'number', 'cannot write a non-number as a number') - assert(value <= max, 'value larger than maximum allowed value') - assert(value >= min, 'value smaller than minimum allowed value') -} - -function assert (test, message) { - if (!test) throw new Error(message || 'Failed assertion') -} - -},{"base64-js":25,"ieee754":26}],25:[function(require,module,exports){ -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - -;(function (exports) { - 'use strict'; - - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array - - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS) - return 62 // '+' - if (code === SLASH) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } - - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length - - var L = 0 - - function push (v) { - arr[L++] = v - } - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } - - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } - - return arr - } - - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length - - function encode (num) { - return lookup.charAt(num) - } - - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } - - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } - - return output - } - - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 -}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) - -},{}],26:[function(require,module,exports){ -exports.read = function(buffer, offset, isLE, mLen, nBytes) { - var e, m, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - nBits = -7, - i = isLE ? (nBytes - 1) : 0, - d = isLE ? -1 : 1, - s = buffer[offset + i]; - - i += d; - - e = s & ((1 << (-nBits)) - 1); - s >>= (-nBits); - nBits += eLen; - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); - - m = e & ((1 << (-nBits)) - 1); - e >>= (-nBits); - nBits += mLen; - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); - - if (e === 0) { - e = 1 - eBias; - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity); - } else { - m = m + Math.pow(2, mLen); - e = e - eBias; - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen); -}; - -exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), - i = isLE ? 0 : (nBytes - 1), - d = isLE ? 1 : -1, - s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; - - value = Math.abs(value); - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0; - e = eMax; - } else { - e = Math.floor(Math.log(value) / Math.LN2); - if (value * (c = Math.pow(2, -e)) < 1) { - e--; - c *= 2; - } - if (e + eBias >= 1) { - value += rt / c; - } else { - value += rt * Math.pow(2, 1 - eBias); - } - if (value * c >= 2) { - e++; - c /= 2; - } - - if (e + eBias >= eMax) { - m = 0; - e = eMax; - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen); - e = e + eBias; - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); - e = 0; - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); - - e = (e << mLen) | m; - eLen += mLen; - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); - - buffer[offset + i - d] |= s * 128; -}; - -},{}],27:[function(require,module,exports){ -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} - -},{}],28:[function(require,module,exports){ -(function (process){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// resolves . and .. elements in a path array with directory names there -// must be no slashes, empty elements, or device names (c:\) in the array -// (so also no leading and trailing slashes - it does not distinguish -// relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = parts.length - 1; i >= 0; i--) { - var last = parts[i]; - if (last === '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); - } - } - - return parts; -} - -// Split a filename into [root, dir, basename, ext], unix version -// 'root' is just a slash, or nothing. -var splitPathRe = - /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; -var splitPath = function(filename) { - return splitPathRe.exec(filename).slice(1); -}; - -// path.resolve([from ...], to) -// posix version -exports.resolve = function() { - var resolvedPath = '', - resolvedAbsolute = false; - - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - var path = (i >= 0) ? arguments[i] : process.cwd(); - - // Skip empty and invalid entries - if (typeof path !== 'string') { - throw new TypeError('Arguments to path.resolve must be strings'); - } else if (!path) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charAt(0) === '/'; - } - - // At this point the path should be resolved to a full absolute path, but - // handle relative paths to be safe (might happen when process.cwd() fails) - - // Normalize the path - resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { - return !!p; - }), !resolvedAbsolute).join('/'); - - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; -}; - -// path.normalize(path) -// posix version -exports.normalize = function(path) { - var isAbsolute = exports.isAbsolute(path), - trailingSlash = substr(path, -1) === '/'; - - // Normalize the path - path = normalizeArray(filter(path.split('/'), function(p) { - return !!p; - }), !isAbsolute).join('/'); - - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } - - return (isAbsolute ? '/' : '') + path; -}; - -// posix version -exports.isAbsolute = function(path) { - return path.charAt(0) === '/'; -}; - -// posix version -exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(filter(paths, function(p, index) { - if (typeof p !== 'string') { - throw new TypeError('Arguments to path.join must be strings'); - } - return p; - }).join('/')); -}; - - -// path.relative(from, to) -// posix version -exports.relative = function(from, to) { - from = exports.resolve(from).substr(1); - to = exports.resolve(to).substr(1); - - function trim(arr) { - var start = 0; - for (; start < arr.length; start++) { - if (arr[start] !== '') break; - } - - var end = arr.length - 1; - for (; end >= 0; end--) { - if (arr[end] !== '') break; - } - - if (start > end) return []; - return arr.slice(start, end - start + 1); - } - - var fromParts = trim(from.split('/')); - var toParts = trim(to.split('/')); - - var length = Math.min(fromParts.length, toParts.length); - var samePartsLength = length; - for (var i = 0; i < length; i++) { - if (fromParts[i] !== toParts[i]) { - samePartsLength = i; - break; - } - } - - var outputParts = []; - for (var i = samePartsLength; i < fromParts.length; i++) { - outputParts.push('..'); - } - - outputParts = outputParts.concat(toParts.slice(samePartsLength)); - - return outputParts.join('/'); -}; - -exports.sep = '/'; -exports.delimiter = ':'; - -exports.dirname = function(path) { - var result = splitPath(path), - root = result[0], - dir = result[1]; - - if (!root && !dir) { - // No dirname whatsoever - return '.'; - } - - if (dir) { - // It has a dirname, strip trailing slash - dir = dir.substr(0, dir.length - 1); - } - - return root + dir; -}; - - -exports.basename = function(path, ext) { - var f = splitPath(path)[2]; - // TODO: make this comparison case-insensitive on windows? - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); - } - return f; -}; - - -exports.extname = function(path) { - return splitPath(path)[3]; -}; - -function filter (xs, f) { - if (xs.filter) return xs.filter(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - if (f(xs[i], i, xs)) res.push(xs[i]); - } - return res; -} - -// String.prototype.substr - negative index don't work in IE8 -var substr = 'ab'.substr(-1) === 'b' - ? function (str, start, len) { return str.substr(start, len) } - : function (str, start, len) { - if (start < 0) start = str.length + start; - return str.substr(start, len); - } -; - -}).call(this,require('_process')) -},{"_process":29}],29:[function(require,module,exports){ -// shim for using process in browser - -var process = module.exports = {}; - -process.nextTick = (function () { - var canSetImmediate = typeof window !== 'undefined' - && window.setImmediate; - var canPost = typeof window !== 'undefined' - && window.postMessage && window.addEventListener - ; - - if (canSetImmediate) { - return function (f) { return window.setImmediate(f) }; - } - - if (canPost) { - var queue = []; - window.addEventListener('message', function (ev) { - var source = ev.source; - if ((source === window || source === null) && ev.data === 'process-tick') { - ev.stopPropagation(); - if (queue.length > 0) { - var fn = queue.shift(); - fn(); - } - } - }, true); - - return function nextTick(fn) { - queue.push(fn); - window.postMessage('process-tick', '*'); - }; - } - - return function nextTick(fn) { - setTimeout(fn, 0); - }; -})(); - -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -} - -// TODO(shtylman) -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; - -},{}],30:[function(require,module,exports){ -module.exports = function isBuffer(arg) { - return arg && typeof arg === 'object' - && typeof arg.copy === 'function' - && typeof arg.fill === 'function' - && typeof arg.readUInt8 === 'function'; -} -},{}],31:[function(require,module,exports){ -(function (process,global){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var formatRegExp = /%[sdj%]/g; -exports.format = function(f) { - if (!isString(f)) { - var objects = []; - for (var i = 0; i < arguments.length; i++) { - objects.push(inspect(arguments[i])); - } - return objects.join(' '); - } - - var i = 1; - var args = arguments; - var len = args.length; - var str = String(f).replace(formatRegExp, function(x) { - if (x === '%%') return '%'; - if (i >= len) return x; - switch (x) { - case '%s': return String(args[i++]); - case '%d': return Number(args[i++]); - case '%j': - try { - return JSON.stringify(args[i++]); - } catch (_) { - return '[Circular]'; - } - default: - return x; - } - }); - for (var x = args[i]; i < len; x = args[++i]) { - if (isNull(x) || !isObject(x)) { - str += ' ' + x; - } else { - str += ' ' + inspect(x); - } - } - return str; -}; - - -// Mark that a method should not be used. -// Returns a modified function which warns once by default. -// If --no-deprecation is set, then it is a no-op. -exports.deprecate = function(fn, msg) { - // Allow for deprecating things in the process of starting up. - if (isUndefined(global.process)) { - return function() { - return exports.deprecate(fn, msg).apply(this, arguments); - }; - } - - if (process.noDeprecation === true) { - return fn; - } - - var warned = false; - function deprecated() { - if (!warned) { - if (process.throwDeprecation) { - throw new Error(msg); - } else if (process.traceDeprecation) { - console.trace(msg); - } else { - console.error(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } - - return deprecated; -}; - - -var debugs = {}; -var debugEnviron; -exports.debuglog = function(set) { - if (isUndefined(debugEnviron)) - debugEnviron = process.env.NODE_DEBUG || ''; - set = set.toUpperCase(); - if (!debugs[set]) { - if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { - var pid = process.pid; - debugs[set] = function() { - var msg = exports.format.apply(exports, arguments); - console.error('%s %d: %s', set, pid, msg); - }; - } else { - debugs[set] = function() {}; - } - } - return debugs[set]; -}; - - -/** - * Echos the value of a value. Trys to print the value out - * in the best way possible given the different types. - * - * @param {Object} obj The object to print out. - * @param {Object} opts Optional options object that alters the output. - */ -/* legacy: obj, showHidden, depth, colors*/ -function inspect(obj, opts) { - // default options - var ctx = { - seen: [], - stylize: stylizeNoColor - }; - // legacy... - if (arguments.length >= 3) ctx.depth = arguments[2]; - if (arguments.length >= 4) ctx.colors = arguments[3]; - if (isBoolean(opts)) { - // legacy... - ctx.showHidden = opts; - } else if (opts) { - // got an "options" object - exports._extend(ctx, opts); - } - // set default options - if (isUndefined(ctx.showHidden)) ctx.showHidden = false; - if (isUndefined(ctx.depth)) ctx.depth = 2; - if (isUndefined(ctx.colors)) ctx.colors = false; - if (isUndefined(ctx.customInspect)) ctx.customInspect = true; - if (ctx.colors) ctx.stylize = stylizeWithColor; - return formatValue(ctx, obj, ctx.depth); -} -exports.inspect = inspect; - - -// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics -inspect.colors = { - 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'inverse' : [7, 27], - 'white' : [37, 39], - 'grey' : [90, 39], - 'black' : [30, 39], - 'blue' : [34, 39], - 'cyan' : [36, 39], - 'green' : [32, 39], - 'magenta' : [35, 39], - 'red' : [31, 39], - 'yellow' : [33, 39] -}; - -// Don't use 'blue' not visible on cmd.exe -inspect.styles = { - 'special': 'cyan', - 'number': 'yellow', - 'boolean': 'yellow', - 'undefined': 'grey', - 'null': 'bold', - 'string': 'green', - 'date': 'magenta', - // "name": intentionally not styling - 'regexp': 'red' -}; - - -function stylizeWithColor(str, styleType) { - var style = inspect.styles[styleType]; - - if (style) { - return '\u001b[' + inspect.colors[style][0] + 'm' + str + - '\u001b[' + inspect.colors[style][1] + 'm'; - } else { - return str; - } -} - - -function stylizeNoColor(str, styleType) { - return str; -} - - -function arrayToHash(array) { - var hash = {}; - - array.forEach(function(val, idx) { - hash[val] = true; - }); - - return hash; -} - - -function formatValue(ctx, value, recurseTimes) { - // Provide a hook for user-specified inspect functions. - // Check that value is an object with an inspect function on it - if (ctx.customInspect && - value && - isFunction(value.inspect) && - // Filter out the util module, it's inspect function is special - value.inspect !== exports.inspect && - // Also filter out any prototype objects using the circular check. - !(value.constructor && value.constructor.prototype === value)) { - var ret = value.inspect(recurseTimes, ctx); - if (!isString(ret)) { - ret = formatValue(ctx, ret, recurseTimes); - } - return ret; - } - - // Primitive types cannot have properties - var primitive = formatPrimitive(ctx, value); - if (primitive) { - return primitive; - } - - // Look up the keys of the object. - var keys = Object.keys(value); - var visibleKeys = arrayToHash(keys); - - if (ctx.showHidden) { - keys = Object.getOwnPropertyNames(value); - } - - // IE doesn't make error fields non-enumerable - // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx - if (isError(value) - && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { - return formatError(value); - } - - // Some type of object without properties can be shortcutted. - if (keys.length === 0) { - if (isFunction(value)) { - var name = value.name ? ': ' + value.name : ''; - return ctx.stylize('[Function' + name + ']', 'special'); - } - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } - if (isDate(value)) { - return ctx.stylize(Date.prototype.toString.call(value), 'date'); - } - if (isError(value)) { - return formatError(value); - } - } - - var base = '', array = false, braces = ['{', '}']; - - // Make Array say that they are Array - if (isArray(value)) { - array = true; - braces = ['[', ']']; - } - - // Make functions say that they are functions - if (isFunction(value)) { - var n = value.name ? ': ' + value.name : ''; - base = ' [Function' + n + ']'; - } - - // Make RegExps say that they are RegExps - if (isRegExp(value)) { - base = ' ' + RegExp.prototype.toString.call(value); - } - - // Make dates with properties first say the date - if (isDate(value)) { - base = ' ' + Date.prototype.toUTCString.call(value); - } - - // Make error with message first say the error - if (isError(value)) { - base = ' ' + formatError(value); - } - - if (keys.length === 0 && (!array || value.length == 0)) { - return braces[0] + base + braces[1]; - } - - if (recurseTimes < 0) { - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } else { - return ctx.stylize('[Object]', 'special'); - } - } - - ctx.seen.push(value); - - var output; - if (array) { - output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); - } else { - output = keys.map(function(key) { - return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); - }); - } - - ctx.seen.pop(); - - return reduceToSingleString(output, base, braces); -} - - -function formatPrimitive(ctx, value) { - if (isUndefined(value)) - return ctx.stylize('undefined', 'undefined'); - if (isString(value)) { - var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; - return ctx.stylize(simple, 'string'); - } - if (isNumber(value)) - return ctx.stylize('' + value, 'number'); - if (isBoolean(value)) - return ctx.stylize('' + value, 'boolean'); - // For some reason typeof null is "object", so special case here. - if (isNull(value)) - return ctx.stylize('null', 'null'); -} - - -function formatError(value) { - return '[' + Error.prototype.toString.call(value) + ']'; -} - - -function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { - var output = []; - for (var i = 0, l = value.length; i < l; ++i) { - if (hasOwnProperty(value, String(i))) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - String(i), true)); - } else { - output.push(''); - } - } - keys.forEach(function(key) { - if (!key.match(/^\d+$/)) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); - } - }); - return output; -} - - -function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { - var name, str, desc; - desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; - if (desc.get) { - if (desc.set) { - str = ctx.stylize('[Getter/Setter]', 'special'); - } else { - str = ctx.stylize('[Getter]', 'special'); - } - } else { - if (desc.set) { - str = ctx.stylize('[Setter]', 'special'); - } - } - if (!hasOwnProperty(visibleKeys, key)) { - name = '[' + key + ']'; - } - if (!str) { - if (ctx.seen.indexOf(desc.value) < 0) { - if (isNull(recurseTimes)) { - str = formatValue(ctx, desc.value, null); - } else { - str = formatValue(ctx, desc.value, recurseTimes - 1); - } - if (str.indexOf('\n') > -1) { - if (array) { - str = str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n').substr(2); - } else { - str = '\n' + str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n'); - } - } - } else { - str = ctx.stylize('[Circular]', 'special'); - } - } - if (isUndefined(name)) { - if (array && key.match(/^\d+$/)) { - return str; - } - name = JSON.stringify('' + key); - if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { - name = name.substr(1, name.length - 2); - name = ctx.stylize(name, 'name'); - } else { - name = name.replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'"); - name = ctx.stylize(name, 'string'); - } - } - - return name + ': ' + str; -} - - -function reduceToSingleString(output, base, braces) { - var numLinesEst = 0; - var length = output.reduce(function(prev, cur) { - numLinesEst++; - if (cur.indexOf('\n') >= 0) numLinesEst++; - return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; - }, 0); - - if (length > 60) { - return braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; - } - - return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; -} - - -// NOTE: These type checking functions intentionally don't use `instanceof` -// because it is fragile and can be easily faked with `Object.create()`. -function isArray(ar) { - return Array.isArray(ar); -} -exports.isArray = isArray; - -function isBoolean(arg) { - return typeof arg === 'boolean'; -} -exports.isBoolean = isBoolean; - -function isNull(arg) { - return arg === null; -} -exports.isNull = isNull; - -function isNullOrUndefined(arg) { - return arg == null; -} -exports.isNullOrUndefined = isNullOrUndefined; - -function isNumber(arg) { - return typeof arg === 'number'; -} -exports.isNumber = isNumber; - -function isString(arg) { - return typeof arg === 'string'; -} -exports.isString = isString; - -function isSymbol(arg) { - return typeof arg === 'symbol'; -} -exports.isSymbol = isSymbol; - -function isUndefined(arg) { - return arg === void 0; -} -exports.isUndefined = isUndefined; - -function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; -} -exports.isRegExp = isRegExp; - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} -exports.isObject = isObject; - -function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; -} -exports.isDate = isDate; - -function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); -} -exports.isError = isError; - -function isFunction(arg) { - return typeof arg === 'function'; -} -exports.isFunction = isFunction; - -function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; -} -exports.isPrimitive = isPrimitive; - -exports.isBuffer = require('./support/isBuffer'); - -function objectToString(o) { - return Object.prototype.toString.call(o); -} - - -function pad(n) { - return n < 10 ? '0' + n.toString(10) : n.toString(10); -} - - -var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', - 'Oct', 'Nov', 'Dec']; - -// 26 Feb 16:19:34 -function timestamp() { - var d = new Date(); - var time = [pad(d.getHours()), - pad(d.getMinutes()), - pad(d.getSeconds())].join(':'); - return [d.getDate(), months[d.getMonth()], time].join(' '); -} - - -// log is just a thin wrapper to console.log that prepends a timestamp -exports.log = function() { - console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); -}; - - -/** - * Inherit the prototype methods from one constructor into another. - * - * The Function.prototype.inherits from lang.js rewritten as a standalone - * function (not on Function.prototype). NOTE: If this file is to be loaded - * during bootstrapping this function needs to be rewritten using some native - * functions as prototype setup using normal JavaScript does not work as - * expected during bootstrapping (see mirror.js in r114903). - * - * @param {function} ctor Constructor function which needs to inherit the - * prototype. - * @param {function} superCtor Constructor function to inherit prototype from. - */ -exports.inherits = require('inherits'); - -exports._extend = function(origin, add) { - // Don't do anything if add isn't an object - if (!add || !isObject(add)) return origin; - - var keys = Object.keys(add); - var i = keys.length; - while (i--) { - origin[keys[i]] = add[keys[i]]; - } - return origin; -}; - -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":30,"_process":29,"inherits":27}],"joi":[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./lib":10}]},{},[])("joi") -}); diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/foxxInstallView.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/foxxInstallView.js index fc88a409eb..26f9b01f98 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/foxxInstallView.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/foxxInstallView.js @@ -46,7 +46,7 @@ validateInput: function () { return [ { - rule: Joi.string().regex(/^(\/(APP[^/]+|(?!APP)[a-zA-Z0-9_\-%]+))+$/i), + rule: Joi.string().regex(/(\/|^)APP(\/|$)/i, {invert: true}), msg: 'May not contain /APP' }, {