@mashroom/mashroom-utils
Advanced tools
Comparing version 2.1.3 to 2.2.0
@@ -7,42 +7,26 @@ "use strict"; | ||
exports.isNodeCluster = exports.getWorkerId = exports.getAllWorkerPids = void 0; | ||
var _cluster = _interopRequireDefault(require("cluster")); | ||
var _findProcess = _interopRequireDefault(require("find-process")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var isNodeCluster = function isNodeCluster() { | ||
return _cluster.default.workers && Object.keys(_cluster.default.workers).length > 0 || !!_cluster.default.worker; | ||
}; | ||
exports.isNodeCluster = isNodeCluster; | ||
var getWorkerId = function getWorkerId() { | ||
return process.env.NODE_APP_INSTANCE || _cluster.default.worker && String(_cluster.default.worker.id) || 'master'; | ||
}; | ||
exports.getWorkerId = getWorkerId; | ||
var getAllWorkerPids = function getAllWorkerPids() { | ||
return (0, _findProcess.default)('pid', process.pid).then(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 1), | ||
thisProcess = _ref2[0]; | ||
thisProcess = _ref2[0]; | ||
if (!thisProcess || !thisProcess.ppid) { | ||
return []; | ||
} | ||
return (0, _findProcess.default)('name', thisProcess.name).then(function (workers) { | ||
@@ -52,3 +36,2 @@ if (!workers) { | ||
} | ||
return workers.filter(function (worker) { | ||
@@ -65,3 +48,2 @@ return worker.ppid === thisProcess.ppid; | ||
}; | ||
exports.getAllWorkerPids = getAllWorkerPids; |
@@ -7,29 +7,9 @@ "use strict"; | ||
exports.safeEvaluateStringTemplate = exports.evaluateTemplatesInConfigObject = exports.INVALID_PLUGIN_NAME_CHARACTERS = void 0; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
var TEMPLATE_CODE_REGEX = /\${(.+?)}/g; | ||
@@ -39,31 +19,22 @@ var TEMPLATE_CODE_ACCESSED_OBJECTS = /(?:^|\W)(\w+?)\./g; | ||
exports.INVALID_PLUGIN_NAME_CHARACTERS = INVALID_PLUGIN_NAME_CHARACTERS; | ||
var isTemplate = function isTemplate(templateStr) { | ||
return templateStr.indexOf('${') !== -1; | ||
}; | ||
var isSafeTemplate = function isSafeTemplate(templateStr, context) { | ||
var objectsAllowedToAccess = Object.keys(context); | ||
var matchCode = TEMPLATE_CODE_REGEX.exec(templateStr); | ||
while (matchCode) { | ||
var code = matchCode[1]; | ||
var matchAccessedObject = TEMPLATE_CODE_ACCESSED_OBJECTS.exec(code); | ||
while (matchAccessedObject) { | ||
var accessedObject = matchAccessedObject[1]; | ||
if (objectsAllowedToAccess.indexOf(accessedObject) === -1) { | ||
return false; | ||
} | ||
matchAccessedObject = TEMPLATE_CODE_ACCESSED_OBJECTS.exec(code); | ||
} | ||
matchCode = TEMPLATE_CODE_REGEX.exec(templateStr); | ||
} | ||
return true; | ||
}; | ||
var safeEvaluateStringTemplate = function safeEvaluateStringTemplate(templateStr, context) { | ||
@@ -73,7 +44,5 @@ if (!isTemplate(templateStr)) { | ||
} | ||
if (!isSafeTemplate(templateStr, context)) { | ||
throw new Error("Template tries to access global objects: ".concat(templateStr)); | ||
} | ||
var args = Object.keys(context); | ||
@@ -83,10 +52,6 @@ var values = args.map(function (arg) { | ||
}); | ||
var template = _construct(Function, _toConsumableArray(args).concat(["return `".concat(templateStr, "`;")])); | ||
var template = _construct(Function, args.concat(["return `".concat(templateStr, "`;")])); | ||
return template.apply({}, values); | ||
}; | ||
exports.safeEvaluateStringTemplate = safeEvaluateStringTemplate; | ||
var evaluateTemplatesInConfigObject = function evaluateTemplatesInConfigObject(config, logger) { | ||
@@ -97,3 +62,2 @@ // Currently only environment variables can be used in templates | ||
}; | ||
var replaceStringValues = function replaceStringValues(config) { | ||
@@ -103,3 +67,2 @@ for (var propName in config) { | ||
var value = config[propName]; | ||
if (typeof value === 'string') { | ||
@@ -117,6 +80,4 @@ try { | ||
}; | ||
replaceStringValues(config); | ||
}; | ||
exports.evaluateTemplatesInConfigObject = evaluateTemplatesInConfigObject; |
@@ -7,9 +7,6 @@ "use strict"; | ||
exports.jsonToHtml = exports.escapeHtml = void 0; | ||
var escapeHtml = function escapeHtml(html) { | ||
return html.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); | ||
}; | ||
exports.escapeHtml = escapeHtml; | ||
var jsonToHtml = function jsonToHtml(obj) { | ||
@@ -22,3 +19,2 @@ var json = JSON.stringify(obj, null, ' '); | ||
}; | ||
exports.jsonToHtml = jsonToHtml; |
@@ -7,15 +7,9 @@ "use strict"; | ||
exports.getClientIP = exports.clientIPMatch = void 0; | ||
var _requestIp = _interopRequireDefault(require("request-ip")); | ||
var _ipFilter = _interopRequireDefault(require("ip-filter")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var getClientIP = function getClientIP(request) { | ||
return _requestIp.default.getClientIp(request); | ||
}; | ||
exports.getClientIP = getClientIP; | ||
var clientIPMatch = function clientIPMatch(request, patterns) { | ||
@@ -25,3 +19,2 @@ var clientIp = getClientIP(request); | ||
}; | ||
exports.clientIPMatch = clientIPMatch; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.userContext = exports.dummyLoggerFactory = void 0; | ||
var dummyLoggerFactory = function dummyLoggerFactory() { | ||
@@ -15,5 +14,3 @@ var dummyLogger = { | ||
error: console.error, | ||
addContext: function addContext() { | ||
/* nothing to do */ | ||
}, | ||
addContext: function addContext() {/* nothing to do */}, | ||
withContext: function withContext() { | ||
@@ -28,16 +25,11 @@ return dummyLogger; | ||
}; | ||
exports.dummyLoggerFactory = dummyLoggerFactory; | ||
dummyLoggerFactory.bindToContext = function () { | ||
return dummyLoggerFactory; | ||
}; | ||
var userContext = function userContext(mashroomUser) { | ||
var username = null; | ||
if (mashroomUser) { | ||
username = mashroomUser.username; | ||
} | ||
return { | ||
@@ -47,3 +39,2 @@ username: username | ||
}; | ||
exports.userContext = userContext; |
@@ -13,3 +13,2 @@ "use strict"; | ||
var ALL_WILDCARDS = [].concat(WILDCARDS_MULTI, WILDCARDS_SINGLE, WILDCARDS_OTHER); | ||
var containsWildcard = function containsWildcard(topic) { | ||
@@ -19,5 +18,3 @@ var allWildcardRegex = new RegExp("[".concat(ALL_WILDCARDS.join(''), "]")); | ||
}; | ||
exports.containsWildcard = containsWildcard; | ||
var startsWithWildcard = function startsWithWildcard(topic) { | ||
@@ -27,5 +24,3 @@ var allWildcardRegex = new RegExp("[".concat(ALL_WILDCARDS.join(''), "]")); | ||
}; | ||
exports.startsWithWildcard = startsWithWildcard; | ||
var topicMatcher = function topicMatcher(pattern, topic) { | ||
@@ -42,3 +37,2 @@ var regex = "^".concat(pattern, "$"); | ||
}; | ||
exports.topicMatcher = topicMatcher; |
@@ -7,19 +7,10 @@ "use strict"; | ||
exports.isObject = exports.getNestedProperty = exports.deepAssign = void 0; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var getNestedProperty = function getNestedProperty(object, path) { | ||
@@ -29,21 +20,15 @@ if (!object) { | ||
} | ||
var _path$split = path.split('.'), | ||
_path$split2 = _toArray(_path$split), | ||
firstProperty = _path$split2[0], | ||
rest = _path$split2.slice(1); | ||
_path$split2 = _toArray(_path$split), | ||
firstProperty = _path$split2[0], | ||
rest = _path$split2.slice(1); | ||
if (rest.length > 0 && object[firstProperty]) { | ||
return getNestedProperty(object[firstProperty], rest.join('.')); | ||
} | ||
if (object[firstProperty]) { | ||
return object[firstProperty]; | ||
} | ||
return null; | ||
}; | ||
exports.getNestedProperty = getNestedProperty; | ||
var deepAssign = function deepAssign(targetObj) { | ||
@@ -53,7 +38,5 @@ for (var _len = arguments.length, sourceObjs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
} | ||
if (!sourceObjs || sourceObjs.length === 0) { | ||
return targetObj; | ||
} | ||
for (var i = 0; i < sourceObjs.length; i++) { | ||
@@ -63,8 +46,5 @@ var sourceObj = sourceObjs[i]; | ||
} | ||
return targetObj; | ||
}; | ||
exports.deepAssign = deepAssign; | ||
var mergeObjects = function mergeObjects(targetObj, sourceObj) { | ||
@@ -78,3 +58,2 @@ if (isObject(targetObj) && isObject(sourceObj)) { | ||
} | ||
deepAssign(targetObj[key], sourceObj[key]); | ||
@@ -88,7 +67,5 @@ } else { | ||
}; | ||
var isObject = function isObject(item) { | ||
return item && _typeof(item) === 'object' && !Array.isArray(item); | ||
}; | ||
exports.isObject = isObject; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,39 +8,21 @@ value: true | ||
exports.default = void 0; | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var BootstrapError = /*#__PURE__*/function (_Error) { | ||
_inherits(BootstrapError, _Error); | ||
var _super = _createSuper(BootstrapError); | ||
function BootstrapError(message) { | ||
var _this; | ||
_classCallCheck(this, BootstrapError); | ||
_this = _super.call(this, message); | ||
@@ -51,6 +32,4 @@ _this.name = 'BootstrapError'; | ||
} | ||
return _createClass(BootstrapError); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
exports.default = BootstrapError; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,39 +8,21 @@ value: true | ||
exports.default = void 0; | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var PluginConfigurationError = /*#__PURE__*/function (_Error) { | ||
_inherits(PluginConfigurationError, _Error); | ||
var _super = _createSuper(PluginConfigurationError); | ||
function PluginConfigurationError(message) { | ||
var _this; | ||
_classCallCheck(this, PluginConfigurationError); | ||
_this = _super.call(this, message); | ||
@@ -51,6 +32,4 @@ _this.name = 'PluginConfigurationError'; | ||
} | ||
return _createClass(PluginConfigurationError); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
exports.default = PluginConfigurationError; |
@@ -7,42 +7,26 @@ "use strict"; | ||
exports.createReadonlyProxy = exports.cloneAndFreezeObject = exports.cloneAndFreezeArray = void 0; | ||
var _ReadOnlyError = _interopRequireDefault(require("./ReadOnlyError")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var cloneAndFreezeObject = function cloneAndFreezeObject(obj) { | ||
return Object.freeze(_objectSpread({}, obj)); | ||
}; | ||
exports.cloneAndFreezeObject = cloneAndFreezeObject; | ||
var cloneAndFreezeArray = function cloneAndFreezeArray(arr) { | ||
return Object.freeze(_toConsumableArray(arr)); | ||
}; | ||
exports.cloneAndFreezeArray = cloneAndFreezeArray; | ||
var createReadonlyProxy = createReadonlyProxyImpl; // eslint-disable-next-line @typescript-eslint/ban-types | ||
var createReadonlyProxy = createReadonlyProxyImpl; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
exports.createReadonlyProxy = createReadonlyProxy; | ||
function createReadonlyProxyImpl(target, logger) { | ||
@@ -54,7 +38,6 @@ return new Proxy(target, { | ||
return undefined; | ||
} // @ts-ignore | ||
} | ||
// @ts-ignore | ||
var val = target[name]; | ||
if (val) { | ||
@@ -67,3 +50,2 @@ if (Array.isArray(val)) { | ||
} | ||
return val; | ||
@@ -70,0 +52,0 @@ }, |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,39 +8,21 @@ value: true | ||
exports.default = void 0; | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var ReadOnlyError = /*#__PURE__*/function (_Error) { | ||
_inherits(ReadOnlyError, _Error); | ||
var _super = _createSuper(ReadOnlyError); | ||
function ReadOnlyError(message) { | ||
var _this; | ||
_classCallCheck(this, ReadOnlyError); | ||
_this = _super.call(this, message); | ||
@@ -51,6 +32,4 @@ _this.name = 'ReadOnlyError'; | ||
} | ||
return _createClass(ReadOnlyError); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
exports.default = ReadOnlyError; |
@@ -7,13 +7,9 @@ "use strict"; | ||
exports.isHtmlRequest = exports.isAjaxRequest = void 0; | ||
var isAjaxRequest = function isAjaxRequest(req) { | ||
return req.xhr || /json/i.test(req.headers.accept); | ||
}; | ||
exports.isAjaxRequest = isAjaxRequest; | ||
var isHtmlRequest = function isHtmlRequest(req) { | ||
return (req.method === 'GET' || req.method === 'POST') && !req.xhr && /html/i.test(req.headers.accept); | ||
}; | ||
exports.isHtmlRequest = isHtmlRequest; |
@@ -7,17 +7,9 @@ "use strict"; | ||
exports.fixTlsOptions = void 0; | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var CERT_PROPERTIES = ['cert', 'ca', 'key', 'crl', 'pfx']; | ||
var fixTlsOptions = function fixTlsOptions(tlsOptions, serverRootFolder, logger) { | ||
@@ -27,9 +19,6 @@ if (!tlsOptions) { | ||
} | ||
var fixedTlsOptions = _objectSpread({}, tlsOptions); | ||
CERT_PROPERTIES.forEach(function (certPropName) { | ||
if (tlsOptions.hasOwnProperty(certPropName)) { | ||
var certs = tlsOptions[certPropName]; | ||
if (certs) { | ||
@@ -41,3 +30,2 @@ var certArray = Array.isArray(certs) ? certs : [certs]; | ||
} | ||
if (!_fs.default.existsSync(certPath)) { | ||
@@ -52,4 +40,4 @@ logger.warn("Certificate path not found: ".concat(certPath)); | ||
return cert !== null; | ||
}); // @ts-ignore | ||
}); | ||
// @ts-ignore | ||
fixedTlsOptions[certPropName] = fixedCertArray || []; | ||
@@ -61,3 +49,2 @@ } | ||
}; | ||
exports.fixTlsOptions = fixTlsOptions; |
@@ -7,12 +7,8 @@ "use strict"; | ||
exports.determineUserAgent = void 0; | ||
var _uaParserJs = _interopRequireDefault(require("ua-parser-js")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var determineUserAgent = function determineUserAgent(req) { | ||
var _UAParser = (0, _uaParserJs.default)(req.headers['user-agent']), | ||
browser = _UAParser.browser, | ||
os = _UAParser.os; | ||
browser = _UAParser.browser, | ||
os = _UAParser.os; | ||
return { | ||
@@ -30,3 +26,2 @@ browser: { | ||
}; | ||
exports.determineUserAgent = determineUserAgent; |
@@ -7,3 +7,3 @@ { | ||
"license": "MIT", | ||
"version": "2.1.3", | ||
"version": "2.2.0", | ||
"main": "lib", | ||
@@ -17,7 +17,7 @@ "files": [ | ||
"kind-of": "^6.0.3", | ||
"request-ip": "^2.2.0", | ||
"ua-parser-js": "^1.0.2" | ||
"request-ip": "^3.3.0", | ||
"ua-parser-js": "^1.0.32" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "^4.17.13", | ||
"@types/express": "^4.17.14", | ||
"@types/request-ip": "^0.0.37", | ||
@@ -24,0 +24,0 @@ "@types/ua-parser-js": "^0.7.36" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47193
34
663
+ Addedrequest-ip@3.3.0(transitive)
- Removedis_js@0.9.0(transitive)
- Removedrequest-ip@2.2.0(transitive)
Updatedrequest-ip@^3.3.0
Updatedua-parser-js@^1.0.32