3776 lines
210 KiB
JavaScript
3776 lines
210 KiB
JavaScript
(function (global, factory) {
|
||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||
typeof define === 'function' && define.amd ? define(factory) :
|
||
global.internalsdk = factory()
|
||
|
||
|
||
}(this, (function () { //'use strict';
|
||
|
||
|
||
class Controller {
|
||
constructor(environment, member_config, json_config){
|
||
console.log(member_config);
|
||
this.config = { "member": member_config, "json": json_config, "environment": environment };
|
||
this.membership = member_config.membership;
|
||
this.testing = true;
|
||
this.config.key = "passthrough";
|
||
|
||
console.log(json_config);
|
||
|
||
|
||
// TODO_4: user should already have json_data & records
|
||
// if(this.config.member.json_data==undefined){
|
||
// this.config.member.json_data = {archive: this.config.json.catalog.archive}
|
||
// }
|
||
// if(this.config.member.json_data.records==undefined){
|
||
// this.config.member.json_data.records = this.config.json.catalog;
|
||
// }
|
||
|
||
RunAccessControlMaker();
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
apicall(path,options,cb){
|
||
const self = this;
|
||
|
||
// if(options.mode==undefined){
|
||
// options["mode"] = "production";
|
||
// }
|
||
if(options.headers==undefined){
|
||
options["headers"] = {
|
||
'Content-Type': 'application/json'
|
||
};
|
||
}
|
||
// options.headers["Access-Control-Allow-Origin"] = "*";
|
||
options.headers["Authorization"] = `token ${self.config.key}`;
|
||
(async function() {
|
||
let url = `https://api.appfactory.studio${path}`;
|
||
// if(self.config.environment=="development"){
|
||
// console.log("IS DEV");
|
||
// url = `https://api-sandbox.appfactory.studio${path}`;
|
||
// }else{
|
||
// console.log("NOT DEV");
|
||
// }
|
||
// const url = `https://api-sandbox.appfactory.studio${path}`;
|
||
// const URL = "https://www15.appfactory.studio/portal/api/v1/core/help";
|
||
|
||
// const url = `${self.config.api.url}${path}`;
|
||
try {
|
||
// if(options==undefined || options==null){ options = {method: "GET"};}
|
||
const response = await fetch(url,options);
|
||
if (!response.ok) { throw new Error(`Response status: ${response.status}`); }
|
||
const json = await response.json();
|
||
if(cb!=undefined) cb(json);
|
||
} catch (error) {
|
||
console.log(error);
|
||
}
|
||
})();
|
||
}
|
||
|
||
allow(category,module,cb){
|
||
const self = this;
|
||
if(self.membership==99){
|
||
if(cb!=undefined) cb({enabled: true});
|
||
return;
|
||
}
|
||
console.log(self.config);
|
||
let registry_alloc = self.config.json.catalog.inventory.alloc;
|
||
|
||
|
||
let archives_alloc =
|
||
|
||
self.config.member.json_data.registry.catalog.archive.alloc;
|
||
|
||
|
||
if(registry_alloc[category]!=undefined && registry_alloc[category]["modules"][module]!=undefined){
|
||
let registry = registry_alloc[category]["modules"][module];
|
||
let archive = archives_alloc[category][module];
|
||
|
||
let allowed = registry_alloc[category]["modules"][module]["memberships"][self.membership];
|
||
let own = archives_alloc[category][module];
|
||
console.log("===========================");
|
||
console.log(allowed);
|
||
console.log(own);
|
||
console.log(registry_alloc);
|
||
console.log(category);
|
||
console.log(self);
|
||
console.log(module);
|
||
if(own.count < allowed.count){
|
||
let access = {enabled: true};
|
||
if(cb!=undefined) cb(access);
|
||
}else{
|
||
let access = {enabled: false};
|
||
if(cb!=undefined) cb(access);
|
||
}
|
||
}else{
|
||
let access = {enabled: false};
|
||
if(cb!=undefined) cb(access);
|
||
}
|
||
}
|
||
|
||
update(category,module,opts,cb){
|
||
const self = this;
|
||
// let registry_alloc = self.config.json.catalog.registry.alloc;
|
||
// self.config.member.json_data.archives.alloc;
|
||
|
||
if(category=="websites" && module=="hosting"){
|
||
_func_update_web_hosting(self,opts,cb);
|
||
}
|
||
}
|
||
|
||
}
|
||
class Features {
|
||
constructor(environment, member_config, json_config){
|
||
this.config = {
|
||
"member": member_config,
|
||
"json": json_config,
|
||
"environment": environment
|
||
}
|
||
}
|
||
|
||
hasFeature(feature){
|
||
// console.log(this.config.json.features.models);
|
||
const self = this;
|
||
let active = true;
|
||
for (let i = 0; i < self.config.json.features.models.length; i++) {
|
||
const element = self.config.json.features.models[i];
|
||
if(element.name==feature){
|
||
active = element.active;
|
||
if(element.environments==undefined) continue;
|
||
for (let n = 0; n < element.environments.length; n++) {
|
||
const env = element.environments[n];
|
||
if(env.id==self.config.environment){
|
||
active = env.active;
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
return active;
|
||
}
|
||
}
|
||
class Authority {
|
||
|
||
constructor(environment, member_config, json_config){
|
||
this.config = {
|
||
"member": member_config,
|
||
"json": json_config,
|
||
"environment": environment
|
||
};
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* Out facing controller
|
||
*
|
||
*/
|
||
class MemberManagementSystem {
|
||
|
||
constructor(environment, member_config, json_config){
|
||
// console.log(member_config);
|
||
// console.log(json_config);
|
||
|
||
this.config = { "member": member_config, "json": json_config, "environment": environment };
|
||
this.controller = new Controller(environment,member_config,json_config);
|
||
this.features = new Features(environment,member_config,json_config);
|
||
this.authority = new Authority(environment,member_config,json_config);
|
||
this.featureLib = new FeatureLib(member_config,json_config);
|
||
}
|
||
|
||
|
||
init(processor_nameid,access_member,access_account){
|
||
let self = this;
|
||
self.member = access_member;
|
||
self.account = access_account;
|
||
self.processor_nameid = processor_nameid;
|
||
self.processor = null;
|
||
self.subscription = null;
|
||
self.authorization = null;
|
||
|
||
// get processor
|
||
for (let i = 0; i < self.account.groups.processors.length; i++) {
|
||
const processor = self.account.groups.processors[i];
|
||
if(processor.processor_nameid==processor_nameid){
|
||
self.processor = processor;
|
||
break;
|
||
}
|
||
}
|
||
|
||
// get subscription
|
||
for (let i = 0; i < self.account.groups.subscriptions.length; i++) {
|
||
const subscription = self.account.groups.subscriptions[i];
|
||
if(self.processor.subscription_group==subscription.name){
|
||
self.subscription = subscription;
|
||
break;
|
||
}
|
||
}
|
||
|
||
// get authorization
|
||
for (let i = 0; i < self.account.groups.authorizations.length; i++) {
|
||
const authorization = self.account.groups.authorizations[i];
|
||
if(self.processor.authorization_group==authorization.name){
|
||
self.authorization = authorization;
|
||
break;
|
||
}
|
||
}
|
||
|
||
// console.log(self.processor);
|
||
// console.log(self.subscription);
|
||
// console.log(self.authorization);
|
||
}
|
||
|
||
// getAuthorization("account","storage","member")
|
||
getAuthorization(name,feature_name,tier_name){
|
||
let self = this;
|
||
let app_auth = null;
|
||
// tier = (tier==undefined) ? null : tier;
|
||
console.log(self.authorization)
|
||
for (let i = 0; i < self.authorization.apps.length; i++) {
|
||
const app = self.authorization.apps[i];
|
||
if(app.name==name){
|
||
for (let n = 0; n < app.features.length; n++) {
|
||
const feature = app.features[n];
|
||
if(feature.name==feature_name){
|
||
app_auth = feature;
|
||
if(tier_name!=undefined){
|
||
for (let v = 0; v < feature.tiers.length; v++) {
|
||
const tier = feature.tiers[v];
|
||
if(tier.name==tier_name){
|
||
app_auth = tier;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
if(app_auth!=null) break;
|
||
}
|
||
}
|
||
|
||
return app_auth;
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
class FeatureLib {
|
||
|
||
constructor(member_config,json_config){
|
||
this.member = member_config;
|
||
this.config = json_config;
|
||
this.init();
|
||
}
|
||
|
||
init(){
|
||
let self = this;
|
||
// console.log(self.member.reference_num);
|
||
flagsmith.init({
|
||
environmentID: "K4RpKAe57hd3VAy4wbRv5r", // YOUR_CLIENT_SIDE_ENVIRONMENT_KEY,
|
||
api:"https://x-flagsmith.systems.appfactory.studio/api/v1/", // set this if you are self hosting, and point it to your API
|
||
cacheFlags: true, // stores flags in localStorage cache
|
||
enableAnalytics: true, // See https://docs.flagsmith.com/flag-analytics/ for more info.
|
||
identity: self.member.reference_num + "___" + self.member.username,
|
||
traits: {
|
||
membership: self.member.membership,
|
||
country_code: self.member.country_code,
|
||
country_name: self.member.country_name
|
||
},
|
||
defaultFlags: {
|
||
"coordinator": {
|
||
"enabled": false,
|
||
"value": null
|
||
},
|
||
"notes": {
|
||
"enabled": false,
|
||
"value": null
|
||
},
|
||
"dreamgraph": {
|
||
"enabled": false,
|
||
"value": null
|
||
},
|
||
"domains": {
|
||
"enabled": true,
|
||
"value": null
|
||
}
|
||
},
|
||
onChange: (oldFlags, params) => {
|
||
//Occurs whenever flags are changed
|
||
const { isFromServer } = params; //determines if the update came from the server or local cached storage
|
||
|
||
//Check for a feature
|
||
// if (flagsmith.hasFeature('my_cool_feature')) {
|
||
// myCoolFeature();
|
||
// }
|
||
|
||
// console.log(oldFlags)
|
||
// console.log(params)
|
||
|
||
//Or, use the value of a feature
|
||
// const bannerSize = flagsmith.getValue('banner_size');
|
||
|
||
//Check whether value has changed
|
||
// const bannerSizeOld = oldFlags['banner_size'] && oldFlags['banner_size'].value;
|
||
// if (bannerSize !== bannerSizeOld) {
|
||
// // Do something!
|
||
// }
|
||
},
|
||
});
|
||
|
||
}
|
||
|
||
hasFeature(feature,yesCb,noCb){
|
||
if (flagsmith.hasFeature(feature)) {
|
||
yesCb();
|
||
}else{
|
||
if(noCb) noCb();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
function _func_update_web_hosting(self,opts,cb){
|
||
let template = self.config.json.catalog.archive.templates.domain;
|
||
template.id = opts.id;
|
||
self.config.member.json_data.registry.catalog.archive.alloc.domains.push(template);
|
||
self.config.member.json_data.registry.catalog.archive.alloc.websites.hosting.count += opts.count;
|
||
|
||
// console.log(self.config.member);
|
||
self.apicall("/v1/core/member_update",{
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/json'
|
||
},
|
||
body: JSON.stringify({data: self.config.member})
|
||
},function(config){
|
||
// console.log(config);
|
||
if(cb!=undefined) cb();
|
||
});
|
||
}
|
||
|
||
|
||
return {MemberManagementSystem};
|
||
})));
|
||
|
||
|
||
|
||
function RunAccessControlMaker(){
|
||
|
||
/**
|
||
* LICENSE
|
||
*
|
||
* The MIT License
|
||
|
||
Copyright (c) 2017-2019, Onur Yıldırım <onur@cutepilot.com>. All rights reserved.
|
||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
of this software and associated documentation files (the "Software"), to deal
|
||
in the Software without restriction, including without limitation the rights
|
||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
copies of the Software, and to permit persons to whom the Software is
|
||
furnished to do so, subject to the following conditions:
|
||
|
||
The above copyright notice and this permission notice shall be included in
|
||
all copies or substantial portions of the Software.
|
||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||
THE SOFTWARE.
|
||
*
|
||
*
|
||
*/
|
||
/******/ (() => { // webpackBootstrap
|
||
/******/ var __webpack_modules__ = ({
|
||
|
||
/***/ "./node_modules/accesscontrol/index.js":
|
||
/*!*********************************************!*\
|
||
!*** ./node_modules/accesscontrol/index.js ***!
|
||
\*********************************************/
|
||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||
|
||
var AC = (__webpack_require__(/*! ./lib */ "./node_modules/accesscontrol/lib/index.js").AccessControl);
|
||
module.exports = AC;
|
||
// adding circular ref to allow easy importing in both ES5/6 and TS projects
|
||
module.exports.AccessControl = AC;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/AccessControl.js":
|
||
/*!*********************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/AccessControl.js ***!
|
||
\*********************************************************/
|
||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
var core_1 = __webpack_require__(/*! ./core */ "./node_modules/accesscontrol/lib/core/index.js");
|
||
var enums_1 = __webpack_require__(/*! ./enums */ "./node_modules/accesscontrol/lib/enums/index.js");
|
||
var utils_1 = __webpack_require__(/*! ./utils */ "./node_modules/accesscontrol/lib/utils.js");
|
||
/**
|
||
* @classdesc
|
||
* AccessControl class that implements RBAC (Role-Based Access Control) basics
|
||
* and ABAC (Attribute-Based Access Control) <i>resource</i> and <i>action</i>
|
||
* attributes.
|
||
*
|
||
* Construct an `AccessControl` instance by either passing a grants object (or
|
||
* array fetched from database) or simply omit `grants` parameter if you are
|
||
* willing to build it programmatically.
|
||
*
|
||
* <p><pre><code> const grants = {
|
||
* role1: {
|
||
* resource1: {
|
||
* "create:any": [ attrs ],
|
||
* "read:own": [ attrs ]
|
||
* },
|
||
* resource2: {
|
||
* "create:any": [ attrs ],
|
||
* "update:own": [ attrs ]
|
||
* }
|
||
* },
|
||
* role2: { ... }
|
||
* };
|
||
* const ac = new AccessControl(grants);</code></pre></p>
|
||
*
|
||
* The `grants` object can also be an array, such as a flat list
|
||
* fetched from a database.
|
||
*
|
||
* <p><pre><code> const flatList = [
|
||
* { role: 'role1', resource: 'resource1', action: 'create:any', attributes: [ attrs ] },
|
||
* { role: 'role1', resource: 'resource1', action: 'read:own', attributes: [ attrs ] },
|
||
* { role: 'role2', ... },
|
||
* ...
|
||
* ];</code></pre></p>
|
||
*
|
||
* We turn this list into a hashtable for better performance. We aggregate
|
||
* the list by roles first, resources second. If possession (in action
|
||
* value or as a separate property) is omitted, it will default to `"any"`.
|
||
* e.g. `"create"` ➞ `"create:any"`
|
||
*
|
||
* Below are equivalent:
|
||
* <p><pre><code> const grants = { role: 'role1', resource: 'resource1', action: 'create:any', attributes: [ attrs ] }
|
||
* const same = { role: 'role1', resource: 'resource1', action: 'create', possession: 'any', attributes: [ attrs ] }</code></pre></p>
|
||
*
|
||
* So we can also initialize with this flat list of grants:
|
||
* <p><pre><code> const ac = new AccessControl(flatList);
|
||
* console.log(ac.getGrants());</code></pre></p>
|
||
*
|
||
* @author Onur Yıldırım <onur@cutepilot.com>
|
||
* @license MIT
|
||
*
|
||
* @class
|
||
* @global
|
||
*
|
||
* @example
|
||
* const ac = new AccessControl(grants);
|
||
*
|
||
* ac.grant('admin').createAny('profile');
|
||
*
|
||
* // or you can chain methods
|
||
* ac.grant('admin')
|
||
* .createAny('profile')
|
||
* .readAny('profile', ["*", "!password"])
|
||
* .readAny('video')
|
||
* .deleteAny('video');
|
||
*
|
||
* // since these permissions have common resources, there is an alternative way:
|
||
* ac.grant('admin')
|
||
* .resource('profile').createAny().readAny(null, ["*", "!password"])
|
||
* .resource('video').readAny()..deleteAny();
|
||
*
|
||
* ac.grant('user')
|
||
* .readOwn('profile', ["uid", "email", "address.*", "account.*", "!account.roles"])
|
||
* .updateOwn('profile', ["uid", "email", "password", "address.*", "!account.roles"])
|
||
* .deleteOwn('profile')
|
||
* .createOwn('video', ["*", "!geo.*"])
|
||
* .readAny('video')
|
||
* .updateOwn('video', ["*", "!geo.*"])
|
||
* .deleteOwn('video');
|
||
*
|
||
* // now we can check for granted or denied permissions
|
||
* const permission = ac.can('admin').readAny('profile');
|
||
* permission.granted // true
|
||
* permission.attributes // ["*", "!password"]
|
||
* permission.filter(data) // { uid, email, address, account }
|
||
* // deny permission
|
||
* ac.deny('admin').createAny('profile');
|
||
* ac.can('admin').createAny('profile').granted; // false
|
||
*
|
||
* // To add a grant but deny access via attributes
|
||
* ac.grant('admin').createAny('profile', []); // no attributes allowed
|
||
* ac.can('admin').createAny('profile').granted; // false
|
||
*
|
||
* // To prevent any more changes:
|
||
* ac.lock();
|
||
*/
|
||
var AccessControl = /** @class */ (function () {
|
||
/**
|
||
* Initializes a new instance of `AccessControl` with the given grants.
|
||
* @ignore
|
||
*
|
||
* @param {Object|Array} [grants] - A list containing the access grant
|
||
* definitions. See the structure of this object in the examples.
|
||
*/
|
||
function AccessControl(grants) {
|
||
/**
|
||
* @private
|
||
*/
|
||
this._isLocked = false;
|
||
// explicit undefined is not allowed
|
||
if (arguments.length === 0)
|
||
grants = {};
|
||
this.setGrants(grants);
|
||
}
|
||
Object.defineProperty(AccessControl.prototype, "isLocked", {
|
||
// -------------------------------
|
||
// PUBLIC PROPERTIES
|
||
// -------------------------------
|
||
/**
|
||
* Specifies whether the underlying grants object is frozen and all
|
||
* functionality for modifying it is disabled.
|
||
* @name AccessControl#isLocked
|
||
* @type {Boolean}
|
||
*/
|
||
get: function () {
|
||
return this._isLocked && Object.isFrozen(this._grants);
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
// -------------------------------
|
||
// PUBLIC METHODS
|
||
// -------------------------------
|
||
/**
|
||
* Gets the internal grants object that stores all current grants.
|
||
*
|
||
* @return {Object} - Hash-map of grants.
|
||
*
|
||
* @example
|
||
* ac.grant('admin')
|
||
* .createAny(['profile', 'video'])
|
||
* .deleteAny(['profile', 'video'])
|
||
* .readAny(['video'])
|
||
* .readAny('profile', ['*', '!password'])
|
||
* .grant('user')
|
||
* .readAny(['profile', 'video'], ['*', '!id', '!password'])
|
||
* .createOwn(['profile', 'video'])
|
||
* .deleteOwn(['video']);
|
||
* // logging underlying grants model
|
||
* console.log(ac.getGrants());
|
||
* // outputs:
|
||
* {
|
||
* "admin": {
|
||
* "profile": {
|
||
* "create:any": ["*"],
|
||
* "delete:any": ["*"],
|
||
* "read:any": ["*", "!password"]
|
||
* },
|
||
* "video": {
|
||
* "create:any": ["*"],
|
||
* "delete:any": ["*"],
|
||
* "read:any": ["*"]
|
||
* }
|
||
* },
|
||
* "user": {
|
||
* "profile": {
|
||
* "read:any": ["*", "!id", "!password"],
|
||
* "create:own": ["*"]
|
||
* },
|
||
* "video": {
|
||
* "read:any": ["*", "!id", "!password"],
|
||
* "create:own": ["*"],
|
||
* "delete:own": ["*"]
|
||
* }
|
||
* }
|
||
* }
|
||
*/
|
||
AccessControl.prototype.getGrants = function () {
|
||
return this._grants;
|
||
};
|
||
/**
|
||
* Sets all access grants at once, from an object or array. Note that this
|
||
* will reset the object and remove all previous grants.
|
||
* @chainable
|
||
*
|
||
* @param {Object|Array} grantsObject - A list containing the access grant
|
||
* definitions.
|
||
*
|
||
* @returns {AccessControl} - `AccessControl` instance for chaining.
|
||
*
|
||
* @throws {AccessControlError} - If called after `.lock()` is called or if
|
||
* passed grants object fails inspection.
|
||
*/
|
||
AccessControl.prototype.setGrants = function (grantsObject) {
|
||
if (this.isLocked)
|
||
throw new core_1.AccessControlError(utils_1.ERR_LOCK);
|
||
this._grants = utils_1.utils.getInspectedGrants(grantsObject);
|
||
return this;
|
||
};
|
||
/**
|
||
* Resets the internal grants object and removes all previous grants.
|
||
* @chainable
|
||
*
|
||
* @returns {AccessControl} - `AccessControl` instance for chaining.
|
||
*
|
||
* @throws {AccessControlError} - If called after `.lock()` is called.
|
||
*/
|
||
AccessControl.prototype.reset = function () {
|
||
if (this.isLocked)
|
||
throw new core_1.AccessControlError(utils_1.ERR_LOCK);
|
||
this._grants = {};
|
||
return this;
|
||
};
|
||
/**
|
||
* Freezes the underlying grants model and disables all functionality for
|
||
* modifying it. This is useful when you want to restrict any changes. Any
|
||
* attempts to modify (such as `#setGrants()`, `#reset()`, `#grant()`,
|
||
* `#deny()`, etc) will throw after grants are locked. Note that <b>there
|
||
* is no `unlock()` method</b>. It's like you lock the door and swallow the
|
||
* key. ;)
|
||
*
|
||
* Remember that this does not prevent the `AccessControl` instance from
|
||
* being altered/replaced. Only the grants inner object is locked.
|
||
*
|
||
* <b>A note about performance</b>: This uses recursive `Object.freeze()`.
|
||
* In NodeJS & V8, enumeration performance is not impacted because of this.
|
||
* In fact, it increases the performance because of V8 optimization.
|
||
* @chainable
|
||
*
|
||
* @returns {AccessControl} - `AccessControl` instance for chaining.
|
||
*
|
||
* @example
|
||
* ac.grant('admin').create('product');
|
||
* ac.lock(); // called on the AccessControl instance.
|
||
* // or
|
||
* ac.grant('admin').create('product').lock(); // called on the chained Access instance.
|
||
*
|
||
* // After this point, any attempt of modification will throw
|
||
* ac.setGrants({}); // throws
|
||
* ac.grant('user'); // throws..
|
||
* // underlying grants model is not changed
|
||
*/
|
||
AccessControl.prototype.lock = function () {
|
||
utils_1.utils.lockAC(this);
|
||
return this;
|
||
};
|
||
/**
|
||
* Extends the given role(s) with privileges of one or more other roles.
|
||
* @chainable
|
||
*
|
||
* @param {string|Array<String>} roles Role(s) to be extended. Single role
|
||
* as a `String` or multiple roles as an `Array`. Note that if a
|
||
* role does not exist, it will be automatically created.
|
||
*
|
||
* @param {string|Array<String>} extenderRoles Role(s) to inherit from.
|
||
* Single role as a `String` or multiple roles as an `Array`. Note
|
||
* that if a extender role does not exist, it will throw.
|
||
*
|
||
* @returns {AccessControl} - `AccessControl` instance for chaining.
|
||
*
|
||
* @throws {AccessControlError} - If a role is extended by itself or a
|
||
* non-existent role. Or if called after `.lock()` is called.
|
||
*/
|
||
AccessControl.prototype.extendRole = function (roles, extenderRoles) {
|
||
if (this.isLocked)
|
||
throw new core_1.AccessControlError(utils_1.ERR_LOCK);
|
||
utils_1.utils.extendRole(this._grants, roles, extenderRoles);
|
||
return this;
|
||
};
|
||
/**
|
||
* Removes all the given role(s) and their granted permissions, at once.
|
||
* @chainable
|
||
*
|
||
* @param {string|Array<String>} roles - An array of roles to be removed.
|
||
* Also accepts a string that can be used to remove a single role.
|
||
*
|
||
* @returns {AccessControl} - `AccessControl` instance for chaining.
|
||
*
|
||
* @throws {AccessControlError} - If called after `.lock()` is called.
|
||
*/
|
||
AccessControl.prototype.removeRoles = function (roles) {
|
||
var _this = this;
|
||
if (this.isLocked)
|
||
throw new core_1.AccessControlError(utils_1.ERR_LOCK);
|
||
var rolesToRemove = utils_1.utils.toStringArray(roles);
|
||
if (rolesToRemove.length === 0 || !utils_1.utils.isFilledStringArray(rolesToRemove)) {
|
||
throw new core_1.AccessControlError("Invalid role(s): " + JSON.stringify(roles));
|
||
}
|
||
rolesToRemove.forEach(function (roleName) {
|
||
if (!_this._grants[roleName]) {
|
||
throw new core_1.AccessControlError("Cannot remove a non-existing role: \"" + roleName + "\"");
|
||
}
|
||
delete _this._grants[roleName];
|
||
});
|
||
// also remove these roles from $extend list of each remaining role.
|
||
utils_1.utils.eachRole(this._grants, function (roleItem, roleName) {
|
||
if (Array.isArray(roleItem.$extend)) {
|
||
roleItem.$extend = utils_1.utils.subtractArray(roleItem.$extend, rolesToRemove);
|
||
}
|
||
});
|
||
return this;
|
||
};
|
||
/**
|
||
* Removes all the given resources for all roles, at once.
|
||
* Pass the `roles` argument to remove access to resources for those
|
||
* roles only.
|
||
* @chainable
|
||
*
|
||
* @param {string|Array<String>} resources - A single or array of resources to
|
||
* be removed.
|
||
* @param {string|Array<String>} [roles] - A single or array of roles to
|
||
* be removed. If omitted, permissions for all roles to all given
|
||
* resources will be removed.
|
||
*
|
||
* @returns {AccessControl} - `AccessControl` instance for chaining.
|
||
*
|
||
* @throws {AccessControlError} - If called after `.lock()` is called.
|
||
*/
|
||
AccessControl.prototype.removeResources = function (resources, roles) {
|
||
if (this.isLocked)
|
||
throw new core_1.AccessControlError(utils_1.ERR_LOCK);
|
||
// _removePermission has a third argument `actionPossession`. if
|
||
// omitted (like below), removes the parent resource object.
|
||
this._removePermission(resources, roles);
|
||
return this;
|
||
};
|
||
/**
|
||
* Gets all the unique roles that have at least one access information.
|
||
*
|
||
* @returns {Array<String>}
|
||
*
|
||
* @example
|
||
* ac.grant('admin, user').createAny('video').grant('user').readOwn('profile');
|
||
* console.log(ac.getRoles()); // ["admin", "user"]
|
||
*/
|
||
AccessControl.prototype.getRoles = function () {
|
||
return Object.keys(this._grants);
|
||
};
|
||
/**
|
||
* Gets the list of inherited roles by the given role.
|
||
* @name AccessControl#getInheritedRolesOf
|
||
* @alias AccessControl#getExtendedRolesOf
|
||
* @function
|
||
*
|
||
* @param {string} role - Target role name.
|
||
*
|
||
* @returns {Array<String>}
|
||
*/
|
||
AccessControl.prototype.getInheritedRolesOf = function (role) {
|
||
var roles = utils_1.utils.getRoleHierarchyOf(this._grants, role);
|
||
roles.shift();
|
||
return roles;
|
||
};
|
||
/**
|
||
* Alias of `getInheritedRolesOf`
|
||
* @private
|
||
*/
|
||
AccessControl.prototype.getExtendedRolesOf = function (role) {
|
||
return this.getInheritedRolesOf(role);
|
||
};
|
||
/**
|
||
* Gets all the unique resources that are granted access for at
|
||
* least one role.
|
||
*
|
||
* @returns {Array<String>}
|
||
*/
|
||
AccessControl.prototype.getResources = function () {
|
||
return utils_1.utils.getResources(this._grants);
|
||
};
|
||
/**
|
||
* Checks whether the grants include the given role or roles.
|
||
*
|
||
* @param {string|string[]} role - Role to be checked. You can also pass an
|
||
* array of strings to check multiple roles at once.
|
||
*
|
||
* @returns {Boolean}
|
||
*/
|
||
AccessControl.prototype.hasRole = function (role) {
|
||
var _this = this;
|
||
if (Array.isArray(role)) {
|
||
return role.every(function (item) { return _this._grants.hasOwnProperty(item); });
|
||
}
|
||
return this._grants.hasOwnProperty(role);
|
||
};
|
||
/**
|
||
* Checks whether grants include the given resource or resources.
|
||
*
|
||
* @param {string|string[]} resource - Resource to be checked. You can also pass an
|
||
* array of strings to check multiple resources at once.
|
||
*
|
||
* @returns {Boolean}
|
||
*/
|
||
AccessControl.prototype.hasResource = function (resource) {
|
||
var resources = this.getResources();
|
||
if (Array.isArray(resource)) {
|
||
return resource.every(function (item) { return resources.indexOf(item) >= 0; });
|
||
}
|
||
if (typeof resource !== 'string' || resource === '')
|
||
return false;
|
||
return resources.indexOf(resource) >= 0;
|
||
};
|
||
/**
|
||
* Gets an instance of `Query` object. This is used to check whether the
|
||
* defined access is allowed for the given role(s) and resource. This
|
||
* object provides chainable methods to define and query the access
|
||
* permissions to be checked.
|
||
* @name AccessControl#can
|
||
* @alias AccessControl#query
|
||
* @function
|
||
* @chainable
|
||
*
|
||
* @param {string|Array|IQueryInfo} role - A single role (as a string), a
|
||
* list of roles (as an array) or an
|
||
* {@link ?api=ac#AccessControl~IQueryInfo|`IQueryInfo` object} that fully
|
||
* or partially defines the access to be checked.
|
||
*
|
||
* @returns {Query} - The returned object provides chainable methods to
|
||
* define and query the access permissions to be checked. See
|
||
* {@link ?api=ac#AccessControl~Query|`Query` inner class}.
|
||
*
|
||
* @example
|
||
* const ac = new AccessControl(grants);
|
||
*
|
||
* ac.can('admin').createAny('profile');
|
||
* // equivalent to:
|
||
* ac.can().role('admin').createAny('profile');
|
||
* // equivalent to:
|
||
* ac.can().role('admin').resource('profile').createAny();
|
||
*
|
||
* // To check for multiple roles:
|
||
* ac.can(['admin', 'user']).createOwn('profile');
|
||
* // Note: when multiple roles checked, acquired attributes are unioned (merged).
|
||
*/
|
||
AccessControl.prototype.can = function (role) {
|
||
// throw on explicit undefined
|
||
if (arguments.length !== 0 && role === undefined) {
|
||
throw new core_1.AccessControlError('Invalid role(s): undefined');
|
||
}
|
||
// other explicit invalid values will be checked in constructor.
|
||
return new core_1.Query(this._grants, role);
|
||
};
|
||
/**
|
||
* Alias of `can()`.
|
||
* @private
|
||
*/
|
||
AccessControl.prototype.query = function (role) {
|
||
return this.can(role);
|
||
};
|
||
/**
|
||
* Gets an instance of `Permission` object that checks and defines the
|
||
* granted access permissions for the target resource and role. Normally
|
||
* you would use `AccessControl#can()` method to check for permissions but
|
||
* this is useful if you need to check at once by passing a `IQueryInfo`
|
||
* object; instead of chaining methods (as in
|
||
* `.can(<role>).<action>(<resource>)`).
|
||
*
|
||
* @param {IQueryInfo} queryInfo - A fulfilled
|
||
* {@link ?api=ac#AccessControl~IQueryInfo|`IQueryInfo` object}.
|
||
*
|
||
* @returns {Permission} - An object that provides properties and methods
|
||
* that defines the granted access permissions. See
|
||
* {@link ?api=ac#AccessControl~Permission|`Permission` inner class}.
|
||
*
|
||
* @example
|
||
* const ac = new AccessControl(grants);
|
||
* const permission = ac.permission({
|
||
* role: "user",
|
||
* action: "update:own",
|
||
* resource: "profile"
|
||
* });
|
||
* permission.granted; // Boolean
|
||
* permission.attributes; // Array e.g. [ 'username', 'password', 'company.*']
|
||
* permission.filter(object); // { username, password, company: { name, address, ... } }
|
||
*/
|
||
AccessControl.prototype.permission = function (queryInfo) {
|
||
return new core_1.Permission(this._grants, queryInfo);
|
||
};
|
||
/**
|
||
* Gets an instance of `Grant` (inner) object. This is used to grant access
|
||
* to specified resource(s) for the given role(s).
|
||
* @name AccessControl#grant
|
||
* @alias AccessControl#allow
|
||
* @function
|
||
* @chainable
|
||
*
|
||
* @param {string|Array<String>|IAccessInfo} [role] A single role (as a
|
||
* string), a list of roles (as an array) or an
|
||
* {@link ?api=ac#AccessControl~IAccessInfo|`IAccessInfo` object} that
|
||
* fully or partially defines the access to be granted. This can be omitted
|
||
* and chained with `.role()` to define the role.
|
||
*
|
||
* @return {Access} - The returned object provides chainable properties to
|
||
* build and define the access to be granted. See the examples for details.
|
||
* See {@link ?api=ac#AccessControl~Access|`Access` inner class}.
|
||
*
|
||
* @throws {AccessControlError} - If `role` is explicitly set to an invalid value.
|
||
* @throws {AccessControlError} - If called after `.lock()` is called.
|
||
*
|
||
* @example
|
||
* const ac = new AccessControl();
|
||
* let attributes = ['*'];
|
||
*
|
||
* ac.grant('admin').createAny('profile', attributes);
|
||
* // equivalent to:
|
||
* ac.grant().role('admin').createAny('profile', attributes);
|
||
* // equivalent to:
|
||
* ac.grant().role('admin').resource('profile').createAny(null, attributes);
|
||
* // equivalent to:
|
||
* ac.grant({
|
||
* role: 'admin',
|
||
* resource: 'profile',
|
||
* }).createAny(null, attributes);
|
||
* // equivalent to:
|
||
* ac.grant({
|
||
* role: 'admin',
|
||
* resource: 'profile',
|
||
* action: 'create:any',
|
||
* attributes: attributes
|
||
* });
|
||
* // equivalent to:
|
||
* ac.grant({
|
||
* role: 'admin',
|
||
* resource: 'profile',
|
||
* action: 'create',
|
||
* possession: 'any', // omitting this will default to 'any'
|
||
* attributes: attributes
|
||
* });
|
||
*
|
||
* // To grant same resource and attributes for multiple roles:
|
||
* ac.grant(['admin', 'user']).createOwn('profile', attributes);
|
||
*
|
||
* // Note: when attributes is omitted, it will default to `['*']`
|
||
* // which means all attributes (of the resource) are allowed.
|
||
*/
|
||
AccessControl.prototype.grant = function (role) {
|
||
if (this.isLocked)
|
||
throw new core_1.AccessControlError(utils_1.ERR_LOCK);
|
||
// throw on explicit undefined
|
||
if (arguments.length !== 0 && role === undefined) {
|
||
throw new core_1.AccessControlError('Invalid role(s): undefined');
|
||
}
|
||
// other explicit invalid values will be checked in constructor.
|
||
return new core_1.Access(this, role, false);
|
||
};
|
||
/**
|
||
* Alias of `grant()`.
|
||
* @private
|
||
*/
|
||
AccessControl.prototype.allow = function (role) {
|
||
return this.grant(role);
|
||
};
|
||
/**
|
||
* Gets an instance of `Access` object. This is used to deny access to
|
||
* specified resource(s) for the given role(s). Denying will only remove a
|
||
* previously created grant. So if not granted before, you don't need to
|
||
* deny an access.
|
||
* @name AccessControl#deny
|
||
* @alias AccessControl#reject
|
||
* @function
|
||
* @chainable
|
||
*
|
||
* @param {string|Array<String>|IAccessInfo} role A single role (as a
|
||
* string), a list of roles (as an array) or an
|
||
* {@link ?api=ac#AccessControl~IAccessInfo|`IAccessInfo` object} that
|
||
* fully or partially defines the access to be denied.
|
||
*
|
||
* @return {Access} The returned object provides chainable properties to
|
||
* build and define the access to be granted. See
|
||
* {@link ?api=ac#AccessControl~Access|`Access` inner class}.
|
||
*
|
||
* @throws {AccessControlError} - If `role` is explicitly set to an invalid value.
|
||
* @throws {AccessControlError} - If called after `.lock()` is called.
|
||
*
|
||
* @example
|
||
* const ac = new AccessControl();
|
||
*
|
||
* ac.deny('admin').createAny('profile');
|
||
* // equivalent to:
|
||
* ac.deny().role('admin').createAny('profile');
|
||
* // equivalent to:
|
||
* ac.deny().role('admin').resource('profile').createAny();
|
||
* // equivalent to:
|
||
* ac.deny({
|
||
* role: 'admin',
|
||
* resource: 'profile',
|
||
* }).createAny();
|
||
* // equivalent to:
|
||
* ac.deny({
|
||
* role: 'admin',
|
||
* resource: 'profile',
|
||
* action: 'create:any'
|
||
* });
|
||
* // equivalent to:
|
||
* ac.deny({
|
||
* role: 'admin',
|
||
* resource: 'profile',
|
||
* action: 'create',
|
||
* possession: 'any' // omitting this will default to 'any'
|
||
* });
|
||
*
|
||
* // To deny same resource for multiple roles:
|
||
* ac.deny(['admin', 'user']).createOwn('profile');
|
||
*/
|
||
AccessControl.prototype.deny = function (role) {
|
||
if (this.isLocked)
|
||
throw new core_1.AccessControlError(utils_1.ERR_LOCK);
|
||
// throw on explicit undefined
|
||
if (arguments.length !== 0 && role === undefined) {
|
||
throw new core_1.AccessControlError('Invalid role(s): undefined');
|
||
}
|
||
// other explicit invalid values will be checked in constructor.
|
||
return new core_1.Access(this, role, true);
|
||
};
|
||
/**
|
||
* Alias of `deny()`.
|
||
* @private
|
||
*/
|
||
AccessControl.prototype.reject = function (role) {
|
||
return this.deny(role);
|
||
};
|
||
// -------------------------------
|
||
// PRIVATE METHODS
|
||
// -------------------------------
|
||
/**
|
||
* @private
|
||
*/
|
||
AccessControl.prototype._removePermission = function (resources, roles, actionPossession) {
|
||
var _this = this;
|
||
resources = utils_1.utils.toStringArray(resources);
|
||
// resources is set but returns empty array.
|
||
if (resources.length === 0 || !utils_1.utils.isFilledStringArray(resources)) {
|
||
throw new core_1.AccessControlError("Invalid resource(s): " + JSON.stringify(resources));
|
||
}
|
||
if (roles !== undefined) {
|
||
roles = utils_1.utils.toStringArray(roles);
|
||
// roles is set but returns empty array.
|
||
if (roles.length === 0 || !utils_1.utils.isFilledStringArray(roles)) {
|
||
throw new core_1.AccessControlError("Invalid role(s): " + JSON.stringify(roles));
|
||
}
|
||
}
|
||
utils_1.utils.eachRoleResource(this._grants, function (role, resource, permissions) {
|
||
if (resources.indexOf(resource) >= 0
|
||
// roles is optional. so remove if role is not defined.
|
||
// if defined, check if the current role is in the list.
|
||
&& (!roles || roles.indexOf(role) >= 0)) {
|
||
if (actionPossession) {
|
||
// e.g. 'create' » 'create:any'
|
||
// to parse and normalize actionPossession string:
|
||
var ap = utils_1.utils.normalizeActionPossession({ action: actionPossession }, true);
|
||
// above will also validate the given actionPossession
|
||
delete _this._grants[role][resource][ap];
|
||
}
|
||
else {
|
||
// this is used for AccessControl#removeResources().
|
||
delete _this._grants[role][resource];
|
||
}
|
||
}
|
||
});
|
||
};
|
||
Object.defineProperty(AccessControl, "Action", {
|
||
// -------------------------------
|
||
// PUBLIC STATIC PROPERTIES
|
||
// -------------------------------
|
||
/**
|
||
* Documented separately in enums/Action
|
||
* @private
|
||
*/
|
||
get: function () {
|
||
return enums_1.Action;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
Object.defineProperty(AccessControl, "Possession", {
|
||
/**
|
||
* Documented separately in enums/Possession
|
||
* @private
|
||
*/
|
||
get: function () {
|
||
return enums_1.Possession;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
Object.defineProperty(AccessControl, "Error", {
|
||
/**
|
||
* Documented separately in AccessControlError
|
||
* @private
|
||
*/
|
||
get: function () {
|
||
return core_1.AccessControlError;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
// -------------------------------
|
||
// PUBLIC STATIC METHODS
|
||
// -------------------------------
|
||
/**
|
||
* A utility method for deep cloning the given data object(s) while
|
||
* filtering its properties by the given attribute (glob) notations.
|
||
* Includes all matched properties and removes the rest.
|
||
*
|
||
* Note that this should be used to manipulate data / arbitrary objects
|
||
* with enumerable properties. It will not deal with preserving the
|
||
* prototype-chain of the given object.
|
||
*
|
||
* @param {Object|Array} data - A single or array of data objects
|
||
* to be filtered.
|
||
* @param {Array|String} attributes - The attribute glob notation(s)
|
||
* to be processed. You can use wildcard stars (*) and negate
|
||
* the notation by prepending a bang (!). A negated notation
|
||
* will be excluded. Order of the globs do not matter, they will
|
||
* be logically sorted. Loose globs will be processed first and
|
||
* verbose globs or normal notations will be processed last.
|
||
* e.g. `[ "car.model", "*", "!car.*" ]`
|
||
* will be sorted as:
|
||
* `[ "*", "!car.*", "car.model" ]`.
|
||
* Passing no parameters or passing an empty string (`""` or `[""]`)
|
||
* will empty the source object.
|
||
*
|
||
* @returns {Object|Array} - Returns the filtered data object or array
|
||
* of data objects.
|
||
*
|
||
* @example
|
||
* var assets = { notebook: "Mac", car: { brand: "Ford", model: "Mustang", year: 1970, color: "red" } };
|
||
*
|
||
* var filtered = AccessControl.filter(assets, [ "*", "!car.*", "car.model" ]);
|
||
* console.log(assets); // { notebook: "Mac", car: { model: "Mustang" } }
|
||
*
|
||
* filtered = AccessControl.filter(assets, "*"); // or AccessControl.filter(assets, ["*"]);
|
||
* console.log(assets); // { notebook: "Mac", car: { model: "Mustang" } }
|
||
*
|
||
* filtered = AccessControl.filter(assets); // or AccessControl.filter(assets, "");
|
||
* console.log(assets); // {}
|
||
*/
|
||
AccessControl.filter = function (data, attributes) {
|
||
return utils_1.utils.filterAll(data, attributes);
|
||
};
|
||
/**
|
||
* Checks whether the given object is an instance of `AccessControl.Error`.
|
||
* @name AccessControl.isACError
|
||
* @alias AccessControl.isAccessControlError
|
||
* @function
|
||
*
|
||
* @param {Any} object
|
||
* Object to be checked.
|
||
*
|
||
* @returns {Boolean}
|
||
*/
|
||
AccessControl.isACError = function (object) {
|
||
return object instanceof core_1.AccessControlError;
|
||
};
|
||
/**
|
||
* Alias of `isACError`
|
||
* @private
|
||
*/
|
||
AccessControl.isAccessControlError = function (object) {
|
||
return AccessControl.isACError(object);
|
||
};
|
||
return AccessControl;
|
||
}());
|
||
exports.AccessControl = AccessControl;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/core/Access.js":
|
||
/*!*******************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/core/Access.js ***!
|
||
\*******************************************************/
|
||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
var core_1 = __webpack_require__(/*! ../core */ "./node_modules/accesscontrol/lib/core/index.js");
|
||
var enums_1 = __webpack_require__(/*! ../enums */ "./node_modules/accesscontrol/lib/enums/index.js");
|
||
var utils_1 = __webpack_require__(/*! ../utils */ "./node_modules/accesscontrol/lib/utils.js");
|
||
/**
|
||
* Represents the inner `Access` class that helps build an access information
|
||
* to be granted or denied; and finally commits it to the underlying grants
|
||
* model. You can get a first instance of this class by calling
|
||
* `AccessControl#grant()` or `AccessControl#deny()` methods.
|
||
* @class
|
||
* @inner
|
||
* @memberof AccessControl
|
||
*/
|
||
var Access = /** @class */ (function () {
|
||
/**
|
||
* Initializes a new instance of `Access`.
|
||
* @private
|
||
*
|
||
* @param {AccessControl} ac
|
||
* AccessControl instance.
|
||
* @param {String|Array<String>|IAccessInfo} [roleOrInfo]
|
||
* Either an `IAccessInfo` object, a single or an array of
|
||
* roles. If an object is passed, possession and attributes
|
||
* properties are optional. CAUTION: if attributes is omitted,
|
||
* and access is not denied, it will default to `["*"]` which means
|
||
* "all attributes allowed". If possession is omitted, it will
|
||
* default to `"any"`.
|
||
* @param {Boolean} denied
|
||
* Specifies whether this `Access` is denied.
|
||
*/
|
||
function Access(ac, roleOrInfo, denied) {
|
||
if (denied === void 0) { denied = false; }
|
||
/**
|
||
* Inner `IAccessInfo` object.
|
||
* @protected
|
||
* @type {IAccessInfo}
|
||
*/
|
||
this._ = {};
|
||
this._ac = ac;
|
||
this._grants = ac._grants;
|
||
this._.denied = denied;
|
||
if (typeof roleOrInfo === 'string' || Array.isArray(roleOrInfo)) {
|
||
this.role(roleOrInfo);
|
||
}
|
||
else if (utils_1.utils.type(roleOrInfo) === 'object') {
|
||
if (Object.keys(roleOrInfo).length === 0) {
|
||
throw new core_1.AccessControlError('Invalid IAccessInfo: {}');
|
||
}
|
||
// if an IAccessInfo instance is passed and it has 'action' defined, we
|
||
// should directly commit it to grants.
|
||
roleOrInfo.denied = denied;
|
||
this._ = utils_1.utils.resetAttributes(roleOrInfo);
|
||
if (utils_1.utils.isInfoFulfilled(this._))
|
||
utils_1.utils.commitToGrants(this._grants, this._, true);
|
||
}
|
||
else if (roleOrInfo !== undefined) {
|
||
// undefined is allowed (`roleOrInfo` can be omitted) but throw if
|
||
// some other type is passed.
|
||
throw new core_1.AccessControlError('Invalid role(s), expected a valid string, string[] or IAccessInfo.');
|
||
}
|
||
}
|
||
Object.defineProperty(Access.prototype, "denied", {
|
||
// -------------------------------
|
||
// PUBLIC PROPERTIES
|
||
// -------------------------------
|
||
/**
|
||
* Specifies whether this access is initally denied.
|
||
* @name AccessControl~Access#denied
|
||
* @type {Boolean}
|
||
* @readonly
|
||
*/
|
||
get: function () {
|
||
return this._.denied;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
// -------------------------------
|
||
// PUBLIC METHODS
|
||
// -------------------------------
|
||
/**
|
||
* A chainer method that sets the role(s) for this `Access` instance.
|
||
* @param {String|Array<String>} value
|
||
* A single or array of roles.
|
||
* @returns {Access}
|
||
* Self instance of `Access`.
|
||
*/
|
||
Access.prototype.role = function (value) {
|
||
// in case chain is not terminated (e.g. `ac.grant('user')`) we'll
|
||
// create/commit the roles to grants with an empty object.
|
||
utils_1.utils.preCreateRoles(this._grants, value);
|
||
this._.role = value;
|
||
return this;
|
||
};
|
||
/**
|
||
* A chainer method that sets the resource for this `Access` instance.
|
||
* @param {String|Array<String>} value
|
||
* Target resource for this `Access` instance.
|
||
* @returns {Access}
|
||
* Self instance of `Access`.
|
||
*/
|
||
Access.prototype.resource = function (value) {
|
||
// this will throw if any item fails
|
||
utils_1.utils.hasValidNames(value, true);
|
||
this._.resource = value;
|
||
return this;
|
||
};
|
||
/**
|
||
* Sets the array of allowed attributes for this `Access` instance.
|
||
* @param {String|Array<String>} value
|
||
* Attributes to be set.
|
||
* @returns {Access}
|
||
* Self instance of `Access`.
|
||
*/
|
||
Access.prototype.attributes = function (value) {
|
||
this._.attributes = value;
|
||
return this;
|
||
};
|
||
/**
|
||
* Sets the roles to be extended for this `Access` instance.
|
||
* @alias Access#inherit
|
||
* @name AccessControl~Access#extend
|
||
* @function
|
||
*
|
||
* @param {String|Array<String>} roles
|
||
* A single or array of roles.
|
||
* @returns {Access}
|
||
* Self instance of `Access`.
|
||
*
|
||
* @example
|
||
* ac.grant('user').createAny('video')
|
||
* .grant('admin').extend('user');
|
||
* const permission = ac.can('admin').createAny('video');
|
||
* console.log(permission.granted); // true
|
||
*/
|
||
Access.prototype.extend = function (roles) {
|
||
utils_1.utils.extendRole(this._grants, this._.role, roles);
|
||
return this;
|
||
};
|
||
/**
|
||
* Alias of `extend`.
|
||
* @private
|
||
*/
|
||
Access.prototype.inherit = function (roles) {
|
||
this.extend(roles);
|
||
return this;
|
||
};
|
||
/**
|
||
* Shorthand to switch to a new `Access` instance with a different role
|
||
* within the method chain.
|
||
*
|
||
* @param {String|Array<String>|IAccessInfo} [roleOrInfo]
|
||
* Either a single or an array of roles or an
|
||
* {@link ?api=ac#AccessControl~IAccessInfo|`IAccessInfo` object}.
|
||
*
|
||
* @returns {Access}
|
||
* A new `Access` instance.
|
||
*
|
||
* @example
|
||
* ac.grant('user').createOwn('video')
|
||
* .grant('admin').updateAny('video');
|
||
*/
|
||
Access.prototype.grant = function (roleOrInfo) {
|
||
return (new Access(this._ac, roleOrInfo, false)).attributes(['*']);
|
||
};
|
||
/**
|
||
* Shorthand to switch to a new `Access` instance with a different
|
||
* (or same) role within the method chain.
|
||
*
|
||
* @param {String|Array<String>|IAccessInfo} [roleOrInfo]
|
||
* Either a single or an array of roles or an
|
||
* {@link ?api=ac#AccessControl~IAccessInfo|`IAccessInfo` object}.
|
||
*
|
||
* @returns {Access}
|
||
* A new `Access` instance.
|
||
*
|
||
* @example
|
||
* ac.grant('admin').createAny('video')
|
||
* .deny('user').deleteAny('video');
|
||
*/
|
||
Access.prototype.deny = function (roleOrInfo) {
|
||
return (new Access(this._ac, roleOrInfo, true)).attributes([]);
|
||
};
|
||
/**
|
||
* Chainable, convenience shortcut for {@link ?api=ac#AccessControl#lock|`AccessControl#lock()`}.
|
||
* @returns {Access}
|
||
*/
|
||
Access.prototype.lock = function () {
|
||
utils_1.utils.lockAC(this._ac);
|
||
return this;
|
||
};
|
||
/**
|
||
* Sets the action to `"create"` and possession to `"own"` and commits the
|
||
* current access instance to the underlying grant model.
|
||
*
|
||
* @param {String|Array<String>} [resource]
|
||
* Defines the target resource this access is granted or denied for.
|
||
* This is only optional if the resource is previously defined.
|
||
* If not defined and omitted, this will throw.
|
||
* @param {String|Array<String>} [attributes]
|
||
* Defines the resource attributes for which the access is granted
|
||
* for. If access is denied previously by calling `.deny()` this
|
||
* will default to an empty array (which means no attributes allowed).
|
||
* Otherwise (if granted before via `.grant()`) this will default
|
||
* to `["*"]` (which means all attributes allowed.)
|
||
*
|
||
* @throws {AccessControlError}
|
||
* If the access instance to be committed has any invalid
|
||
* data.
|
||
*
|
||
* @returns {Access}
|
||
* Self instance of `Access` so that you can chain and define
|
||
* another access instance to be committed.
|
||
*/
|
||
Access.prototype.createOwn = function (resource, attributes) {
|
||
return this._prepareAndCommit(enums_1.Action.CREATE, enums_1.Possession.OWN, resource, attributes);
|
||
};
|
||
/**
|
||
* Sets the action to `"create"` and possession to `"any"` and commits the
|
||
* current access instance to the underlying grant model.
|
||
* @alias Access#create
|
||
* @name AccessControl~Access#createAny
|
||
* @function
|
||
*
|
||
* @param {String|Array<String>} [resource]
|
||
* Defines the target resource this access is granted or denied for.
|
||
* This is only optional if the resource is previously defined.
|
||
* If not defined and omitted, this will throw.
|
||
* @param {String|Array<String>} [attributes]
|
||
* Defines the resource attributes for which the access is granted
|
||
* for. If access is denied previously by calling `.deny()` this
|
||
* will default to an empty array (which means no attributes allowed).
|
||
* Otherwise (if granted before via `.grant()`) this will default
|
||
* to `["*"]` (which means all attributes allowed.)
|
||
*
|
||
* @throws {AccessControlError}
|
||
* If the access instance to be committed has any invalid data.
|
||
*
|
||
* @returns {Access}
|
||
* Self instance of `Access` so that you can chain and define
|
||
* another access instance to be committed.
|
||
*/
|
||
Access.prototype.createAny = function (resource, attributes) {
|
||
return this._prepareAndCommit(enums_1.Action.CREATE, enums_1.Possession.ANY, resource, attributes);
|
||
};
|
||
/**
|
||
* Alias of `createAny`
|
||
* @private
|
||
*/
|
||
Access.prototype.create = function (resource, attributes) {
|
||
return this.createAny(resource, attributes);
|
||
};
|
||
/**
|
||
* Sets the action to `"read"` and possession to `"own"` and commits the
|
||
* current access instance to the underlying grant model.
|
||
*
|
||
* @param {String|Array<String>} [resource]
|
||
* Defines the target resource this access is granted or denied for.
|
||
* This is only optional if the resource is previously defined.
|
||
* If not defined and omitted, this will throw.
|
||
* @param {String|Array<String>} [attributes]
|
||
* Defines the resource attributes for which the access is granted
|
||
* for. If access is denied previously by calling `.deny()` this
|
||
* will default to an empty array (which means no attributes allowed).
|
||
* Otherwise (if granted before via `.grant()`) this will default
|
||
* to `["*"]` (which means all attributes allowed.)
|
||
*
|
||
* @throws {AccessControlError}
|
||
* If the access instance to be committed has any invalid data.
|
||
*
|
||
* @returns {Access}
|
||
* Self instance of `Access` so that you can chain and define
|
||
* another access instance to be committed.
|
||
*/
|
||
Access.prototype.readOwn = function (resource, attributes) {
|
||
return this._prepareAndCommit(enums_1.Action.READ, enums_1.Possession.OWN, resource, attributes);
|
||
};
|
||
/**
|
||
* Sets the action to `"read"` and possession to `"any"` and commits the
|
||
* current access instance to the underlying grant model.
|
||
* @alias Access#read
|
||
* @name AccessControl~Access#readAny
|
||
* @function
|
||
*
|
||
* @param {String|Array<String>} [resource]
|
||
* Defines the target resource this access is granted or denied for.
|
||
* This is only optional if the resource is previously defined.
|
||
* If not defined and omitted, this will throw.
|
||
* @param {String|Array<String>} [attributes]
|
||
* Defines the resource attributes for which the access is granted
|
||
* for. If access is denied previously by calling `.deny()` this
|
||
* will default to an empty array (which means no attributes allowed).
|
||
* Otherwise (if granted before via `.grant()`) this will default
|
||
* to `["*"]` (which means all attributes allowed.)
|
||
*
|
||
* @throws {AccessControlError}
|
||
* If the access instance to be committed has any invalid data.
|
||
*
|
||
* @returns {Access}
|
||
* Self instance of `Access` so that you can chain and define
|
||
* another access instance to be committed.
|
||
*/
|
||
Access.prototype.readAny = function (resource, attributes) {
|
||
return this._prepareAndCommit(enums_1.Action.READ, enums_1.Possession.ANY, resource, attributes);
|
||
};
|
||
/**
|
||
* Alias of `readAny`
|
||
* @private
|
||
*/
|
||
Access.prototype.read = function (resource, attributes) {
|
||
return this.readAny(resource, attributes);
|
||
};
|
||
/**
|
||
* Sets the action to `"update"` and possession to `"own"` and commits the
|
||
* current access instance to the underlying grant model.
|
||
*
|
||
* @param {String|Array<String>} [resource]
|
||
* Defines the target resource this access is granted or denied for.
|
||
* This is only optional if the resource is previously defined.
|
||
* If not defined and omitted, this will throw.
|
||
* @param {String|Array<String>} [attributes]
|
||
* Defines the resource attributes for which the access is granted
|
||
* for. If access is denied previously by calling `.deny()` this
|
||
* will default to an empty array (which means no attributes allowed).
|
||
* Otherwise (if granted before via `.grant()`) this will default
|
||
* to `["*"]` (which means all attributes allowed.)
|
||
*
|
||
* @throws {AccessControlError}
|
||
* If the access instance to be committed has any invalid data.
|
||
*
|
||
* @returns {Access}
|
||
* Self instance of `Access` so that you can chain and define
|
||
* another access instance to be committed.
|
||
*/
|
||
Access.prototype.updateOwn = function (resource, attributes) {
|
||
return this._prepareAndCommit(enums_1.Action.UPDATE, enums_1.Possession.OWN, resource, attributes);
|
||
};
|
||
/**
|
||
* Sets the action to `"update"` and possession to `"any"` and commits the
|
||
* current access instance to the underlying grant model.
|
||
* @alias Access#update
|
||
* @name AccessControl~Access#updateAny
|
||
* @function
|
||
*
|
||
* @param {String|Array<String>} [resource]
|
||
* Defines the target resource this access is granted or denied for.
|
||
* This is only optional if the resource is previously defined.
|
||
* If not defined and omitted, this will throw.
|
||
* @param {String|Array<String>} [attributes]
|
||
* Defines the resource attributes for which the access is granted
|
||
* for. If access is denied previously by calling `.deny()` this
|
||
* will default to an empty array (which means no attributes allowed).
|
||
* Otherwise (if granted before via `.grant()`) this will default
|
||
* to `["*"]` (which means all attributes allowed.)
|
||
*
|
||
* @throws {AccessControlError}
|
||
* If the access instance to be committed has any invalid data.
|
||
*
|
||
* @returns {Access}
|
||
* Self instance of `Access` so that you can chain and define
|
||
* another access instance to be committed.
|
||
*/
|
||
Access.prototype.updateAny = function (resource, attributes) {
|
||
return this._prepareAndCommit(enums_1.Action.UPDATE, enums_1.Possession.ANY, resource, attributes);
|
||
};
|
||
/**
|
||
* Alias of `updateAny`
|
||
* @private
|
||
*/
|
||
Access.prototype.update = function (resource, attributes) {
|
||
return this.updateAny(resource, attributes);
|
||
};
|
||
/**
|
||
* Sets the action to `"delete"` and possession to `"own"` and commits the
|
||
* current access instance to the underlying grant model.
|
||
*
|
||
* @param {String|Array<String>} [resource]
|
||
* Defines the target resource this access is granted or denied for.
|
||
* This is only optional if the resource is previously defined.
|
||
* If not defined and omitted, this will throw.
|
||
* @param {String|Array<String>} [attributes]
|
||
* Defines the resource attributes for which the access is granted
|
||
* for. If access is denied previously by calling `.deny()` this
|
||
* will default to an empty array (which means no attributes allowed).
|
||
* Otherwise (if granted before via `.grant()`) this will default
|
||
* to `["*"]` (which means all attributes allowed.)
|
||
*
|
||
* @throws {AccessControlError}
|
||
* If the access instance to be committed has any invalid data.
|
||
*
|
||
* @returns {Access}
|
||
* Self instance of `Access` so that you can chain and define
|
||
* another access instance to be committed.
|
||
*/
|
||
Access.prototype.deleteOwn = function (resource, attributes) {
|
||
return this._prepareAndCommit(enums_1.Action.DELETE, enums_1.Possession.OWN, resource, attributes);
|
||
};
|
||
/**
|
||
* Sets the action to `"delete"` and possession to `"any"` and commits the
|
||
* current access instance to the underlying grant model.
|
||
* @alias Access#delete
|
||
* @name AccessControl~Access#deleteAny
|
||
* @function
|
||
*
|
||
* @param {String|Array<String>} [resource]
|
||
* Defines the target resource this access is granted or denied for.
|
||
* This is only optional if the resource is previously defined.
|
||
* If not defined and omitted, this will throw.
|
||
* @param {String|Array<String>} [attributes]
|
||
* Defines the resource attributes for which the access is granted
|
||
* for. If access is denied previously by calling `.deny()` this
|
||
* will default to an empty array (which means no attributes allowed).
|
||
* Otherwise (if granted before via `.grant()`) this will default
|
||
* to `["*"]` (which means all attributes allowed.)
|
||
*
|
||
* @throws {AccessControlError}
|
||
* If the access instance to be committed has any invalid data.
|
||
*
|
||
* @returns {Access}
|
||
* Self instance of `Access` so that you can chain and define
|
||
* another access instance to be committed.
|
||
*/
|
||
Access.prototype.deleteAny = function (resource, attributes) {
|
||
return this._prepareAndCommit(enums_1.Action.DELETE, enums_1.Possession.ANY, resource, attributes);
|
||
};
|
||
/**
|
||
* Alias of `deleteAny`
|
||
* @private
|
||
*/
|
||
Access.prototype.delete = function (resource, attributes) {
|
||
return this.deleteAny(resource, attributes);
|
||
};
|
||
// -------------------------------
|
||
// PRIVATE METHODS
|
||
// -------------------------------
|
||
/**
|
||
* @private
|
||
* @param {String} action [description]
|
||
* @param {String} possession [description]
|
||
* @param {String|Array<String>} resource [description]
|
||
* @param {String|Array<String>} attributes [description]
|
||
* @returns {Access}
|
||
* Self instance of `Access`.
|
||
*/
|
||
Access.prototype._prepareAndCommit = function (action, possession, resource, attributes) {
|
||
this._.action = action;
|
||
this._.possession = possession;
|
||
if (resource)
|
||
this._.resource = resource;
|
||
if (this._.denied) {
|
||
this._.attributes = [];
|
||
}
|
||
else {
|
||
// if omitted and not denied, all attributes are allowed
|
||
this._.attributes = attributes ? utils_1.utils.toStringArray(attributes) : ['*'];
|
||
}
|
||
utils_1.utils.commitToGrants(this._grants, this._, false);
|
||
// important: reset attributes for chained methods
|
||
this._.attributes = undefined;
|
||
return this;
|
||
};
|
||
return Access;
|
||
}());
|
||
exports.Access = Access;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/core/AccessControlError.js":
|
||
/*!*******************************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/core/AccessControlError.js ***!
|
||
\*******************************************************************/
|
||
/***/ (function(__unused_webpack_module, exports) {
|
||
|
||
"use strict";
|
||
|
||
var __extends = (this && this.__extends) || (function () {
|
||
var extendStatics = Object.setPrototypeOf ||
|
||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||
return function (d, b) {
|
||
extendStatics(d, b);
|
||
function __() { this.constructor = d; }
|
||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||
};
|
||
})();
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
/**
|
||
* Error class specific to `AccessControl`.
|
||
* @readonly
|
||
* @name AccessControl.Error
|
||
* @class
|
||
* @static
|
||
*/
|
||
var AccessControlError = /** @class */ (function (_super) {
|
||
__extends(AccessControlError, _super);
|
||
function AccessControlError(message) {
|
||
if (message === void 0) { message = ''; }
|
||
var _this = _super.call(this, message) /* istanbul ignore next */ || this;
|
||
_this.message = message;
|
||
_this.name = 'AccessControlError';
|
||
// https://github.com/gotwarlost/istanbul/issues/690
|
||
// http://stackoverflow.com/a/41429145/112731
|
||
Object.setPrototypeOf(_this, AccessControlError.prototype);
|
||
return _this;
|
||
}
|
||
return AccessControlError;
|
||
}(Error));
|
||
exports.AccessControlError = AccessControlError;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/core/Permission.js":
|
||
/*!***********************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/core/Permission.js ***!
|
||
\***********************************************************/
|
||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
var utils_1 = __webpack_require__(/*! ../utils */ "./node_modules/accesscontrol/lib/utils.js");
|
||
/**
|
||
* Represents the inner `Permission` class that defines the granted or denied
|
||
* access permissions for the target resource and role.
|
||
*
|
||
* You can check for a permission in two ways:
|
||
*
|
||
* <ul>
|
||
* <li>
|
||
* You can first obtain a {@link ?api=ac#AccessControl~Query|`Query` instance}
|
||
* via {@link ?api=ac#AccessControl#can|`AccessControl#can`} which returns
|
||
* a `Permission` instance when an action method such as
|
||
* {@link ?api=ac#AccessControl~Query#createAny|`.createAny()`} is
|
||
* called.
|
||
* <p><pre><code> var permission = ac.can('user').createAny('video');
|
||
* console.log(permission.granted); // boolean</code></pre></p>
|
||
* </li>
|
||
* <li>
|
||
* Or you can call {@link ?api=ac#AccessControl#permission|`AccessControl#permission`}
|
||
* by passing a fulfilled {@link ?api=ac#AccessControl#IQueryInfo|`IQueryInfo` object}.
|
||
* <p><pre><code> var permission = ac.permission({
|
||
* role: 'user',
|
||
* resource: 'video',
|
||
* action: 'create',
|
||
* possession: 'any'
|
||
* });
|
||
* console.log(permission.granted); // boolean</code></pre></p>
|
||
* </li>
|
||
* </ul>
|
||
*
|
||
* @class
|
||
* @inner
|
||
* @memberof AccessControl
|
||
*/
|
||
var Permission = /** @class */ (function () {
|
||
/**
|
||
* Initializes a new `Permission` instance.
|
||
* @private
|
||
*
|
||
* @param {IQueryInfo} query
|
||
* An `IQueryInfo` arbitrary object.
|
||
*/
|
||
function Permission(grants, query) {
|
||
/**
|
||
* @private
|
||
*/
|
||
this._ = {};
|
||
// set attributes first. this also validates the `query` object.
|
||
this._.attributes = utils_1.utils.getUnionAttrsOfRoles(grants, query);
|
||
this._.role = query.role;
|
||
this._.resource = query.resource;
|
||
}
|
||
Object.defineProperty(Permission.prototype, "roles", {
|
||
/**
|
||
* Specifies the roles for which the permission is queried for.
|
||
* Even if the permission is queried for a single role, this will still
|
||
* return an array.
|
||
*
|
||
* If the returned array has multiple roles, this does not necessarily mean
|
||
* that the queried permission is granted or denied for each and all roles.
|
||
* Note that when a permission is queried for multiple roles, attributes
|
||
* are unioned (merged) for all given roles. This means "at least one of
|
||
* these roles" have the permission for this action and resource attribute.
|
||
*
|
||
* @name AccessControl~Permission#roles
|
||
* @type {Array<String>}
|
||
* @readonly
|
||
*/
|
||
get: function () {
|
||
return this._.role;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
Object.defineProperty(Permission.prototype, "resource", {
|
||
/**
|
||
* Specifies the target resource for which the permission is queried for.
|
||
*
|
||
* @name AccessControl~Permission#resource
|
||
* @type {String}
|
||
* @readonly
|
||
*/
|
||
get: function () {
|
||
return this._.resource;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
Object.defineProperty(Permission.prototype, "attributes", {
|
||
/**
|
||
* Gets an array of allowed attributes which are defined via
|
||
* Glob notation. If access is not granted, this will be an empty array.
|
||
*
|
||
* Note that when a permission is queried for multiple roles, attributes
|
||
* are unioned (merged) for all given roles. This means "at least one of
|
||
* these roles" have the permission for this action and resource attribute.
|
||
*
|
||
* @name AccessControl~Permission#attributes
|
||
* @type {Array<String>}
|
||
* @readonly
|
||
*/
|
||
get: function () {
|
||
return this._.attributes;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
Object.defineProperty(Permission.prototype, "granted", {
|
||
/**
|
||
* Specifies whether the permission is granted. If `true`, this means at
|
||
* least one attribute of the target resource is allowed.
|
||
*
|
||
* @name AccessControl~Permission#granted
|
||
* @type {Boolean}
|
||
* @readonly
|
||
*/
|
||
get: function () {
|
||
if (!this.attributes || this.attributes.length === 0)
|
||
return false;
|
||
// just one non-negated attribute is enough.
|
||
return this.attributes.some(function (attr) {
|
||
return attr.trim().slice(0, 1) !== '!';
|
||
});
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
/**
|
||
* Filters the given data object (or array of objects) by the permission
|
||
* attributes and returns this data with allowed attributes.
|
||
*
|
||
* @param {Object|Array} data
|
||
* Data object to be filtered. Either a single object or array
|
||
* of objects.
|
||
*
|
||
* @returns {Object|Array}
|
||
* The filtered data object.
|
||
*/
|
||
Permission.prototype.filter = function (data) {
|
||
return utils_1.utils.filterAll(data, this.attributes);
|
||
};
|
||
return Permission;
|
||
}());
|
||
exports.Permission = Permission;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/core/Query.js":
|
||
/*!******************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/core/Query.js ***!
|
||
\******************************************************/
|
||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
var core_1 = __webpack_require__(/*! ../core */ "./node_modules/accesscontrol/lib/core/index.js");
|
||
var enums_1 = __webpack_require__(/*! ../enums */ "./node_modules/accesscontrol/lib/enums/index.js");
|
||
var utils_1 = __webpack_require__(/*! ../utils */ "./node_modules/accesscontrol/lib/utils.js");
|
||
/**
|
||
* Represents the inner `Query` class that helps build an access information
|
||
* for querying and checking permissions, from the underlying grants model.
|
||
* You can get a first instance of this class by calling
|
||
* `AccessControl#can(<role>)` method.
|
||
* @class
|
||
* @inner
|
||
* @memberof AccessControl
|
||
*/
|
||
var Query = /** @class */ (function () {
|
||
/**
|
||
* Initializes a new instance of `Query`.
|
||
* @private
|
||
*
|
||
* @param {Any} grants
|
||
* Underlying grants model against which the permissions will be
|
||
* queried and checked.
|
||
* @param {string|Array<String>|IQueryInfo} [roleOrInfo]
|
||
* Either a single or array of roles or an
|
||
* {@link ?api=ac#AccessControl~IQueryInfo|`IQueryInfo` arbitrary object}.
|
||
*/
|
||
function Query(grants, roleOrInfo) {
|
||
/**
|
||
* Inner `IQueryInfo` object.
|
||
* @protected
|
||
* @type {IQueryInfo}
|
||
*/
|
||
this._ = {};
|
||
this._grants = grants;
|
||
if (typeof roleOrInfo === 'string' || Array.isArray(roleOrInfo)) {
|
||
// if this is just role(s); a string or array; we start building
|
||
// the grant object for this.
|
||
this.role(roleOrInfo);
|
||
}
|
||
else if (utils_1.utils.type(roleOrInfo) === 'object') {
|
||
// if this is a (permission) object, we directly build attributes
|
||
// from grants.
|
||
if (Object.keys(roleOrInfo).length === 0) {
|
||
throw new core_1.AccessControlError('Invalid IQueryInfo: {}');
|
||
}
|
||
this._ = roleOrInfo;
|
||
}
|
||
else if (roleOrInfo !== undefined) {
|
||
// undefined is allowed (`role` can be omitted) but throw if some
|
||
// other type is passed.
|
||
throw new core_1.AccessControlError('Invalid role(s), expected a valid string, string[] or IQueryInfo.');
|
||
}
|
||
}
|
||
// -------------------------------
|
||
// PUBLIC METHODS
|
||
// -------------------------------
|
||
/**
|
||
* A chainer method that sets the role(s) for this `Query` instance.
|
||
* @param {String|Array<String>} roles
|
||
* A single or array of roles.
|
||
* @returns {Query}
|
||
* Self instance of `Query`.
|
||
*/
|
||
Query.prototype.role = function (role) {
|
||
this._.role = role;
|
||
return this;
|
||
};
|
||
/**
|
||
* A chainer method that sets the resource for this `Query` instance.
|
||
* @param {String} resource
|
||
* Target resource for this `Query` instance.
|
||
* @returns {Query}
|
||
* Self instance of `Query`.
|
||
*/
|
||
Query.prototype.resource = function (resource) {
|
||
this._.resource = resource;
|
||
return this;
|
||
};
|
||
/**
|
||
* Queries the underlying grant model and checks whether the current
|
||
* role(s) can "create" their "own" resource.
|
||
*
|
||
* @param {String} [resource]
|
||
* Defines the target resource to be checked.
|
||
* This is only optional if the target resource is previously
|
||
* defined. If not defined and omitted, this will throw.
|
||
*
|
||
* @throws {Error} If the access query instance to be committed has any
|
||
* invalid data.
|
||
*
|
||
* @returns {Permission}
|
||
* An object that defines whether the permission is granted; and
|
||
* the resource attributes that the permission is granted for.
|
||
*/
|
||
Query.prototype.createOwn = function (resource) {
|
||
return this._getPermission(enums_1.Action.CREATE, enums_1.Possession.OWN, resource);
|
||
};
|
||
/**
|
||
* Queries the underlying grant model and checks whether the current
|
||
* role(s) can "create" "any" resource.
|
||
*
|
||
* @param {String} [resource]
|
||
* Defines the target resource to be checked.
|
||
* This is only optional if the target resource is previously
|
||
* defined. If not defined and omitted, this will throw.
|
||
*
|
||
* @throws {Error} If the access query instance to be committed has any
|
||
* invalid data.
|
||
*
|
||
* @returns {Permission}
|
||
* An object that defines whether the permission is granted; and
|
||
* the resource attributes that the permission is granted for.
|
||
*/
|
||
Query.prototype.createAny = function (resource) {
|
||
return this._getPermission(enums_1.Action.CREATE, enums_1.Possession.ANY, resource);
|
||
};
|
||
/**
|
||
* Alias if `createAny`
|
||
* @private
|
||
*/
|
||
Query.prototype.create = function (resource) {
|
||
return this.createAny(resource);
|
||
};
|
||
/**
|
||
* Queries the underlying grant model and checks whether the current
|
||
* role(s) can "read" their "own" resource.
|
||
*
|
||
* @param {String} [resource]
|
||
* Defines the target resource to be checked.
|
||
* This is only optional if the target resource is previously
|
||
* defined. If not defined and omitted, this will throw.
|
||
*
|
||
* @throws {Error} If the access query instance to be committed has any
|
||
* invalid data.
|
||
*
|
||
* @returns {Permission}
|
||
* An object that defines whether the permission is granted; and
|
||
* the resource attributes that the permission is granted for.
|
||
*/
|
||
Query.prototype.readOwn = function (resource) {
|
||
return this._getPermission(enums_1.Action.READ, enums_1.Possession.OWN, resource);
|
||
};
|
||
/**
|
||
* Queries the underlying grant model and checks whether the current
|
||
* role(s) can "read" "any" resource.
|
||
*
|
||
* @param {String} [resource]
|
||
* Defines the target resource to be checked.
|
||
* This is only optional if the target resource is previously
|
||
* defined. If not defined and omitted, this will throw.
|
||
*
|
||
* @throws {Error} If the access query instance to be committed has any
|
||
* invalid data.
|
||
*
|
||
* @returns {Permission}
|
||
* An object that defines whether the permission is granted; and
|
||
* the resource attributes that the permission is granted for.
|
||
*/
|
||
Query.prototype.readAny = function (resource) {
|
||
return this._getPermission(enums_1.Action.READ, enums_1.Possession.ANY, resource);
|
||
};
|
||
/**
|
||
* Alias if `readAny`
|
||
* @private
|
||
*/
|
||
Query.prototype.read = function (resource) {
|
||
return this.readAny(resource);
|
||
};
|
||
/**
|
||
* Queries the underlying grant model and checks whether the current
|
||
* role(s) can "update" their "own" resource.
|
||
*
|
||
* @param {String} [resource]
|
||
* Defines the target resource to be checked.
|
||
* This is only optional if the target resource is previously
|
||
* defined. If not defined and omitted, this will throw.
|
||
*
|
||
* @throws {Error} If the access query instance to be committed has any
|
||
* invalid data.
|
||
*
|
||
* @returns {Permission}
|
||
* An object that defines whether the permission is granted; and
|
||
* the resource attributes that the permission is granted for.
|
||
*/
|
||
Query.prototype.updateOwn = function (resource) {
|
||
return this._getPermission(enums_1.Action.UPDATE, enums_1.Possession.OWN, resource);
|
||
};
|
||
/**
|
||
* Queries the underlying grant model and checks whether the current
|
||
* role(s) can "update" "any" resource.
|
||
*
|
||
* @param {String} [resource]
|
||
* Defines the target resource to be checked.
|
||
* This is only optional if the target resource is previously
|
||
* defined. If not defined and omitted, this will throw.
|
||
*
|
||
* @throws {Error} If the access query instance to be committed has any
|
||
* invalid data.
|
||
*
|
||
* @returns {Permission}
|
||
* An object that defines whether the permission is granted; and
|
||
* the resource attributes that the permission is granted for.
|
||
*/
|
||
Query.prototype.updateAny = function (resource) {
|
||
return this._getPermission(enums_1.Action.UPDATE, enums_1.Possession.ANY, resource);
|
||
};
|
||
/**
|
||
* Alias if `updateAny`
|
||
* @private
|
||
*/
|
||
Query.prototype.update = function (resource) {
|
||
return this.updateAny(resource);
|
||
};
|
||
/**
|
||
* Queries the underlying grant model and checks whether the current
|
||
* role(s) can "delete" their "own" resource.
|
||
*
|
||
* @param {String} [resource]
|
||
* Defines the target resource to be checked.
|
||
* This is only optional if the target resource is previously
|
||
* defined. If not defined and omitted, this will throw.
|
||
*
|
||
* @throws {Error} If the access query instance to be committed has any
|
||
* invalid data.
|
||
*
|
||
* @returns {Permission}
|
||
* An object that defines whether the permission is granted; and
|
||
* the resource attributes that the permission is granted for.
|
||
*/
|
||
Query.prototype.deleteOwn = function (resource) {
|
||
return this._getPermission(enums_1.Action.DELETE, enums_1.Possession.OWN, resource);
|
||
};
|
||
/**
|
||
* Queries the underlying grant model and checks whether the current
|
||
* role(s) can "delete" "any" resource.
|
||
*
|
||
* @param {String} [resource]
|
||
* Defines the target resource to be checked.
|
||
* This is only optional if the target resource is previously
|
||
* defined. If not defined and omitted, this will throw.
|
||
*
|
||
* @throws {Error} If the access query instance to be committed has any
|
||
* invalid data.
|
||
*
|
||
* @returns {Permission}
|
||
* An object that defines whether the permission is granted; and
|
||
* the resource attributes that the permission is granted for.
|
||
*/
|
||
Query.prototype.deleteAny = function (resource) {
|
||
return this._getPermission(enums_1.Action.DELETE, enums_1.Possession.ANY, resource);
|
||
};
|
||
/**
|
||
* Alias if `deleteAny`
|
||
* @private
|
||
*/
|
||
Query.prototype.delete = function (resource) {
|
||
return this.deleteAny(resource);
|
||
};
|
||
// -------------------------------
|
||
// PRIVATE METHODS
|
||
// -------------------------------
|
||
/**
|
||
* @private
|
||
* @param {String} action
|
||
* @param {String} possession
|
||
* @param {String} [resource]
|
||
* @returns {Permission}
|
||
*/
|
||
Query.prototype._getPermission = function (action, possession, resource) {
|
||
this._.action = action;
|
||
this._.possession = possession;
|
||
if (resource)
|
||
this._.resource = resource;
|
||
return new core_1.Permission(this._grants, this._);
|
||
};
|
||
return Query;
|
||
}());
|
||
exports.Query = Query;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/core/index.js":
|
||
/*!******************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/core/index.js ***!
|
||
\******************************************************/
|
||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
|
||
function __export(m) {
|
||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||
}
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
__export(__webpack_require__(/*! ./AccessControlError */ "./node_modules/accesscontrol/lib/core/AccessControlError.js"));
|
||
__export(__webpack_require__(/*! ./Access */ "./node_modules/accesscontrol/lib/core/Access.js"));
|
||
__export(__webpack_require__(/*! ./Query */ "./node_modules/accesscontrol/lib/core/Query.js"));
|
||
__export(__webpack_require__(/*! ./Permission */ "./node_modules/accesscontrol/lib/core/Permission.js"));
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/enums/Action.js":
|
||
/*!********************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/enums/Action.js ***!
|
||
\********************************************************/
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
/**
|
||
* Enumerates the possible actions of a role.
|
||
* An action defines the type of an operation that will be executed on a
|
||
* "resource" by a "role".
|
||
* This is known as CRUD (CREATE, READ, UPDATE, DELETE).
|
||
* @enum {String}
|
||
* @readonly
|
||
* @memberof! AccessControl
|
||
*/
|
||
var Action = {
|
||
/**
|
||
* Specifies a CREATE action to be performed on a resource.
|
||
* For example, an HTTP POST request or an INSERT database operation.
|
||
* @type {String}
|
||
*/
|
||
CREATE: 'create',
|
||
/**
|
||
* Specifies a READ action to be performed on a resource.
|
||
* For example, an HTTP GET request or an database SELECT operation.
|
||
* @type {String}
|
||
*/
|
||
READ: 'read',
|
||
/**
|
||
* Specifies an UPDATE action to be performed on a resource.
|
||
* For example, an HTTP PUT or POST request or an database UPDATE operation.
|
||
* @type {String}
|
||
*/
|
||
UPDATE: 'update',
|
||
/**
|
||
* Specifies a DELETE action to be performed on a resource.
|
||
* For example, an HTTP DELETE request or a database DELETE operation.
|
||
* @type {String}
|
||
*/
|
||
DELETE: 'delete'
|
||
};
|
||
exports.Action = Action;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/enums/Possession.js":
|
||
/*!************************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/enums/Possession.js ***!
|
||
\************************************************************/
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
/**
|
||
* Enumerates the possible possessions of a resource, for an action.
|
||
* A possession defines whether the action is (or not) to be performed on "own"
|
||
* resource(s) of the current subject or "any" resources - including "own".
|
||
* @enum {String}
|
||
* @readonly
|
||
* @memberof! AccessControl
|
||
*/
|
||
var Possession = {
|
||
/**
|
||
* Indicates that the action is (or not) to be performed on <b>own</b>
|
||
* resource(s) of the current subject.
|
||
* @type {String}
|
||
*/
|
||
OWN: 'own',
|
||
/**
|
||
* Indicates that the action is (or not) to be performed on <b>any</b>
|
||
* resource(s); including <i>own</i> resource(s) of the current subject.
|
||
* @type {String}
|
||
*/
|
||
ANY: 'any'
|
||
};
|
||
exports.Possession = Possession;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/enums/index.js":
|
||
/*!*******************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/enums/index.js ***!
|
||
\*******************************************************/
|
||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
var Action_1 = __webpack_require__(/*! ./Action */ "./node_modules/accesscontrol/lib/enums/Action.js");
|
||
exports.Action = Action_1.Action;
|
||
var Possession_1 = __webpack_require__(/*! ./Possession */ "./node_modules/accesscontrol/lib/enums/Possession.js");
|
||
exports.Possession = Possession_1.Possession;
|
||
var actions = Object.keys(Action_1.Action).map(function (k) { return Action_1.Action[k]; });
|
||
exports.actions = actions;
|
||
var possessions = Object.keys(Possession_1.Possession).map(function (k) { return Possession_1.Possession[k]; });
|
||
exports.possessions = possessions;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/index.js":
|
||
/*!*************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/index.js ***!
|
||
\*************************************************/
|
||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
|
||
function __export(m) {
|
||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||
}
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
__export(__webpack_require__(/*! ./AccessControl */ "./node_modules/accesscontrol/lib/AccessControl.js"));
|
||
__export(__webpack_require__(/*! ./core */ "./node_modules/accesscontrol/lib/core/index.js"));
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/accesscontrol/lib/utils.js":
|
||
/*!*************************************************!*\
|
||
!*** ./node_modules/accesscontrol/lib/utils.js ***!
|
||
\*************************************************/
|
||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
// dep modules
|
||
var Notation = __webpack_require__(/*! notation */ "./node_modules/notation/lib/notation.min.js");
|
||
var enums_1 = __webpack_require__(/*! ./enums */ "./node_modules/accesscontrol/lib/enums/index.js");
|
||
var core_1 = __webpack_require__(/*! ./core */ "./node_modules/accesscontrol/lib/core/index.js");
|
||
/**
|
||
* List of reserved keywords.
|
||
* i.e. Roles, resources with these names are not allowed.
|
||
*/
|
||
var RESERVED_KEYWORDS = ['*', '!', '$', '$extend'];
|
||
exports.RESERVED_KEYWORDS = RESERVED_KEYWORDS;
|
||
/**
|
||
* Error message to be thrown after AccessControl instance is locked.
|
||
*/
|
||
var ERR_LOCK = 'Cannot alter the underlying grants model. AccessControl instance is locked.';
|
||
exports.ERR_LOCK = ERR_LOCK;
|
||
var utils = {
|
||
// ----------------------
|
||
// GENERIC UTILS
|
||
// ----------------------
|
||
/**
|
||
* Gets the type of the given object.
|
||
* @param {Any} o
|
||
* @returns {String}
|
||
*/
|
||
type: function (o) {
|
||
return Object.prototype.toString.call(o).match(/\s(\w+)/i)[1].toLowerCase();
|
||
},
|
||
// for later use
|
||
// isPlainObject(o:any) {
|
||
// return o && (o.constructor === Object || o.constructor === undefined);
|
||
// },
|
||
/**
|
||
* Specifies whether the given value is set (other that `null` or
|
||
* `undefined`).
|
||
* @param {Any} o - Value to be checked.
|
||
* @returns {Boolean}
|
||
*/
|
||
// isset(o:any):boolean {
|
||
// return o === null || o === undefined;
|
||
// },
|
||
/**
|
||
* Specifies whether the property/key is defined on the given object.
|
||
* @param {Object} o
|
||
* @param {string} propName
|
||
* @returns {Boolean}
|
||
*/
|
||
hasDefined: function (o, propName) {
|
||
return o.hasOwnProperty(propName) && o[propName] !== undefined;
|
||
},
|
||
/**
|
||
* Converts the given (string) value into an array of string. Note that
|
||
* this does not throw if the value is not a string or array. It will
|
||
* silently return `[]` (empty array). So where ever it's used, the host
|
||
* function should consider throwing.
|
||
* @param {Any} value
|
||
* @returns {string[]}
|
||
*/
|
||
toStringArray: function (value) {
|
||
if (Array.isArray(value))
|
||
return value;
|
||
if (typeof value === 'string')
|
||
return value.trim().split(/\s*[;,]\s*/);
|
||
// throw new Error('Expected a string or array of strings, got ' + utils.type(value));
|
||
return [];
|
||
},
|
||
/**
|
||
* Checks whether the given array consists of non-empty string items.
|
||
* (Array can be empty but no item should be an empty string.)
|
||
* @param {Array} arr - Array to be checked.
|
||
* @returns {Boolean}
|
||
*/
|
||
isFilledStringArray: function (arr) {
|
||
if (!arr || !Array.isArray(arr))
|
||
return false;
|
||
for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
|
||
var s = arr_1[_i];
|
||
if (typeof s !== 'string' || s.trim() === '')
|
||
return false;
|
||
}
|
||
return true;
|
||
},
|
||
/**
|
||
* Checks whether the given value is an empty array.
|
||
* @param {Any} value - Value to be checked.
|
||
* @returns {Boolean}
|
||
*/
|
||
isEmptyArray: function (value) {
|
||
return Array.isArray(value) && value.length === 0;
|
||
},
|
||
/**
|
||
* Ensures that the pushed item is unique in the target array.
|
||
* @param {Array} arr - Target array.
|
||
* @param {Any} item - Item to be pushed to array.
|
||
* @returns {Array}
|
||
*/
|
||
pushUniq: function (arr, item) {
|
||
if (arr.indexOf(item) < 0)
|
||
arr.push(item);
|
||
return arr;
|
||
},
|
||
/**
|
||
* Concats the given two arrays and ensures all items are unique.
|
||
* @param {Array} arrA
|
||
* @param {Array} arrB
|
||
* @returns {Array} - Concat'ed array.
|
||
*/
|
||
uniqConcat: function (arrA, arrB) {
|
||
var arr = arrA.concat();
|
||
arrB.forEach(function (b) {
|
||
utils.pushUniq(arr, b);
|
||
});
|
||
return arr;
|
||
},
|
||
/**
|
||
* Subtracts the second array from the first.
|
||
* @param {Array} arrA
|
||
* @param {Array} arrB
|
||
* @return {Array} - Resulting array.
|
||
*/
|
||
subtractArray: function (arrA, arrB) {
|
||
return arrA.concat().filter(function (a) { return arrB.indexOf(a) === -1; });
|
||
},
|
||
/**
|
||
* Deep freezes the given object.
|
||
* @param {Object} o - Object to be frozen.
|
||
* @returns {Object} - Frozen object.
|
||
*/
|
||
deepFreeze: function (o) {
|
||
// Object.freeze accepts also an array. But here, we only use this for
|
||
// objects.
|
||
if (utils.type(o) !== 'object')
|
||
return;
|
||
var props = Object.getOwnPropertyNames(o);
|
||
// freeze deeper before self
|
||
props.forEach(function (key) {
|
||
var sub = o[key];
|
||
if (Array.isArray(sub))
|
||
Object.freeze(sub);
|
||
if (utils.type(sub) === 'object') {
|
||
utils.deepFreeze(sub);
|
||
}
|
||
});
|
||
// finally freeze self
|
||
return Object.freeze(o);
|
||
},
|
||
/**
|
||
* Similar to JS .forEach, except this allows for breaking out early,
|
||
* (before all iterations are executed) by returning `false`.
|
||
* @param array
|
||
* @param callback
|
||
* @param thisArg
|
||
*/
|
||
each: function (array, callback, thisArg) {
|
||
if (thisArg === void 0) { thisArg = null; }
|
||
var length = array.length;
|
||
var index = -1;
|
||
while (++index < length) {
|
||
if (callback.call(thisArg, array[index], index, array) === false)
|
||
break;
|
||
}
|
||
},
|
||
/**
|
||
* Iterates through the keys of the given object. Breaking out early is
|
||
* possible by returning `false`.
|
||
* @param object
|
||
* @param callback
|
||
* @param thisArg
|
||
*/
|
||
eachKey: function (object, callback, thisArg) {
|
||
if (thisArg === void 0) { thisArg = null; }
|
||
// return Object.keys(o).forEach(callback);
|
||
// forEach has no way to interrupt execution, short-circuit unless an
|
||
// error is thrown. so we use this:
|
||
utils.each(Object.keys(object), callback, thisArg);
|
||
},
|
||
// ----------------------
|
||
// AC ITERATION UTILS
|
||
// ----------------------
|
||
eachRole: function (grants, callback) {
|
||
utils.eachKey(grants, function (name) { return callback(grants[name], name); });
|
||
},
|
||
/**
|
||
*
|
||
*/
|
||
eachRoleResource: function (grants, callback) {
|
||
var resources, resourceDefinition;
|
||
utils.eachKey(grants, function (role) {
|
||
resources = grants[role];
|
||
utils.eachKey(resources, function (resource) {
|
||
resourceDefinition = role[resource];
|
||
callback(role, resource, resourceDefinition);
|
||
});
|
||
});
|
||
},
|
||
// ----------------------
|
||
// AC VALIDATION UTILS
|
||
// ----------------------
|
||
/**
|
||
* Checks whether the given access info can be commited to grants model.
|
||
* @param {IAccessInfo|IQueryInfo} info
|
||
* @returns {Boolean}
|
||
*/
|
||
isInfoFulfilled: function (info) {
|
||
return utils.hasDefined(info, 'role')
|
||
&& utils.hasDefined(info, 'action')
|
||
&& utils.hasDefined(info, 'resource');
|
||
},
|
||
/**
|
||
* Checks whether the given name can be used and is not a reserved keyword.
|
||
*
|
||
* @param {string} name - Name to be checked.
|
||
* @param {boolean} [throwOnInvalid=true] - Specifies whether to throw if
|
||
* name is not valid.
|
||
*
|
||
* @returns {Boolean}
|
||
*
|
||
* @throws {AccessControlError} - If `throwOnInvalid` is enabled and name
|
||
* is invalid.
|
||
*/
|
||
validName: function (name, throwOnInvalid) {
|
||
if (throwOnInvalid === void 0) { throwOnInvalid = true; }
|
||
if (typeof name !== 'string' || name.trim() === '') {
|
||
if (!throwOnInvalid)
|
||
return false;
|
||
throw new core_1.AccessControlError('Invalid name, expected a valid string.');
|
||
}
|
||
if (RESERVED_KEYWORDS.indexOf(name) >= 0) {
|
||
if (!throwOnInvalid)
|
||
return false;
|
||
throw new core_1.AccessControlError("Cannot use reserved name: \"" + name + "\"");
|
||
}
|
||
return true;
|
||
},
|
||
/**
|
||
* Checks whether the given array does not contain a reserved keyword.
|
||
*
|
||
* @param {string|string[]} list - Name(s) to be checked.
|
||
* @param {boolean} [throwOnInvalid=true] - Specifies whether to throw if
|
||
* name is not valid.
|
||
*
|
||
* @returns {Boolean}
|
||
*
|
||
* @throws {AccessControlError} - If `throwOnInvalid` is enabled and name
|
||
* is invalid.
|
||
*/
|
||
hasValidNames: function (list, throwOnInvalid) {
|
||
if (throwOnInvalid === void 0) { throwOnInvalid = true; }
|
||
var allValid = true;
|
||
utils.each(utils.toStringArray(list), function (name) {
|
||
if (!utils.validName(name, throwOnInvalid)) {
|
||
allValid = false;
|
||
return false; // break out of loop
|
||
}
|
||
// suppress tslint warning
|
||
return true; // continue
|
||
});
|
||
return allValid;
|
||
},
|
||
/**
|
||
* Checks whether the given object is a valid resource definition object.
|
||
*
|
||
* @param {Object} o - Resource definition to be checked.
|
||
*
|
||
* @returns {Boolean}
|
||
*
|
||
* @throws {AccessControlError} - If `throwOnInvalid` is enabled and object
|
||
* is invalid.
|
||
*/
|
||
validResourceObject: function (o) {
|
||
if (utils.type(o) !== 'object') {
|
||
throw new core_1.AccessControlError("Invalid resource definition.");
|
||
}
|
||
utils.eachKey(o, function (action) {
|
||
var s = action.split(':');
|
||
if (enums_1.actions.indexOf(s[0]) === -1) {
|
||
throw new core_1.AccessControlError("Invalid action: \"" + action + "\"");
|
||
}
|
||
if (s[1] && enums_1.possessions.indexOf(s[1]) === -1) {
|
||
throw new core_1.AccessControlError("Invalid action possession: \"" + action + "\"");
|
||
}
|
||
var perms = o[action];
|
||
if (!utils.isEmptyArray(perms) && !utils.isFilledStringArray(perms)) {
|
||
throw new core_1.AccessControlError("Invalid resource attributes for action \"" + action + "\".");
|
||
}
|
||
});
|
||
return true;
|
||
},
|
||
/**
|
||
* Checks whether the given object is a valid role definition object.
|
||
*
|
||
* @param {Object} grants - Original grants object being inspected.
|
||
* @param {string} roleName - Name of the role.
|
||
*
|
||
* @returns {Boolean}
|
||
*
|
||
* @throws {AccessControlError} - If `throwOnInvalid` is enabled and object
|
||
* is invalid.
|
||
*/
|
||
validRoleObject: function (grants, roleName) {
|
||
var role = grants[roleName];
|
||
if (!role || utils.type(role) !== 'object') {
|
||
throw new core_1.AccessControlError("Invalid role definition.");
|
||
}
|
||
utils.eachKey(role, function (resourceName) {
|
||
if (!utils.validName(resourceName, false)) {
|
||
if (resourceName === '$extend') {
|
||
var extRoles = role[resourceName]; // semantics
|
||
if (!utils.isFilledStringArray(extRoles)) {
|
||
throw new core_1.AccessControlError("Invalid extend value for role \"" + roleName + "\": " + JSON.stringify(extRoles));
|
||
}
|
||
else {
|
||
// attempt to actually extend the roles. this will throw
|
||
// on failure.
|
||
utils.extendRole(grants, roleName, extRoles);
|
||
}
|
||
}
|
||
else {
|
||
throw new core_1.AccessControlError("Cannot use reserved name \"" + resourceName + "\" for a resource.");
|
||
}
|
||
}
|
||
else {
|
||
utils.validResourceObject(role[resourceName]); // throws on failure
|
||
}
|
||
});
|
||
return true;
|
||
},
|
||
/**
|
||
* Inspects whether the given grants object has a valid structure and
|
||
* configuration; and returns a restructured grants object that can be used
|
||
* internally by AccessControl.
|
||
*
|
||
* @param {Object|Array} o - Original grants object to be inspected.
|
||
*
|
||
* @returns {Object} - Inspected, restructured grants object.
|
||
*
|
||
* @throws {AccessControlError} - If given grants object has an invalid
|
||
* structure or configuration.
|
||
*/
|
||
getInspectedGrants: function (o) {
|
||
var grants = {};
|
||
var strErr = 'Invalid grants object.';
|
||
var type = utils.type(o);
|
||
if (type === 'object') {
|
||
utils.eachKey(o, function (roleName) {
|
||
if (utils.validName(roleName)) {
|
||
return utils.validRoleObject(o, roleName); // throws on failure
|
||
}
|
||
/* istanbul ignore next */
|
||
return false;
|
||
// above is redundant, previous checks will already throw on
|
||
// failure so we'll never need to break early from this.
|
||
});
|
||
grants = o;
|
||
}
|
||
else if (type === 'array') {
|
||
o.forEach(function (item) { return utils.commitToGrants(grants, item, true); });
|
||
}
|
||
else {
|
||
throw new core_1.AccessControlError(strErr + " Expected an array or object.");
|
||
}
|
||
return grants;
|
||
},
|
||
// ----------------------
|
||
// AC COMMON UTILS
|
||
// ----------------------
|
||
/**
|
||
* Gets all the unique resources that are granted access for at
|
||
* least one role.
|
||
*
|
||
* @returns {string[]}
|
||
*/
|
||
getResources: function (grants) {
|
||
// using an object for unique list
|
||
var resources = {};
|
||
utils.eachRoleResource(grants, function (role, resource, permissions) {
|
||
resources[resource] = null;
|
||
});
|
||
return Object.keys(resources);
|
||
},
|
||
/**
|
||
* Normalizes the actions and possessions in the given `IQueryInfo` or
|
||
* `IAccessInfo`.
|
||
*
|
||
* @param {IQueryInfo|IAccessInfo} info
|
||
* @param {boolean} [asString=false]
|
||
*
|
||
* @return {IQueryInfo|IAccessInfo|string}
|
||
*
|
||
* @throws {AccessControlError} - If invalid action/possession found.
|
||
*/
|
||
normalizeActionPossession: function (info, asString) {
|
||
if (asString === void 0) { asString = false; }
|
||
// validate and normalize action
|
||
if (typeof info.action !== 'string') {
|
||
// throw new AccessControlError(`Invalid action: ${info.action}`);
|
||
throw new core_1.AccessControlError("Invalid action: " + JSON.stringify(info));
|
||
}
|
||
var s = info.action.split(':');
|
||
if (enums_1.actions.indexOf(s[0].trim().toLowerCase()) < 0) {
|
||
throw new core_1.AccessControlError("Invalid action: " + s[0]);
|
||
}
|
||
info.action = s[0].trim().toLowerCase();
|
||
// validate and normalize possession
|
||
var poss = info.possession || s[1];
|
||
if (poss) {
|
||
if (enums_1.possessions.indexOf(poss.trim().toLowerCase()) < 0) {
|
||
throw new core_1.AccessControlError("Invalid action possession: " + poss);
|
||
}
|
||
else {
|
||
info.possession = poss.trim().toLowerCase();
|
||
}
|
||
}
|
||
else {
|
||
// if no possession is set, we'll default to "any".
|
||
info.possession = enums_1.Possession.ANY;
|
||
}
|
||
return asString
|
||
? info.action + ':' + info.possession
|
||
: info;
|
||
},
|
||
/**
|
||
* Normalizes the roles and resources in the given `IQueryInfo`.
|
||
*
|
||
* @param {IQueryInfo} info
|
||
*
|
||
* @return {IQueryInfo}
|
||
*
|
||
* @throws {AccessControlError} - If invalid role/resource found.
|
||
*/
|
||
normalizeQueryInfo: function (query) {
|
||
if (utils.type(query) !== 'object') {
|
||
throw new core_1.AccessControlError("Invalid IQueryInfo: " + typeof query);
|
||
}
|
||
// clone the object
|
||
query = Object.assign({}, query);
|
||
// validate and normalize role(s)
|
||
query.role = utils.toStringArray(query.role);
|
||
if (!utils.isFilledStringArray(query.role)) {
|
||
throw new core_1.AccessControlError("Invalid role(s): " + JSON.stringify(query.role));
|
||
}
|
||
// validate resource
|
||
if (typeof query.resource !== 'string' || query.resource.trim() === '') {
|
||
throw new core_1.AccessControlError("Invalid resource: \"" + query.resource + "\"");
|
||
}
|
||
query.resource = query.resource.trim();
|
||
query = utils.normalizeActionPossession(query);
|
||
return query;
|
||
},
|
||
/**
|
||
* Normalizes the roles and resources in the given `IAccessInfo`.
|
||
*
|
||
* @param {IAccessInfo} info
|
||
* @param {boolean} [all=false] - Whether to validate all properties such
|
||
* as `action` and `possession`.
|
||
*
|
||
* @return {IQueryInfo}
|
||
*
|
||
* @throws {AccessControlError} - If invalid role/resource found.
|
||
*/
|
||
normalizeAccessInfo: function (access, all) {
|
||
if (all === void 0) { all = false; }
|
||
if (utils.type(access) !== 'object') {
|
||
throw new core_1.AccessControlError("Invalid IAccessInfo: " + typeof access);
|
||
}
|
||
// clone the object
|
||
access = Object.assign({}, access);
|
||
// validate and normalize role(s)
|
||
access.role = utils.toStringArray(access.role);
|
||
if (access.role.length === 0 || !utils.isFilledStringArray(access.role)) {
|
||
throw new core_1.AccessControlError("Invalid role(s): " + JSON.stringify(access.role));
|
||
}
|
||
// validate and normalize resource
|
||
access.resource = utils.toStringArray(access.resource);
|
||
if (access.resource.length === 0 || !utils.isFilledStringArray(access.resource)) {
|
||
throw new core_1.AccessControlError("Invalid resource(s): " + JSON.stringify(access.resource));
|
||
}
|
||
// normalize attributes
|
||
if (access.denied || (Array.isArray(access.attributes) && access.attributes.length === 0)) {
|
||
access.attributes = [];
|
||
}
|
||
else {
|
||
// if omitted and not denied, all attributes are allowed
|
||
access.attributes = !access.attributes ? ['*'] : utils.toStringArray(access.attributes);
|
||
}
|
||
// this part is not necessary if this is invoked from a comitter method
|
||
// such as `createAny()`. So we'll check if we need to validate all
|
||
// properties such as `action` and `possession`.
|
||
if (all)
|
||
access = utils.normalizeActionPossession(access);
|
||
return access;
|
||
},
|
||
/**
|
||
* Used to re-set (prepare) the `attributes` of an `IAccessInfo` object
|
||
* when it's first initialized with e.g. `.grant()` or `.deny()` chain
|
||
* methods.
|
||
* @param {IAccessInfo} access
|
||
* @returns {IAccessInfo}
|
||
*/
|
||
resetAttributes: function (access) {
|
||
if (access.denied) {
|
||
access.attributes = [];
|
||
return access;
|
||
}
|
||
if (!access.attributes || utils.isEmptyArray(access.attributes)) {
|
||
access.attributes = ['*'];
|
||
}
|
||
return access;
|
||
},
|
||
/**
|
||
* Gets a flat, ordered list of inherited roles for the given role.
|
||
* @param {Object} grants - Main grants object to be processed.
|
||
* @param {string} roleName - Role name to be inspected.
|
||
* @returns {string[]}
|
||
*/
|
||
getRoleHierarchyOf: function (grants, roleName, rootRole) {
|
||
// `rootRole` is for memory storage. Do NOT set it when using;
|
||
// and do NOT document this paramter.
|
||
// rootRole = rootRole || roleName;
|
||
var role = grants[roleName];
|
||
if (!role)
|
||
throw new core_1.AccessControlError("Role not found: \"" + roleName + "\"");
|
||
var arr = [roleName];
|
||
if (!Array.isArray(role.$extend) || role.$extend.length === 0)
|
||
return arr;
|
||
role.$extend.forEach(function (exRoleName) {
|
||
if (!grants[exRoleName]) {
|
||
throw new core_1.AccessControlError("Role not found: \"" + grants[exRoleName] + "\"");
|
||
}
|
||
if (exRoleName === roleName) {
|
||
throw new core_1.AccessControlError("Cannot extend role \"" + roleName + "\" by itself.");
|
||
}
|
||
// throw if cross-inheritance and also avoid memory leak with
|
||
// maximum call stack error
|
||
if (rootRole && (rootRole === exRoleName)) {
|
||
throw new core_1.AccessControlError("Cross inheritance is not allowed. Role \"" + exRoleName + "\" already extends \"" + rootRole + "\".");
|
||
}
|
||
var ext = utils.getRoleHierarchyOf(grants, exRoleName, rootRole || roleName);
|
||
arr = utils.uniqConcat(arr, ext);
|
||
});
|
||
return arr;
|
||
},
|
||
/**
|
||
* Gets roles and extended roles in a flat array.
|
||
*/
|
||
getFlatRoles: function (grants, roles) {
|
||
var arrRoles = utils.toStringArray(roles);
|
||
if (arrRoles.length === 0) {
|
||
throw new core_1.AccessControlError("Invalid role(s): " + JSON.stringify(roles));
|
||
}
|
||
var arr = utils.uniqConcat([], arrRoles); // roles.concat();
|
||
arrRoles.forEach(function (roleName) {
|
||
arr = utils.uniqConcat(arr, utils.getRoleHierarchyOf(grants, roleName));
|
||
});
|
||
// console.log(`flat roles for ${roles}`, arr);
|
||
return arr;
|
||
},
|
||
/**
|
||
* Checks the given grants model and gets an array of non-existent roles
|
||
* from the given roles.
|
||
* @param {Any} grants - Grants model to be checked.
|
||
* @param {string[]} roles - Roles to be checked.
|
||
* @returns {string[]} - Array of non-existent roles. Empty array if
|
||
* all exist.
|
||
*/
|
||
getNonExistentRoles: function (grants, roles) {
|
||
var non = [];
|
||
if (utils.isEmptyArray(roles))
|
||
return non;
|
||
for (var _i = 0, roles_1 = roles; _i < roles_1.length; _i++) {
|
||
var role = roles_1[_i];
|
||
if (!grants.hasOwnProperty(role))
|
||
non.push(role);
|
||
}
|
||
return non;
|
||
},
|
||
/**
|
||
* Checks whether the given extender role(s) is already (cross) inherited
|
||
* by the given role and returns the first cross-inherited role. Otherwise,
|
||
* returns `false`.
|
||
*
|
||
* Note that cross-inheritance is not allowed.
|
||
*
|
||
* @param {Any} grants - Grants model to be checked.
|
||
* @param {string} roles - Target role to be checked.
|
||
* @param {string|string[]} extenderRoles - Extender role(s) to be checked.
|
||
*
|
||
* @returns {string|null} - Returns the first cross extending role. `null`
|
||
* if none.
|
||
*/
|
||
getCrossExtendingRole: function (grants, roleName, extenderRoles) {
|
||
var extenders = utils.toStringArray(extenderRoles);
|
||
var crossInherited = null;
|
||
utils.each(extenders, function (e) {
|
||
if (crossInherited || roleName === e) {
|
||
return false; // break out of loop
|
||
}
|
||
var inheritedByExtender = utils.getRoleHierarchyOf(grants, e);
|
||
utils.each(inheritedByExtender, function (r) {
|
||
if (r === roleName) {
|
||
// get/report the parent role
|
||
crossInherited = e;
|
||
return false; // break out of loop
|
||
}
|
||
// suppress tslint warning
|
||
return true; // continue
|
||
});
|
||
// suppress tslint warning
|
||
return true; // continue
|
||
});
|
||
return crossInherited;
|
||
},
|
||
/**
|
||
* Extends the given role(s) with privileges of one or more other roles.
|
||
*
|
||
* @param {Any} grants
|
||
* @param {string|string[]} roles Role(s) to be extended. Single role
|
||
* as a `String` or multiple roles as an `Array`. Note that if a
|
||
* role does not exist, it will be automatically created.
|
||
*
|
||
* @param {string|string[]} extenderRoles Role(s) to inherit from.
|
||
* Single role as a `String` or multiple roles as an `Array`. Note
|
||
* that if a extender role does not exist, it will throw.
|
||
*
|
||
* @throws {Error} If a role is extended by itself, a non-existent role or
|
||
* a cross-inherited role.
|
||
*/
|
||
extendRole: function (grants, roles, extenderRoles) {
|
||
// roles cannot be omitted or an empty array
|
||
roles = utils.toStringArray(roles);
|
||
if (roles.length === 0) {
|
||
throw new core_1.AccessControlError("Invalid role(s): " + JSON.stringify(roles));
|
||
}
|
||
// extenderRoles cannot be omitted or but can be an empty array
|
||
if (utils.isEmptyArray(extenderRoles))
|
||
return;
|
||
var arrExtRoles = utils.toStringArray(extenderRoles).concat();
|
||
if (arrExtRoles.length === 0) {
|
||
throw new core_1.AccessControlError("Cannot inherit invalid role(s): " + JSON.stringify(extenderRoles));
|
||
}
|
||
var nonExistentExtRoles = utils.getNonExistentRoles(grants, arrExtRoles);
|
||
if (nonExistentExtRoles.length > 0) {
|
||
throw new core_1.AccessControlError("Cannot inherit non-existent role(s): \"" + nonExistentExtRoles.join(', ') + "\"");
|
||
}
|
||
roles.forEach(function (roleName) {
|
||
if (!grants[roleName])
|
||
throw new core_1.AccessControlError("Role not found: \"" + roleName + "\"");
|
||
if (arrExtRoles.indexOf(roleName) >= 0) {
|
||
throw new core_1.AccessControlError("Cannot extend role \"" + roleName + "\" by itself.");
|
||
}
|
||
// getCrossExtendingRole() returns false or the first
|
||
// cross-inherited role, if found.
|
||
var crossInherited = utils.getCrossExtendingRole(grants, roleName, arrExtRoles);
|
||
if (crossInherited) {
|
||
throw new core_1.AccessControlError("Cross inheritance is not allowed. Role \"" + crossInherited + "\" already extends \"" + roleName + "\".");
|
||
}
|
||
utils.validName(roleName); // throws if false
|
||
var r = grants[roleName];
|
||
if (Array.isArray(r.$extend)) {
|
||
r.$extend = utils.uniqConcat(r.$extend, arrExtRoles);
|
||
}
|
||
else {
|
||
r.$extend = arrExtRoles;
|
||
}
|
||
});
|
||
},
|
||
/**
|
||
* `utils.commitToGrants()` method already creates the roles but it's
|
||
* executed when the chain is terminated with either `.extend()` or an
|
||
* action method (e.g. `.createOwn()`). In case the chain is not
|
||
* terminated, we'll still (pre)create the role(s) with an empty object.
|
||
* @param {Any} grants
|
||
* @param {string|string[]} roles
|
||
*/
|
||
preCreateRoles: function (grants, roles) {
|
||
if (typeof roles === 'string')
|
||
roles = utils.toStringArray(roles);
|
||
if (!Array.isArray(roles) || roles.length === 0) {
|
||
throw new core_1.AccessControlError("Invalid role(s): " + JSON.stringify(roles));
|
||
}
|
||
roles.forEach(function (role) {
|
||
if (utils.validName(role) && !grants.hasOwnProperty(role)) {
|
||
grants[role] = {};
|
||
}
|
||
});
|
||
},
|
||
/**
|
||
* Commits the given `IAccessInfo` object to the grants model.
|
||
* CAUTION: if attributes is omitted, it will default to `['*']` which
|
||
* means "all attributes allowed".
|
||
* @param {Any} grants
|
||
* @param {IAccessInfo} access
|
||
* @param {boolean} normalizeAll
|
||
* Specifies whether to validate and normalize all properties of
|
||
* the inner `IAccessInfo` object, including `action` and `possession`.
|
||
* @throws {Error} If `IAccessInfo` object fails validation.
|
||
*/
|
||
commitToGrants: function (grants, access, normalizeAll) {
|
||
if (normalizeAll === void 0) { normalizeAll = false; }
|
||
access = utils.normalizeAccessInfo(access, normalizeAll);
|
||
// console.log(access);
|
||
// grant.role also accepts an array, so treat it like it.
|
||
access.role.forEach(function (role) {
|
||
if (utils.validName(role) && !grants.hasOwnProperty(role)) {
|
||
grants[role] = {};
|
||
}
|
||
var grantItem = grants[role];
|
||
var ap = access.action + ':' + access.possession;
|
||
access.resource.forEach(function (res) {
|
||
if (utils.validName(res) && !grantItem.hasOwnProperty(res)) {
|
||
grantItem[res] = {};
|
||
}
|
||
// If possession (in action value or as a separate property) is
|
||
// omitted, it will default to "any". e.g. "create" —>
|
||
// "create:any"
|
||
grantItem[res][ap] = utils.toStringArray(access.attributes);
|
||
});
|
||
});
|
||
},
|
||
/**
|
||
* When more than one role is passed, we union the permitted attributes
|
||
* for all given roles; so we can check whether "at least one of these
|
||
* roles" have the permission to execute this action.
|
||
* e.g. `can(['admin', 'user']).createAny('video')`
|
||
*
|
||
* @param {Any} grants
|
||
* @param {IQueryInfo} query
|
||
*
|
||
* @returns {string[]} - Array of union'ed attributes.
|
||
*/
|
||
getUnionAttrsOfRoles: function (grants, query) {
|
||
// throws if has any invalid property value
|
||
query = utils.normalizeQueryInfo(query);
|
||
var role;
|
||
var resource;
|
||
var attrsList = [];
|
||
// get roles and extended roles in a flat array
|
||
var roles = utils.getFlatRoles(grants, query.role);
|
||
// iterate through roles and add permission attributes (array) of
|
||
// each role to attrsList (array).
|
||
roles.forEach(function (roleName, index) {
|
||
role = grants[roleName];
|
||
// no need to check role existence #getFlatRoles() does that.
|
||
resource = role[query.resource];
|
||
if (resource) {
|
||
// e.g. resource['create:own']
|
||
// If action has possession "any", it will also return
|
||
// `granted=true` for "own", if "own" is not defined.
|
||
attrsList.push((resource[query.action + ':' + query.possession]
|
||
|| resource[query.action + ':any']
|
||
|| []).concat());
|
||
// console.log(resource, 'for:', action + '.' + possession);
|
||
}
|
||
});
|
||
// union all arrays of (permitted resource) attributes (for each role)
|
||
// into a single array.
|
||
var attrs = [];
|
||
var len = attrsList.length;
|
||
if (len > 0) {
|
||
attrs = attrsList[0];
|
||
var i = 1;
|
||
while (i < len) {
|
||
attrs = Notation.Glob.union(attrs, attrsList[i]);
|
||
i++;
|
||
}
|
||
}
|
||
return attrs;
|
||
},
|
||
/**
|
||
* Locks the given AccessControl instance by freezing underlying grants
|
||
* model and disabling all functionality to modify it.
|
||
* @param {AccessControl} ac
|
||
*/
|
||
lockAC: function (ac) {
|
||
var _ac = ac; // ts
|
||
if (!_ac._grants || Object.keys(_ac._grants).length === 0) {
|
||
throw new core_1.AccessControlError('Cannot lock empty or invalid grants model.');
|
||
}
|
||
var locked = ac.isLocked && Object.isFrozen(_ac._grants);
|
||
if (!locked)
|
||
locked = Boolean(utils.deepFreeze(_ac._grants));
|
||
/* istanbul ignore next */
|
||
if (!locked) {
|
||
throw new core_1.AccessControlError("Could not lock grants: " + typeof _ac._grants);
|
||
}
|
||
_ac._isLocked = locked;
|
||
},
|
||
// ----------------------
|
||
// NOTATION/GLOB UTILS
|
||
// ----------------------
|
||
/**
|
||
* Deep clones the source object while filtering its properties by the
|
||
* given attributes (glob notations). Includes all matched properties and
|
||
* removes the rest.
|
||
*
|
||
* @param {Object} object - Object to be filtered.
|
||
* @param {string[]} attributes - Array of glob notations.
|
||
*
|
||
* @returns {Object} - Filtered object.
|
||
*/
|
||
filter: function (object, attributes) {
|
||
if (!Array.isArray(attributes) || attributes.length === 0) {
|
||
return {};
|
||
}
|
||
var notation = new Notation(object);
|
||
return notation.filter(attributes).value;
|
||
},
|
||
/**
|
||
* Deep clones the source array of objects or a single object while
|
||
* filtering their properties by the given attributes (glob notations).
|
||
* Includes all matched properties and removes the rest of each object in
|
||
* the array.
|
||
*
|
||
* @param {Array|Object} arrOrObj - Array of objects or single object to be
|
||
* filtered.
|
||
* @param {string[]} attributes - Array of glob notations.
|
||
*
|
||
* @returns {Array|Object}
|
||
*/
|
||
filterAll: function (arrOrObj, attributes) {
|
||
if (!Array.isArray(arrOrObj)) {
|
||
return utils.filter(arrOrObj, attributes);
|
||
}
|
||
return arrOrObj.map(function (o) {
|
||
return utils.filter(o, attributes);
|
||
});
|
||
}
|
||
};
|
||
exports.utils = utils;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/css-loader/dist/cjs.js!./src/assets/css/normalize.css":
|
||
/*!****************************************************************************!*\
|
||
!*** ./node_modules/css-loader/dist/cjs.js!./src/assets/css/normalize.css ***!
|
||
\****************************************************************************/
|
||
/***/ ((module, __webpack_exports__, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
__webpack_require__.r(__webpack_exports__);
|
||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||
/* harmony export */ });
|
||
/* harmony import */ var _node_modules_css_loader_dist_runtime_cssWithMappingToString_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../node_modules/css-loader/dist/runtime/cssWithMappingToString.js */ "./node_modules/css-loader/dist/runtime/cssWithMappingToString.js");
|
||
/* harmony import */ var _node_modules_css_loader_dist_runtime_cssWithMappingToString_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_cssWithMappingToString_js__WEBPACK_IMPORTED_MODULE_0__);
|
||
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../node_modules/css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
|
||
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
|
||
// Imports
|
||
|
||
|
||
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_cssWithMappingToString_js__WEBPACK_IMPORTED_MODULE_0___default()));
|
||
// Module
|
||
___CSS_LOADER_EXPORT___.push([module.id, "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */\n\n/* Document\n ========================================================================== */\n\n/**\n * 1. Correct the line height in all browsers.\n * 2. Prevent adjustments of font size after orientation changes in iOS.\n */\n\nhtml {\n line-height: 1.15; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n}\n\n/* Sections\n ========================================================================== */\n\n/**\n * Remove the margin in all browsers.\n */\n\nbody {\n margin: 0;\n}\n\n/**\n * Render the `main` element consistently in IE.\n */\n\nmain {\n display: block;\n}\n\n/**\n * Correct the font size and margin on `h1` elements within `section` and\n * `article` contexts in Chrome, Firefox, and Safari.\n */\n\nh1 {\n font-size: 2em;\n margin: 0.67em 0;\n}\n\n/* Grouping content\n ========================================================================== */\n\n/**\n * 1. Add the correct box sizing in Firefox.\n * 2. Show the overflow in Edge and IE.\n */\n\nhr {\n box-sizing: content-box; /* 1 */\n height: 0; /* 1 */\n overflow: visible; /* 2 */\n}\n\n/**\n * 1. Correct the inheritance and scaling of font size in all browsers.\n * 2. Correct the odd `em` font sizing in all browsers.\n */\n\npre {\n font-family: monospace, monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/* Text-level semantics\n ========================================================================== */\n\n/**\n * Remove the gray background on active links in IE 10.\n */\n\na {\n background-color: transparent;\n}\n\n/**\n * 1. Remove the bottom border in Chrome 57-\n * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.\n */\n\nabbr[title] {\n border-bottom: none; /* 1 */\n text-decoration: underline; /* 2 */\n text-decoration: underline dotted; /* 2 */\n}\n\n/**\n * Add the correct font weight in Chrome, Edge, and Safari.\n */\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/**\n * 1. Correct the inheritance and scaling of font size in all browsers.\n * 2. Correct the odd `em` font sizing in all browsers.\n */\n\ncode,\nkbd,\nsamp {\n font-family: monospace, monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/**\n * Add the correct font size in all browsers.\n */\n\nsmall {\n font-size: 80%;\n}\n\n/**\n * Prevent `sub` and `sup` elements from affecting the line height in\n * all browsers.\n */\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/* Embedded content\n ========================================================================== */\n\n/**\n * Remove the border on images inside links in IE 10.\n */\n\nimg {\n border-style: none;\n}\n\n/* Forms\n ========================================================================== */\n\n/**\n * 1. Change the font styles in all browsers.\n * 2. Remove the margin in Firefox and Safari.\n */\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-size: 100%; /* 1 */\n line-height: 1.15; /* 1 */\n margin: 0; /* 2 */\n}\n\n/**\n * Show the overflow in IE.\n * 1. Show the overflow in Edge.\n */\n\nbutton,\ninput {\n /* 1 */\n overflow: visible;\n}\n\n/**\n * Remove the inheritance of text transform in Edge, Firefox, and IE.\n * 1. Remove the inheritance of text transform in Firefox.\n */\n\nbutton,\nselect {\n /* 1 */\n text-transform: none;\n}\n\n/**\n * Correct the inability to style clickable types in iOS and Safari.\n */\n\nbutton,\n[type=\"button\"],\n[type=\"reset\"],\n[type=\"submit\"] {\n -webkit-appearance: button;\n}\n\n/**\n * Remove the inner border and padding in Firefox.\n */\n\nbutton::-moz-focus-inner,\n[type=\"button\"]::-moz-focus-inner,\n[type=\"reset\"]::-moz-focus-inner,\n[type=\"submit\"]::-moz-focus-inner {\n border-style: none;\n padding: 0;\n}\n\n/**\n * Restore the focus styles unset by the previous rule.\n */\n\nbutton:-moz-focusring,\n[type=\"button\"]:-moz-focusring,\n[type=\"reset\"]:-moz-focusring,\n[type=\"submit\"]:-moz-focusring {\n outline: 1px dotted ButtonText;\n}\n\n/**\n * Correct the padding in Firefox.\n */\n\nfieldset {\n padding: 0.35em 0.75em 0.625em;\n}\n\n/**\n * 1. Correct the text wrapping in Edge and IE.\n * 2. Correct the color inheritance from `fieldset` elements in IE.\n * 3. Remove the padding so developers are not caught out when they zero out\n * `fieldset` elements in all browsers.\n */\n\nlegend {\n box-sizing: border-box; /* 1 */\n color: inherit; /* 2 */\n display: table; /* 1 */\n max-width: 100%; /* 1 */\n padding: 0; /* 3 */\n white-space: normal; /* 1 */\n}\n\n/**\n * Add the correct vertical alignment in Chrome, Firefox, and Opera.\n */\n\nprogress {\n vertical-align: baseline;\n}\n\n/**\n * Remove the default vertical scrollbar in IE 10+.\n */\n\ntextarea {\n overflow: auto;\n}\n\n/**\n * 1. Add the correct box sizing in IE 10.\n * 2. Remove the padding in IE 10.\n */\n\n[type=\"checkbox\"],\n[type=\"radio\"] {\n box-sizing: border-box; /* 1 */\n padding: 0; /* 2 */\n}\n\n/**\n * Correct the cursor style of increment and decrement buttons in Chrome.\n */\n\n[type=\"number\"]::-webkit-inner-spin-button,\n[type=\"number\"]::-webkit-outer-spin-button {\n height: auto;\n}\n\n/**\n * 1. Correct the odd appearance in Chrome and Safari.\n * 2. Correct the outline style in Safari.\n */\n\n[type=\"search\"] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/**\n * Remove the inner padding in Chrome and Safari on macOS.\n */\n\n[type=\"search\"]::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/**\n * 1. Correct the inability to style clickable types in iOS and Safari.\n * 2. Change font properties to `inherit` in Safari.\n */\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/* Interactive\n ========================================================================== */\n\n/*\n * Add the correct display in Edge, IE 10+, and Firefox.\n */\n\ndetails {\n display: block;\n}\n\n/*\n * Add the correct display in all browsers.\n */\n\nsummary {\n display: list-item;\n}\n\n/* Misc\n ========================================================================== */\n\n/**\n * Add the correct display in IE 10+.\n */\n\ntemplate {\n display: none;\n}\n\n/**\n * Add the correct display in IE 10.\n */\n\n[hidden] {\n display: none;\n}\n", "",{"version":3,"sources":["webpack://./src/assets/css/normalize.css"],"names":[],"mappings":"AAAA,2EAA2E;;AAE3E;+EAC+E;;AAE/E;;;EAGE;;AAEF;EACE,iBAAiB,EAAE,MAAM;EACzB,8BAA8B,EAAE,MAAM;AACxC;;AAEA;+EAC+E;;AAE/E;;EAEE;;AAEF;EACE,SAAS;AACX;;AAEA;;EAEE;;AAEF;EACE,cAAc;AAChB;;AAEA;;;EAGE;;AAEF;EACE,cAAc;EACd,gBAAgB;AAClB;;AAEA;+EAC+E;;AAE/E;;;EAGE;;AAEF;EACE,uBAAuB,EAAE,MAAM;EAC/B,SAAS,EAAE,MAAM;EACjB,iBAAiB,EAAE,MAAM;AAC3B;;AAEA;;;EAGE;;AAEF;EACE,iCAAiC,EAAE,MAAM;EACzC,cAAc,EAAE,MAAM;AACxB;;AAEA;+EAC+E;;AAE/E;;EAEE;;AAEF;EACE,6BAA6B;AAC/B;;AAEA;;;EAGE;;AAEF;EACE,mBAAmB,EAAE,MAAM;EAC3B,0BAA0B,EAAE,MAAM;EAClC,iCAAiC,EAAE,MAAM;AAC3C;;AAEA;;EAEE;;AAEF;;EAEE,mBAAmB;AACrB;;AAEA;;;EAGE;;AAEF;;;EAGE,iCAAiC,EAAE,MAAM;EACzC,cAAc,EAAE,MAAM;AACxB;;AAEA;;EAEE;;AAEF;EACE,cAAc;AAChB;;AAEA;;;EAGE;;AAEF;;EAEE,cAAc;EACd,cAAc;EACd,kBAAkB;EAClB,wBAAwB;AAC1B;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,WAAW;AACb;;AAEA;+EAC+E;;AAE/E;;EAEE;;AAEF;EACE,kBAAkB;AACpB;;AAEA;+EAC+E;;AAE/E;;;EAGE;;AAEF;;;;;EAKE,oBAAoB,EAAE,MAAM;EAC5B,eAAe,EAAE,MAAM;EACvB,iBAAiB,EAAE,MAAM;EACzB,SAAS,EAAE,MAAM;AACnB;;AAEA;;;EAGE;;AAEF;;EAEE,MAAM;EACN,iBAAiB;AACnB;;AAEA;;;EAGE;;AAEF;;EAEE,MAAM;EACN,oBAAoB;AACtB;;AAEA;;EAEE;;AAEF;;;;EAIE,0BAA0B;AAC5B;;AAEA;;EAEE;;AAEF;;;;EAIE,kBAAkB;EAClB,UAAU;AACZ;;AAEA;;EAEE;;AAEF;;;;EAIE,8BAA8B;AAChC;;AAEA;;EAEE;;AAEF;EACE,8BAA8B;AAChC;;AAEA;;;;;EAKE;;AAEF;EACE,sBAAsB,EAAE,MAAM;EAC9B,cAAc,EAAE,MAAM;EACtB,cAAc,EAAE,MAAM;EACtB,eAAe,EAAE,MAAM;EACvB,UAAU,EAAE,MAAM;EAClB,mBAAmB,EAAE,MAAM;AAC7B;;AAEA;;EAEE;;AAEF;EACE,wBAAwB;AAC1B;;AAEA;;EAEE;;AAEF;EACE,cAAc;AAChB;;AAEA;;;EAGE;;AAEF;;EAEE,sBAAsB,EAAE,MAAM;EAC9B,UAAU,EAAE,MAAM;AACpB;;AAEA;;EAEE;;AAEF;;EAEE,YAAY;AACd;;AAEA;;;EAGE;;AAEF;EACE,6BAA6B,EAAE,MAAM;EACrC,oBAAoB,EAAE,MAAM;AAC9B;;AAEA;;EAEE;;AAEF;EACE,wBAAwB;AAC1B;;AAEA;;;EAGE;;AAEF;EACE,0BAA0B,EAAE,MAAM;EAClC,aAAa,EAAE,MAAM;AACvB;;AAEA;+EAC+E;;AAE/E;;EAEE;;AAEF;EACE,cAAc;AAChB;;AAEA;;EAEE;;AAEF;EACE,kBAAkB;AACpB;;AAEA;+EAC+E;;AAE/E;;EAEE;;AAEF;EACE,aAAa;AACf;;AAEA;;EAEE;;AAEF;EACE,aAAa;AACf","sourcesContent":["/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */\n\n/* Document\n ========================================================================== */\n\n/**\n * 1. Correct the line height in all browsers.\n * 2. Prevent adjustments of font size after orientation changes in iOS.\n */\n\nhtml {\n line-height: 1.15; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n}\n\n/* Sections\n ========================================================================== */\n\n/**\n * Remove the margin in all browsers.\n */\n\nbody {\n margin: 0;\n}\n\n/**\n * Render the `main` element consistently in IE.\n */\n\nmain {\n display: block;\n}\n\n/**\n * Correct the font size and margin on `h1` elements within `section` and\n * `article` contexts in Chrome, Firefox, and Safari.\n */\n\nh1 {\n font-size: 2em;\n margin: 0.67em 0;\n}\n\n/* Grouping content\n ========================================================================== */\n\n/**\n * 1. Add the correct box sizing in Firefox.\n * 2. Show the overflow in Edge and IE.\n */\n\nhr {\n box-sizing: content-box; /* 1 */\n height: 0; /* 1 */\n overflow: visible; /* 2 */\n}\n\n/**\n * 1. Correct the inheritance and scaling of font size in all browsers.\n * 2. Correct the odd `em` font sizing in all browsers.\n */\n\npre {\n font-family: monospace, monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/* Text-level semantics\n ========================================================================== */\n\n/**\n * Remove the gray background on active links in IE 10.\n */\n\na {\n background-color: transparent;\n}\n\n/**\n * 1. Remove the bottom border in Chrome 57-\n * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.\n */\n\nabbr[title] {\n border-bottom: none; /* 1 */\n text-decoration: underline; /* 2 */\n text-decoration: underline dotted; /* 2 */\n}\n\n/**\n * Add the correct font weight in Chrome, Edge, and Safari.\n */\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/**\n * 1. Correct the inheritance and scaling of font size in all browsers.\n * 2. Correct the odd `em` font sizing in all browsers.\n */\n\ncode,\nkbd,\nsamp {\n font-family: monospace, monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/**\n * Add the correct font size in all browsers.\n */\n\nsmall {\n font-size: 80%;\n}\n\n/**\n * Prevent `sub` and `sup` elements from affecting the line height in\n * all browsers.\n */\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/* Embedded content\n ========================================================================== */\n\n/**\n * Remove the border on images inside links in IE 10.\n */\n\nimg {\n border-style: none;\n}\n\n/* Forms\n ========================================================================== */\n\n/**\n * 1. Change the font styles in all browsers.\n * 2. Remove the margin in Firefox and Safari.\n */\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-size: 100%; /* 1 */\n line-height: 1.15; /* 1 */\n margin: 0; /* 2 */\n}\n\n/**\n * Show the overflow in IE.\n * 1. Show the overflow in Edge.\n */\n\nbutton,\ninput {\n /* 1 */\n overflow: visible;\n}\n\n/**\n * Remove the inheritance of text transform in Edge, Firefox, and IE.\n * 1. Remove the inheritance of text transform in Firefox.\n */\n\nbutton,\nselect {\n /* 1 */\n text-transform: none;\n}\n\n/**\n * Correct the inability to style clickable types in iOS and Safari.\n */\n\nbutton,\n[type=\"button\"],\n[type=\"reset\"],\n[type=\"submit\"] {\n -webkit-appearance: button;\n}\n\n/**\n * Remove the inner border and padding in Firefox.\n */\n\nbutton::-moz-focus-inner,\n[type=\"button\"]::-moz-focus-inner,\n[type=\"reset\"]::-moz-focus-inner,\n[type=\"submit\"]::-moz-focus-inner {\n border-style: none;\n padding: 0;\n}\n\n/**\n * Restore the focus styles unset by the previous rule.\n */\n\nbutton:-moz-focusring,\n[type=\"button\"]:-moz-focusring,\n[type=\"reset\"]:-moz-focusring,\n[type=\"submit\"]:-moz-focusring {\n outline: 1px dotted ButtonText;\n}\n\n/**\n * Correct the padding in Firefox.\n */\n\nfieldset {\n padding: 0.35em 0.75em 0.625em;\n}\n\n/**\n * 1. Correct the text wrapping in Edge and IE.\n * 2. Correct the color inheritance from `fieldset` elements in IE.\n * 3. Remove the padding so developers are not caught out when they zero out\n * `fieldset` elements in all browsers.\n */\n\nlegend {\n box-sizing: border-box; /* 1 */\n color: inherit; /* 2 */\n display: table; /* 1 */\n max-width: 100%; /* 1 */\n padding: 0; /* 3 */\n white-space: normal; /* 1 */\n}\n\n/**\n * Add the correct vertical alignment in Chrome, Firefox, and Opera.\n */\n\nprogress {\n vertical-align: baseline;\n}\n\n/**\n * Remove the default vertical scrollbar in IE 10+.\n */\n\ntextarea {\n overflow: auto;\n}\n\n/**\n * 1. Add the correct box sizing in IE 10.\n * 2. Remove the padding in IE 10.\n */\n\n[type=\"checkbox\"],\n[type=\"radio\"] {\n box-sizing: border-box; /* 1 */\n padding: 0; /* 2 */\n}\n\n/**\n * Correct the cursor style of increment and decrement buttons in Chrome.\n */\n\n[type=\"number\"]::-webkit-inner-spin-button,\n[type=\"number\"]::-webkit-outer-spin-button {\n height: auto;\n}\n\n/**\n * 1. Correct the odd appearance in Chrome and Safari.\n * 2. Correct the outline style in Safari.\n */\n\n[type=\"search\"] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/**\n * Remove the inner padding in Chrome and Safari on macOS.\n */\n\n[type=\"search\"]::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/**\n * 1. Correct the inability to style clickable types in iOS and Safari.\n * 2. Change font properties to `inherit` in Safari.\n */\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/* Interactive\n ========================================================================== */\n\n/*\n * Add the correct display in Edge, IE 10+, and Firefox.\n */\n\ndetails {\n display: block;\n}\n\n/*\n * Add the correct display in all browsers.\n */\n\nsummary {\n display: list-item;\n}\n\n/* Misc\n ========================================================================== */\n\n/**\n * Add the correct display in IE 10+.\n */\n\ntemplate {\n display: none;\n}\n\n/**\n * Add the correct display in IE 10.\n */\n\n[hidden] {\n display: none;\n}\n"],"sourceRoot":""}]);
|
||
// Exports
|
||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/css-loader/dist/runtime/api.js":
|
||
/*!*****************************************************!*\
|
||
!*** ./node_modules/css-loader/dist/runtime/api.js ***!
|
||
\*****************************************************/
|
||
/***/ ((module) => {
|
||
|
||
"use strict";
|
||
|
||
|
||
/*
|
||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||
Author Tobias Koppers @sokra
|
||
*/
|
||
// css base code, injected by the css-loader
|
||
// eslint-disable-next-line func-names
|
||
module.exports = function (cssWithMappingToString) {
|
||
var list = []; // return the list of modules as css string
|
||
|
||
list.toString = function toString() {
|
||
return this.map(function (item) {
|
||
var content = cssWithMappingToString(item);
|
||
|
||
if (item[2]) {
|
||
return "@media ".concat(item[2], " {").concat(content, "}");
|
||
}
|
||
|
||
return content;
|
||
}).join("");
|
||
}; // import a list of modules into the list
|
||
// eslint-disable-next-line func-names
|
||
|
||
|
||
list.i = function (modules, mediaQuery, dedupe) {
|
||
if (typeof modules === "string") {
|
||
// eslint-disable-next-line no-param-reassign
|
||
modules = [[null, modules, ""]];
|
||
}
|
||
|
||
var alreadyImportedModules = {};
|
||
|
||
if (dedupe) {
|
||
for (var i = 0; i < this.length; i++) {
|
||
// eslint-disable-next-line prefer-destructuring
|
||
var id = this[i][0];
|
||
|
||
if (id != null) {
|
||
alreadyImportedModules[id] = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
for (var _i = 0; _i < modules.length; _i++) {
|
||
var item = [].concat(modules[_i]);
|
||
|
||
if (dedupe && alreadyImportedModules[item[0]]) {
|
||
// eslint-disable-next-line no-continue
|
||
continue;
|
||
}
|
||
|
||
if (mediaQuery) {
|
||
if (!item[2]) {
|
||
item[2] = mediaQuery;
|
||
} else {
|
||
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
|
||
}
|
||
}
|
||
|
||
list.push(item);
|
||
}
|
||
};
|
||
|
||
return list;
|
||
};
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/css-loader/dist/runtime/cssWithMappingToString.js":
|
||
/*!************************************************************************!*\
|
||
!*** ./node_modules/css-loader/dist/runtime/cssWithMappingToString.js ***!
|
||
\************************************************************************/
|
||
/***/ ((module) => {
|
||
|
||
"use strict";
|
||
|
||
|
||
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 && (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; }
|
||
|
||
module.exports = function cssWithMappingToString(item) {
|
||
var _item = _slicedToArray(item, 4),
|
||
content = _item[1],
|
||
cssMapping = _item[3];
|
||
|
||
if (!cssMapping) {
|
||
return content;
|
||
}
|
||
|
||
if (typeof btoa === "function") {
|
||
// eslint-disable-next-line no-undef
|
||
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
|
||
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
|
||
var sourceMapping = "/*# ".concat(data, " */");
|
||
var sourceURLs = cssMapping.sources.map(function (source) {
|
||
return "/*# sourceURL=".concat(cssMapping.sourceRoot || "").concat(source, " */");
|
||
});
|
||
return [content].concat(sourceURLs).concat([sourceMapping]).join("\n");
|
||
}
|
||
|
||
return [content].join("\n");
|
||
};
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/notation/lib/notation.min.js":
|
||
/*!***************************************************!*\
|
||
!*** ./node_modules/notation/lib/notation.min.js ***!
|
||
\***************************************************/
|
||
/***/ (function(module) {
|
||
|
||
!function(e,t){ true?module.exports=t():0}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="lib/",t(t.s=2)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.prototype.toString,i={isObject:function(e){return"[object Object]"===r.call(e)},isArray:function(e){return"[object Array]"===r.call(e)},ensureArray:function(e){return i.isArray(e)?e:null===e||void 0===e?[]:[e]},hasOwn:function(e,t){return e&&"function"==typeof e.hasOwnProperty&&e.hasOwnProperty(t)},deepCopy:function(e){if(!i.isObject(e))return e;var t=void 0,n=void 0,r={};for(t in e)i.hasOwn(e,t)&&(n=e[t],r[t]=i.isObject(n)?i.deepCopy(n):n);return r},each:function(e,t,n){for(var r=e.length,i=-1;++i<r&&!1!==t.call(n,e[i],i,e););},eachRight:function(e,t){for(var n=e.length;n--&&!1!==t(e[n],n,e););},pregQuote:function(e,t){return String(e).replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\"+(t||"")+"-]","g"),"\\$&")},stringOrArrayOf:function(e,t){return"string"==typeof e&&e===t||i.isArray(e)&&1===e.length&&e[0]===t},hasSingleItemOf:function(e,t){return 1===e.length&&(2!==arguments.length||e[0]===t)}};t.default=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.name=n.constructor.name,Object.defineProperty(n,"name",{enumerable:!1,writable:!1,value:"NotationError"}),Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:e}),Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(n,n.constructor):Object.defineProperty(n,"stack",{enumerable:!1,writable:!1,value:new Error(e).stack}),n}return u(t,e),t}(Error);t.default=a},function(e,t,n){"use strict";var r=n(3),i=function(e){return e&&e.__esModule?e:{default:e}}(r);e.exports=i.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(0),o=r(a),s=n(4),l=r(s),c=n(1),f=r(c),v={SOURCE:"Invalid source object.",DEST:"Invalid destination object.",NOTATION:"Invalid notation: ",NOTA_OBJ:"Invalid notations object: "},h=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(i(this,e),!o.default.isObject(t))throw new f.default(v.SOURCE);this._source=t}return u(e,[{key:"each",value:function(t){var n=this,r=this._source,i=Object.keys(r);o.default.each(i,function(i,u,a){var s=r[i],l=void 0;o.default.isObject(s)?(l=new e(s),l.each(function(e,n,u,a){var o=i+"."+e;t.call(l,o,n,u,r)})):t.call(n,i,i,s,r)})}},{key:"eachKey",value:function(e){return this.each(e)}},{key:"eachValue",value:function(t,n){if(!e.isValid(t))throw new f.default(v.NOTATION+"`"+t+"`");var r=this._source;e.eachNote(t,function(e,t,i,u){if(r=o.default.hasOwn(r,t)?r[t]:void 0,!1===n(r,e,t,i,u))return!1})}},{key:"getNotations",value:function(){var e=[];return this.each(function(t,n,r,i){e.push(t)}),e}},{key:"flatten",value:function(){var e={};return this.each(function(t,n,r,i){e[t]=r}),this._source=e,this}},{key:"expand",value:function(){return this._source=e.create({}).merge(this._source).value,this}},{key:"aggregate",value:function(){return this.expand()}},{key:"inspect",value:function(t){if(!e.isValid(t))throw new f.default(v.NOTATION+"`"+t+"`");var n=this._source,r={has:!1,value:void 0};return e.eachNote(t,function(e,t,i,u){if(!o.default.hasOwn(n,t))return r={has:!1,value:void 0},!1;n=n[t],r={has:!0,value:n}}),r}},{key:"inspectRemove",value:function(t){if(!e.isValid(t))throw new f.default(v.NOTATION+"`"+t+"`");var n=void 0,r=void 0;if(t.indexOf(".")<0)r=t,n=this._source;else{var i=e.parent(t);r=e.last(t),n=this.inspect(i).value}var u=void 0;return o.default.hasOwn(n,r)?(u={has:!0,value:n[r]},delete n[r]):u={has:!1,value:void 0},u}},{key:"has",value:function(e){return this.inspect(e).has}},{key:"hasDefined",value:function(e){return void 0!==this.inspect(e).value}},{key:"get",value:function(e,t){var n=this.inspect(e);return n.has?n.value:t}},{key:"set",value:function(t,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!e.isValid(t))throw new f.default(v.NOTATION+"`"+t+"`");var i=this._source,u=void 0;return e.eachNote(t,function(e,t,a,s){u=a===s.length-1,o.default.hasOwn(i,t)?u?r&&(i[t]=n):i=i[t]:i=i[t]=u?n:{}}),this}},{key:"merge",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!o.default.isObject(e))throw new f.default(v.NOTA_OBJ+"`"+e+"`");var r=void 0;return o.default.each(Object.keys(e),function(i,u,a){r=e[i],t.set(i,r,n)}),this}},{key:"separate",value:function(t){var n=this;if(!o.default.isArray(t))throw new f.default(v.NOTA_OBJ+"`"+t+"`");var r=new e({});return o.default.each(t,function(e,t,i){var u=n.inspectRemove(e);r.set(e,u.value)}),this._source=r._source,this}},{key:"filter",value:function(t){var n=this,r=this.value,i=o.default.deepCopy(r),u=l.default.normalize(t).concat();if(o.default.stringOrArrayOf(u,"*"))return this._source=i,this;if(0===arguments.length||o.default.stringOrArrayOf(u,"")||o.default.stringOrArrayOf(u,"!*"))return this._source={},this;var a=void 0;"*"===u[0]?(a=new e(i),u.shift()):a=new e({});var s=void 0,c=void 0,f=void 0;return o.default.each(u,function(t,i,u){if(s=new l.default(t),c=".*"===s.absGlob.slice(-2),f=c?s.absGlob.slice(0,-2):s.absGlob,f.indexOf("*")<0)return s.isNegated?(a.remove(f),c&&a.set(f,{},!0)):a.copyFrom(r,f,null,!0),!0;n.each(function(t,n,r,i){e.eachNote(t,function(e,t,n,i){if(s.test(e)){if(s.isNegated)return a.remove(e),!1;a.set(e,r,!0)}})})}),this._source=a.value,this}},{key:"remove",value:function(e){return this.inspectRemove(e),this}},{key:"delete",value:function(e){return this.remove(e),this}},{key:"clone",value:function(){return new e(o.default.deepCopy(this.value))}},{key:"copyTo",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!o.default.isObject(t))throw new f.default(v.DEST);var u=this.inspect(n);return u.has&&new e(t).set(r||n,u.value,i),this}},{key:"copyFrom",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!o.default.isObject(t))throw new f.default(v.DEST);var u=new e(t).inspect(n);return u.has&&this.set(r||n,u.value,i),this}},{key:"moveTo",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!o.default.isObject(t))throw new f.default(v.DEST);var u=this.inspectRemove(n);return u.has&&new e(t).set(r||n,u.value,i),this}},{key:"moveFrom",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!o.default.isObject(t))throw new f.default(v.DEST);var u=new e(t).inspectRemove(n);return u.has&&this.set(r||n,u.value,i),this}},{key:"rename",value:function(e,t,n){return t?this.moveTo(this._source,e,t,n):this}},{key:"renote",value:function(e,t,n){return this.rename(e,t,n)}},{key:"extract",value:function(e,t){var n={};return this.copyTo(n,e,t),n}},{key:"copyToNew",value:function(e,t){return this.extract(e,t)}},{key:"extrude",value:function(e,t){var n={};return this.moveTo(n,e,t),n}},{key:"moveToNew",value:function(e,t){return this.extrude(e,t)}},{key:"value",get:function(){return this._source}}],[{key:"create",value:function(){return new e(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"isValid",value:function(e){return"string"==typeof e&&/^[^\s.!]+(\.[^\s.!]+)*$/.test(e)}},{key:"countNotes",value:function(t){if(!e.isValid(t))throw new f.default(v.NOTATION+"`"+t+"`");return t.split(".").length}},{key:"countLevels",value:function(t){return e.countNotes(t)}},{key:"first",value:function(t){if(!e.isValid(t))throw new f.default(v.NOTATION+"`"+t+"`");return t.split(".")[0]}},{key:"last",value:function(t){if(!e.isValid(t))throw new f.default(v.NOTATION+"`"+t+"`");return t.split(".").reverse()[0]}},{key:"parent",value:function(t){if(!e.isValid(t))throw new f.default(v.NOTATION+"`"+t+"`");return t.indexOf(".")>=0?t.replace(/\.[^.]*$/,""):null}},{key:"eachNote",value:function(t,n){if(!e.isValid(t))throw new f.default(v.NOTATION+"`"+t+"`");var r=t.split("."),i=[],u=void 0;o.default.each(r,function(e,t,a){if(i.push(e),u=i.join("."),!1===n(u,e,t,r))return!1},e)}},{key:"eachLevel",value:function(t,n){e.eachNote(t,n)}}]),e}();h.Error=f.default,h.Glob=l.default,t.default=h},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(0),o=r(a),s=n(1),l=r(s),c=function(){function e(t){if(i(this,e),!e.isValid(t))throw new l.default('Invalid notation glob: "'+t+'"');var n=e.inspect(t);this._={glob:t,absGlob:n.absGlob,isNegated:n.isNegated,regexp:e.toRegExp(n.absGlob),levels:n.absGlob.split(".")}}return u(e,[{key:"test",value:function(e){return"*"===this.absGlob||""!==this.absGlob&&""!==e&&this.regexp.test(e)}},{key:"glob",get:function(){return this._.glob}},{key:"absGlob",get:function(){return this._.absGlob}},{key:"isNegated",get:function(){return this._.isNegated}},{key:"regexp",get:function(){return this._.regexp}},{key:"notes",get:function(){return this._.levels}},{key:"levels",get:function(){return this._.levels}}],[{key:"create",value:function(t){return new e(t)}},{key:"toRegExp",value:function(e){return 0===e.indexOf("!")&&(e=e.slice(1)),e=o.default.pregQuote(e).replace(/\\\*/g,"[^\\s\\.]*").replace(/\\\?/g,"."),new RegExp("^"+e+"(\\..+|$)")}},{key:"inspect",value:function(e){var t="!"===e.slice(0,1);return e=t?e.slice(1):e,{absGlob:e,isNegated:t}}},{key:"isValid",value:function(e){return"string"==typeof e&&/^(!?([^\s.!*]+|\*)(\.([^\s.!*]+|\*))*)$/.test(e)}},{key:"compare",value:function(e,t){if(e===t)return 0;var n=e.split("."),r=t.split(".");if(n.length===r.length){var i=/(?:^|\.)\*(?:$|\.)/g,u=e.match(i),a=t.match(i),o=u?u.length:0,s=a?a.length:0;if(o===s){var l=0===e.indexOf("!"),c=0===t.indexOf("!");if(l===c)return e<t?-1:1;var f=l?e.slice(1):e,v=c?t.slice(1):t;return f===v?l?1:-1:f<v?-1:1}return o>s?-1:1}return n.length<r.length?-1:1}},{key:"sort",value:function(t){return t.sort(e.compare)}},{key:"normalize",value:function(t){t=o.default.ensureArray(t).map(function(e){return e.trim()}),t=e.sort(t),o.default.eachRight(t,function(n,r){var i=e.inspect(n),u=!1,a=!1,s=!1,l=!0,c=!1,f=!0;o.default.eachRight(t,function(t,o){if(o!==r){var v=e.inspect(t),h=e.toRegExp(v.absGlob);if(n===t)return u=!0,!1;if(v.isNegated&&n===v.absGlob)return a=!0,!1;if(i.isNegated){if(v.isNegated&&h.test(i.absGlob))return s=!0,!1;l&&h.test(i.absGlob)&&(l=!1)}else!v.isNegated&&h.test(i.absGlob)?c=!0:f&&h.test(i.absGlob)&&(f=!1)}});var v=i.isNegated?s||l:c&&f;(u||a||v)&&t.splice(r,1)});var n=t.indexOf("!*");return n>=0&&t.splice(n,1),t}},{key:"union",value:function(t,n){if(o.default.hasSingleItemOf(t,"*")||o.default.hasSingleItemOf(n,"*"))return["*"];var r=t.concat(),i=n.concat(),u=void 0,a=void 0,s=void 0,l=void 0,c=[];o.default.eachRight(r,function(t,n){s=e.inspect(t),u=e.toRegExp(s.absGlob),o.default.eachRight(i,function(o,f){if(l=e.inspect(o),a=e.toRegExp(l.absGlob),s.isNegated&&!l.isNegated){if(s.absGlob===l.absGlob)return r.splice(n,1),!1;if(a.test(s.absGlob)&&-1===i.indexOf(t)&&-1===c.indexOf(t))return r.splice(n,1),!1}if(!s.isNegated&&l.isNegated){if(s.absGlob===l.absGlob)return void i.splice(f,1);if(u.test(l.absGlob)&&-1===r.indexOf(o)&&-1===c.indexOf(o))return void i.splice(f,1)}if(s.isNegated&&l.isNegated&&t!==o){if(a.test(s.absGlob))return i.splice(f,1),void c.push(t);if(u.test(l.absGlob))return r.splice(n,1),c.push(o),!1}if(!s.isNegated&&!l.isNegated&&t===o)return r.splice(n,1),!1})});var f=r.concat(i);return e.normalize(f)}}]),e}();t.default=c}])});
|
||
//# sourceMappingURL=notation.min.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./src/assets/css/normalize.css":
|
||
/*!**************************************!*\
|
||
!*** ./src/assets/css/normalize.css ***!
|
||
\**************************************/
|
||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
__webpack_require__.r(__webpack_exports__);
|
||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||
/* harmony export */ });
|
||
/* harmony import */ var _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
|
||
/* harmony import */ var _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
|
||
/* harmony import */ var _node_modules_css_loader_dist_cjs_js_normalize_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !!../../../node_modules/css-loader/dist/cjs.js!./normalize.css */ "./node_modules/css-loader/dist/cjs.js!./src/assets/css/normalize.css");
|
||
|
||
|
||
|
||
var options = {};
|
||
|
||
options.insert = "head";
|
||
options.singleton = false;
|
||
|
||
var update = _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_node_modules_css_loader_dist_cjs_js_normalize_css__WEBPACK_IMPORTED_MODULE_1__["default"], options);
|
||
|
||
|
||
|
||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_normalize_css__WEBPACK_IMPORTED_MODULE_1__["default"].locals || {});
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":
|
||
/*!****************************************************************************!*\
|
||
!*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
|
||
\****************************************************************************/
|
||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
|
||
|
||
var isOldIE = function isOldIE() {
|
||
var memo;
|
||
return function memorize() {
|
||
if (typeof memo === 'undefined') {
|
||
// Test for IE <= 9 as proposed by Browserhacks
|
||
// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
|
||
// Tests for existence of standard globals is to allow style-loader
|
||
// to operate correctly into non-standard environments
|
||
// @see https://github.com/webpack-contrib/style-loader/issues/177
|
||
memo = Boolean(window && document && document.all && !window.atob);
|
||
}
|
||
|
||
return memo;
|
||
};
|
||
}();
|
||
|
||
var getTarget = function getTarget() {
|
||
var memo = {};
|
||
return function memorize(target) {
|
||
if (typeof memo[target] === 'undefined') {
|
||
var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
|
||
|
||
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
|
||
try {
|
||
// This will throw an exception if access to iframe is blocked
|
||
// due to cross-origin restrictions
|
||
styleTarget = styleTarget.contentDocument.head;
|
||
} catch (e) {
|
||
// istanbul ignore next
|
||
styleTarget = null;
|
||
}
|
||
}
|
||
|
||
memo[target] = styleTarget;
|
||
}
|
||
|
||
return memo[target];
|
||
};
|
||
}();
|
||
|
||
var stylesInDom = [];
|
||
|
||
function getIndexByIdentifier(identifier) {
|
||
var result = -1;
|
||
|
||
for (var i = 0; i < stylesInDom.length; i++) {
|
||
if (stylesInDom[i].identifier === identifier) {
|
||
result = i;
|
||
break;
|
||
}
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
function modulesToDom(list, options) {
|
||
var idCountMap = {};
|
||
var identifiers = [];
|
||
|
||
for (var i = 0; i < list.length; i++) {
|
||
var item = list[i];
|
||
var id = options.base ? item[0] + options.base : item[0];
|
||
var count = idCountMap[id] || 0;
|
||
var identifier = "".concat(id, " ").concat(count);
|
||
idCountMap[id] = count + 1;
|
||
var index = getIndexByIdentifier(identifier);
|
||
var obj = {
|
||
css: item[1],
|
||
media: item[2],
|
||
sourceMap: item[3]
|
||
};
|
||
|
||
if (index !== -1) {
|
||
stylesInDom[index].references++;
|
||
stylesInDom[index].updater(obj);
|
||
} else {
|
||
stylesInDom.push({
|
||
identifier: identifier,
|
||
updater: addStyle(obj, options),
|
||
references: 1
|
||
});
|
||
}
|
||
|
||
identifiers.push(identifier);
|
||
}
|
||
|
||
return identifiers;
|
||
}
|
||
|
||
function insertStyleElement(options) {
|
||
var style = document.createElement('style');
|
||
var attributes = options.attributes || {};
|
||
|
||
if (typeof attributes.nonce === 'undefined') {
|
||
var nonce = true ? __webpack_require__.nc : 0;
|
||
|
||
if (nonce) {
|
||
attributes.nonce = nonce;
|
||
}
|
||
}
|
||
|
||
Object.keys(attributes).forEach(function (key) {
|
||
style.setAttribute(key, attributes[key]);
|
||
});
|
||
|
||
if (typeof options.insert === 'function') {
|
||
options.insert(style);
|
||
} else {
|
||
var target = getTarget(options.insert || 'head');
|
||
|
||
if (!target) {
|
||
throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
|
||
}
|
||
|
||
target.appendChild(style);
|
||
}
|
||
|
||
return style;
|
||
}
|
||
|
||
function removeStyleElement(style) {
|
||
// istanbul ignore if
|
||
if (style.parentNode === null) {
|
||
return false;
|
||
}
|
||
|
||
style.parentNode.removeChild(style);
|
||
}
|
||
/* istanbul ignore next */
|
||
|
||
|
||
var replaceText = function replaceText() {
|
||
var textStore = [];
|
||
return function replace(index, replacement) {
|
||
textStore[index] = replacement;
|
||
return textStore.filter(Boolean).join('\n');
|
||
};
|
||
}();
|
||
|
||
function applyToSingletonTag(style, index, remove, obj) {
|
||
var css = remove ? '' : obj.media ? "@media ".concat(obj.media, " {").concat(obj.css, "}") : obj.css; // For old IE
|
||
|
||
/* istanbul ignore if */
|
||
|
||
if (style.styleSheet) {
|
||
style.styleSheet.cssText = replaceText(index, css);
|
||
} else {
|
||
var cssNode = document.createTextNode(css);
|
||
var childNodes = style.childNodes;
|
||
|
||
if (childNodes[index]) {
|
||
style.removeChild(childNodes[index]);
|
||
}
|
||
|
||
if (childNodes.length) {
|
||
style.insertBefore(cssNode, childNodes[index]);
|
||
} else {
|
||
style.appendChild(cssNode);
|
||
}
|
||
}
|
||
}
|
||
|
||
function applyToTag(style, options, obj) {
|
||
var css = obj.css;
|
||
var media = obj.media;
|
||
var sourceMap = obj.sourceMap;
|
||
|
||
if (media) {
|
||
style.setAttribute('media', media);
|
||
} else {
|
||
style.removeAttribute('media');
|
||
}
|
||
|
||
if (sourceMap && typeof btoa !== 'undefined') {
|
||
css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
|
||
} // For old IE
|
||
|
||
/* istanbul ignore if */
|
||
|
||
|
||
if (style.styleSheet) {
|
||
style.styleSheet.cssText = css;
|
||
} else {
|
||
while (style.firstChild) {
|
||
style.removeChild(style.firstChild);
|
||
}
|
||
|
||
style.appendChild(document.createTextNode(css));
|
||
}
|
||
}
|
||
|
||
var singleton = null;
|
||
var singletonCounter = 0;
|
||
|
||
function addStyle(obj, options) {
|
||
var style;
|
||
var update;
|
||
var remove;
|
||
|
||
if (options.singleton) {
|
||
var styleIndex = singletonCounter++;
|
||
style = singleton || (singleton = insertStyleElement(options));
|
||
update = applyToSingletonTag.bind(null, style, styleIndex, false);
|
||
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
|
||
} else {
|
||
style = insertStyleElement(options);
|
||
update = applyToTag.bind(null, style, options);
|
||
|
||
remove = function remove() {
|
||
removeStyleElement(style);
|
||
};
|
||
}
|
||
|
||
update(obj);
|
||
return function updateStyle(newObj) {
|
||
if (newObj) {
|
||
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
|
||
return;
|
||
}
|
||
|
||
update(obj = newObj);
|
||
} else {
|
||
remove();
|
||
}
|
||
};
|
||
}
|
||
|
||
module.exports = function (list, options) {
|
||
options = options || {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
|
||
// tags it will allow on a page
|
||
|
||
if (!options.singleton && typeof options.singleton !== 'boolean') {
|
||
options.singleton = isOldIE();
|
||
}
|
||
|
||
list = list || [];
|
||
var lastIdentifiers = modulesToDom(list, options);
|
||
return function update(newList) {
|
||
newList = newList || [];
|
||
|
||
if (Object.prototype.toString.call(newList) !== '[object Array]') {
|
||
return;
|
||
}
|
||
|
||
for (var i = 0; i < lastIdentifiers.length; i++) {
|
||
var identifier = lastIdentifiers[i];
|
||
var index = getIndexByIdentifier(identifier);
|
||
stylesInDom[index].references--;
|
||
}
|
||
|
||
var newLastIdentifiers = modulesToDom(newList, options);
|
||
|
||
for (var _i = 0; _i < lastIdentifiers.length; _i++) {
|
||
var _identifier = lastIdentifiers[_i];
|
||
|
||
var _index = getIndexByIdentifier(_identifier);
|
||
|
||
if (stylesInDom[_index].references === 0) {
|
||
stylesInDom[_index].updater();
|
||
|
||
stylesInDom.splice(_index, 1);
|
||
}
|
||
}
|
||
|
||
lastIdentifiers = newLastIdentifiers;
|
||
};
|
||
};
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./src/users.ts":
|
||
/*!**********************!*\
|
||
!*** ./src/users.ts ***!
|
||
\**********************/
|
||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
||
"use strict";
|
||
__webpack_require__.r(__webpack_exports__);
|
||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
/* harmony export */ "getUsers": () => (/* binding */ getUsers)
|
||
/* harmony export */ });
|
||
var __awaiter = (undefined && undefined.__awaiter) || function (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 getUsers() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return Promise.resolve([{ name: "Javi" }, { name: "Núria" }, { name: "Isma" }]);
|
||
});
|
||
}
|
||
|
||
|
||
/***/ })
|
||
|
||
/******/ });
|
||
/************************************************************************/
|
||
/******/ // The module cache
|
||
/******/ var __webpack_module_cache__ = {};
|
||
/******/
|
||
/******/ // The require function
|
||
/******/ function __webpack_require__(moduleId) {
|
||
/******/ // Check if module is in cache
|
||
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||
/******/ if (cachedModule !== undefined) {
|
||
/******/ return cachedModule.exports;
|
||
/******/ }
|
||
/******/ // Create a new module (and put it into the cache)
|
||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||
/******/ id: moduleId,
|
||
/******/ // no module.loaded needed
|
||
/******/ exports: {}
|
||
/******/ };
|
||
/******/
|
||
/******/ // Execute the module function
|
||
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||
/******/
|
||
/******/ // Return the exports of the module
|
||
/******/ return module.exports;
|
||
/******/ }
|
||
/******/
|
||
/************************************************************************/
|
||
/******/ /* webpack/runtime/compat get default export */
|
||
/******/ (() => {
|
||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||
/******/ __webpack_require__.n = (module) => {
|
||
/******/ var getter = module && module.__esModule ?
|
||
/******/ () => (module['default']) :
|
||
/******/ () => (module);
|
||
/******/ __webpack_require__.d(getter, { a: getter });
|
||
/******/ return getter;
|
||
/******/ };
|
||
/******/ })();
|
||
/******/
|
||
/******/ /* webpack/runtime/define property getters */
|
||
/******/ (() => {
|
||
/******/ // define getter functions for harmony exports
|
||
/******/ __webpack_require__.d = (exports, definition) => {
|
||
/******/ for(var key in definition) {
|
||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||
/******/ }
|
||
/******/ }
|
||
/******/ };
|
||
/******/ })();
|
||
/******/
|
||
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||
/******/ (() => {
|
||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||
/******/ })();
|
||
/******/
|
||
/******/ /* webpack/runtime/make namespace object */
|
||
/******/ (() => {
|
||
/******/ // define __esModule on exports
|
||
/******/ __webpack_require__.r = (exports) => {
|
||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||
/******/ }
|
||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||
/******/ };
|
||
/******/ })();
|
||
/******/
|
||
/******/ /* webpack/runtime/nonce */
|
||
/******/ (() => {
|
||
/******/ __webpack_require__.nc = undefined;
|
||
/******/ })();
|
||
/******/
|
||
/************************************************************************/
|
||
var __webpack_exports__ = {};
|
||
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
||
(() => {
|
||
"use strict";
|
||
/*!**********************!*\
|
||
!*** ./src/index.ts ***!
|
||
\**********************/
|
||
__webpack_require__.r(__webpack_exports__);
|
||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
/* harmony export */ "printUsers": () => (/* binding */ printUsers)
|
||
/* harmony export */ });
|
||
/* harmony import */ var _assets_css_normalize_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./assets/css/normalize.css */ "./src/assets/css/normalize.css");
|
||
/* harmony import */ var _users__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./users */ "./src/users.ts");
|
||
/* harmony import */ var accesscontrol__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! accesscontrol */ "./node_modules/accesscontrol/index.js");
|
||
/* harmony import */ var accesscontrol__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(accesscontrol__WEBPACK_IMPORTED_MODULE_2__);
|
||
var __awaiter = (undefined && undefined.__awaiter) || function (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());
|
||
});
|
||
};
|
||
|
||
|
||
// const AccessControl = require("./libs/accesscontrol/AccessControl");
|
||
|
||
// window.Action = Action;
|
||
window.AccessControl = accesscontrol__WEBPACK_IMPORTED_MODULE_2__.AccessControl;
|
||
function printUsers() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const users = yield (0,_users__WEBPACK_IMPORTED_MODULE_1__.getUsers)();
|
||
const element = document.createElement("div");
|
||
element.innerHTML = `<h2>Current users</h2>
|
||
${users.map((user) => `<div>${user.name}</div>`).join("")}`;
|
||
return element;
|
||
});
|
||
}
|
||
// const ac = new AccessControl();
|
||
// ac.grant('user') // define new or modify existing role. also takes an array.
|
||
// .createOwn('video') // equivalent to .createOwn('video', ['*'])
|
||
// .deleteOwn('video')
|
||
// .readAny('video')
|
||
// .grant('admin') // switch to another role without breaking the chain
|
||
// .extend('user') // inherit role capabilities. also takes an array
|
||
// .updateAny('video', ['title']) // explicitly defined attributes
|
||
// .deleteAny('video');
|
||
// let permission = ac.can('user').createOwn('video');
|
||
// console.log(permission.granted); // —> true
|
||
// console.log(permission.attributes); // —> ['*'] (all attributes)
|
||
// permission = ac.can('admin').updateAny('video');
|
||
// console.log(permission.granted); // —> true
|
||
// console.log(permission.attributes); // —> ['title']
|
||
// printUsers()
|
||
// .then((element) => document.body.appendChild(element))
|
||
// .catch(() => console.error("Something went wrong"));
|
||
|
||
})();
|
||
|
||
/******/ })();
|
||
} |