UNPKG

truffle

Version:

Truffle - Simple development framework for Ethereum

1,628 lines (1,392 loc) 532 kB
#!/usr/bin/env node exports.id = 1472; exports.ids = [1472]; exports.modules = { /***/ 80657: /***/ ((module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); const util = __webpack_require__(73837); const toString = Object.prototype.toString; const isOfType = (type) => (value) => typeof value === type; // tslint:disable-line:strict-type-predicates const getObjectType = (value) => { const objectName = toString.call(value).slice(8, -1); if (objectName) { return objectName; } return null; }; const isObjectOfType = (typeName) => (value) => { return getObjectType(value) === typeName; }; function is(value) { if (value === null) { return "null" /* null */; } if (value === true || value === false) { return "boolean" /* boolean */; } const type = typeof value; if (type === 'undefined') { return "undefined" /* undefined */; } if (type === 'string') { return "string" /* string */; } if (type === 'number') { return "number" /* number */; } if (type === 'symbol') { return "symbol" /* symbol */; } if (is.function_(value)) { return "Function" /* Function */; } if (Array.isArray(value)) { return "Array" /* Array */; } if (Buffer.isBuffer(value)) { return "Buffer" /* Buffer */; } const tagType = getObjectType(value); if (tagType) { return tagType; } if (value instanceof String || value instanceof Boolean || value instanceof Number) { throw new TypeError('Please don\'t use object wrappers for primitive types'); } return "Object" /* Object */; } (function (is) { const isObject = (value) => typeof value === 'object'; // tslint:disable:variable-name is.undefined = isOfType('undefined'); is.string = isOfType('string'); is.number = isOfType('number'); is.function_ = isOfType('function'); is.null_ = (value) => value === null; is.class_ = (value) => is.function_(value) && value.toString().startsWith('class '); is.boolean = (value) => value === true || value === false; // tslint:enable:variable-name is.symbol = isOfType('symbol'); is.array = Array.isArray; is.buffer = Buffer.isBuffer; is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value); is.object = (value) => !is.nullOrUndefined(value) && (is.function_(value) || isObject(value)); is.iterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.iterator]); is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw); is.nativePromise = isObjectOfType("Promise" /* Promise */); const hasPromiseAPI = (value) => !is.null_(value) && isObject(value) && is.function_(value.then) && is.function_(value.catch); is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value); // TODO: Change to use `isObjectOfType` once Node.js 6 or higher is targeted const isFunctionOfType = (type) => (value) => is.function_(value) && is.function_(value.constructor) && value.constructor.name === type; is.generatorFunction = isFunctionOfType('GeneratorFunction'); is.asyncFunction = isFunctionOfType('AsyncFunction'); is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype'); is.regExp = isObjectOfType("RegExp" /* RegExp */); is.date = isObjectOfType("Date" /* Date */); is.error = isObjectOfType("Error" /* Error */); is.map = isObjectOfType("Map" /* Map */); is.set = isObjectOfType("Set" /* Set */); is.weakMap = isObjectOfType("WeakMap" /* WeakMap */); is.weakSet = isObjectOfType("WeakSet" /* WeakSet */); is.int8Array = isObjectOfType("Int8Array" /* Int8Array */); is.uint8Array = isObjectOfType("Uint8Array" /* Uint8Array */); is.uint8ClampedArray = isObjectOfType("Uint8ClampedArray" /* Uint8ClampedArray */); is.int16Array = isObjectOfType("Int16Array" /* Int16Array */); is.uint16Array = isObjectOfType("Uint16Array" /* Uint16Array */); is.int32Array = isObjectOfType("Int32Array" /* Int32Array */); is.uint32Array = isObjectOfType("Uint32Array" /* Uint32Array */); is.float32Array = isObjectOfType("Float32Array" /* Float32Array */); is.float64Array = isObjectOfType("Float64Array" /* Float64Array */); is.arrayBuffer = isObjectOfType("ArrayBuffer" /* ArrayBuffer */); is.sharedArrayBuffer = isObjectOfType("SharedArrayBuffer" /* SharedArrayBuffer */); is.dataView = isObjectOfType("DataView" /* DataView */); // TODO: Remove `object` checks when targeting ES2015 or higher // See `Notes`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf is.directInstanceOf = (instance, klass) => is.object(instance) && is.object(klass) && Object.getPrototypeOf(instance) === klass.prototype; is.truthy = (value) => Boolean(value); is.falsy = (value) => !value; is.nan = (value) => Number.isNaN(value); const primitiveTypes = new Set([ 'undefined', 'string', 'number', 'boolean', 'symbol' ]); is.primitive = (value) => is.null_(value) || primitiveTypes.has(typeof value); is.integer = (value) => Number.isInteger(value); is.safeInteger = (value) => Number.isSafeInteger(value); is.plainObject = (value) => { // From: https://github.com/sindresorhus/is-plain-obj/blob/master/index.js let prototype; return getObjectType(value) === "Object" /* Object */ && (prototype = Object.getPrototypeOf(value), prototype === null || // tslint:disable-line:ban-comma-operator prototype === Object.getPrototypeOf({})); }; const typedArrayTypes = new Set([ "Int8Array" /* Int8Array */, "Uint8Array" /* Uint8Array */, "Uint8ClampedArray" /* Uint8ClampedArray */, "Int16Array" /* Int16Array */, "Uint16Array" /* Uint16Array */, "Int32Array" /* Int32Array */, "Uint32Array" /* Uint32Array */, "Float32Array" /* Float32Array */, "Float64Array" /* Float64Array */ ]); is.typedArray = (value) => { const objectType = getObjectType(value); if (objectType === null) { return false; } return typedArrayTypes.has(objectType); }; const isValidLength = (value) => is.safeInteger(value) && value > -1; is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length); is.inRange = (value, range) => { if (is.number(range)) { return value >= Math.min(0, range) && value <= Math.max(range, 0); } if (is.array(range) && range.length === 2) { // TODO: Use spread operator here when targeting Node.js 6 or higher return value >= Math.min.apply(null, range) && value <= Math.max.apply(null, range); } throw new TypeError(`Invalid range: ${util.inspect(range)}`); }; const NODE_TYPE_ELEMENT = 1; const DOM_PROPERTIES_TO_CHECK = [ 'innerHTML', 'ownerDocument', 'style', 'attributes', 'nodeValue' ]; is.domElement = (value) => is.object(value) && value.nodeType === NODE_TYPE_ELEMENT && is.string(value.nodeName) && !is.plainObject(value) && DOM_PROPERTIES_TO_CHECK.every(property => property in value); is.nodeStream = (value) => !is.nullOrUndefined(value) && isObject(value) && is.function_(value.pipe); is.infinite = (value) => value === Infinity || value === -Infinity; const isAbsoluteMod2 = (value) => (rem) => is.integer(rem) && Math.abs(rem % 2) === value; is.even = isAbsoluteMod2(0); is.odd = isAbsoluteMod2(1); const isWhiteSpaceString = (value) => is.string(value) && /\S/.test(value) === false; const isEmptyStringOrArray = (value) => (is.string(value) || is.array(value)) && value.length === 0; const isEmptyObject = (value) => !is.map(value) && !is.set(value) && is.object(value) && Object.keys(value).length === 0; const isEmptyMapOrSet = (value) => (is.map(value) || is.set(value)) && value.size === 0; is.empty = (value) => is.falsy(value) || isEmptyStringOrArray(value) || isEmptyObject(value) || isEmptyMapOrSet(value); is.emptyOrWhitespace = (value) => is.empty(value) || isWhiteSpaceString(value); const predicateOnArray = (method, predicate, args) => { // `args` is the calling function's "arguments object". // We have to do it this way to keep node v4 support. // So here we convert it to an array and slice off the first item. const values = Array.prototype.slice.call(args, 1); if (is.function_(predicate) === false) { throw new TypeError(`Invalid predicate: ${util.inspect(predicate)}`); } if (values.length === 0) { throw new TypeError('Invalid number of values'); } return method.call(values, predicate); }; function any(predicate) { return predicateOnArray(Array.prototype.some, predicate, arguments); } is.any = any; function all(predicate) { return predicateOnArray(Array.prototype.every, predicate, arguments); } is.all = all; // tslint:enable:only-arrow-functions no-function-expression })(is || (is = {})); // Some few keywords are reserved, but we'll populate them for Node.js users // See https://github.com/Microsoft/TypeScript/issues/2536 Object.defineProperties(is, { class: { value: is.class_ }, function: { value: is.function_ }, null: { value: is.null_ } }); exports["default"] = is; // For CommonJS default export support module.exports = is; module.exports["default"] = is; /***/ }), /***/ 95217: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; const fileType = __webpack_require__(31180); const exts = new Set([ '7z', 'bz2', 'gz', 'rar', 'tar', 'zip', 'xz', 'gz' ]); module.exports = input => { const ret = fileType(input); return exts.has(ret && ret.ext) ? ret : null; }; /***/ }), /***/ 31180: /***/ ((module) => { "use strict"; module.exports = input => { const buf = new Uint8Array(input); if (!(buf && buf.length > 1)) { return null; } const check = (header, opts) => { opts = Object.assign({ offset: 0 }, opts); for (let i = 0; i < header.length; i++) { if (header[i] !== buf[i + opts.offset]) { return false; } } return true; }; if (check([0xFF, 0xD8, 0xFF])) { return { ext: 'jpg', mime: 'image/jpeg' }; } if (check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) { return { ext: 'png', mime: 'image/png' }; } if (check([0x47, 0x49, 0x46])) { return { ext: 'gif', mime: 'image/gif' }; } if (check([0x57, 0x45, 0x42, 0x50], {offset: 8})) { return { ext: 'webp', mime: 'image/webp' }; } if (check([0x46, 0x4C, 0x49, 0x46])) { return { ext: 'flif', mime: 'image/flif' }; } // Needs to be before `tif` check if ( (check([0x49, 0x49, 0x2A, 0x0]) || check([0x4D, 0x4D, 0x0, 0x2A])) && check([0x43, 0x52], {offset: 8}) ) { return { ext: 'cr2', mime: 'image/x-canon-cr2' }; } if ( check([0x49, 0x49, 0x2A, 0x0]) || check([0x4D, 0x4D, 0x0, 0x2A]) ) { return { ext: 'tif', mime: 'image/tiff' }; } if (check([0x42, 0x4D])) { return { ext: 'bmp', mime: 'image/bmp' }; } if (check([0x49, 0x49, 0xBC])) { return { ext: 'jxr', mime: 'image/vnd.ms-photo' }; } if (check([0x38, 0x42, 0x50, 0x53])) { return { ext: 'psd', mime: 'image/vnd.adobe.photoshop' }; } // Needs to be before the `zip` check if ( check([0x50, 0x4B, 0x3, 0x4]) && check([0x6D, 0x69, 0x6D, 0x65, 0x74, 0x79, 0x70, 0x65, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x65, 0x70, 0x75, 0x62, 0x2B, 0x7A, 0x69, 0x70], {offset: 30}) ) { return { ext: 'epub', mime: 'application/epub+zip' }; } // Needs to be before `zip` check // Assumes signed `.xpi` from addons.mozilla.org if ( check([0x50, 0x4B, 0x3, 0x4]) && check([0x4D, 0x45, 0x54, 0x41, 0x2D, 0x49, 0x4E, 0x46, 0x2F, 0x6D, 0x6F, 0x7A, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x72, 0x73, 0x61], {offset: 30}) ) { return { ext: 'xpi', mime: 'application/x-xpinstall' }; } if ( check([0x50, 0x4B]) && (buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) && (buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8) ) { return { ext: 'zip', mime: 'application/zip' }; } if (check([0x75, 0x73, 0x74, 0x61, 0x72], {offset: 257})) { return { ext: 'tar', mime: 'application/x-tar' }; } if ( check([0x52, 0x61, 0x72, 0x21, 0x1A, 0x7]) && (buf[6] === 0x0 || buf[6] === 0x1) ) { return { ext: 'rar', mime: 'application/x-rar-compressed' }; } if (check([0x1F, 0x8B, 0x8])) { return { ext: 'gz', mime: 'application/gzip' }; } if (check([0x42, 0x5A, 0x68])) { return { ext: 'bz2', mime: 'application/x-bzip2' }; } if (check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) { return { ext: '7z', mime: 'application/x-7z-compressed' }; } if (check([0x78, 0x01])) { return { ext: 'dmg', mime: 'application/x-apple-diskimage' }; } if ( ( check([0x0, 0x0, 0x0]) && (buf[3] === 0x18 || buf[3] === 0x20) && check([0x66, 0x74, 0x79, 0x70], {offset: 4}) ) || check([0x33, 0x67, 0x70, 0x35]) || ( check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32]) && check([0x6D, 0x70, 0x34, 0x31, 0x6D, 0x70, 0x34, 0x32, 0x69, 0x73, 0x6F, 0x6D], {offset: 16}) ) || check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6F, 0x6D]) || check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32, 0x0, 0x0, 0x0, 0x0]) ) { return { ext: 'mp4', mime: 'video/mp4' }; } if (check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x56])) { return { ext: 'm4v', mime: 'video/x-m4v' }; } if (check([0x4D, 0x54, 0x68, 0x64])) { return { ext: 'mid', mime: 'audio/midi' }; } // https://github.com/threatstack/libmagic/blob/master/magic/Magdir/matroska if (check([0x1A, 0x45, 0xDF, 0xA3])) { const sliced = buf.subarray(4, 4 + 4096); const idPos = sliced.findIndex((el, i, arr) => arr[i] === 0x42 && arr[i + 1] === 0x82); if (idPos >= 0) { const docTypePos = idPos + 3; const findDocType = type => Array.from(type).every((c, i) => sliced[docTypePos + i] === c.charCodeAt(0)); if (findDocType('matroska')) { return { ext: 'mkv', mime: 'video/x-matroska' }; } if (findDocType('webm')) { return { ext: 'webm', mime: 'video/webm' }; } } } if (check([0x0, 0x0, 0x0, 0x14, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20]) || check([0x66, 0x72, 0x65, 0x65], {offset: 4}) || check([0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20], {offset: 4}) || check([0x6D, 0x64, 0x61, 0x74], {offset: 4}) || // MJPEG check([0x77, 0x69, 0x64, 0x65], {offset: 4})) { return { ext: 'mov', mime: 'video/quicktime' }; } if ( check([0x52, 0x49, 0x46, 0x46]) && check([0x41, 0x56, 0x49], {offset: 8}) ) { return { ext: 'avi', mime: 'video/x-msvideo' }; } if (check([0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9])) { return { ext: 'wmv', mime: 'video/x-ms-wmv' }; } if (check([0x0, 0x0, 0x1, 0xBA])) { return { ext: 'mpg', mime: 'video/mpeg' }; } if ( check([0x49, 0x44, 0x33]) || check([0xFF, 0xFB]) ) { return { ext: 'mp3', mime: 'audio/mpeg' }; } if ( check([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41], {offset: 4}) || check([0x4D, 0x34, 0x41, 0x20]) ) { return { ext: 'm4a', mime: 'audio/m4a' }; } // Needs to be before `ogg` check if (check([0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64], {offset: 28})) { return { ext: 'opus', mime: 'audio/opus' }; } if (check([0x4F, 0x67, 0x67, 0x53])) { return { ext: 'ogg', mime: 'audio/ogg' }; } if (check([0x66, 0x4C, 0x61, 0x43])) { return { ext: 'flac', mime: 'audio/x-flac' }; } if ( check([0x52, 0x49, 0x46, 0x46]) && check([0x57, 0x41, 0x56, 0x45], {offset: 8}) ) { return { ext: 'wav', mime: 'audio/x-wav' }; } if (check([0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A])) { return { ext: 'amr', mime: 'audio/amr' }; } if (check([0x25, 0x50, 0x44, 0x46])) { return { ext: 'pdf', mime: 'application/pdf' }; } if (check([0x4D, 0x5A])) { return { ext: 'exe', mime: 'application/x-msdownload' }; } if ( (buf[0] === 0x43 || buf[0] === 0x46) && check([0x57, 0x53], {offset: 1}) ) { return { ext: 'swf', mime: 'application/x-shockwave-flash' }; } if (check([0x7B, 0x5C, 0x72, 0x74, 0x66])) { return { ext: 'rtf', mime: 'application/rtf' }; } if (check([0x00, 0x61, 0x73, 0x6D])) { return { ext: 'wasm', mime: 'application/wasm' }; } if ( check([0x77, 0x4F, 0x46, 0x46]) && ( check([0x00, 0x01, 0x00, 0x00], {offset: 4}) || check([0x4F, 0x54, 0x54, 0x4F], {offset: 4}) ) ) { return { ext: 'woff', mime: 'application/font-woff' }; } if ( check([0x77, 0x4F, 0x46, 0x32]) && ( check([0x00, 0x01, 0x00, 0x00], {offset: 4}) || check([0x4F, 0x54, 0x54, 0x4F], {offset: 4}) ) ) { return { ext: 'woff2', mime: 'application/font-woff' }; } if ( check([0x4C, 0x50], {offset: 34}) && ( check([0x00, 0x00, 0x01], {offset: 8}) || check([0x01, 0x00, 0x02], {offset: 8}) || check([0x02, 0x00, 0x02], {offset: 8}) ) ) { return { ext: 'eot', mime: 'application/octet-stream' }; } if (check([0x00, 0x01, 0x00, 0x00, 0x00])) { return { ext: 'ttf', mime: 'application/font-sfnt' }; } if (check([0x4F, 0x54, 0x54, 0x4F, 0x00])) { return { ext: 'otf', mime: 'application/font-sfnt' }; } if (check([0x00, 0x00, 0x01, 0x00])) { return { ext: 'ico', mime: 'image/x-icon' }; } if (check([0x46, 0x4C, 0x56, 0x01])) { return { ext: 'flv', mime: 'video/x-flv' }; } if (check([0x25, 0x21])) { return { ext: 'ps', mime: 'application/postscript' }; } if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) { return { ext: 'xz', mime: 'application/x-xz' }; } if (check([0x53, 0x51, 0x4C, 0x69])) { return { ext: 'sqlite', mime: 'application/x-sqlite3' }; } if (check([0x4E, 0x45, 0x53, 0x1A])) { return { ext: 'nes', mime: 'application/x-nintendo-nes-rom' }; } if (check([0x43, 0x72, 0x32, 0x34])) { return { ext: 'crx', mime: 'application/x-google-chrome-extension' }; } if ( check([0x4D, 0x53, 0x43, 0x46]) || check([0x49, 0x53, 0x63, 0x28]) ) { return { ext: 'cab', mime: 'application/vnd.ms-cab-compressed' }; } // Needs to be before `ar` check if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E, 0x0A, 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79])) { return { ext: 'deb', mime: 'application/x-deb' }; } if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E])) { return { ext: 'ar', mime: 'application/x-unix-archive' }; } if (check([0xED, 0xAB, 0xEE, 0xDB])) { return { ext: 'rpm', mime: 'application/x-rpm' }; } if ( check([0x1F, 0xA0]) || check([0x1F, 0x9D]) ) { return { ext: 'Z', mime: 'application/x-compress' }; } if (check([0x4C, 0x5A, 0x49, 0x50])) { return { ext: 'lz', mime: 'application/x-lzip' }; } if (check([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) { return { ext: 'msi', mime: 'application/x-msi' }; } if (check([0x06, 0x0E, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x02])) { return { ext: 'mxf', mime: 'application/mxf' }; } if (check([0x42, 0x4C, 0x45, 0x4E, 0x44, 0x45, 0x52])) { return { ext: 'blend', mime: 'application/x-blender' }; } return null; }; /***/ }), /***/ 31909: /***/ ((module) => { function allocUnsafe (size) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be a number') } if (size < 0) { throw new RangeError('"size" argument must not be negative') } if (Buffer.allocUnsafe) { return Buffer.allocUnsafe(size) } else { return new Buffer(size) } } module.exports = allocUnsafe /***/ }), /***/ 42822: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { var bufferFill = __webpack_require__(7676) var allocUnsafe = __webpack_require__(31909) module.exports = function alloc (size, fill, encoding) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be a number') } if (size < 0) { throw new RangeError('"size" argument must not be negative') } if (Buffer.alloc) { return Buffer.alloc(size, fill, encoding) } var buffer = allocUnsafe(size) if (size === 0) { return buffer } if (fill === undefined) { return bufferFill(buffer, 0) } if (typeof encoding !== 'string') { encoding = undefined } return bufferFill(buffer, fill, encoding) } /***/ }), /***/ 82779: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { var Buffer = (__webpack_require__(14300).Buffer); var CRC_TABLE = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d ]; if (typeof Int32Array !== 'undefined') { CRC_TABLE = new Int32Array(CRC_TABLE); } function ensureBuffer(input) { if (Buffer.isBuffer(input)) { return input; } var hasNewBufferAPI = typeof Buffer.alloc === "function" && typeof Buffer.from === "function"; if (typeof input === "number") { return hasNewBufferAPI ? Buffer.alloc(input) : new Buffer(input); } else if (typeof input === "string") { return hasNewBufferAPI ? Buffer.from(input) : new Buffer(input); } else { throw new Error("input must be buffer, number, or string, received " + typeof input); } } function bufferizeInt(num) { var tmp = ensureBuffer(4); tmp.writeInt32BE(num, 0); return tmp; } function _crc32(buf, previous) { buf = ensureBuffer(buf); if (Buffer.isBuffer(previous)) { previous = previous.readUInt32BE(0); } var crc = ~~previous ^ -1; for (var n = 0; n < buf.length; n++) { crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8); } return (crc ^ -1); } function crc32() { return bufferizeInt(_crc32.apply(null, arguments)); } crc32.signed = function () { return _crc32.apply(null, arguments); }; crc32.unsigned = function () { return _crc32.apply(null, arguments) >>> 0; }; module.exports = crc32; /***/ }), /***/ 7676: /***/ ((module) => { /* Node.js 6.4.0 and up has full support */ var hasFullSupport = (function () { try { if (!Buffer.isEncoding('latin1')) { return false } var buf = Buffer.alloc ? Buffer.alloc(4) : new Buffer(4) buf.fill('ab', 'ucs2') return (buf.toString('hex') === '61006200') } catch (_) { return false } }()) function isSingleByte (val) { return (val.length === 1 && val.charCodeAt(0) < 256) } function fillWithNumber (buffer, val, start, end) { if (start < 0 || end > buffer.length) { throw new RangeError('Out of range index') } start = start >>> 0 end = end === undefined ? buffer.length : end >>> 0 if (end > start) { buffer.fill(val, start, end) } return buffer } function fillWithBuffer (buffer, val, start, end) { if (start < 0 || end > buffer.length) { throw new RangeError('Out of range index') } if (end <= start) { return buffer } start = start >>> 0 end = end === undefined ? buffer.length : end >>> 0 var pos = start var len = val.length while (pos <= (end - len)) { val.copy(buffer, pos) pos += len } if (pos !== end) { val.copy(buffer, pos, 0, end - pos) } return buffer } function fill (buffer, val, start, end, encoding) { if (hasFullSupport) { return buffer.fill(val, start, end, encoding) } if (typeof val === 'number') { return fillWithNumber(buffer, val, start, end) } if (typeof val === 'string') { if (typeof start === 'string') { encoding = start start = 0 end = buffer.length } else if (typeof end === 'string') { encoding = end end = buffer.length } if (encoding !== undefined && typeof encoding !== 'string') { throw new TypeError('encoding must be a string') } if (encoding === 'latin1') { encoding = 'binary' } if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { throw new TypeError('Unknown encoding: ' + encoding) } if (val === '') { return fillWithNumber(buffer, 0, start, end) } if (isSingleByte(val)) { return fillWithNumber(buffer, val.charCodeAt(0), start, end) } val = new Buffer(val, encoding) } if (Buffer.isBuffer(val)) { return fillWithBuffer(buffer, val, start, end) } // Other values (e.g. undefined, boolean, object) results in zero-fill return fillWithNumber(buffer, 0, start, end) } module.exports = fill /***/ }), /***/ 22818: /***/ ((module) => { "use strict"; // rfc7231 6.1 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var statusCodeCacheableByDefault = [200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501]; // This implementation does not understand partial responses (206) var understoodStatuses = [200, 203, 204, 300, 301, 302, 303, 307, 308, 404, 405, 410, 414, 501]; var hopByHopHeaders = { 'connection': true, 'keep-alive': true, 'proxy-authenticate': true, 'proxy-authorization': true, 'te': true, 'trailer': true, 'transfer-encoding': true, 'upgrade': true }; var excludedFromRevalidationUpdate = { // Since the old body is reused, it doesn't make sense to change properties of the body 'content-length': true, 'content-encoding': true, 'transfer-encoding': true, 'content-range': true }; function parseCacheControl(header) { var cc = {}; if (!header) return cc; // TODO: When there is more than one value present for a given directive (e.g., two Expires header fields, multiple Cache-Control: max-age directives), // the directive's value is considered invalid. Caches are encouraged to consider responses that have invalid freshness information to be stale var parts = header.trim().split(/\s*,\s*/); // TODO: lame parsing for (var _iterator = parts, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { var _ref; if (_isArray) { if (_i >= _iterator.length) break; _ref = _iterator[_i++]; } else { _i = _iterator.next(); if (_i.done) break; _ref = _i.value; } var part = _ref; var _part$split = part.split(/\s*=\s*/, 2), k = _part$split[0], v = _part$split[1]; cc[k] = v === undefined ? true : v.replace(/^"|"$/g, ''); // TODO: lame unquoting } return cc; } function formatCacheControl(cc) { var parts = []; for (var k in cc) { var v = cc[k]; parts.push(v === true ? k : k + '=' + v); } if (!parts.length) { return undefined; } return parts.join(', '); } module.exports = function () { function CachePolicy(req, res) { var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, shared = _ref2.shared, cacheHeuristic = _ref2.cacheHeuristic, immutableMinTimeToLive = _ref2.immutableMinTimeToLive, ignoreCargoCult = _ref2.ignoreCargoCult, _fromObject = _ref2._fromObject; _classCallCheck(this, CachePolicy); if (_fromObject) { this._fromObject(_fromObject); return; } if (!res || !res.headers) { throw Error("Response headers missing"); } this._assertRequestHasHeaders(req); this._responseTime = this.now(); this._isShared = shared !== false; this._cacheHeuristic = undefined !== cacheHeuristic ? cacheHeuristic : 0.1; // 10% matches IE this._immutableMinTtl = undefined !== immutableMinTimeToLive ? immutableMinTimeToLive : 24 * 3600 * 1000; this._status = 'status' in res ? res.status : 200; this._resHeaders = res.headers; this._rescc = parseCacheControl(res.headers['cache-control']); this._method = 'method' in req ? req.method : 'GET'; this._url = req.url; this._host = req.headers.host; this._noAuthorization = !req.headers.authorization; this._reqHeaders = res.headers.vary ? req.headers : null; // Don't keep all request headers if they won't be used this._reqcc = parseCacheControl(req.headers['cache-control']); // Assume that if someone uses legacy, non-standard uncecessary options they don't understand caching, // so there's no point stricly adhering to the blindly copy&pasted directives. if (ignoreCargoCult && "pre-check" in this._rescc && "post-check" in this._rescc) { delete this._rescc['pre-check']; delete this._rescc['post-check']; delete this._rescc['no-cache']; delete this._rescc['no-store']; delete this._rescc['must-revalidate']; this._resHeaders = Object.assign({}, this._resHeaders, { 'cache-control': formatCacheControl(this._rescc) }); delete this._resHeaders.expires; delete this._resHeaders.pragma; } // When the Cache-Control header field is not present in a request, caches MUST consider the no-cache request pragma-directive // as having the same effect as if "Cache-Control: no-cache" were present (see Section 5.2.1). if (!res.headers['cache-control'] && /no-cache/.test(res.headers.pragma)) { this._rescc['no-cache'] = true; } } CachePolicy.prototype.now = function now() { return Date.now(); }; CachePolicy.prototype.storable = function storable() { // The "no-store" request directive indicates that a cache MUST NOT store any part of either this request or any response to it. return !!(!this._reqcc['no-store'] && ( // A cache MUST NOT store a response to any request, unless: // The request method is understood by the cache and defined as being cacheable, and 'GET' === this._method || 'HEAD' === this._method || 'POST' === this._method && this._hasExplicitExpiration()) && // the response status code is understood by the cache, and understoodStatuses.indexOf(this._status) !== -1 && // the "no-store" cache directive does not appear in request or response header fields, and !this._rescc['no-store'] && ( // the "private" response directive does not appear in the response, if the cache is shared, and !this._isShared || !this._rescc.private) && ( // the Authorization header field does not appear in the request, if the cache is shared, !this._isShared || this._noAuthorization || this._allowsStoringAuthenticated()) && ( // the response either: // contains an Expires header field, or this._resHeaders.expires || // contains a max-age response directive, or // contains a s-maxage response directive and the cache is shared, or // contains a public response directive. this._rescc.public || this._rescc['max-age'] || this._rescc['s-maxage'] || // has a status code that is defined as cacheable by default statusCodeCacheableByDefault.indexOf(this._status) !== -1)); }; CachePolicy.prototype._hasExplicitExpiration = function _hasExplicitExpiration() { // 4.2.1 Calculating Freshness Lifetime return this._isShared && this._rescc['s-maxage'] || this._rescc['max-age'] || this._resHeaders.expires; }; CachePolicy.prototype._assertRequestHasHeaders = function _assertRequestHasHeaders(req) { if (!req || !req.headers) { throw Error("Request headers missing"); } }; CachePolicy.prototype.satisfiesWithoutRevalidation = function satisfiesWithoutRevalidation(req) { this._assertRequestHasHeaders(req); // When presented with a request, a cache MUST NOT reuse a stored response, unless: // the presented request does not contain the no-cache pragma (Section 5.4), nor the no-cache cache directive, // unless the stored response is successfully validated (Section 4.3), and var requestCC = parseCacheControl(req.headers['cache-control']); if (requestCC['no-cache'] || /no-cache/.test(req.headers.pragma)) { return false; } if (requestCC['max-age'] && this.age() > requestCC['max-age']) { return false; } if (requestCC['min-fresh'] && this.timeToLive() < 1000 * requestCC['min-fresh']) { return false; } // the stored response is either: // fresh, or allowed to be served stale if (this.stale()) { var allowsStale = requestCC['max-stale'] && !this._rescc['must-revalidate'] && (true === requestCC['max-stale'] || requestCC['max-stale'] > this.age() - this.maxAge()); if (!allowsStale) { return false; } } return this._requestMatches(req, false); }; CachePolicy.prototype._requestMatches = function _requestMatches(req, allowHeadMethod) { // The presented effective request URI and that of the stored response match, and return (!this._url || this._url === req.url) && this._host === req.headers.host && ( // the request method associated with the stored response allows it to be used for the presented request, and !req.method || this._method === req.method || allowHeadMethod && 'HEAD' === req.method) && // selecting header fields nominated by the stored response (if any) match those presented, and this._varyMatches(req); }; CachePolicy.prototype._allowsStoringAuthenticated = function _allowsStoringAuthenticated() { // following Cache-Control response directives (Section 5.2.2) have such an effect: must-revalidate, public, and s-maxage. return this._rescc['must-revalidate'] || this._rescc.public || this._rescc['s-maxage']; }; CachePolicy.prototype._varyMatches = function _varyMatches(req) { if (!this._resHeaders.vary) { return true; } // A Vary header field-value of "*" always fails to match if (this._resHeaders.vary === '*') { return false; } var fields = this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/); for (var _iterator2 = fields, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { var _ref3; if (_isArray2) { if (_i2 >= _iterator2.length) break; _ref3 = _iterator2[_i2++]; } else { _i2 = _iterator2.next(); if (_i2.done) break; _ref3 = _i2.value; } var name = _ref3; if (req.headers[name] !== this._reqHeaders[name]) return false; } return true; }; CachePolicy.prototype._copyWithoutHopByHopHeaders = function _copyWithoutHopByHopHeaders(inHeaders) { var headers = {}; for (var name in inHeaders) { if (hopByHopHeaders[name]) continue; headers[name] = inHeaders[name]; } // 9.1. Connection if (inHeaders.connection) { var tokens = inHeaders.connection.trim().split(/\s*,\s*/); for (var _iterator3 = tokens, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { var _ref4; if (_isArray3) { if (_i3 >= _iterator3.length) break; _ref4 = _iterator3[_i3++]; } else { _i3 = _iterator3.next(); if (_i3.done) break; _ref4 = _i3.value; } var _name = _ref4; delete headers[_name]; } } if (headers.warning) { var warnings = headers.warning.split(/,/).filter(function (warning) { return !/^\s*1[0-9][0-9]/.test(warning); }); if (!warnings.length) { delete headers.warning; } else { headers.warning = warnings.join(',').trim(); } } return headers; }; CachePolicy.prototype.responseHeaders = function responseHeaders() { var headers = this._copyWithoutHopByHopHeaders(this._resHeaders); var age = this.age(); // A cache SHOULD generate 113 warning if it heuristically chose a freshness // lifetime greater than 24 hours and the response's age is greater than 24 hours. if (age > 3600 * 24 && !this._hasExplicitExpiration() && this.maxAge() > 3600 * 24) { headers.warning = (headers.warning ? `${headers.warning}, ` : '') + '113 - "rfc7234 5.5.4"'; } headers.age = `${Math.round(age)}`; return headers; }; /** * Value of the Date response header or current time if Date was demed invalid * @return timestamp */ CachePolicy.prototype.date = function date() { var dateValue = Date.parse(this._resHeaders.date); var maxClockDrift = 8 * 3600 * 1000; if (Number.isNaN(dateValue) || dateValue < this._responseTime - maxClockDrift || dateValue > this._responseTime + maxClockDrift) { return this._responseTime; } return dateValue; }; /** * Value of the Age header, in seconds, updated for the current time. * May be fractional. * * @return Number */ CachePolicy.prototype.age = function age() { var age = Math.max(0, (this._responseTime - this.date()) / 1000); if (this._resHeaders.age) { var ageValue = this._ageValue(); if (ageValue > age) age = ageValue; } var residentTime = (this.now() - this._responseTime) / 1000; return age + residentTime; }; CachePolicy.prototype._ageValue = function _ageValue() { var ageValue = parseInt(this._resHeaders.age); return isFinite(ageValue) ? ageValue : 0; }; /** * Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`. * * For an up-to-date value, see `timeToLive()`. * * @return Number */ CachePolicy.prototype.maxAge = function maxAge() { if (!this.storable() || this._rescc['no-cache']) { return 0; } // Shared responses with cookies are cacheable according to the RFC, but IMHO it'd be unwise to do so by default // so this implementation requires explicit opt-in via public header if (this._isShared && this._resHeaders['set-cookie'] && !this._rescc.public && !this._rescc.immutable) { return 0; } if (this._resHeaders.vary === '*') { return 0; } if (this._isShared) { if (this._rescc['proxy-revalidate']) { return 0; } // if a response includes the s-maxage directive, a shared cache recipient MUST ignore the Expires field. if (this._rescc['s-maxage']) { return parseInt(this._rescc['s-maxage'], 10); } } // If a response includes a Cache-Control field with the max-age directive, a recipient MUST ignore the Expires field. if (this._rescc['max-age']) { return parseInt(this._rescc['max-age'], 10); } var defaultMinTtl = this._rescc.immutable ? this._immutableMinTtl : 0; var dateValue = this.date(); if (this._resHeaders.expires) { var expires = Date.parse(this._resHeaders.expires); // A cache recipient MUST interpret invalid date formats, especially the value "0", as representing a time in the past (i.e., "already expired"). if (Number.isNaN(expires) || expires < dateValue) { return 0; } return Math.max(defaultMinTtl, (expires - dateValue) / 1000); } if (this._resHeaders['last-modified']) { var lastModified = Date.parse(this._resHeaders['last-modified']); if (isFinite(lastModified) && dateValue > lastModified) { return Math.max(defaultMinTtl, (dateValue - lastModified) / 1000 * this._cacheHeuristic); } } return defaultMinTtl; }; CachePolicy.prototype.timeToLive = function timeToLive() { return Math.max(0, this.maxAge() - this.age()) * 1000; }; CachePolicy.prototype.stale = function stale() { return this.maxAge() <= this.age(); }; CachePolicy.fromObject = function fromObject(obj) { return new this(undefined, undefined, { _fromObject: obj }); }; CachePolicy.prototype._fromObject = function _fromObject(obj) { if (this._responseTime) throw Error("Reinitialized"); if (!obj || obj.v !== 1) throw Error("Invalid serialization"); this._responseTime = obj.t; this._isShared = obj.sh; this._cacheHeuristic = obj.ch; this._immutableMinTtl = obj.imm !== undefined ? obj.imm : 24 * 3600 * 1000; this._status = obj.st; this._resHeaders = obj.resh; this._rescc = obj.rescc; this._method = obj.m; this._url = obj.u; this._host = obj.h; this._noAuthorization = obj.a; this._reqHeaders = obj.reqh; this._reqcc = obj.reqcc; }; CachePolicy.prototype.toObject = function toObject() { return { v: 1, t: this._responseTime, sh: this._isShared, ch: this._cacheHeuristic, imm: this._immutableMinTtl, st: this._status, resh: this._resHeaders, rescc: this._rescc, m: this._method, u: this._url, h: this._host, a: this._noAuthorization, reqh: this._reqHeaders, reqcc: this._reqcc }; }; /** * Headers for sending to the origin server to revalidate stale response. * Allows server to return 304 to allow reuse of the previous response. * * Hop by hop headers are always stripped. * Revalidation headers may be added or removed, depending on request. */ CachePolicy.prototype.revalidationHeaders = function revalidationHeaders(incomingReq) { this._assertRequestHasHeaders(incomingReq); var headers = this._copyWithoutHopByHopHeaders(incomingReq.headers); // This implementation does not understand range requests delete headers['if-range']; if (!this._requestMatches(incomingReq, true) || !this.storable()) { // revalidation allowed via HEAD // not for the same resource, or wasn't allowed to be cached anyway delete headers['if-none-match']; delete headers['if-modified-since']; return headers; } /* MUST send that entity-tag in any cache validation request (using If-Match or If-None-Match) if an entity-tag has been provided by the origin server. */ if (this._resHeaders.etag) { headers['if-none-match'] = headers['if-none-match'] ? `${headers['if-none-match']}, ${this._resHeaders.etag}` : this._resHeaders.etag; } // Clients MAY issue simple (non-subrange) GET requests with either weak validators or strong validators. Clients MUST NOT use weak validators in other forms of request. var forbidsWeakValidators = headers['accept-ranges'] || headers['if-match'] || headers['if-unmodified-since'] || this._method && this._method != 'GET'; /* SHOULD send the Last-Modified value in non-subrange cache validation requests (using If-Modified-Since) if only a Last-Modified value has been provided by the origin server. Note: This implementation does not understand partial responses (206) */ if (forbidsWeakValidators) { delete headers['if-modified-since']; if (headers['if-none-match']) { var etags = headers['if-none-match'].split(/,/).filter(function (etag) { return !/^\s*W\//.test(etag); }); if (!etags.length) { delete headers['if-none-match']; } else { headers['if-none-match'] = etags.join(',').trim(); } } } else if (this._resHeaders['last-modified'] && !headers['if-modified-since']) { headers['if-modified-since'] = this._resHeaders['last-modified']; } return headers; }; /** * Creates new CachePolicy with information combined from the previews response, * and the new revalidation response. * * Returns {policy, modified} where modified is a boolean indicating * whether the response body has been modified, and old cached body can't be used. * * @return {Object} {policy: CachePolicy, modified: Boolean} */ CachePolicy.prototype.revalidatedPolicy = function revalidatedPolicy(request, response) { this._assertRequestHasHeaders(request); if (!response || !response.headers) { throw Error("Response headers missing"); } // These aren't going to be supported exactly, since one CachePolicy object // doesn't know about all the other cached objects. var matches = false; if (response.status !== undefined && response.status != 304) { matches = false; } else if (response.headers.etag && !/^\s*W\//.test(response.headers.etag)) { // "All of the stored responses with the same strong validator are selected. // If none of the stored responses contain the same strong validator, // then the cache MUST NOT use the new response to update any stored responses." matches = this._resHeaders.etag && this._resHeaders.etag.replace