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.2.3 to 1.3.0

24

lib/logging_utils.js

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

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

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

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

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

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

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

return {
username
username: username
};

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

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

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

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

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

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

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);
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);
return !!topic.match(matcher);

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

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

const getNestedProperty = (object, path) => {
function _typeof(obj) { 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) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var getNestedProperty = function getNestedProperty(object, path) {
if (!object) {

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

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

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

const deepAssign = (targetObj, ...sourceObjs) => {
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];
}
if (!sourceObjs || sourceObjs.length === 0) {

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

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

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

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

@@ -61,5 +78,3 @@

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

@@ -71,6 +86,6 @@ }

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

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

class BootstrapError extends Error {
constructor(message) {
super(message);
this.name = 'BootstrapError';
function _typeof(obj) { 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 _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 _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 _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 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 _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 _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);
function BootstrapError(message) {
var _this;
_classCallCheck(this, BootstrapError);
_this = _possibleConstructorReturn(this, _getPrototypeOf(BootstrapError).call(this, message));
_this.name = 'BootstrapError';
return _this;
}
}
return BootstrapError;
}(_wrapNativeSuper(Error));
exports.default = BootstrapError;

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

class PluginConfigurationError extends Error {
constructor(message) {
super(message);
this.name = 'PluginConfigurationError';
function _typeof(obj) { 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 _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 _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 _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 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 _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 _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);
function PluginConfigurationError(message) {
var _this;
_classCallCheck(this, PluginConfigurationError);
_this = _possibleConstructorReturn(this, _getPrototypeOf(PluginConfigurationError).call(this, message));
_this.name = 'PluginConfigurationError';
return _this;
}
}
return PluginConfigurationError;
}(_wrapNativeSuper(Error));
exports.default = PluginConfigurationError;

@@ -12,10 +12,24 @@ "use strict";

const cloneAndFreezeObject = obj => Object.freeze(Object.assign({}, obj));
function _typeof(obj) { 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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var cloneAndFreezeObject = function cloneAndFreezeObject(obj) {
return Object.freeze(Object.assign({}, obj));
};
exports.cloneAndFreezeObject = cloneAndFreezeObject;
const cloneAndFreezeArray = arr => Object.freeze([...arr]);
var cloneAndFreezeArray = function cloneAndFreezeArray(arr) {
return Object.freeze(_toConsumableArray(arr));
};
exports.cloneAndFreezeArray = cloneAndFreezeArray;
const createReadonlyProxy = createReadonlyProxyImpl;
var createReadonlyProxy = createReadonlyProxyImpl;
exports.createReadonlyProxy = createReadonlyProxy;

@@ -25,9 +39,9 @@

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

@@ -37,3 +51,3 @@ if (val) {

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

@@ -45,6 +59,6 @@ }

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

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

class ReadOnlyError extends Error {
constructor(message) {
super(message);
this.name = 'ReadOnlyError';
function _typeof(obj) { 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 _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 _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 _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 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 _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 _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);
function ReadOnlyError(message) {
var _this;
_classCallCheck(this, ReadOnlyError);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReadOnlyError).call(this, message));
_this.name = 'ReadOnlyError';
return _this;
}
}
return ReadOnlyError;
}(_wrapNativeSuper(Error));
exports.default = ReadOnlyError;

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

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

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

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

"license": "MIT",
"version": "1.2.3",
"version": "1.3.0",
"main": "lib",

@@ -14,8 +14,8 @@ "files": [

"dependencies": {
"ua-parser-js": "^0.7.20"
"ua-parser-js": "^0.7.21"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"eslint": "^6.6.0",
"flow-copy-source": "^2.0.8",
"@babel/cli": "^7.8.3",
"eslint": "^6.8.0",
"flow-copy-source": "^2.0.9",
"jest": "^24.9.0"

@@ -22,0 +22,0 @@ },

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