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

@mitm/common

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mitm/common - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

739

index.umd.js

@@ -7,81 +7,2 @@ (function (global, factory) {

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
/**

@@ -99,126 +20,281 @@ * Evaluates a value that may be a thunk (arity=0), or returns the value directly.

function normalizeToArray(arrayOrSingle) {
return Array.isArray(arrayOrSingle) ? arrayOrSingle : [arrayOrSingle];
}
/**
* Checks if any of the given predicates is true, in sequence.
* Checks if all the of the given predicates are true, in sequence.
* A predicate can be a thunk, returning the boolean, or a promise that resolves to the boolean.
* Stops at the first predicate that returns true.
* Stops at the first predicate that returns false.
*/
function _await(value, then, direct) {
if (direct) {
return then ? then(value) : value;
}
function any() {
var conditions = [];
if (!value || !value.then) {
value = Promise.resolve(value);
}
for (var _i = 0; _i < arguments.length; _i++) {
conditions[_i] = arguments[_i];
return then ? value.then(then) : value;
}
/**
* Returns a new array with elements of the first array grouped by two as a tuple array.
* If the array length is not even, a value can be provided to fill the last slot, otherwise `undefined` is used.
*
* @example
* arrayPairwise([1, 2, 3, 4]); // [[1, 2], [3, 4]]
* arrayPairwise([1, 2, 3]); // [[1, 2], [3, undefined]]
* arrayPairwise([1, 2, 3], 'missing value'); // [[1, 2], [3, 'missing value']]
*/
const _iteratorSymbol = typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
function _settle(pact, state, value) {
if (!pact.s) {
if (value instanceof _Pact) {
if (value.s) {
if (state & 1) {
state = value.s;
}
value = value.v;
} else {
value.o = _settle.bind(null, pact, state);
return;
}
}
if (value && value.then) {
value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
return;
}
pact.s = state;
pact.v = value;
const observer = pact.o;
if (observer) {
observer(pact);
}
}
}
return __awaiter(this, void 0, void 0, function () {
var _a, conditions_1, condition;
const _Pact = /*#__PURE__*/function () {
function _Pact() {}
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = 0, conditions_1 = conditions;
_b.label = 1;
_Pact.prototype.then = function (onFulfilled, onRejected) {
const result = new _Pact();
const state = this.s;
case 1:
if (!(_a < conditions_1.length)) return [3
/*break*/
, 4];
condition = conditions_1[_a];
return [4
/*yield*/
, evalThunk(condition)];
if (state) {
const callback = state & 1 ? onFulfilled : onRejected;
case 2:
if (_b.sent()) {
return [2
/*return*/
, true];
}
if (callback) {
try {
_settle(result, 1, callback(this.v));
} catch (e) {
_settle(result, 2, e);
}
_b.label = 3;
return result;
} else {
return this;
}
}
case 3:
_a++;
return [3
/*break*/
, 1];
this.o = function (_this) {
try {
const value = _this.v;
case 4:
return [2
/*return*/
, false];
if (_this.s & 1) {
_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
} else if (onRejected) {
_settle(result, 1, onRejected(value));
} else {
_settle(result, 2, value);
}
} catch (e) {
_settle(result, 2, e);
}
});
});
};
return result;
};
return _Pact;
}();
function _isSettledPact(thenable) {
return thenable instanceof _Pact && thenable.s & 1;
}
/**
* Checks if all the of the given predicates are true, in sequence.
* A predicate can be a thunk, returning the boolean, or a promise that resolves to the boolean.
* Stops at the first predicate that returns false.
*/
function all() {
var conditions = [];
function _forTo(array, body, check) {
var i = -1,
pact,
reject;
for (var _i = 0; _i < arguments.length; _i++) {
conditions[_i] = arguments[_i];
function _cycle(result) {
try {
while (++i < array.length && (!check || !check())) {
result = body(i);
if (result && result.then) {
if (_isSettledPact(result)) {
result = result.v;
} else {
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
return;
}
}
}
if (pact) {
_settle(pact, 1, result);
} else {
pact = result;
}
} catch (e) {
_settle(pact || (pact = new _Pact()), 2, e);
}
}
return __awaiter(this, void 0, void 0, function () {
var _a, conditions_2, condition;
_cycle();
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = 0, conditions_2 = conditions;
_b.label = 1;
return pact;
}
case 1:
if (!(_a < conditions_2.length)) return [3
/*break*/
, 4];
condition = conditions_2[_a];
return [4
/*yield*/
, evalThunk(condition)];
function _forOf(target, body, check) {
if (typeof target[_iteratorSymbol] === "function") {
var iterator = target[_iteratorSymbol](),
step,
pact,
reject;
case 2:
if (!_b.sent()) {
return [2
/*return*/
, false];
function _cycle(result) {
try {
while (!(step = iterator.next()).done && (!check || !check())) {
result = body(step.value);
if (result && result.then) {
if (_isSettledPact(result)) {
result = result.v;
} else {
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
return;
}
}
}
_b.label = 3;
if (pact) {
_settle(pact, 1, result);
} else {
pact = result;
}
} catch (e) {
_settle(pact || (pact = new _Pact()), 2, e);
}
}
case 3:
_a++;
return [3
/*break*/
, 1];
_cycle();
case 4:
return [2
/*return*/
, true];
if (iterator.return) {
var _fixup = function _fixup(value) {
try {
if (!step.done) {
iterator.return();
}
} catch (e) {}
return value;
};
if (pact && pact.then) {
return pact.then(_fixup, function (e) {
throw _fixup(e);
});
}
_fixup();
}
return pact;
} // No support for Symbol.iterator
// No support for Symbol.iterator
if (!("length" in target)) {
throw new TypeError("Object is not iterable");
} // Handle live collections properly
// Handle live collections properly
var values = [];
for (var i = 0; i < target.length; i++) {
values.push(target[i]);
}
return _forTo(values, function (i) {
return body(values[i]);
}, check);
}
function _continue(value, then) {
return value && value.then ? value.then(then) : then(value);
}
function _async(f) {
return function () {
for (var args = [], i = 0; i < arguments.length; i++) {
args[i] = arguments[i];
}
try {
return Promise.resolve(f.apply(this, args));
} catch (e) {
return Promise.reject(e);
}
};
}
const all = _async(function (...conditions) {
let _exit2 = false;
return _continue(_forOf(conditions, function (condition) {
return _await(evalThunk(condition), function (_evalThunk2) {
if (!_evalThunk2) {
_exit2 = true;
return false;
}
});
}, function () {
return _exit2;
}), function (_result2) {
return _exit2 ? _result2 : true;
});
}
});
/**
* Returns a new array with elements of the first array grouped by two as a tuple array.
* If the array length is not even, a value can be provided to fill the last slot, otherwise `undefined` is used.
*
* @example
* arrayPairwise([1, 2, 3, 4]); // [[1, 2], [3, 4]]
* arrayPairwise([1, 2, 3]); // [[1, 2], [3, undefined]]
* arrayPairwise([1, 2, 3], 'missing value'); // [[1, 2], [3, 'missing value']]
* Checks if any of the given predicates is true, in sequence.
* A predicate can be a thunk, returning the boolean, or a promise that resolves to the boolean.
* Stops at the first predicate that returns true.
*/
const any = _async(function (...conditions) {
let _exit = false;
return _continue(_forOf(conditions, function (condition) {
return _await(evalThunk(condition), function (_evalThunk) {
if (_evalThunk) {
_exit = true;
return true;
}
});
}, function () {
return _exit;
}), function (_result) {
return _exit ? _result : false;
});
});
function normalizeToArray(arrayOrSingle) {
return Array.isArray(arrayOrSingle) ? arrayOrSingle : [arrayOrSingle];
}
function arrayPairwise(array, defaultLastValue) {
return array.reduce(function (result, value, index) {
var pair = index <= array.length - 2 ? array.slice(index, index + 2) : [array[index], defaultLastValue];
return array.reduce((result, value, index) => {
const pair = index <= array.length - 2 ? array.slice(index, index + 2) : [array[index], defaultLastValue];
index % 2 === 0 && result.push(pair);

@@ -229,6 +305,4 @@ return result;

var Stopwatch =
/** @class */
function () {
function Stopwatch() {
class Stopwatch {
constructor() {
this.isRunning = false;

@@ -239,20 +313,10 @@ this.timestamps = [];

Stopwatch.prototype.elapsed = function (allowNegative) {
if (allowNegative === void 0) {
allowNegative = false;
}
var startStopPairs = arrayPairwise(this.timestamps, new Date().valueOf());
var elapsed = startStopPairs.reduce(function (count, _a) {
var start = _a[0],
stop = _a[1];
return count + stop - start;
}, 0);
var advanced = this.addedMilliseconds.reduce(function (count, added) {
return count + added;
}, elapsed);
elapsed(allowNegative = false) {
const startStopPairs = arrayPairwise(this.timestamps, new Date().valueOf());
const elapsed = startStopPairs.reduce((count, [start, stop]) => count + stop - start, 0);
const advanced = this.addedMilliseconds.reduce((count, added) => count + added, elapsed);
return allowNegative ? advanced : Math.max(0, advanced);
};
}
Stopwatch.prototype.start = function () {
start() {
if (this.isRunning) {

@@ -264,5 +328,5 @@ return;

this.timestamps.push(new Date().valueOf());
};
}
Stopwatch.prototype.stop = function () {
stop() {
if (!this.isRunning) {

@@ -274,9 +338,5 @@ return;

this.timestamps.push(new Date().valueOf());
};
}
Stopwatch.prototype.reset = function (stop) {
if (stop === void 0) {
stop = true;
}
reset(stop = true) {
this.timestamps = [];

@@ -290,10 +350,9 @@ this.addedMilliseconds = [];

}
};
}
Stopwatch.prototype.advanceBy = function (millis) {
advanceBy(millis) {
this.addedMilliseconds.push(millis);
};
}
return Stopwatch;
}();
}

@@ -306,12 +365,4 @@ /**

var StopwatchMutexMap =
/** @class */
function (_super) {
__extends(StopwatchMutexMap, _super);
function StopwatchMutexMap() {
return _super !== null && _super.apply(this, arguments) || this;
}
StopwatchMutexMap.prototype.for = function (key) {
class StopwatchMutexMap extends Map {
for(key) {
if (!this.has(key)) {

@@ -322,14 +373,12 @@ this.set(key, new Stopwatch());

return this.get(key);
};
}
StopwatchMutexMap.prototype.start = function (key) {
this.forEach(function (stopwatch) {
return stopwatch.stop();
});
start(key) {
this.forEach(stopwatch => stopwatch.stop());
this.for(key).start();
};
}
return StopwatchMutexMap;
}(Map);
}
/* eslint-disable no-console,no-restricted-globals */
/**

@@ -342,15 +391,9 @@ * Gets the current stack trace as an array of strings representing each call.

function getStacktrace(offset) {
var _a, _b;
function getStacktrace(offset = 1) {
var _a, _b; // .slice skips "Error: msg" line and this call on the stack
if (offset === void 0) {
offset = 1;
} // .slice skips "Error: msg" line and this call on the stack
return (_b = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split('\n').slice(1 + offset).map(function (line) {
return line.trim();
})) !== null && _b !== void 0 ? _b : [];
return (_b = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split('\n').slice(1 + offset).map(line => line.trim())) !== null && _b !== void 0 ? _b : [];
}
var unnamedObservableCounter = 0;
let unnamedObservableCounter = 0;
/**

@@ -361,42 +404,18 @@ * You generally don't want to import this variable, prefer the simpler "d" global variable.

var debug = {
const debug = {
logger: console.debug,
log: function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return debug.logger.apply(console, args);
},
logStack: function () {
return debug.logger.apply(console, [getStacktrace(2).join('\n')]);
},
log$: function (name) {
if (name === void 0) {
name = (++unnamedObservableCounter).toString();
}
return function (source) {
return source.pipe(rxjs.tap({
subscribe: logObservableEvent.bind(void 0, name, 'subscribe'),
unsubscribe: logObservableEvent.bind(void 0, name, 'unsubscribe'),
next: logObservableEvent.bind(void 0, name, 'next'),
complete: logObservableEvent.bind(void 0, name, 'complete'),
error: logObservableEvent.bind(void 0, name, 'error'),
finalize: logObservableEvent.bind(void 0, name, 'finalize')
}));
};
}
log: (...args) => debug.logger.apply(console, args),
logStack: () => debug.logger.apply(console, [getStacktrace(2).join('\n')]),
log$: (name = (++unnamedObservableCounter).toString()) => source => source.pipe(rxjs.tap({
subscribe: logObservableEvent.bind(void 0, name, 'subscribe'),
unsubscribe: logObservableEvent.bind(void 0, name, 'unsubscribe'),
next: logObservableEvent.bind(void 0, name, 'next'),
complete: logObservableEvent.bind(void 0, name, 'complete'),
error: logObservableEvent.bind(void 0, name, 'error'),
finalize: logObservableEvent.bind(void 0, name, 'finalize')
}))
};
function logObservableEvent(name, event) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
debug.log.apply(debug, __spreadArray(["$ [".concat(name, "] ").concat(event).concat(args.length ? ':' : '')], args, false));
function logObservableEvent(name, event, ...args) {
debug.log(`$ [${name}] ${event}${args.length ? ':' : ''}`, ...args);
}

@@ -416,3 +435,3 @@

function throwUnexpectedTypeError(thingType) {
throw new Error("".concat(thingType, " is unsupported here."));
throw new Error(`${thingType} is unsupported here.`);
}

@@ -424,3 +443,3 @@ /**

function throwThisShouldNeverHappenError() {
throw new Error("This should never happen.");
throw new Error(`This should never happen.`);
}

@@ -436,3 +455,3 @@ /**

return fn();
} catch (_a) {
} catch (_unused) {
return undefined;

@@ -451,4 +470,4 @@ }

function equalIds(firstId, secondId) {
var firstIdValue = typeof firstId == 'object' ? firstId === null || firstId === void 0 ? void 0 : firstId.toString() : firstId;
var secondIdValue = typeof secondId == 'object' ? secondId === null || secondId === void 0 ? void 0 : secondId.toString() : secondId;
const firstIdValue = typeof firstId == 'object' ? firstId === null || firstId === void 0 ? void 0 : firstId.toString() : firstId;
const secondIdValue = typeof secondId == 'object' ? secondId === null || secondId === void 0 ? void 0 : secondId.toString() : secondId;

@@ -467,48 +486,23 @@ if (!firstId || !secondId) {

function arrayContainsId(arrayOfIds, id) {
return !!arrayOfIds.find(function (arrayId) {
return equalIds(arrayId, id);
});
return !!arrayOfIds.find(arrayId => equalIds(arrayId, id));
}
var MetadataError =
/** @class */
function (_super) {
__extends(MetadataError, _super);
function MetadataError(documentId, problem) {
var _this = this;
var message = "Document \"".concat(documentId !== null && documentId !== void 0 ? documentId : 'unknown', "\" has invalid metadata: ").concat(problem);
_this = _super.call(this, message) || this;
return _this;
class MetadataError extends Error {
constructor(documentId, problem) {
const message = `Document "${documentId !== null && documentId !== void 0 ? documentId : 'unknown'}" has invalid metadata: ${problem}`;
super(message);
}
return MetadataError;
}(Error);
var MetadataKeyError =
/** @class */
function (_super) {
__extends(MetadataKeyError, _super);
function MetadataKeyError(documentId, key, problem) {
var _this = this;
var message = "@ key \"".concat(key, "\": ").concat(problem);
_this = _super.call(this, documentId, message) || this;
return _this;
}
class MetadataKeyError extends MetadataError {
constructor(documentId, key, problem) {
const message = `@ key "${key}": ${problem}`;
super(documentId, message);
}
return MetadataKeyError;
}(MetadataError);
}
function hasKey(metadata, key) {
return !!metadata && key in metadata;
}
function getValue(documentId, metadata, key, typeGuard) {
if (typeGuard === void 0) {
typeGuard = function (val) {
return typeof val == 'string';
};
}
function getValue(documentId, metadata, key, typeGuard = val => typeof val == 'string') {
if (!metadata) {

@@ -518,3 +512,3 @@ return;

var value = metadata[key];
const value = metadata[key];

@@ -526,3 +520,3 @@ if (!value) {

if (!typeGuard(value)) {
throw new MetadataKeyError(documentId, key, "the value \"".concat(value, "\" did not pass the type guard test, being ").concat(typeGuard));
throw new MetadataKeyError(documentId, key, `the value "${value}" did not pass the type guard test, being ${typeGuard}`);
}

@@ -533,13 +527,5 @@

function getUnknownValue(documentId, metadata, key) {
return getValue(documentId, metadata, key, function (val) {
return true;
});
return getValue(documentId, metadata, key, val => true);
}
function requireValue(documentId, metadata, key, typeGuard) {
if (typeGuard === void 0) {
typeGuard = function (val) {
return typeof val == 'string';
};
}
function requireValue(documentId, metadata, key, typeGuard = val => typeof val == 'string') {
if (!metadata) {

@@ -553,6 +539,6 @@ throw new MetadataError(documentId, 'metadata object is not present');

var value = metadata[key];
const value = metadata[key];
if (!typeGuard(value)) {
throw new MetadataKeyError(documentId, key, "the value \"".concat(value, "\" did not pass the type guard test, being ").concat(typeGuard));
throw new MetadataKeyError(documentId, key, `the value "${value}" did not pass the type guard test, being ${typeGuard}`);
}

@@ -566,30 +552,10 @@

return (_a = array === null || array === void 0 ? void 0 : array.filter(function (entry) {
return entry != void 0;
})) !== null && _a !== void 0 ? _a : [];
return (_a = array === null || array === void 0 ? void 0 : array.filter(entry => entry != void 0)) !== null && _a !== void 0 ? _a : [];
}
function wait(milliseconds) {
if (milliseconds === void 0) {
milliseconds = 0;
}
return new Promise(function (resolve) {
return setTimeout(resolve, milliseconds);
});
function wait(milliseconds = 0) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}
function waitThenReject(milliseconds, error) {
if (milliseconds === void 0) {
milliseconds = 0;
}
if (error === void 0) {
error = new Error("".concat(waitThenReject.name, " ").concat(milliseconds, "ms"));
}
return new Promise(function (resolve, reject) {
return setTimeout(function () {
return reject(error);
}, milliseconds);
});
function waitThenReject(milliseconds = 0, error = new Error(`${waitThenReject.name} ${milliseconds}ms`)) {
return new Promise((resolve, reject) => setTimeout(() => reject(error), milliseconds));
}

@@ -624,6 +590,4 @@

*/
var RolesHierarchy =
/** @class */
function () {
function RolesHierarchy(hierarchy) {
class RolesHierarchy {
constructor(hierarchy) {
this.hierarchy = hierarchy;

@@ -633,4 +597,4 @@ this.flatHierarchy = new Map();

for (var role in hierarchy) {
var uniqRoles = new Set(this.expandRoles(role));
for (const role in hierarchy) {
const uniqRoles = new Set(this.expandRoles(role));
this.flatHierarchy.set(role, uniqRoles);

@@ -645,12 +609,10 @@ this.flatHierarchyObject[role] = Array.from(uniqRoles);

RolesHierarchy.prototype.reachableRolesFrom = function (roles) {
var _this = this; //=> Gather all reachable roles in the flat hierarchy, with `roles` as the entry points.
var reachableRoleArrays = roles.map(function (role) {
return _this.flatHierarchy.has(role) ? Array.from(_this.flatHierarchy.get(role)) : [];
reachableRolesFrom(roles) {
//=> Gather all reachable roles in the flat hierarchy, with `roles` as the entry points.
const reachableRoleArrays = roles.map(role => {
return this.flatHierarchy.has(role) ? Array.from(this.flatHierarchy.get(role)) : [];
}); //=> Concatenate all those roles, and convert to a Set then to an array again to have unique entries
return new Set(roles.concat.apply(roles, reachableRoleArrays));
};
return new Set(roles.concat(...reachableRoleArrays));
}
/**

@@ -661,5 +623,5 @@ * Given an array of roles, check if a userRole is reachable from them (directly inherited or not).

RolesHierarchy.prototype.canReachRoleFrom = function (targetRole, availableRoles) {
canReachRoleFrom(targetRole, availableRoles) {
return this.reachableRolesFrom(availableRoles).has(targetRole);
};
}
/**

@@ -674,11 +636,9 @@ * Determines whether an array of roles is a superset of another array of roles or not.

RolesHierarchy.prototype.isSuperset = function (superset, subset) {
var expSuperset = Array.from(this.reachableRolesFrom(superset));
var expSubset = Array.from(this.reachableRolesFrom(subset));
var supersetIsLarger = expSuperset.length > expSubset.length;
var supersetIncludesSubset = expSubset.every(function (role) {
return expSuperset.includes(role);
});
isSuperset(superset, subset) {
const expSuperset = Array.from(this.reachableRolesFrom(superset));
const expSubset = Array.from(this.reachableRolesFrom(subset));
const supersetIsLarger = expSuperset.length > expSubset.length;
const supersetIncludesSubset = expSubset.every(role => expSuperset.includes(role));
return supersetIsLarger && supersetIncludesSubset;
};
}
/**

@@ -690,24 +650,19 @@ * Finds all the reachable roles from a userRole, recursively exploring the inherited roles.

RolesHierarchy.prototype.expandRoles = function (roleKey) {
var _this = this;
var includedRoles = this.hierarchy[roleKey];
var roles = [roleKey];
includedRoles === null || includedRoles === void 0 ? void 0 : includedRoles.forEach(function (role) {
var inheritedRoles = role in _this.hierarchy ? _this.expandRoles(role) : [role];
roles.push.apply(roles, inheritedRoles);
expandRoles(roleKey) {
const includedRoles = this.hierarchy[roleKey];
const roles = [roleKey];
includedRoles === null || includedRoles === void 0 ? void 0 : includedRoles.forEach(role => {
const inheritedRoles = role in this.hierarchy ? this.expandRoles(role) : [role];
roles.push(...inheritedRoles);
});
return roles;
};
}
return RolesHierarchy;
}();
}
function shareReplayOne() {
return function (source) {
return source.pipe(operators.shareReplay({
bufferSize: 1,
refCount: true
}));
};
return source => source.pipe(operators.shareReplay({
bufferSize: 1,
refCount: true
}));
}

@@ -805,3 +760,3 @@

function expectedValueTypeMismatchError(expected, value) {
return new TypeError("Expected value to be ".concat(expected, ", found (").concat(typeof value, ") ").concat(value, "."));
return new TypeError(`Expected value to be ${expected}, found (${typeof value}) ${value}.`);
}

@@ -808,0 +763,0 @@

{
"name": "@mitm/common",
"version": "1.7.0",
"version": "1.8.0",
"peerDependencies": {

@@ -5,0 +5,0 @@ "rxjs": "^7.4.0"

# @mitm/common
Une librairie portable (node, web, etc) contenant des fonctions et types utilitaires.
## Changelog
### 1.8.0
- Cible de compilation plus moderne.
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