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

@agendize/vue-acl

Package Overview
Dependencies
Maintainers
7
Versions
201
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agendize/vue-acl - npm Package Compare versions

Comparing version 0.0.3-beta02 to 0.0.3-beta03

1

dist/vue-acl.es.js

@@ -82,2 +82,3 @@ import { reactive, computed } from "vue";

const evaluateRouterAcl = (to, from, next) => {
console.log("====", to.params, to.path, to.query);
if (to.meta && to.meta.can) {

@@ -84,0 +85,0 @@ const abilities = to.meta.can;

2

dist/vue-acl.umd.js

@@ -1,1 +0,1 @@

(function(f,h){typeof exports=="object"&&typeof module!="undefined"?h(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],h):(f=typeof globalThis!="undefined"?globalThis:f||self,h(f.VueACL={},f.Vue))})(this,function(f,h){"use strict";const n=h.reactive({registeredUser:{},registeredRights:{},registeredRules:{},options:{}}),y=(e,t)=>{const i={...{user:Object.create(null),rules:V,router:null,onDeniedRoute:"/",debug:!1},...t};M(i);const a=(o,g)=>{const r=g.arg,u=g.value,c=g.modifiers,p=!!c.any,d=!!c.not,F=!!c.readonly,_=!!(c.disable||c.disabled),q=!!(c.hide||c.hidden);v({abilities:r,args:u,any:p})?d?o.style.display="none":o.style.display="":d?o.style.display="":_?o.disabled=!0:F?o.readOnly=!0:o.style.display="none"};if(((o,g)=>{o.directive(`${g}`,{mounted(r,u){a(r,u)},updated(r,u){a(r,u)}})})(e,"can"),i.router){const o=(r,u,c,p)=>{if(p)c();else{let d=i.onDeniedRoute;r.meta&&r.meta.onDeniedRoute&&(d=r.meta.onDeniedRoute),c(typeof d=="object"?d:d==="$from"?u:{path:`${d}`,replace:!0})}},g=(r,u,c)=>{if(r.meta&&r.meta.can){const p=r.meta.can;let d=b(p,r.params);o(r,u,c,d)}else if(r.meta&&r.meta.canNot){const p=r.meta.canNot;let d=S(p,r.params);o(r,u,c,d)}else if(r.meta&&r.meta.canAny){const p=r.meta.canAny;let d=C(p,r.params);o(r,u,c,d)}else c()};i.router.beforeEach((r,u,c)=>{g(r,u,c)})}else console.error(":::VueACL::: Instance of vue-router is required.")},w=e=>({install:(t,s={})=>{y(t,{...s,...e})}}),R=e=>{typeof e=="function"&&e(U)},N=()=>{const e={};return e.user=h.computed(()=>n.registeredUser).value,e.getUser=()=>n.registeredUser,e.setUser=t=>n.registeredUser=t,e.rights=h.computed(()=>n.registeredRights).value,e.getRights=()=>n.registeredRights,e.setRights=t=>n.registeredRights=t,e.fetchRights=(t,s,i)=>T(t,s,i),e.can=b,e.can.not=S,e.can.any=C,h.reactive(e)},V=()=>R(e=>{["companySettings","servicesSettings","staffsSettings","resourcesSettings","appointmentsNew","appointmentsAccept","appointmentsReschedule","appointmentsStatusChange","appointmentsModeFree"].forEach(s=>{e(s,(i,a)=>D(i,s,a))})}),M=e=>{const t=e.user;if(n.registeredUser=t,e.rights){const s=e.rights;n.registeredRights=s}e.rules&&typeof e.rules=="function"&&e.rules(),n.options=e},U=(e,t)=>{typeof e=="string"&&j(e,t)},j=(e,t)=>{Object.prototype.hasOwnProperty.call(n.registeredRules,e)?console.warn(`:::VueACL::: Duplicate ACL Rule '${e}' defined. Only the first defined rule will be evaluated.`):n.registeredRules[e]=t},b=(e,t)=>A({abilities:e,args:t,any:!1}),S=(e,t)=>!A({abilities:e,args:t,any:!1}),C=(e,t)=>A({abilities:e,args:t,any:!0}),A=({abilities:e,args:t,any:s=!1})=>e&&typeof e=="string"?v({abilities:e,args:t,any:s}):(console.warn(":::VueACL::: Invalid ACL arguments specified: ",e,t,s),!1),v=({abilities:e,args:t,any:s=!1})=>{const i=e,a=t;let l=!1;return i&&(a?l=L({abilities:i,args:a}):l=L({abilities:i})),l},L=({abilities:e,args:t,any:s=!1})=>{if(e&&typeof e=="string"&&Object.prototype.hasOwnProperty.call(n.registeredRules,e)){const i=n.registeredRules[e];return H(i,e,t)}return!1},H=(e,t,s)=>{try{return typeof e=="function"?typeof s=="object"&&!Array.isArray(s)?e(n.registeredUser,s):typeof s=="object"&&Array.isArray(s)?e(n.registeredUser,...s):e(n.registeredUser):!1}catch(i){const a=P(e);a&&Array.isArray(a)&&a.shift();let l=':::VueACL::: The defined ACL Rule for "'+t+'" require some argument(s) or data object to be specified for matching.';return console.error(l),console.error(i),!1}},P=e=>{let t=null;const s=/\(([a-z0-9 ,$_+*\-/]+)\)/im,a=e.toString().match(s);if(a&&Array.isArray(a)&&a[0]){let l=a[0];l=l.replace(/\(|\)|[ ]/g,"");const o=l.split(",");o.length>0&&(t=o)}return t},D=(e,t,s)=>{if(s&&s.id&&s.owner&&s.owner.userName){const i=O(e,s.id);if(i)if(n.registeredRights){const a=n.registeredRights.find(l=>l.owner===s.owner.userName);if(a){const l=a.rights[i];if(l){const o=l[t];return n.options.debug&&console.debug(":::VueACL::: Ability ["+t+"] on ["+s.id+"]: "+o),o}else n.options.debug&&console.debug(":::VueACL::: No ability found for this role ["+i+"] on ["+s.id+"]")}else n.options.debug&&console.debug(":::VueACL::: No company ["+s.id+"] rights founded ["+s.owner.userName+"]")}else n.options.debug&&console.debug(":::VueACL::: No registeredRights");else n.options.debug&&console.debug(":::VueACL::: User has no role on this company ["+s.id+"]",e)}return!1},O=(e,t)=>{if(e&&e.roles&&t){const s=e.roles.find(i=>i.companyId===t);if(s)return s.role}},T=async(e,t,s)=>{var i;((i=n.registeredRights)==null?void 0:i.length)>0&&!s||(n.registeredRights=[],await Promise.all([...t].map(a=>e.getAccountSettings(a).then(l=>{const o=l.result;if(o){const g=m(o.adminRights),r=m(o.schedulerRights),u=m(o.readerRights),c={owner:a,rights:{admin:g,scheduler:r,reader:u}};n.registeredRights.push(c)}}))),n.options.debug&&console.info(":::VueACL::: Registered rights:",n.registeredRights))},m=e=>({companySettings:e.companySettings,servicesSettings:e.servicesSettings,staffsSettings:e.staffsSettings,resourcesSettings:e.resourcesSettings,appointmentsNew:e.appointmentsNew,appointmentsReschedule:e.appointmentsReschedule,appointmentsStatusChange:e.appointmentsStatusChange,appointmentsModeFree:e.appointmentsModeFree,appointmentsAccept:e.appointmentsAccept}),$={install:(e,t)=>y(e,t)};f.createAcl=w,f.default=$,f.defineAclRules=R,f.useAcl=N,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(f,h){typeof exports=="object"&&typeof module!="undefined"?h(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],h):(f=typeof globalThis!="undefined"?globalThis:f||self,h(f.VueACL={},f.Vue))})(this,function(f,h){"use strict";const n=h.reactive({registeredUser:{},registeredRights:{},registeredRules:{},options:{}}),y=(e,t)=>{const i={...{user:Object.create(null),rules:V,router:null,onDeniedRoute:"/",debug:!1},...t};M(i);const a=(o,g)=>{const r=g.arg,u=g.value,c=g.modifiers,p=!!c.any,d=!!c.not,q=!!c.readonly,F=!!(c.disable||c.disabled),_=!!(c.hide||c.hidden);v({abilities:r,args:u,any:p})?d?o.style.display="none":o.style.display="":d?o.style.display="":F?o.disabled=!0:q?o.readOnly=!0:o.style.display="none"};if(((o,g)=>{o.directive(`${g}`,{mounted(r,u){a(r,u)},updated(r,u){a(r,u)}})})(e,"can"),i.router){const o=(r,u,c,p)=>{if(p)c();else{let d=i.onDeniedRoute;r.meta&&r.meta.onDeniedRoute&&(d=r.meta.onDeniedRoute),c(typeof d=="object"?d:d==="$from"?u:{path:`${d}`,replace:!0})}},g=(r,u,c)=>{if(console.log("====",r.params,r.path,r.query),r.meta&&r.meta.can){const p=r.meta.can;let d=b(p,r.params);o(r,u,c,d)}else if(r.meta&&r.meta.canNot){const p=r.meta.canNot;let d=S(p,r.params);o(r,u,c,d)}else if(r.meta&&r.meta.canAny){const p=r.meta.canAny;let d=C(p,r.params);o(r,u,c,d)}else c()};i.router.beforeEach((r,u,c)=>{g(r,u,c)})}else console.error(":::VueACL::: Instance of vue-router is required.")},w=e=>({install:(t,s={})=>{y(t,{...s,...e})}}),R=e=>{typeof e=="function"&&e(U)},N=()=>{const e={};return e.user=h.computed(()=>n.registeredUser).value,e.getUser=()=>n.registeredUser,e.setUser=t=>n.registeredUser=t,e.rights=h.computed(()=>n.registeredRights).value,e.getRights=()=>n.registeredRights,e.setRights=t=>n.registeredRights=t,e.fetchRights=(t,s,i)=>T(t,s,i),e.can=b,e.can.not=S,e.can.any=C,h.reactive(e)},V=()=>R(e=>{["companySettings","servicesSettings","staffsSettings","resourcesSettings","appointmentsNew","appointmentsAccept","appointmentsReschedule","appointmentsStatusChange","appointmentsModeFree"].forEach(s=>{e(s,(i,a)=>D(i,s,a))})}),M=e=>{const t=e.user;if(n.registeredUser=t,e.rights){const s=e.rights;n.registeredRights=s}e.rules&&typeof e.rules=="function"&&e.rules(),n.options=e},U=(e,t)=>{typeof e=="string"&&j(e,t)},j=(e,t)=>{Object.prototype.hasOwnProperty.call(n.registeredRules,e)?console.warn(`:::VueACL::: Duplicate ACL Rule '${e}' defined. Only the first defined rule will be evaluated.`):n.registeredRules[e]=t},b=(e,t)=>A({abilities:e,args:t,any:!1}),S=(e,t)=>!A({abilities:e,args:t,any:!1}),C=(e,t)=>A({abilities:e,args:t,any:!0}),A=({abilities:e,args:t,any:s=!1})=>e&&typeof e=="string"?v({abilities:e,args:t,any:s}):(console.warn(":::VueACL::: Invalid ACL arguments specified: ",e,t,s),!1),v=({abilities:e,args:t,any:s=!1})=>{const i=e,a=t;let l=!1;return i&&(a?l=L({abilities:i,args:a}):l=L({abilities:i})),l},L=({abilities:e,args:t,any:s=!1})=>{if(e&&typeof e=="string"&&Object.prototype.hasOwnProperty.call(n.registeredRules,e)){const i=n.registeredRules[e];return H(i,e,t)}return!1},H=(e,t,s)=>{try{return typeof e=="function"?typeof s=="object"&&!Array.isArray(s)?e(n.registeredUser,s):typeof s=="object"&&Array.isArray(s)?e(n.registeredUser,...s):e(n.registeredUser):!1}catch(i){const a=P(e);a&&Array.isArray(a)&&a.shift();let l=':::VueACL::: The defined ACL Rule for "'+t+'" require some argument(s) or data object to be specified for matching.';return console.error(l),console.error(i),!1}},P=e=>{let t=null;const s=/\(([a-z0-9 ,$_+*\-/]+)\)/im,a=e.toString().match(s);if(a&&Array.isArray(a)&&a[0]){let l=a[0];l=l.replace(/\(|\)|[ ]/g,"");const o=l.split(",");o.length>0&&(t=o)}return t},D=(e,t,s)=>{if(s&&s.id&&s.owner&&s.owner.userName){const i=O(e,s.id);if(i)if(n.registeredRights){const a=n.registeredRights.find(l=>l.owner===s.owner.userName);if(a){const l=a.rights[i];if(l){const o=l[t];return n.options.debug&&console.debug(":::VueACL::: Ability ["+t+"] on ["+s.id+"]: "+o),o}else n.options.debug&&console.debug(":::VueACL::: No ability found for this role ["+i+"] on ["+s.id+"]")}else n.options.debug&&console.debug(":::VueACL::: No company ["+s.id+"] rights founded ["+s.owner.userName+"]")}else n.options.debug&&console.debug(":::VueACL::: No registeredRights");else n.options.debug&&console.debug(":::VueACL::: User has no role on this company ["+s.id+"]",e)}return!1},O=(e,t)=>{if(e&&e.roles&&t){const s=e.roles.find(i=>i.companyId===t);if(s)return s.role}},T=async(e,t,s)=>{var i;((i=n.registeredRights)==null?void 0:i.length)>0&&!s||(n.registeredRights=[],await Promise.all([...t].map(a=>e.getAccountSettings(a).then(l=>{const o=l.result;if(o){const g=m(o.adminRights),r=m(o.schedulerRights),u=m(o.readerRights),c={owner:a,rights:{admin:g,scheduler:r,reader:u}};n.registeredRights.push(c)}}))),n.options.debug&&console.info(":::VueACL::: Registered rights:",n.registeredRights))},m=e=>({companySettings:e.companySettings,servicesSettings:e.servicesSettings,staffsSettings:e.staffsSettings,resourcesSettings:e.resourcesSettings,appointmentsNew:e.appointmentsNew,appointmentsReschedule:e.appointmentsReschedule,appointmentsStatusChange:e.appointmentsStatusChange,appointmentsModeFree:e.appointmentsModeFree,appointmentsAccept:e.appointmentsAccept}),$={install:(e,t)=>y(e,t)};f.createAcl=w,f.default=$,f.defineAclRules=R,f.useAcl=N,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
{
"name": "@agendize/vue-acl",
"private": false,
"version": "0.0.3-beta02",
"version": "0.0.3-beta03",
"description": "Vue agendize's ACL management",

@@ -6,0 +6,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc