Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mashroom/mashroom-utils

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mashroom/mashroom-utils - npm Package Compare versions

Comparing version 1.5.2 to 1.5.3

lib/cluster_utils.js

75

lib/config_utils.js

@@ -7,46 +7,17 @@ "use strict";

exports.evaluateTemplatesInConfigObject = exports.safeEvaluateStringTemplate = void 0;
const TEMPLATE_CODE_REGEX = /\${(.+?)}/g;
const TEMPLATE_CODE_ACCESSED_OBJECTS = /(?:^|\W)(\w+?)\./g;
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
const isTemplate = templateStr => templateStr.indexOf('${') !== -1;
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
const isSafeTemplate = (templateStr, context) => {
const objectsAllowedToAccess = Object.keys(context);
let matchCode = TEMPLATE_CODE_REGEX.exec(templateStr);
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || 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" && Symbol.iterator in Object(iter)) 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;
var TEMPLATE_CODE_ACCESSED_OBJECTS = /(?:^|\W)(\w+?)\./g;
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);
const code = matchCode[1];
let matchAccessedObject = TEMPLATE_CODE_ACCESSED_OBJECTS.exec(code);
while (matchAccessedObject) {
var accessedObject = matchAccessedObject[1];
const accessedObject = matchAccessedObject[1];

@@ -66,3 +37,3 @@ if (objectsAllowedToAccess.indexOf(accessedObject) === -1) {

var safeEvaluateStringTemplate = function safeEvaluateStringTemplate(templateStr, context) {
const safeEvaluateStringTemplate = (templateStr, context) => {
if (!isTemplate(templateStr)) {

@@ -73,12 +44,9 @@ return templateStr;

if (!isSafeTemplate(templateStr, context)) {
throw new Error("Template tries to access global objects: ".concat(templateStr));
throw new Error(`Template tries to access global objects: ${templateStr}`);
}
var args = Object.keys(context);
var values = args.map(function (arg) {
return context[arg];
}); // $FlowFixMe
const args = Object.keys(context);
const values = args.map(arg => context[arg]); // $FlowFixMe
var template = _construct(Function, _toConsumableArray(args).concat(["return `".concat(templateStr, "`;")]));
const template = new Function(...args, `return \`${templateStr}\`;`);
return template.apply({}, values);

@@ -89,12 +57,13 @@ };

var evaluateTemplatesInConfigObject = function evaluateTemplatesInConfigObject(config, logger) {
const evaluateTemplatesInConfigObject = (config, logger) => {
// Currently only environment variables can be used in templates
var context = {
env: _objectSpread({}, process.env)
const context = {
env: { ...process.env
}
};
var replaceStringValues = function replaceStringValues(config) {
for (var propName in config) {
const replaceStringValues = config => {
for (const propName in config) {
if (config.hasOwnProperty(propName)) {
var value = config[propName];
const value = config[propName];

@@ -107,3 +76,3 @@ if (typeof value === 'string') {

}
} else if (_typeof(value) === 'object') {
} else if (typeof value === 'object') {
replaceStringValues(value);

@@ -110,0 +79,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

var escapeHtml = function escapeHtml(html) {
const escapeHtml = html => {
return html.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');

@@ -15,4 +15,4 @@ };

var jsonToHtml = function jsonToHtml(obj) {
var json = JSON.stringify(obj, null, ' ');
const jsonToHtml = obj => {
let json = JSON.stringify(obj, null, ' ');
json = escapeHtml(json);

@@ -19,0 +19,0 @@ json = json.replace(/ /g, '&nbsp;');

@@ -14,3 +14,3 @@ "use strict";

var getClientIP = function getClientIP(request) {
const getClientIP = request => {
return _requestIp.default.getClientIp(request);

@@ -21,3 +21,3 @@ };

var clientIPMatch = function clientIPMatch(request, patterns) {
const clientIPMatch = (request, patterns) => {
return !!(0, _ipFilter.default)(getClientIP(request), patterns);

@@ -24,0 +24,0 @@ };

@@ -9,4 +9,4 @@ "use strict";

/* eslint no-console: off */
var dummyLoggerFactory = function dummyLoggerFactory() {
var dummyLogger = {
const dummyLoggerFactory = () => {
const dummyLogger = {
debug: console.debug,

@@ -16,9 +16,5 @@ info: console.info,

error: console.error,
addContext: function addContext() {},
withContext: function withContext() {
return dummyLogger;
},
getContext: function getContext() {
return {};
}
addContext: () => {},
withContext: () => dummyLogger,
getContext: () => ({})
};

@@ -30,8 +26,6 @@ return dummyLogger;

dummyLoggerFactory.bindToContext = function () {
return dummyLoggerFactory;
};
dummyLoggerFactory.bindToContext = () => dummyLoggerFactory;
var userContext = function userContext(mashroomUser) {
var username = null;
const userContext = mashroomUser => {
let username = null;

@@ -43,3 +37,3 @@ if (mashroomUser) {

return {
username: username
username
};

@@ -46,0 +40,0 @@ };

@@ -7,11 +7,11 @@ "use strict";

exports.topicMatcher = exports.startsWithWildcard = exports.containsWildcard = exports.WILDCARDS_SINGLE = exports.WILDCARDS_MULTI = void 0;
var WILDCARDS_MULTI = ['#'];
const WILDCARDS_MULTI = ['#'];
exports.WILDCARDS_MULTI = WILDCARDS_MULTI;
var WILDCARDS_SINGLE = ['+', '*'];
const WILDCARDS_SINGLE = ['+', '*'];
exports.WILDCARDS_SINGLE = WILDCARDS_SINGLE;
var WILDCARDS_OTHER = ['?'];
var ALL_WILDCARDS = [].concat(WILDCARDS_MULTI, WILDCARDS_SINGLE, WILDCARDS_OTHER);
const WILDCARDS_OTHER = ['?'];
const ALL_WILDCARDS = [...WILDCARDS_MULTI, ...WILDCARDS_SINGLE, ...WILDCARDS_OTHER];
var containsWildcard = function containsWildcard(topic) {
var allWildcardRegex = new RegExp("[".concat(ALL_WILDCARDS.join(''), "]"));
const containsWildcard = topic => {
const allWildcardRegex = new RegExp(`[${ALL_WILDCARDS.join('')}]`);
return topic.search(allWildcardRegex) !== -1;

@@ -22,4 +22,4 @@ };

var startsWithWildcard = function startsWithWildcard(topic) {
var allWildcardRegex = new RegExp("[".concat(ALL_WILDCARDS.join(''), "]"));
const startsWithWildcard = topic => {
const allWildcardRegex = new RegExp(`[${ALL_WILDCARDS.join('')}]`);
return topic.search(allWildcardRegex) === 0;

@@ -30,11 +30,7 @@ };

var topicMatcher = function topicMatcher(pattern, topic) {
var regex = "^".concat(pattern, "$");
WILDCARDS_SINGLE.forEach(function (w) {
return regex = regex.replace(w, '[^/]+');
});
WILDCARDS_MULTI.forEach(function (w) {
return regex = regex.replace(w, '.*');
});
var matcher = new RegExp(regex);
const topicMatcher = (pattern, topic) => {
let regex = `^${pattern}$`;
WILDCARDS_SINGLE.forEach(w => regex = regex.replace(w, '[^/]+'));
WILDCARDS_MULTI.forEach(w => regex = regex.replace(w, '.*'));
const matcher = new RegExp(regex);
return !!topic.match(matcher);

@@ -41,0 +37,0 @@ };

@@ -8,19 +8,3 @@ "use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _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" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var getNestedProperty = function getNestedProperty(object, path) {
const getNestedProperty = (object, path) => {
if (!object) {

@@ -30,6 +14,3 @@ return null;

var _path$split = path.split('.'),
_path$split2 = _toArray(_path$split),
firstProperty = _path$split2[0],
rest = _path$split2.slice(1);
const [firstProperty, ...rest] = path.split('.');

@@ -49,7 +30,3 @@ if (rest.length > 0 && object[firstProperty]) {

var deepAssign = function deepAssign(targetObj) {
for (var _len = arguments.length, sourceObjs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sourceObjs[_key - 1] = arguments[_key];
}
const deepAssign = (targetObj, ...sourceObjs) => {
if (!sourceObjs || sourceObjs.length === 0) {

@@ -59,4 +36,4 @@ return targetObj;

for (var i = 0; i < sourceObjs.length; i++) {
var sourceObj = sourceObjs[i];
for (let i = 0; i < sourceObjs.length; i++) {
const sourceObj = sourceObjs[i];
mergeObjects(targetObj, sourceObj);

@@ -70,9 +47,11 @@ }

var mergeObjects = function mergeObjects(targetObj, sourceObj) {
const mergeObjects = (targetObj, sourceObj) => {
if (isObject(targetObj) && isObject(sourceObj)) {
for (var key in sourceObj) {
for (const key in sourceObj) {
if (sourceObj.hasOwnProperty(key)) {
if (isObject(sourceObj[key])) {
if (!targetObj[key]) {
Object.assign(targetObj, _defineProperty({}, key, {}));
Object.assign(targetObj, {
[key]: {}
});
}

@@ -82,3 +61,5 @@

} else {
Object.assign(targetObj, _defineProperty({}, key, sourceObj[key]));
Object.assign(targetObj, {
[key]: sourceObj[key]
});
}

@@ -90,6 +71,6 @@ }

var isObject = function isObject(item) {
return item && _typeof(item) === 'object' && !Array.isArray(item);
const isObject = item => {
return item && typeof item === 'object' && !Array.isArray(item);
};
exports.isObject = isObject;

@@ -8,44 +8,10 @@ "use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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 } }); 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; } 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], 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 || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : 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);
_this.name = 'BootstrapError';
return _this;
class BootstrapError extends Error {
constructor(message) {
super(message);
this.name = 'BootstrapError';
}
return BootstrapError;
}( /*#__PURE__*/_wrapNativeSuper(Error));
}
exports.default = BootstrapError;

@@ -8,44 +8,10 @@ "use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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 } }); 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; } 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], 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 || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : 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);
_this.name = 'PluginConfigurationError';
return _this;
class PluginConfigurationError extends Error {
constructor(message) {
super(message);
this.name = 'PluginConfigurationError';
}
return PluginConfigurationError;
}( /*#__PURE__*/_wrapNativeSuper(Error));
}
exports.default = PluginConfigurationError;

@@ -12,34 +12,11 @@ "use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
const cloneAndFreezeObject = obj => Object.freeze({ ...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" && Symbol.iterator in Object(iter)) 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); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { 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));
};
const cloneAndFreezeArray = arr => Object.freeze([...arr]);
exports.cloneAndFreezeArray = cloneAndFreezeArray;
var createReadonlyProxy = createReadonlyProxyImpl;
const createReadonlyProxy = createReadonlyProxyImpl;
exports.createReadonlyProxy = createReadonlyProxy;

@@ -49,9 +26,9 @@

return new Proxy(target, {
get: function get(target, name) {
get: function (target, name) {
if (!(name in target)) {
if (logger) logger.warn("Attempt to access non existent property: ".concat(name));
if (logger) logger.warn(`Attempt to access non existent property: ${name}`);
return undefined;
}
var val = target[name];
const val = target[name];

@@ -61,3 +38,3 @@ if (val) {

return cloneAndFreezeArray(val);
} else if (_typeof(val) === 'object') {
} else if (typeof val === 'object') {
return createReadonlyProxy(val, logger);

@@ -69,6 +46,6 @@ }

},
set: function set(target, name) {
throw new _ReadOnlyError.default("Attempt to set property on read-only object: ".concat(name));
set: function (target, name) {
throw new _ReadOnlyError.default(`Attempt to set property on read-only object: ${name}`);
}
});
}

@@ -8,44 +8,10 @@ "use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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 } }); 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; } 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], 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 || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : 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);
_this.name = 'ReadOnlyError';
return _this;
class ReadOnlyError extends Error {
constructor(message) {
super(message);
this.name = 'ReadOnlyError';
}
return ReadOnlyError;
}( /*#__PURE__*/_wrapNativeSuper(Error));
}
exports.default = ReadOnlyError;

@@ -12,4 +12,4 @@ "use strict";

var determineUserAgent = function determineUserAgent(req) {
var ua = (0, _uaParserJs.default)(req.headers['user-agent']);
const determineUserAgent = req => {
const ua = (0, _uaParserJs.default)(req.headers['user-agent']);
return {

@@ -16,0 +16,0 @@ browser: {

@@ -7,3 +7,3 @@ {

"license": "MIT",
"version": "1.5.2",
"version": "1.5.3",
"main": "lib",

@@ -14,2 +14,3 @@ "files": [

"dependencies": {
"find-process": "^1.4.3",
"ip-filter": "^3.0.5",

@@ -16,0 +17,0 @@ "kind-of": "^6.0.3",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc