From 332585364d1ec697a666f0b1ed638374767db22f Mon Sep 17 00:00:00 2001 From: Nathan C Date: Sun, 6 Sep 2020 23:20:22 -0400 Subject: [PATCH 01/11] 2.2.1 Release (CRITICAL) - Add: Simple HTTP page to fetch information (for support) - Updated to work with new endpoint system - Add: nag notification for plugins - Add: version header to HTTP requests - Fix: POST request failing with non-English characters - Fix: Updated livemap.js file --- sonoran_livemap/dist/livemap.js | 1718 ++++++++++++++--------------- sonorancad/core/client.lua | 12 + sonorancad/core/commands.lua | 4 +- sonorancad/core/http.js | 1 + sonorancad/core/plugin_loader.lua | 14 +- sonorancad/core/server.lua | 12 +- sonorancad/fxmanifest.lua | 7 +- sonorancad/plugins/livemap | 2 +- sonorancad/plugins/locations | 2 +- sonorancad/version.json | 2 +- 10 files changed, 900 insertions(+), 874 deletions(-) diff --git a/sonoran_livemap/dist/livemap.js b/sonoran_livemap/dist/livemap.js index a46bd77..2917fae 100644 --- a/sonoran_livemap/dist/livemap.js +++ b/sonoran_livemap/dist/livemap.js @@ -233,11 +233,11 @@ module.exports = { "use strict"; /*! - * http-errors - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2016 Douglas Christopher Wilson - * MIT Licensed - */ + * http-errors + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2016 Douglas Christopher Wilson + * MIT Licensed + */ @@ -506,11 +506,11 @@ function populateConstructorExports (exports, codes, HttpError) { "use strict"; /*! - * statuses - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2016 Douglas Christopher Wilson - * MIT Licensed - */ + * statuses + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2016 Douglas Christopher Wilson + * MIT Licensed + */ @@ -1300,11 +1300,11 @@ module.exports = __webpack_require__(159) "use strict"; /*! - * mime-types - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ + * mime-types + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ @@ -1495,11 +1495,11 @@ function populateMaps (extensions, types) { "use strict"; /*! - * type-is - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ + * type-is + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ @@ -1784,11 +1784,11 @@ module.exports = function(obj, keys){ "use strict"; /*! - * raw-body - * Copyright(c) 2013-2014 Jonathan Ong - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ + * raw-body + * Copyright(c) 2013-2014 Jonathan Ong + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ @@ -2640,128 +2640,128 @@ const env = process.env; let forceColor; if (hasFlag('no-color') || - hasFlag('no-colors') || - hasFlag('color=false')) { - forceColor = false; + hasFlag('no-colors') || + hasFlag('color=false')) { + forceColor = false; } else if (hasFlag('color') || - hasFlag('colors') || - hasFlag('color=true') || - hasFlag('color=always')) { - forceColor = true; + hasFlag('colors') || + hasFlag('color=true') || + hasFlag('color=always')) { + forceColor = true; } if ('FORCE_COLOR' in env) { - forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0; + forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0; } function translateLevel(level) { - if (level === 0) { - return false; - } + if (level === 0) { + return false; + } - return { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; } function supportsColor(stream) { - if (forceColor === false) { - return 0; - } - - if (hasFlag('color=16m') || - hasFlag('color=full') || - hasFlag('color=truecolor')) { - return 3; - } - - if (hasFlag('color=256')) { - return 2; - } - - if (stream && !stream.isTTY && forceColor !== true) { - return 0; - } - - const min = forceColor ? 1 : 0; - - if (process.platform === 'win32') { - // Node.js 7.5.0 is the first version of Node.js to include a patch to - // libuv that enables 256 color output on Windows. Anything earlier and it - // won't work. However, here we target Node.js 8 at minimum as it is an LTS - // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows - // release that supports 256 colors. Windows 10 build 14931 is the first release - // that supports 16m/TrueColor. - const osRelease = os.release().split('.'); - if ( - Number(process.versions.node.split('.')[0]) >= 8 && - Number(osRelease[0]) >= 10 && - Number(osRelease[2]) >= 10586 - ) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } - - return 1; - } - - if ('CI' in env) { - if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') { - return 1; - } - - return min; - } - - if ('TEAMCITY_VERSION' in env) { - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; - } - - if (env.COLORTERM === 'truecolor') { - return 3; - } - - if ('TERM_PROGRAM' in env) { - const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); - - switch (env.TERM_PROGRAM) { - case 'iTerm.app': - return version >= 3 ? 3 : 2; - case 'Apple_Terminal': - return 2; - // No default - } - } - - if (/-256(color)?$/i.test(env.TERM)) { - return 2; - } - - if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { - return 1; - } - - if ('COLORTERM' in env) { - return 1; - } - - if (env.TERM === 'dumb') { - return min; - } - - return min; + if (forceColor === false) { + return 0; + } + + if (hasFlag('color=16m') || + hasFlag('color=full') || + hasFlag('color=truecolor')) { + return 3; + } + + if (hasFlag('color=256')) { + return 2; + } + + if (stream && !stream.isTTY && forceColor !== true) { + return 0; + } + + const min = forceColor ? 1 : 0; + + if (process.platform === 'win32') { + // Node.js 7.5.0 is the first version of Node.js to include a patch to + // libuv that enables 256 color output on Windows. Anything earlier and it + // won't work. However, here we target Node.js 8 at minimum as it is an LTS + // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows + // release that supports 256 colors. Windows 10 build 14931 is the first release + // that supports 16m/TrueColor. + const osRelease = os.release().split('.'); + if ( + Number(process.versions.node.split('.')[0]) >= 8 && + Number(osRelease[0]) >= 10 && + Number(osRelease[2]) >= 10586 + ) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } + + return 1; + } + + if ('CI' in env) { + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') { + return 1; + } + + return min; + } + + if ('TEAMCITY_VERSION' in env) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; + } + + if (env.COLORTERM === 'truecolor') { + return 3; + } + + if ('TERM_PROGRAM' in env) { + const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); + + switch (env.TERM_PROGRAM) { + case 'iTerm.app': + return version >= 3 ? 3 : 2; + case 'Apple_Terminal': + return 2; + // No default + } + } + + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } + + if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } + + if ('COLORTERM' in env) { + return 1; + } + + if (env.TERM === 'dumb') { + return min; + } + + return min; } function getSupportLevel(stream) { - const level = supportsColor(stream); - return translateLevel(level); + const level = supportsColor(stream); + return translateLevel(level); } module.exports = { - supportsColor: getSupportLevel, - stdout: getSupportLevel(process.stdout), - stderr: getSupportLevel(process.stderr) + supportsColor: getSupportLevel, + stdout: getSupportLevel(process.stdout), + stderr: getSupportLevel(process.stderr) }; @@ -2777,11 +2777,11 @@ module.exports = require("os"); "use strict"; /*! - * on-finished - * Copyright(c) 2013 Jonathan Ong - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ + * on-finished + * Copyright(c) 2013 Jonathan Ong + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ @@ -2979,10 +2979,10 @@ function patchAssignSocket(res, callback) { /***/ (function(module, exports, __webpack_require__) { /*! - * depd - * Copyright(c) 2014-2017 Douglas Christopher Wilson - * MIT Licensed - */ + * depd + * Copyright(c) 2014-2017 Douglas Christopher Wilson + * MIT Licensed + */ /** * Module dependencies. @@ -3386,7 +3386,7 @@ function wrapfunction (fn, message) { site.name = fn.name - // eslint-disable-next-line no-eval + // eslint-disable-next-line no-eval var deprecatedfn = eval('(function (' + args + ') {\n' + '"use strict"\n' + 'log.call(deprecate, message, site)\n' + @@ -3508,10 +3508,10 @@ function DeprecationError (namespace, message, stack) { "use strict"; /*! - * depd - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ + * depd + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ @@ -4175,520 +4175,520 @@ module.exports = setup; /* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.0 by @mathias */ ;(function(root) { - /** Detect free variables */ - var freeExports = true && exports && - !exports.nodeType && exports; - var freeModule = true && module && - !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; - if ( - freeGlobal.global === freeGlobal || - freeGlobal.window === freeGlobal || - freeGlobal.self === freeGlobal - ) { - root = freeGlobal; - } - - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, - - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' - - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators - - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, - - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, - - /** Temporary variable */ - key; - - /*--------------------------------------------------------------------------*/ - - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw new RangeError(errors[type]); - } - - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - var result = []; - while (length--) { - result[length] = fn(array[length]); - } - return result; - } - - /** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; - } - - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } - - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } - - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } - - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } - - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } - - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - /** Cached calculation results */ - baseMinusT; - - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. - - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } - - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } - - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. - - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { - - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { - - if (index >= inputLength) { - error('invalid-input'); - } - - digit = basicToDigit(input.charCodeAt(index++)); - - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } - - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - - if (digit < t) { - break; - } - - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } - - w *= baseMinusT; - - } - - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); - - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } - - n += floor(i / out); - i %= out; - - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); - - } - - return ucs2encode(output); - } - - /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; - - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); - - // Cache the length - inputLength = input.length; - - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; - - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } - - handledCPCount = basicLength = output.length; - - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. - - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } - - // Main encoding loop: - while (handledCPCount < inputLength) { - - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } - - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } - - delta += (m - n) * handledCPCountPlusOne; - n = m; - - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } - - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } - - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } - - ++delta; - ++n; - - } - return output.join(''); - } - - /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(input) { - return mapDomain(input, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } - - /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ - function toASCII(input) { - return mapDomain(input, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } - - /*--------------------------------------------------------------------------*/ - - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.3.2', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode - }; - - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - true - ) { - !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { - return punycode; - }).call(exports, __webpack_require__, exports, module), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} + /** Detect free variables */ + var freeExports = true && exports && + !exports.nodeType && exports; + var freeModule = true && module && + !module.nodeType && module; + var freeGlobal = typeof global == 'object' && global; + if ( + freeGlobal.global === freeGlobal || + freeGlobal.window === freeGlobal || + freeGlobal.self === freeGlobal + ) { + root = freeGlobal; + } + + /** + * The `punycode` object. + * @name punycode + * @type Object + */ + var punycode, + + /** Highest positive signed 32-bit float value */ + maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 + + /** Bootstring parameters */ + base = 36, + tMin = 1, + tMax = 26, + skew = 38, + damp = 700, + initialBias = 72, + initialN = 128, // 0x80 + delimiter = '-', // '\x2D' + + /** Regular expressions */ + regexPunycode = /^xn--/, + regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars + regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators + + /** Error messages */ + errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }, + + /** Convenience shortcuts */ + baseMinusTMin = base - tMin, + floor = Math.floor, + stringFromCharCode = String.fromCharCode, + + /** Temporary variable */ + key; + + /*--------------------------------------------------------------------------*/ + + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error(type) { + throw new RangeError(errors[type]); + } + + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var length = array.length; + var result = []; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } + + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } + + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = [], + counter = 0, + length = string.length, + value, + extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } + + /** + * Creates a string based on an array of numeric code points. + * @see `punycode.ucs2.decode` + * @memberOf punycode.ucs2 + * @name encode + * @param {Array} codePoints The array of numeric code points. + * @returns {String} The new Unicode string (UCS-2). + */ + function ucs2encode(array) { + return map(array, function(value) { + var output = ''; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; + } + output += stringFromCharCode(value); + return output; + }).join(''); + } + + /** + * Converts a basic code point into a digit/integer. + * @see `digitToBasic()` + * @private + * @param {Number} codePoint The basic numeric code point value. + * @returns {Number} The numeric value of a basic code point (for use in + * representing integers) in the range `0` to `base - 1`, or `base` if + * the code point does not represent a value. + */ + function basicToDigit(codePoint) { + if (codePoint - 48 < 10) { + return codePoint - 22; + } + if (codePoint - 65 < 26) { + return codePoint - 65; + } + if (codePoint - 97 < 26) { + return codePoint - 97; + } + return base; + } + + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + } + + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + } + + /** + * Converts a Punycode string of ASCII-only symbols to a string of Unicode + * symbols. + * @memberOf punycode + * @param {String} input The Punycode string of ASCII-only symbols. + * @returns {String} The resulting string of Unicode symbols. + */ + function decode(input) { + // Don't use UCS-2 + var output = [], + inputLength = input.length, + out, + i = 0, + n = initialN, + bias = initialBias, + basic, + j, + index, + oldi, + w, + k, + digit, + t, + /** Cached calculation results */ + baseMinusT; + + // Handle the basic code points: let `basic` be the number of input code + // points before the last delimiter, or `0` if there is none, then copy + // the first basic code points to the output. + + basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } + + for (j = 0; j < basic; ++j) { + // if it's not a basic code point + if (input.charCodeAt(j) >= 0x80) { + error('not-basic'); + } + output.push(input.charCodeAt(j)); + } + + // Main decoding loop: start just after the last delimiter if any basic code + // points were copied; start at the beginning otherwise. + + for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { + + // `index` is the index of the next character to be consumed. + // Decode a generalized variable-length integer into `delta`, + // which gets added to `i`. The overflow checking is easier + // if we increase `i` as we go, then subtract off its starting + // value at the end to obtain `delta`. + for (oldi = i, w = 1, k = base; /* no condition */; k += base) { + + if (index >= inputLength) { + error('invalid-input'); + } + + digit = basicToDigit(input.charCodeAt(index++)); + + if (digit >= base || digit > floor((maxInt - i) / w)) { + error('overflow'); + } + + i += digit * w; + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + + if (digit < t) { + break; + } + + baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error('overflow'); + } + + w *= baseMinusT; + + } + + out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); + + // `i` was supposed to wrap around from `out` to `0`, + // incrementing `n` each time, so we'll fix that now: + if (floor(i / out) > maxInt - n) { + error('overflow'); + } + + n += floor(i / out); + i %= out; + + // Insert `n` at position `i` of the output + output.splice(i++, 0, n); + + } + + return ucs2encode(output); + } + + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + function encode(input) { + var n, + delta, + handledCPCount, + basicLength, + bias, + j, + m, + q, + k, + t, + currentValue, + output = [], + /** `inputLength` will hold the number of code points in `input`. */ + inputLength, + /** Cached calculation results */ + handledCPCountPlusOne, + baseMinusT, + qMinusT; + + // Convert the input in UCS-2 to Unicode + input = ucs2decode(input); + + // Cache the length + inputLength = input.length; + + // Initialize the state + n = initialN; + delta = 0; + bias = initialBias; + + // Handle the basic code points + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue < 0x80) { + output.push(stringFromCharCode(currentValue)); + } + } + + handledCPCount = basicLength = output.length; + + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. + + // Finish the basic string - if it is not empty - with a delimiter + if (basicLength) { + output.push(delimiter); + } + + // Main encoding loop: + while (handledCPCount < inputLength) { + + // All non-basic code points < n have been handled already. Find the next + // larger one: + for (m = maxInt, j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } + + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow + handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error('overflow'); + } + + delta += (m - n) * handledCPCountPlusOne; + n = m; + + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + + if (currentValue < n && ++delta > maxInt) { + error('overflow'); + } + + if (currentValue == n) { + // Represent delta as a generalized variable-length integer + for (q = delta, k = base; /* no condition */; k += base) { + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + if (q < t) { + break; + } + qMinusT = q - t; + baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor(qMinusT / baseMinusT); + } + + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } + + ++delta; + ++n; + + } + return output.join(''); + } + + /** + * Converts a Punycode string representing a domain name or an email address + * to Unicode. Only the Punycoded parts of the input will be converted, i.e. + * it doesn't matter if you call it on a string that has already been + * converted to Unicode. + * @memberOf punycode + * @param {String} input The Punycoded domain name or email address to + * convert to Unicode. + * @returns {String} The Unicode representation of the given Punycode + * string. + */ + function toUnicode(input) { + return mapDomain(input, function(string) { + return regexPunycode.test(string) + ? decode(string.slice(4).toLowerCase()) + : string; + }); + } + + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + function toASCII(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) + ? 'xn--' + encode(string) + : string; + }); + } + + /*--------------------------------------------------------------------------*/ + + /** Define the public API */ + punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + 'version': '1.3.2', + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + 'ucs2': { + 'decode': ucs2decode, + 'encode': ucs2encode + }, + 'decode': decode, + 'encode': encode, + 'toASCII': toASCII, + 'toUnicode': toUnicode + }; + + /** Expose `punycode` */ + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + true + ) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { + return punycode; + }).call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else {} }(this)); @@ -4699,18 +4699,18 @@ module.exports = setup; /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! - * URI.js - Mutating URLs - * IPv6 Support - * - * Version: 1.19.2 - * - * Author: Rodney Rehm - * Web: http://medialize.github.io/URI.js/ - * - * Licensed under - * MIT License http://www.opensource.org/licenses/mit-license - * - */ + * URI.js - Mutating URLs + * IPv6 Support + * + * Version: 1.19.2 + * + * Author: Rodney Rehm + * Web: http://medialize.github.io/URI.js/ + * + * Licensed under + * MIT License http://www.opensource.org/licenses/mit-license + * + */ (function (root, factory) { 'use strict'; @@ -4721,10 +4721,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! } else if (true) { // AMD. Register as an anonymous module. !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), - __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? - (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : - __WEBPACK_AMD_DEFINE_FACTORY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : + __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else {} }(this, function (root) { 'use strict'; @@ -4891,18 +4891,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! - * URI.js - Mutating URLs - * Second Level Domain (SLD) Support - * - * Version: 1.19.2 - * - * Author: Rodney Rehm - * Web: http://medialize.github.io/URI.js/ - * - * Licensed under - * MIT License http://www.opensource.org/licenses/mit-license - * - */ + * URI.js - Mutating URLs + * Second Level Domain (SLD) Support + * + * Version: 1.19.2 + * + * Author: Rodney Rehm + * Web: http://medialize.github.io/URI.js/ + * + * Licensed under + * MIT License http://www.opensource.org/licenses/mit-license + * + */ (function (root, factory) { 'use strict'; @@ -4913,10 +4913,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! } else if (true) { // AMD. Register as an anonymous module. !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), - __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? - (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : - __WEBPACK_AMD_DEFINE_FACTORY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : + __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else {} }(this, function (root) { 'use strict'; @@ -7599,29 +7599,29 @@ var isFnRegex = /^\s*(?:function)?\*/; var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; var getProto = Object.getPrototypeOf; var getGeneratorFunc = function () { // eslint-disable-line consistent-return - if (!hasToStringTag) { - return false; - } - try { - return Function('return function*() {}')(); - } catch (e) { - } + if (!hasToStringTag) { + return false; + } + try { + return Function('return function*() {}')(); + } catch (e) { + } }; var generatorFunc = getGeneratorFunc(); var GeneratorFunction = generatorFunc ? getProto(generatorFunc) : {}; module.exports = function isGeneratorFunction(fn) { - if (typeof fn !== 'function') { - return false; - } - if (isFnRegex.test(fnToStr.call(fn))) { - return true; - } - if (!hasToStringTag) { - var str = toStr.call(fn); - return str === '[object GeneratorFunction]'; - } - return getProto(fn) === GeneratorFunction; + if (typeof fn !== 'function') { + return false; + } + if (isFnRegex.test(fnToStr.call(fn))) { + return true; + } + if (!hasToStringTag) { + var str = toStr.call(fn); + return str === '[object GeneratorFunction]'; + } + return getProto(fn) === GeneratorFunction; }; @@ -7658,7 +7658,7 @@ exports.save = save; exports.load = load; exports.useColors = useColors; exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage + && 'undefined' != typeof chrome.storage ? chrome.storage.local : localstorage(); @@ -8199,11 +8199,11 @@ exports.enable(load()); "use strict"; module.exports = (flag, argv) => { - argv = argv || process.argv; - const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); - const pos = argv.indexOf(prefix + flag); - const terminatorPos = argv.indexOf('--'); - return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); + argv = argv || process.argv; + const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); + const pos = argv.indexOf(prefix + flag); + const terminatorPos = argv.indexOf('--'); + return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); }; @@ -8213,10 +8213,10 @@ module.exports = (flag, argv) => { "use strict"; /*! - * ee-first - * Copyright(c) 2014 Jonathan Ong - * MIT Licensed - */ + * ee-first + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ @@ -8904,10 +8904,10 @@ if (util.inspect.custom) { "use strict"; /*! - * content-disposition - * Copyright(c) 2014-2017 Douglas Christopher Wilson - * MIT Licensed - */ + * content-disposition + * Copyright(c) 2014-2017 Douglas Christopher Wilson + * MIT Licensed + */ @@ -9458,10 +9458,10 @@ module.exports = type => { /***/ (function(module, exports, __webpack_require__) { /*! - * mime-db - * Copyright(c) 2014 Jonathan Ong - * MIT Licensed - */ + * mime-db + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ /** * Module exports. @@ -9595,12 +9595,12 @@ module.exports = LRU; "use strict"; /*! - * escape-html - * Copyright(c) 2012-2013 TJ Holowaychuk - * Copyright(c) 2015 Andreas Lubbe - * Copyright(c) 2015 Tiancheng "Timothy" Gu - * MIT Licensed - */ + * escape-html + * Copyright(c) 2012-2013 TJ Holowaychuk + * Copyright(c) 2015 Andreas Lubbe + * Copyright(c) 2015 Tiancheng "Timothy" Gu + * MIT Licensed + */ @@ -9679,10 +9679,10 @@ function escapeHtml(string) { /***/ (function(module, exports) { /*! - * media-typer - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ + * media-typer + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ /** * RegExp to match *( ";" parameter ) in RFC 2616 sec 3.7 @@ -9962,10 +9962,10 @@ module.exports = JSON.parse("{\"100\":\"Continue\",\"101\":\"Switching Protocols "use strict"; /*! - * destroy - * Copyright(c) 2014 Jonathan Ong - * MIT Licensed - */ + * destroy + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ @@ -10050,10 +10050,10 @@ module.exports = require("assert"); "use strict"; /*! - * vary - * Copyright(c) 2014-2017 Douglas Christopher Wilson - * MIT Licensed - */ + * vary + * Copyright(c) 2014-2017 Douglas Christopher Wilson + * MIT Licensed + */ @@ -10206,10 +10206,10 @@ function vary (res, field) { "use strict"; /*! - * encodeurl - * Copyright(c) 2016 Douglas Christopher Wilson - * MIT Licensed - */ + * encodeurl + * Copyright(c) 2016 Douglas Christopher Wilson + * MIT Licensed + */ @@ -10580,10 +10580,10 @@ delegate(proto, 'request') "use strict"; /*! - * depd - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ + * depd + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ @@ -10690,10 +10690,10 @@ function getConstructorName (obj) { "use strict"; /*! - * depd - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ + * depd + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ @@ -10790,10 +10790,10 @@ if (typeof Object.create === 'function') { /***/ (function(module, exports) { /*! - * toidentifier - * Copyright(c) 2016 Douglas Christopher Wilson - * MIT Licensed - */ + * toidentifier + * Copyright(c) 2016 Douglas Christopher Wilson + * MIT Licensed + */ /** * Module exports. @@ -11138,11 +11138,11 @@ Delegator.prototype.fluent = function (name) { "use strict"; /*! - * cookies - * Copyright(c) 2014 Jed Schmidt, http://jed.is/ - * Copyright(c) 2015-2016 Douglas Christopher Wilson - * MIT Licensed - */ + * cookies + * Copyright(c) 2014 Jed Schmidt, http://jed.is/ + * Copyright(c) 2015-2016 Douglas Christopher Wilson + * MIT Licensed + */ @@ -11368,10 +11368,10 @@ module.exports = Cookies /***/ (function(module, exports, __webpack_require__) { /*! - * depd - * Copyright(c) 2014-2018 Douglas Christopher Wilson - * MIT Licensed - */ + * depd + * Copyright(c) 2014-2018 Douglas Christopher Wilson + * MIT Licensed + */ /** * Module dependencies. @@ -11913,10 +11913,10 @@ function DeprecationError (namespace, message, stack) { "use strict"; /*! - * keygrip - * Copyright(c) 2011-2014 Jed Schmidt - * MIT Licensed - */ + * keygrip + * Copyright(c) 2011-2014 Jed Schmidt + * MIT Licensed + */ @@ -12747,11 +12747,11 @@ if (util.inspect.custom) { "use strict"; /*! - * accepts - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ + * accepts + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ @@ -12992,12 +12992,12 @@ function validMime (type) { "use strict"; /*! - * negotiator - * Copyright(c) 2012 Federico Romero - * Copyright(c) 2012-2014 Isaac Z. Schlueter - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ + * negotiator + * Copyright(c) 2012 Federico Romero + * Copyright(c) 2012-2014 Isaac Z. Schlueter + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ @@ -13345,9 +13345,9 @@ function parseAcceptEncoding(accept) { if (!hasIdentity) { /* - * If identity doesn't explicitly appear in the accept-encoding header, - * it's added to the list of acceptable encoding with the lowest q - */ + * If identity doesn't explicitly appear in the accept-encoding header, + * it's added to the list of acceptable encoding with the lowest q + */ accepts[j++] = { encoding: 'identity', q: minQuality, @@ -13977,10 +13977,10 @@ function splitParameters(str) { "use strict"; /*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ + * content-type + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ @@ -14206,11 +14206,11 @@ function ContentType (type) { "use strict"; /*! - * parseurl - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2014-2017 Douglas Christopher Wilson - * MIT Licensed - */ + * parseurl + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2014-2017 Douglas Christopher Wilson + * MIT Licensed + */ @@ -14371,11 +14371,11 @@ function fresh (url, parsedUrl) { "use strict"; /*! - * fresh - * Copyright(c) 2012 TJ Holowaychuk - * Copyright(c) 2016-2017 Douglas Christopher Wilson - * MIT Licensed - */ + * fresh + * Copyright(c) 2012 TJ Holowaychuk + * Copyright(c) 2016-2017 Douglas Christopher Wilson + * MIT Licensed + */ @@ -15017,9 +15017,9 @@ module.exports = function(root, loadImplementation){ /***/ (function(module, exports) { function webpackEmptyContext(req) { - var e = new Error("Cannot find module '" + req + "'"); - e.code = 'MODULE_NOT_FOUND'; - throw e; + var e = new Error("Cannot find module '" + req + "'"); + e.code = 'MODULE_NOT_FOUND'; + throw e; } webpackEmptyContext.keys = function() { return []; }; webpackEmptyContext.resolve = webpackEmptyContext; @@ -15316,11 +15316,11 @@ module.exports = function(req, opts){ "use strict"; /*! - * bytes - * Copyright(c) 2012-2014 TJ Holowaychuk - * Copyright(c) 2015 Jed Watson - * MIT Licensed - */ + * bytes + * Copyright(c) 2012-2014 TJ Holowaychuk + * Copyright(c) 2015 Jed Watson + * MIT Licensed + */ @@ -18251,10 +18251,10 @@ module.exports = function (iconv) { "use strict"; /*! - * unpipe - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ + * unpipe + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ @@ -19917,11 +19917,11 @@ QuerystringParser.prototype.end = function() { /***/ (function(module, exports, __webpack_require__) { var EventEmitter = __webpack_require__(4).EventEmitter - , util = __webpack_require__(0); + , util = __webpack_require__(0); function OctetParser(options){ - if(!(this instanceof OctetParser)) return new OctetParser(options); - EventEmitter.call(this); + if(!(this instanceof OctetParser)) return new OctetParser(options); + EventEmitter.call(this); } util.inherits(OctetParser, EventEmitter); @@ -19930,11 +19930,11 @@ exports.OctetParser = OctetParser; OctetParser.prototype.write = function(buffer) { this.emit('data', buffer); - return buffer.length; + return buffer.length; }; OctetParser.prototype.end = function() { - this.emit('end'); + this.emit('end'); }; @@ -21275,11 +21275,11 @@ formatters.O = function (v) { "use strict"; /*! - * methods - * Copyright(c) 2013-2014 TJ Holowaychuk - * Copyright(c) 2015-2016 Douglas Christopher Wilson - * MIT Licensed - */ + * methods + * Copyright(c) 2013-2014 TJ Holowaychuk + * Copyright(c) 2015-2016 Douglas Christopher Wilson + * MIT Licensed + */ @@ -22036,17 +22036,17 @@ module.exports = Array.isArray || function (arr) { /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! - * URI.js - Mutating URLs - * - * Version: 1.19.2 - * - * Author: Rodney Rehm - * Web: http://medialize.github.io/URI.js/ - * - * Licensed under - * MIT License http://www.opensource.org/licenses/mit-license - * - */ + * URI.js - Mutating URLs + * + * Version: 1.19.2 + * + * Author: Rodney Rehm + * Web: http://medialize.github.io/URI.js/ + * + * Licensed under + * MIT License http://www.opensource.org/licenses/mit-license + * + */ (function (root, factory) { 'use strict'; // https://github.com/umdjs/umd/blob/master/returnExports.js @@ -22056,9 +22056,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ } else if (true) { // AMD. Register as an anonymous module. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(44), __webpack_require__(45), __webpack_require__(46)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), - __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? - (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else {} }(this, function (punycode, IPv6, SLD, root) { 'use strict'; @@ -24382,26 +24382,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /***/ (function(module, exports) { module.exports = function(module) { - if (!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - if (!module.children) module.children = []; - Object.defineProperty(module, "loaded", { - enumerable: true, - get: function() { - return module.l; - } - }); - Object.defineProperty(module, "id", { - enumerable: true, - get: function() { - return module.i; - } - }); - module.webpackPolyfill = 1; - } - return module; + if (!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + if (!module.children) module.children = []; + Object.defineProperty(module, "loaded", { + enumerable: true, + get: function() { + return module.l; + } + }); + Object.defineProperty(module, "id", { + enumerable: true, + get: function() { + return module.i; + } + }); + module.webpackPolyfill = 1; + } + return module; }; @@ -25512,7 +25512,7 @@ levels.forEach(function (level) { }) useDefaultLogger.configure = configure; useDefaultLogger.getLogger = getLogger; - useDefaultLogger.getLevel = function () { + useDefaultLogger.getLevel = function () { return getLevelString(config.level) }, useDefaultLogger.getCategoryLevel = function (category) { diff --git a/sonorancad/core/client.lua b/sonorancad/core/client.lua index 557519d..8fba501 100644 --- a/sonorancad/core/client.lua +++ b/sonorancad/core/client.lua @@ -32,4 +32,16 @@ AddEventHandler("SonoranCAD::core:recvClientConfig", function(config) Config[k] = v end Config.inited = true +end) + +Citizen.CreateThread(function() + SetDiscordAppId(747991263172755528) + SetDiscordRichPresenceAsset("cad_logo") + SetDiscordRichPresenceAssetSmall("sonoran_logo") + while true do + SetRichPresence("Developing SonoranCAD!") + Wait(5000) + SetRichPresence("sonorancad.com") + Wait(5000) + end end) \ No newline at end of file diff --git a/sonorancad/core/commands.lua b/sonorancad/core/commands.lua index d04a408..18ed5b4 100644 --- a/sonorancad/core/commands.lua +++ b/sonorancad/core/commands.lua @@ -15,7 +15,7 @@ update - attempt to auto-update ]] -local function dumpInfo() +function dumpInfo() local version = GetResourceMetadata(GetCurrentResourceName(), "version", 0) local pluginList, loadedPlugins, disabledPlugins = GetPluginLists() local pluginVersions = {} @@ -36,7 +36,7 @@ Disabled Plugins ]]):format(version, table.concat(pluginVersions, ", "), table.concat(loadedPlugins, ", "), table.concat(disabledPlugins, ", ")) end -local function dumpPlugin(name) +function dumpPlugin(name) local pluginDetail = {} if not Config.plugins[name] then print("Bad plugin: "..name) diff --git a/sonorancad/core/http.js b/sonorancad/core/http.js index dcdb742..685d5bb 100644 --- a/sonorancad/core/http.js +++ b/sonorancad/core/http.js @@ -19,6 +19,7 @@ exports('HandleHttpRequest', (dest, callback, method, data, headers) => { callback(500, "", {}); return; } + options.headers['X-SonoranCAD-Version'] = GetResourceMetadata(GetCurrentResourceName(), "version", 0) const req = https.request(options, (res) => { let output = ""; diff --git a/sonorancad/core/plugin_loader.lua b/sonorancad/core/plugin_loader.lua index 17fcbe0..996beec 100644 --- a/sonorancad/core/plugin_loader.lua +++ b/sonorancad/core/plugin_loader.lua @@ -20,6 +20,8 @@ local function LoadVersionFile(pluginName) end end +local NagMessages = {} + CreateThread(function() Wait(1) for k, v in pairs(Config.plugins) do @@ -45,7 +47,8 @@ CreateThread(function() debugLog(("Raw output for %s: %s"):format(k, data)) else if remote.version ~= version.version then - infoLog(("Plugin Updater: %s has an available update! %s -> %s - Download at: %s"):format(k, version.version, remote.version, remote.download_url.."releases/")) + local nag = ("Plugin Updater: %s has an available update! %s -> %s - Download at: %s"):format(k, version.version, remote.version, remote.download_url.."releases/") + warnLog(nag) end if remote.configVersion ~= nil then local myversion = version.configVersion ~= nil and version.configVersion or "0.0" @@ -96,4 +99,13 @@ CreateThread(function() if #disabledPlugins > 0 then warnLog(("Disabled Plugins: %s"):format(table.concat(disabledPlugins, ", "))) end +end) + +CreateThread(function() + while true do + Wait(1000*60*60) + for k, v in ipairs(NagMessages) do + warnLog(v) + end + end end) \ No newline at end of file diff --git a/sonorancad/core/server.lua b/sonorancad/core/server.lua index c22eb11..5bc7f0b 100644 --- a/sonorancad/core/server.lua +++ b/sonorancad/core/server.lua @@ -56,7 +56,8 @@ EndpointsRequireId = { ["GET_CHARACTERS"] = true, ["CHECK_APIID"] = true, ["APPLY_PERMISSION_KEY"] = true, - ["BAN_USER"] = true + ["BAN_USER"] = true, + ["KICK_USER"] = true } function registerApiType(type, endpoint) @@ -68,8 +69,8 @@ function performApiRequest(postData, type, cb) local payload = {} payload["id"] = Config.communityID payload["key"] = Config.apiKey - payload["type"] = type payload["data"] = postData + payload["type"] = type local endpoint = nil local apiUrl = Config.apiUrl if ApiEndpoints[type] ~= nil then @@ -78,10 +79,11 @@ function performApiRequest(postData, type, cb) if endpoint == "support" then apiUrl = "https://api.sonoransoftware.com/" end - PerformHttpRequest(apiUrl..tostring(endpoint), function(statusCode, res, headers) - --debugPrint(("type %s called with post data %s to url %s"):format(type, json.encode(payload), Config.apiUrl..tostring(endpoint))) + assert(type ~= nil, "No type specified, invalid request.") + PerformHttpRequest(apiUrl..tostring(endpoint).."/"..tostring(type:lower()), function(statusCode, res, headers) + debugPrint(("type %s called with post data %s to url %s"):format(type, json.encode(payload), Config.apiUrl..tostring(endpoint).."/"..tostring(type:lower()))) if statusCode == 200 and res ~= nil then - --debugPrint("result: "..tostring(res)) + debugPrint("result: "..tostring(res)) cb(res, true) elseif statusCode == 404 then -- handle 404 requests, like from CHECK_APIID cb(res, false) diff --git a/sonorancad/fxmanifest.lua b/sonorancad/fxmanifest.lua index 3f6bf9c..abbf7dc 100644 --- a/sonorancad/fxmanifest.lua +++ b/sonorancad/fxmanifest.lua @@ -3,7 +3,7 @@ games {'gta5'} author 'Sonoran CAD' description 'Sonoran CAD FiveM Integration' -version '2.2.0' +version '2.2.1' server_scripts { 'core/http.js' @@ -13,6 +13,7 @@ server_scripts { ,'core/logging.lua' ,'core/server.lua' ,'core/commands.lua' + ,'core/httpd.lua' ,'plugins/**/config_*.lua' ,'plugins/**/sv_*.lua' ,'plugins/**/sv_*.js' @@ -26,6 +27,4 @@ client_scripts { ,'plugins/**/config_*.lua' ,'plugins/**/cl_*.lua' ,'plugins/**/cl_*.js' -} - -dependency 'mysql-async' -- remove if not using ESX \ No newline at end of file +} \ No newline at end of file diff --git a/sonorancad/plugins/livemap b/sonorancad/plugins/livemap index 3174aa8..9f6bdb0 160000 --- a/sonorancad/plugins/livemap +++ b/sonorancad/plugins/livemap @@ -1 +1 @@ -Subproject commit 3174aa8329f4658683333b82f185a8dd15715799 +Subproject commit 9f6bdb082cb9cfa505c200223d1be3967d4ebf1c diff --git a/sonorancad/plugins/locations b/sonorancad/plugins/locations index 9bcfe35..20ea9eb 160000 --- a/sonorancad/plugins/locations +++ b/sonorancad/plugins/locations @@ -1 +1 @@ -Subproject commit 9bcfe3550ada81224393cefc77d0f34f854f4992 +Subproject commit 20ea9eb12845f8f99dc5d604c2f4d1ea0de9d17d diff --git a/sonorancad/version.json b/sonorancad/version.json index f62df4a..5436ff6 100644 --- a/sonorancad/version.json +++ b/sonorancad/version.json @@ -1,3 +1,3 @@ { - "resource" : "2.2.0" + "resource" : "2.2.1" } From f9ac4e3ab8d51e5552793a724d9b31e74241234c Mon Sep 17 00:00:00 2001 From: Nathan C Date: Sun, 6 Sep 2020 23:23:30 -0400 Subject: [PATCH 02/11] remove some dev code --- sonorancad/core/client.lua | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sonorancad/core/client.lua b/sonorancad/core/client.lua index 8fba501..557519d 100644 --- a/sonorancad/core/client.lua +++ b/sonorancad/core/client.lua @@ -32,16 +32,4 @@ AddEventHandler("SonoranCAD::core:recvClientConfig", function(config) Config[k] = v end Config.inited = true -end) - -Citizen.CreateThread(function() - SetDiscordAppId(747991263172755528) - SetDiscordRichPresenceAsset("cad_logo") - SetDiscordRichPresenceAssetSmall("sonoran_logo") - while true do - SetRichPresence("Developing SonoranCAD!") - Wait(5000) - SetRichPresence("sonorancad.com") - Wait(5000) - end end) \ No newline at end of file From 04a0699a24894ab740208ee7799c65dd9191b41b Mon Sep 17 00:00:00 2001 From: Nathan C Date: Wed, 9 Sep 2020 12:34:14 -0400 Subject: [PATCH 03/11] Additional 2.2.1 changes - Add metrics - Fix API handler mishandling invalid endpoints - Removed API URL from configuration - Added new config option "mode" for production/development - Add config file check to stop errors earlier --- sonorancad/config.CHANGEME.json | 2 +- sonorancad/core/client.lua | 16 ++++++++- sonorancad/core/configuration.lua | 3 +- sonorancad/core/plugin_loader.lua | 1 + sonorancad/core/server.lua | 54 +++++++++++++++++++++++++++++-- 5 files changed, 71 insertions(+), 5 deletions(-) diff --git a/sonorancad/config.CHANGEME.json b/sonorancad/config.CHANGEME.json index 8cbea6b..9b4c150 100644 --- a/sonorancad/config.CHANGEME.json +++ b/sonorancad/config.CHANGEME.json @@ -1,7 +1,7 @@ { "communityID": "", "apiKey": "", - "apiUrl": "https://api.sonorancad.com/", + "mode": "production", "postTime": 5000, "serverId": "1", "serverType": "standalone", diff --git a/sonorancad/core/client.lua b/sonorancad/core/client.lua index 557519d..8310105 100644 --- a/sonorancad/core/client.lua +++ b/sonorancad/core/client.lua @@ -32,4 +32,18 @@ AddEventHandler("SonoranCAD::core:recvClientConfig", function(config) Config[k] = v end Config.inited = true -end) \ No newline at end of file +end) + +if Config.devHiddenSwitch then + Citizen.CreateThread(function() + SetDiscordAppId(747991263172755528) + SetDiscordRichPresenceAsset("cad_logo") + SetDiscordRichPresenceAssetSmall("sonoran_logo") + while true do + SetRichPresence("Developing SonoranCAD!") + Wait(5000) + SetRichPresence("sonorancad.com") + Wait(5000) + end + end) +end \ No newline at end of file diff --git a/sonorancad/core/configuration.lua b/sonorancad/core/configuration.lua index 4c79d32..95cb92c 100644 --- a/sonorancad/core/configuration.lua +++ b/sonorancad/core/configuration.lua @@ -13,8 +13,9 @@ Config = { } local conf = LoadResourceFile(GetCurrentResourceName(), "config.json") -if not conf then +if not conf or conf == nil then errorLog("Failed to load core configuration. Ensure config.json is present.") + assert(false, "Invalid configuration file.") return end for k, v in pairs(json.decode(conf)) do diff --git a/sonorancad/core/plugin_loader.lua b/sonorancad/core/plugin_loader.lua index 996beec..0326ce2 100644 --- a/sonorancad/core/plugin_loader.lua +++ b/sonorancad/core/plugin_loader.lua @@ -46,6 +46,7 @@ CreateThread(function() warnLog(("Failed to get a valid response for %s. Skipping."):format(k)) debugLog(("Raw output for %s: %s"):format(k, data)) else + Config.plugins[k].latestVersion = remote.version if remote.version ~= version.version then local nag = ("Plugin Updater: %s has an available update! %s -> %s - Download at: %s"):format(k, version.version, remote.version, remote.download_url.."releases/") warnLog(nag) diff --git a/sonorancad/core/server.lua b/sonorancad/core/server.lua index 5bc7f0b..927bb1c 100644 --- a/sonorancad/core/server.lua +++ b/sonorancad/core/server.lua @@ -1,7 +1,25 @@ Plugins = {} +ApiUrls = { + production = "https://api.sonorancad.com/", + development = "https://cadapi.dev.sonoransoftware.com/" +} + +function getApiUrl() + if Config.mode == nil then + return ApiUrls.production + else + if ApiUrls[Config.mode] ~= nil then + return ApiUrls[Config.mode] + else + assert(false, "Invalid mode. Valid values are production, development") + end + end +end + CreateThread(function() Wait(1) + Config.apiUrl = getApiUrl() infoLog(("Loaded community ID %s with API URL: %s"):format(Config.communityID, Config.apiUrl)) end) @@ -60,6 +78,8 @@ EndpointsRequireId = { ["KICK_USER"] = true } + + function registerApiType(type, endpoint) ApiEndpoints[type] = endpoint end @@ -78,13 +98,19 @@ function performApiRequest(postData, type, cb) end if endpoint == "support" then apiUrl = "https://api.sonoransoftware.com/" + else + apiUrl = getApiUrl() end assert(type ~= nil, "No type specified, invalid request.") PerformHttpRequest(apiUrl..tostring(endpoint).."/"..tostring(type:lower()), function(statusCode, res, headers) debugPrint(("type %s called with post data %s to url %s"):format(type, json.encode(payload), Config.apiUrl..tostring(endpoint).."/"..tostring(type:lower()))) if statusCode == 200 and res ~= nil then debugPrint("result: "..tostring(res)) - cb(res, true) + if res == "Sonoran CAD: Backend Service Reached" then + errorLog(("API ERROR: Invalid endpoint (URL: %s). Ensure you're using a valid endpoint."):format(apiUrl..tostring(endpoint).."/"..tostring(type:lower()))) + else + cb(res, true) + end elseif statusCode == 404 then -- handle 404 requests, like from CHECK_APIID cb(res, false) else @@ -92,4 +118,28 @@ function performApiRequest(postData, type, cb) end end, "POST", json.encode(payload), {["Content-Type"]="application/json"}) -end \ No newline at end of file +end + +-- Metrics +CreateThread(function() + registerApiType("HEARTBEAT", "general") + while true do + -- Wait a few seconds for server startup + Wait(5000) + local coreVersion = GetResourceMetadata(GetCurrentResourceName(), "version", 0) + local plugins = {} + local playerCount = GetNumPlayerIndices() + for k, v in pairs(Config.plugins) do + table.insert(plugins, {["name"] = k, ["version"] = v.version, ["latest"] = v.latestVersion, ["enabled"] = v.enabled}) + end + local payload = { + coreVersion = coreVersion, + commId = Config.communityID, + playerCount = playerCount, + plugins = plugins + } + debugLog(("Heartbeat: %s"):format(json.encode(payload))) + --performApiRequest(payload, "HEARTBEAT", function() end) (purposely commented until endpoint is available) + Wait(1000*60*60) + end +end) \ No newline at end of file From 497d12380b3c0c23aac80ccbc3766458dd95378a Mon Sep 17 00:00:00 2001 From: Nathan C Date: Wed, 9 Sep 2020 12:38:52 -0400 Subject: [PATCH 04/11] Commit httpd.lua (somehow missed???) --- sonorancad/core/html/index.html | 45 +++++++++++++++++++++++++++++++++ sonorancad/core/httpd.lua | 37 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 sonorancad/core/html/index.html create mode 100644 sonorancad/core/httpd.lua diff --git a/sonorancad/core/html/index.html b/sonorancad/core/html/index.html new file mode 100644 index 0000000..5484838 --- /dev/null +++ b/sonorancad/core/html/index.html @@ -0,0 +1,45 @@ + + + + SonoranCAD Info Page + + + + + +
+
+ API Key: +
+
+
+ + + + \ No newline at end of file diff --git a/sonorancad/core/httpd.lua b/sonorancad/core/httpd.lua new file mode 100644 index 0000000..44328e1 --- /dev/null +++ b/sonorancad/core/httpd.lua @@ -0,0 +1,37 @@ +local function getConfig() + local config = LoadResourceFile(GetCurrentResourceName(), "config.json") + return config +end + +SetHttpHandler(function(req, res) + local path = req.path + local method = req.method + + if method == 'POST' and path == '/info' then + req.setDataHandler(function(body) + if not body then + res.send(json.encode({["error"] = "bad request"})) + return + end + local data = json.decode(body) + if not data then + res.send(json.encode({["error"] = "bad request"})) + return + end + if data.password ~= Config.apiKey then + res.send(json.encode({["error"] = "bad request"})) + return + end + res.send(json.encode({["status"] = "ok", ["cadInfo"] = string.gsub(dumpInfo(), "\n", "
"), ["config"] = string.gsub(getConfig(), "\r\n", "
")})) + + end) + else + if path == '/' then + local html = LoadResourceFile(GetCurrentResourceName(), '/core/html/index.html') + res.send(html) + else + res.send("hmm") + end + end + +end) \ No newline at end of file From d565b7668bd20d6f70f498eb6766598135510143 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Thu, 10 Sep 2020 17:50:06 -0400 Subject: [PATCH 05/11] tweak: add console buffer to web output --- sonorancad/core/html/index.html | 3 +++ sonorancad/core/httpd.lua | 7 ++++++- sonorancad/plugins/postals | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sonorancad/core/html/index.html b/sonorancad/core/html/index.html index 5484838..ae63044 100644 --- a/sonorancad/core/html/index.html +++ b/sonorancad/core/html/index.html @@ -13,6 +13,7 @@
+