Файловый менеджер - Редактировать - /home/freeclou/app.optimyar.com/backend/node_modules/@casl/ability/dist/es6c/index.js
Назад
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@ucast/mongo2js");function s(t){return Array.isArray(t)?t:[t]}const e="__caslSubjectType__";function i(t){if(!t)return"all";if("string"==typeof t)return t;if(t.hasOwnProperty(e))return t[e];const s="function"==typeof t?t:t.constructor;return s.modelName||s.name}const r=t=>t;function n(t,s,e){for(let i=e;i<s.length;i++)t.push(s[i])}function o(t,s){if(!t||!t.length)return s||[];if(!s||!s.length)return t||[];let e=0,i=0;const r=[];for(;e<t.length&&i<s.length;)t[e].priority<s[i].priority?(r.push(t[e]),e++):(r.push(s[i]),i++);return n(r,t,e),n(r,s,i),r}function h(t,s,e){let i=t.get(s);return i||(i=e(),t.set(s,i)),i}class c{constructor(t,e,i=0){this.__matchConditions=void 0,this.__matchField=void 0,function(t,s){if(Array.isArray(t.fields)&&!t.fields.length)throw new Error("`rawRule.fields` cannot be an empty array. https://bit.ly/390miLa");if(t.fields&&!s.fieldMatcher)throw new Error('You need to pass "fieldMatcher" option in order to restrict access by fields');if(t.conditions&&!s.conditionsMatcher)throw new Error('You need to pass "conditionsMatcher" option in order to restrict access by conditions')}(t,e),this.action=e.resolveAction(t.action),this.subject=t.subject,this.inverted=!!t.inverted,this.conditions=t.conditions,this.reason=t.reason,this.fields=t.fields?s(t.fields):void 0,this.priority=i,this.t=e}get s(){return this.conditions&&!this.__matchConditions&&(this.__matchConditions=this.t.conditionsMatcher(this.conditions)),this.__matchConditions}get i(){return this.fields&&!this.__matchField&&(this.__matchField=this.t.fieldMatcher(this.fields)),this.__matchField}get ast(){return this.s?this.s.ast:void 0}matchesConditions(t){return!this.s||(t&&"string"!=typeof t&&"function"!=typeof t?this.s(t):!this.inverted)}matchesField(t){return!this.i||(t?this.i(t):!this.inverted)}}class u{constructor(t,s=null){this.next=null,this.value=t,this.prev=s,s&&(s.next=this)}destroy(){const{next:t,prev:s}=this;t&&(t.prev=s),s&&(s.next=t),this.next=this.prev=null}}const a=()=>({rules:[],merged:!1}),l=()=>new Map,f=()=>({emits:!1,last:null,destroy:null});class d extends class{constructor(t=[],s={}){this.o=!1,this.h=new Map,this.u={conditionsMatcher:s.conditionsMatcher,fieldMatcher:s.fieldMatcher,resolveAction:s.resolveAction||r},this.detectSubjectType=s.detectSubjectType||i,this.l=t,this.p=this.g(t)}get rules(){return this.l}update(t){const s={rules:t,ability:this,target:this};return this.$("update",s),this.l=t,this.p=this.g(t),this.$("updated",s),this}g(t){const e=new Map;for(let i=t.length-1;i>=0;i--){const r=t.length-i-1,n=new c(t[i],this.u,r),o=s(n.action),u=s(n.subject);this.m(n);for(let t=0;t<u.length;t++){const s=h(e,this.detectSubjectType(u[t]),l);for(let t=0;t<o.length;t++)h(s,o[t],a).rules.push(n)}}return e}m(t){!this.o&&t.fields&&(this.o=!0)}possibleRulesFor(...[t,s]){const e=this.detectSubjectType(s),i=h(this.p,e,l),r=h(i,t,a);if(r.merged)return r.rules;const n="manage"!==t&&i.has("manage")?i.get("manage").rules:void 0;let c=o(r.rules,n);return"all"!==e&&(c=o(c,this.possibleRulesFor(t,"all"))),r.rules=c,r.merged=!0,c}rulesFor(t,s,e){const i=this.possibleRulesFor(t,s);if(e&&"string"!=typeof e)throw new Error("The 3rd, `field` parameter is expected to be a string. See https://stalniy.github.io/casl/en/api/casl-ability#can-of-pure-ability for details");return this.o?i.filter(t=>t.matchesField(e)):i}on(t,s){const e=h(this.h,t,f),i=new u(s,e.last);e.last=i;const r=()=>{if(e.emits)return e.destroy=e.destroy||[],void e.destroy.push(r);i.next||i.prev||e.last!==i?i.destroy():e.last=null};return r}$(t,s){const e=this.h.get(t);if(e)try{e.emits=!0;let t=e.last;for(;null!==t;)t.value(s),t=t.prev}finally{e.emits=!1,e.destroy&&e.destroy.forEach(t=>t())}}}{can(...t){const s=this.relevantRuleFor(...t);return!!s&&!s.inverted}relevantRuleFor(...t){const s=this.rulesFor(...t),e=t[1];for(let t=0;t<s.length;t++)if(s[t].matchesConditions(e))return s[t];return null}cannot(...t){return!this.can(...t)}}const p={$eq:t.$eq,$ne:t.$ne,$lt:t.$lt,$lte:t.$lte,$gt:t.$gt,$gte:t.$gte,$in:t.$in,$nin:t.$nin,$all:t.$all,$size:t.$size,$regex:t.$regex,$options:t.$options,$elemMatch:t.$elemMatch,$exists:t.$exists},g={eq:t.eq,ne:t.ne,lt:t.lt,lte:t.lte,gt:t.gt,gte:t.gte,in:t.within,nin:t.nin,all:t.all,size:t.size,regex:t.regex,elemMatch:t.elemMatch,exists:t.exists},y=t.createFactory(p,g),w=/[-/\\^$+?.()|[\]{}]/g,b=/\.?\*+\.?/g,x=/\*+/,$=/\./g;function m(t,s,e){const i="*"===e[0]||"."===t[0]&&"."===t[t.length-1]?"+":"*",r=-1===t.indexOf("**")?"[^.]":".",n=t.replace($,"\\$&").replace(x,r+i);return s+t.length===e.length?`(?:${n})?`:n}function v(t,s,e){return"."!==t||"*"!==e[s-1]&&"*"!==e[s+1]?"\\"+t:t}const M=t=>{let s;return e=>(void 0===s&&(s=-1===t.join("").indexOf("*")?null:function(t){const s=t.map(t=>t.replace(w,v).replace(b,m)),e=s.length>1?`(?:${s.join("|")})`:s[0];return new RegExp(`^${e}$`)}(t)),null===s||-1!==e.indexOf("*")?-1!==t.indexOf(e):s.test(e))};class E extends d{constructor(t,s){super(t,Object.assign({conditionsMatcher:y,fieldMatcher:M},s))}}class j{constructor(t){this.v=t}because(t){return this.v.reason=t,this}}class _{constructor(t){this.rules=[],this.M=t;this.can=this.can.bind(this),this.cannot=this.cannot.bind(this),this.build=this.build.bind(this)}can(t,s,e,i){const r={action:t};return s&&(r.subject=s,Array.isArray(e)||"string"==typeof e?r.fields=e:void 0!==e&&(r.conditions=e),void 0!==i&&(r.conditions=i)),this.rules.push(r),new j(r)}cannot(t,s,e,i){const r=this.can(t,s,e,i);return r.v.inverted=!0,r}build(t){return new this.M(this.rules,t)}}const F=t=>`Cannot execute "${t.action}" on "${t.subjectType}"`,O=function(t){this.message=t};O.prototype=Object.create(Error.prototype);class A extends O{static setDefaultMessage(t){this.j="string"==typeof t?()=>t:t}static from(t){return new this(t)}constructor(t){super(""),this.field=void 0,this.ability=t,"function"==typeof Error.captureStackTrace&&(this.name="ForbiddenError",Error.captureStackTrace(this,this.constructor))}setMessage(t){return this.message=t,this}throwUnlessCan(...t){const s=this.ability.relevantRuleFor(...t);if(s&&!s.inverted)return;this.action=t[0],this.subject=t[1],this.subjectType=this.ability.detectSubjectType(t[1]),this.field=t[2];const e=s?s.reason:"";throw this.message=this.message||e||this.constructor.j(this),this}}A.j=F,exports.Ability=E,exports.AbilityBuilder=_,exports.ForbiddenError=A,exports.PureAbility=d,exports.buildMongoQueryMatcher=(s,e,i)=>t.createFactory(Object.assign({},p,s),Object.assign({},g,e),i),exports.createAliasResolver=function(t){return"production"!==process.env.NODE_ENV&&function(t){if(t.manage)throw new Error('Cannot add alias for "manage" action because it is reserved');Object.keys(t).forEach(s=>{if(s===t[s]||Array.isArray(t[s])&&(-1!==t[s].indexOf(s)||-1!==t[s].indexOf("manage")))throw new Error(`Attempt to alias action to itself: ${s} -> ${t[s]}`)})}(t),e=>function(t,e){let i=s(e),r=0;for(;r<i.length;){const s=i[r++];t.hasOwnProperty(s)&&(i=i.concat(t[s]))}return i}(t,e)},exports.defineAbility=function(t,s){const e=new _(E),i=t(e.can,e.cannot);return i&&"function"==typeof i.then?i.then(()=>e.build(s)):e.build(s)},exports.detectSubjectType=i,exports.fieldPatternMatcher=M,exports.getDefaultErrorMessage=F,exports.mongoQueryMatcher=y,exports.subject=function(t,s){if(s)if(s.hasOwnProperty(e)){if(t!==s[e])throw new Error(`Trying to cast object to subject type ${t} but previously it was casted to ${s[e]}`)}else Object.defineProperty(s,e,{value:t});return s},exports.wrapArray=s; //# sourceMappingURL=index.js.map
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка