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

casbin

Package Overview
Dependencies
Maintainers
3
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casbin - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0

13

lib/cachedEnforcer.js
"use strict";
// Copyright 2020 The Casbin Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -3,0 +16,0 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

4

lib/enforcer.d.ts

@@ -141,3 +141,3 @@ import { ManagementEnforcer } from './managementEnforcer';

*/
getPermissionsForUser(user: string): string[][];
getPermissionsForUser(user: string): Promise<string[][]>;
/**

@@ -150,3 +150,3 @@ * hasPermissionForUser determines whether a user has a permission.

*/
hasPermissionForUser(user: string, ...permission: string[]): boolean;
hasPermissionForUser(user: string, ...permission: string[]): Promise<boolean>;
/**

@@ -153,0 +153,0 @@ * getImplicitRolesForUser gets implicit roles that a user has.

@@ -97,6 +97,6 @@ "use strict";

if (domain == null) {
return yield this.rm.getRoles(name);
return this.rm.getRoles(name);
}
else {
return yield this.rm.getRoles(name, domain);
return this.rm.getRoles(name, domain);
}

@@ -115,6 +115,6 @@ });

if (domain == null) {
return yield this.rm.getUsers(name);
return this.rm.getUsers(name);
}
else {
return yield this.rm.getUsers(name, domain);
return this.rm.getUsers(name, domain);
}

@@ -156,6 +156,6 @@ });

if (domain == null) {
return yield this.addGroupingPolicy(user, role);
return this.addGroupingPolicy(user, role);
}
else {
return yield this.addGroupingPolicy(user, role, domain);
return this.addGroupingPolicy(user, role, domain);
}

@@ -176,6 +176,6 @@ });

if (domain == null) {
return yield this.removeGroupingPolicy(user, role);
return this.removeGroupingPolicy(user, role);
}
else {
return yield this.removeGroupingPolicy(user, role, domain);
return this.removeGroupingPolicy(user, role, domain);
}

@@ -195,6 +195,6 @@ });

if (domain == null) {
return yield this.removeFilteredGroupingPolicy(0, user);
return this.removeFilteredGroupingPolicy(0, user);
}
else {
return yield this.removeFilteredGroupingPolicy(0, user, '', domain);
return this.removeFilteredGroupingPolicy(0, user, '', domain);
}

@@ -212,3 +212,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
return yield this.removeFilteredGroupingPolicy(0, user);
return this.removeFilteredGroupingPolicy(0, user);
});

@@ -238,3 +238,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.removeFilteredPolicy(1, ...permission);
return this.removeFilteredPolicy(1, ...permission);
});

@@ -253,3 +253,3 @@ }

permission.unshift(user);
return yield this.addPolicy(...permission);
return this.addPolicy(...permission);
});

@@ -268,3 +268,3 @@ }

permission.unshift(user);
return yield this.removePolicy(...permission);
return this.removePolicy(...permission);
});

@@ -281,3 +281,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.removeFilteredPolicy(0, user);
return this.removeFilteredPolicy(0, user);
});

@@ -292,3 +292,5 @@ }

getPermissionsForUser(user) {
return this.getFilteredPolicy(0, user);
return __awaiter(this, void 0, void 0, function* () {
return this.getFilteredPolicy(0, user);
});
}

@@ -303,4 +305,6 @@ /**

hasPermissionForUser(user, ...permission) {
permission.unshift(user);
return this.hasPolicy(...permission);
return __awaiter(this, void 0, void 0, function* () {
permission.unshift(user);
return this.hasPolicy(...permission);
});
}

@@ -322,5 +326,5 @@ /**

res.push(...roles);
yield Promise.all(roles.map((n) => __awaiter(this, void 0, void 0, function* () {
for (const n of roles) {
res.push(...(yield this.getImplicitRolesForUser(n, ...domain)));
})));
}
return res;

@@ -345,10 +349,10 @@ });

const withDomain = domain && domain.length !== 0;
roles.forEach(n => {
for (const n of roles) {
if (withDomain) {
res.push(...this.getFilteredPolicy(0, n, ...domain));
res.push(...(yield this.getFilteredPolicy(0, n, ...domain)));
}
else {
res.push(...this.getPermissionsForUser(n));
res.push(...(yield this.getPermissionsForUser(n)));
}
});
}
return res;

@@ -355,0 +359,0 @@ });

@@ -13,3 +13,3 @@ import { InternalEnforcer } from './internalEnforcer';

*/
getAllSubjects(): string[];
getAllSubjects(): Promise<string[]>;
/**

@@ -24,3 +24,3 @@ * getAllNamedSubjects gets the list of subjects that show up in the currentnamed policy.

*/
getAllNamedSubjects(ptype: string): string[];
getAllNamedSubjects(ptype: string): Promise<string[]>;
/**

@@ -34,3 +34,3 @@ * getAllObjects gets the list of objects that show up in the current policy.

*/
getAllObjects(): string[];
getAllObjects(): Promise<string[]>;
/**

@@ -45,3 +45,3 @@ * getAllNamedObjects gets the list of objects that show up in the current named policy.

*/
getAllNamedObjects(ptype: string): string[];
getAllNamedObjects(ptype: string): Promise<string[]>;
/**

@@ -55,3 +55,3 @@ * getAllActions gets the list of actions that show up in the current policy.

*/
getAllActions(): string[];
getAllActions(): Promise<string[]>;
/**

@@ -66,3 +66,3 @@ * GetAllNamedActions gets the list of actions that show up in the current named policy.

*/
getAllNamedActions(ptype: string): string[];
getAllNamedActions(ptype: string): Promise<string[]>;
/**

@@ -76,3 +76,3 @@ * getAllRoles gets the list of roles that show up in the current policy.

*/
getAllRoles(): string[];
getAllRoles(): Promise<string[]>;
/**

@@ -87,3 +87,3 @@ * getAllNamedRoles gets the list of roles that show up in the current named policy.

*/
getAllNamedRoles(ptype: string): string[];
getAllNamedRoles(ptype: string): Promise<string[]>;
/**

@@ -94,3 +94,3 @@ * getPolicy gets all the authorization rules in the policy.

*/
getPolicy(): string[][];
getPolicy(): Promise<string[][]>;
/**

@@ -104,3 +104,3 @@ * getFilteredPolicy gets all the authorization rules in the policy, field filters can be specified.

*/
getFilteredPolicy(fieldIndex: number, ...fieldValues: string[]): string[][];
getFilteredPolicy(fieldIndex: number, ...fieldValues: string[]): Promise<string[][]>;
/**

@@ -112,3 +112,3 @@ * getNamedPolicy gets all the authorization rules in the named policy.

*/
getNamedPolicy(ptype: string): string[][];
getNamedPolicy(ptype: string): Promise<string[][]>;
/**

@@ -123,3 +123,3 @@ * getFilteredNamedPolicy gets all the authorization rules in the named policy, field filters can be specified.

*/
getFilteredNamedPolicy(ptype: string, fieldIndex: number, ...fieldValues: string[]): string[][];
getFilteredNamedPolicy(ptype: string, fieldIndex: number, ...fieldValues: string[]): Promise<string[][]>;
/**

@@ -130,3 +130,3 @@ * getGroupingPolicy gets all the role inheritance rules in the policy.

*/
getGroupingPolicy(): string[][];
getGroupingPolicy(): Promise<string[][]>;
/**

@@ -139,3 +139,3 @@ * getFilteredGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.

*/
getFilteredGroupingPolicy(fieldIndex: number, ...fieldValues: string[]): string[][];
getFilteredGroupingPolicy(fieldIndex: number, ...fieldValues: string[]): Promise<string[][]>;
/**

@@ -147,3 +147,3 @@ * getNamedGroupingPolicy gets all the role inheritance rules in the policy.

*/
getNamedGroupingPolicy(ptype: string): string[][];
getNamedGroupingPolicy(ptype: string): Promise<string[][]>;
/**

@@ -158,3 +158,3 @@ * getFilteredNamedGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.

*/
getFilteredNamedGroupingPolicy(ptype: string, fieldIndex: number, ...fieldValues: string[]): string[][];
getFilteredNamedGroupingPolicy(ptype: string, fieldIndex: number, ...fieldValues: string[]): Promise<string[][]>;
/**

@@ -166,3 +166,3 @@ * hasPolicy determines whether an authorization rule exists.

*/
hasPolicy(...params: string[]): boolean;
hasPolicy(...params: string[]): Promise<boolean>;
/**

@@ -175,3 +175,3 @@ * hasNamedPolicy determines whether a named authorization rule exists.

*/
hasNamedPolicy(ptype: string, ...params: string[]): boolean;
hasNamedPolicy(ptype: string, ...params: string[]): Promise<boolean>;
/**

@@ -236,3 +236,3 @@ * addPolicy adds an authorization rule to the current policy.

*/
hasGroupingPolicy(...params: string[]): boolean;
hasGroupingPolicy(...params: string[]): Promise<boolean>;
/**

@@ -245,3 +245,3 @@ * hasNamedGroupingPolicy determines whether a named role inheritance rule exists.

*/
hasNamedGroupingPolicy(ptype: string, ...params: string[]): boolean;
hasNamedGroupingPolicy(ptype: string, ...params: string[]): Promise<boolean>;
/**

@@ -305,3 +305,3 @@ * addGroupingPolicy adds a role inheritance rule to the current policy.

*/
addFunction(name: string, func: any): void;
addFunction(name: string, func: any): Promise<void>;
}

@@ -38,3 +38,5 @@ "use strict";

getAllSubjects() {
return this.getAllNamedSubjects('p');
return __awaiter(this, void 0, void 0, function* () {
return this.getAllNamedSubjects('p');
});
}

@@ -51,3 +53,5 @@ /**

getAllNamedSubjects(ptype) {
return this.model.getValuesForFieldInPolicy('p', ptype, 0);
return __awaiter(this, void 0, void 0, function* () {
return this.model.getValuesForFieldInPolicy('p', ptype, 0);
});
}

@@ -63,3 +67,5 @@ /**

getAllObjects() {
return this.getAllNamedObjects('p');
return __awaiter(this, void 0, void 0, function* () {
return this.getAllNamedObjects('p');
});
}

@@ -76,3 +82,5 @@ /**

getAllNamedObjects(ptype) {
return this.model.getValuesForFieldInPolicy('p', ptype, 1);
return __awaiter(this, void 0, void 0, function* () {
return this.model.getValuesForFieldInPolicy('p', ptype, 1);
});
}

@@ -88,3 +96,5 @@ /**

getAllActions() {
return this.getAllNamedActions('p');
return __awaiter(this, void 0, void 0, function* () {
return this.getAllNamedActions('p');
});
}

@@ -101,3 +111,5 @@ /**

getAllNamedActions(ptype) {
return this.model.getValuesForFieldInPolicy('p', ptype, 2);
return __awaiter(this, void 0, void 0, function* () {
return this.model.getValuesForFieldInPolicy('p', ptype, 2);
});
}

@@ -113,3 +125,5 @@ /**

getAllRoles() {
return this.getAllNamedRoles('g');
return __awaiter(this, void 0, void 0, function* () {
return this.getAllNamedRoles('g');
});
}

@@ -126,3 +140,5 @@ /**

getAllNamedRoles(ptype) {
return this.model.getValuesForFieldInPolicy('g', ptype, 1);
return __awaiter(this, void 0, void 0, function* () {
return this.model.getValuesForFieldInPolicy('g', ptype, 1);
});
}

@@ -135,3 +151,5 @@ /**

getPolicy() {
return this.getNamedPolicy('p');
return __awaiter(this, void 0, void 0, function* () {
return this.getNamedPolicy('p');
});
}

@@ -147,3 +165,5 @@ /**

getFilteredPolicy(fieldIndex, ...fieldValues) {
return this.getFilteredNamedPolicy('p', fieldIndex, ...fieldValues);
return __awaiter(this, void 0, void 0, function* () {
return this.getFilteredNamedPolicy('p', fieldIndex, ...fieldValues);
});
}

@@ -157,3 +177,5 @@ /**

getNamedPolicy(ptype) {
return this.model.getPolicy('p', ptype);
return __awaiter(this, void 0, void 0, function* () {
return this.model.getPolicy('p', ptype);
});
}

@@ -170,3 +192,5 @@ /**

getFilteredNamedPolicy(ptype, fieldIndex, ...fieldValues) {
return this.model.getFilteredPolicy('p', ptype, fieldIndex, ...fieldValues);
return __awaiter(this, void 0, void 0, function* () {
return this.model.getFilteredPolicy('p', ptype, fieldIndex, ...fieldValues);
});
}

@@ -179,3 +203,5 @@ /**

getGroupingPolicy() {
return this.getNamedGroupingPolicy('g');
return __awaiter(this, void 0, void 0, function* () {
return this.getNamedGroupingPolicy('g');
});
}

@@ -190,3 +216,5 @@ /**

getFilteredGroupingPolicy(fieldIndex, ...fieldValues) {
return this.getFilteredNamedGroupingPolicy('g', fieldIndex, ...fieldValues);
return __awaiter(this, void 0, void 0, function* () {
return this.getFilteredNamedGroupingPolicy('g', fieldIndex, ...fieldValues);
});
}

@@ -200,3 +228,5 @@ /**

getNamedGroupingPolicy(ptype) {
return this.model.getPolicy('g', ptype);
return __awaiter(this, void 0, void 0, function* () {
return this.model.getPolicy('g', ptype);
});
}

@@ -213,3 +243,5 @@ /**

getFilteredNamedGroupingPolicy(ptype, fieldIndex, ...fieldValues) {
return this.model.getFilteredPolicy('g', ptype, fieldIndex, ...fieldValues);
return __awaiter(this, void 0, void 0, function* () {
return this.model.getFilteredPolicy('g', ptype, fieldIndex, ...fieldValues);
});
}

@@ -223,3 +255,5 @@ /**

hasPolicy(...params) {
return this.hasNamedPolicy('p', ...params);
return __awaiter(this, void 0, void 0, function* () {
return this.hasNamedPolicy('p', ...params);
});
}

@@ -234,3 +268,5 @@ /**

hasNamedPolicy(ptype, ...params) {
return this.model.hasPolicy('p', ptype, params);
return __awaiter(this, void 0, void 0, function* () {
return this.model.hasPolicy('p', ptype, params);
});
}

@@ -261,3 +297,3 @@ /**

return __awaiter(this, void 0, void 0, function* () {
return yield this.addPolicyInternal('p', ptype, params);
return this.addPolicyInternal('p', ptype, params);
});

@@ -273,3 +309,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.removeNamedPolicy('p', ...params);
return this.removeNamedPolicy('p', ...params);
});

@@ -287,3 +323,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.removeFilteredNamedPolicy('p', fieldIndex, ...fieldValues);
return this.removeFilteredNamedPolicy('p', fieldIndex, ...fieldValues);
});

@@ -300,3 +336,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.removePolicyInternal('p', ptype, params);
return this.removePolicyInternal('p', ptype, params);
});

@@ -315,3 +351,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.removeFilteredPolicyInternal('p', ptype, fieldIndex, fieldValues);
return this.removeFilteredPolicyInternal('p', ptype, fieldIndex, fieldValues);
});

@@ -326,3 +362,5 @@ }

hasGroupingPolicy(...params) {
return this.hasNamedGroupingPolicy('g', ...params);
return __awaiter(this, void 0, void 0, function* () {
return this.hasNamedGroupingPolicy('g', ...params);
});
}

@@ -337,3 +375,5 @@ /**

hasNamedGroupingPolicy(ptype, ...params) {
return this.model.hasPolicy('g', ptype, params);
return __awaiter(this, void 0, void 0, function* () {
return this.model.hasPolicy('g', ptype, params);
});
}

@@ -350,3 +390,3 @@ /**

return __awaiter(this, void 0, void 0, function* () {
return yield this.addNamedGroupingPolicy('g', ...params);
return this.addNamedGroupingPolicy('g', ...params);
});

@@ -380,3 +420,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.removeNamedGroupingPolicy('g', ...params);
return this.removeNamedGroupingPolicy('g', ...params);
});

@@ -394,3 +434,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.removeFilteredNamedGroupingPolicy('g', fieldIndex, ...fieldValues);
return this.removeFilteredNamedGroupingPolicy('g', fieldIndex, ...fieldValues);
});

@@ -438,5 +478,7 @@ }

addFunction(name, func) {
this.fm.addFunction(name, func);
return __awaiter(this, void 0, void 0, function* () {
this.fm.addFunction(name, func);
});
}
}
exports.ManagementEnforcer = ManagementEnforcer;
{
"name": "casbin",
"version": "3.1.0",
"version": "4.0.0",
"description": "An authorization library that supports access control models like ACL, RBAC, ABAC in Node.JS",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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