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 2.0.1 to 2.0.2

0

lib/casbin.d.ts

@@ -0,0 +0,0 @@ import { Enforcer } from './enforcer';

@@ -0,0 +0,0 @@ "use strict";

4

lib/config.d.ts

@@ -5,4 +5,5 @@ export declare class Config {

private static DEFAULT_COMMENT_SEM;
private static DEFAULT_MULTI_LINE_SEPARATOR;
private data;
constructor();
private constructor();
/**

@@ -28,2 +29,3 @@ * newConfig create an empty configuration representation from file.

private parseBuffer;
private write;
getBool(key: string): boolean;

@@ -30,0 +32,0 @@ getInt(key: string): number;

@@ -68,29 +68,51 @@ "use strict";

parseBuffer(buf) {
const lines = buf.toString().split('\n');
const linesCount = lines.length;
let section = '';
const lines = buf.toString().split('\n');
let currentLine = '';
lines.forEach((n, index) => {
const line = n.trim();
const lineNumber = index + 1;
if (!line) {
return;
}
if (line.startsWith(Config.DEFAULT_COMMENT)) {
if (line.startsWith(Config.DEFAULT_COMMENT) || line.startsWith(Config.DEFAULT_COMMENT_SEM)) {
return;
}
else if (line.startsWith(Config.DEFAULT_COMMENT_SEM)) {
return;
}
else if (line.startsWith('[') && line.endsWith(']')) {
if (currentLine.length !== 0) {
this.write(section, lineNumber - 1, currentLine);
currentLine = '';
}
section = line.substring(1, line.length - 1);
}
else {
const equalIndex = line.indexOf('=');
if (equalIndex === -1) {
throw new Error(`parse the content error : line ${index + 1}`);
let shouldWrite = false;
if (line.includes(Config.DEFAULT_MULTI_LINE_SEPARATOR)) {
currentLine += line.substring(0, line.length - 1).trim();
// when the last line has a "\" string
if (lineNumber + 1 === linesCount) {
shouldWrite = true;
}
}
const key = line.substring(0, equalIndex);
const value = line.substring(equalIndex + 1);
this.addConfig(section, key.trim(), value.trim());
else {
currentLine += line;
shouldWrite = true;
}
if (shouldWrite) {
this.write(section, lineNumber, currentLine);
currentLine = '';
}
}
});
}
write(section, lineNum, line) {
const equalIndex = line.indexOf('=');
if (equalIndex === -1) {
throw new Error(`parse the content error : line ${lineNum}`);
}
const key = line.substring(0, equalIndex);
const value = line.substring(equalIndex + 1);
this.addConfig(section, key.trim(), value.trim());
}
getBool(key) {

@@ -148,2 +170,3 @@ return !!this.get(key);

Config.DEFAULT_COMMENT_SEM = ';';
Config.DEFAULT_MULTI_LINE_SEPARATOR = '\\';
exports.Config = Config;

@@ -0,0 +0,0 @@ import { Effector } from './effect';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Effect, Effector } from './effector';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export declare enum Effect {

@@ -0,0 +0,0 @@ "use strict";

export * from './defaultEffector';
export * from './effector';

@@ -0,0 +0,0 @@ "use strict";

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

@@ -0,0 +0,0 @@ "use strict";

import * as Util from './util';
export * from './config';
export * from './enforcer';

@@ -3,0 +4,0 @@ export * from './effect';

@@ -21,2 +21,3 @@ "use strict";

exports.Util = Util;
__export(require("./config"));
__export(require("./enforcer"));

@@ -23,0 +24,0 @@ __export(require("./effect"));

@@ -0,0 +0,0 @@ import { CoreEnforcer } from './coreEnforcer';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Logger } from './logger';

@@ -0,0 +0,0 @@ "use strict";

export * from './defaultLogger';
export * from './logger';
export * from './logUtil';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface Logger {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Logger } from './logger';

@@ -0,0 +0,0 @@ "use strict";

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

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

@@ -218,3 +218,4 @@ * hasGroupingPolicy determines whether a role inheritance rule exists.

* @return whether the rule exists.
*/ hasGroupingPolicy(...params: string[]): boolean;
*/
hasGroupingPolicy(...params: string[]): boolean;
/**

@@ -221,0 +222,0 @@ * hasNamedGroupingPolicy determines whether a named role inheritance rule exists.

@@ -266,3 +266,3 @@ "use strict";

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

@@ -291,3 +291,3 @@ }

*/
removeFilteredNamedPolicy(ptype, fieldIndex, fieldValues) {
removeFilteredNamedPolicy(ptype, fieldIndex, ...fieldValues) {
return __awaiter(this, void 0, void 0, function* () {

@@ -302,3 +302,4 @@ return yield this.removeFilteredPolicyInternal('p', ptype, fieldIndex, fieldValues);

* @return whether the rule exists.
*/ hasGroupingPolicy(...params) {
*/
hasGroupingPolicy(...params) {
return this.hasNamedGroupingPolicy('g', ...params);

@@ -305,0 +306,0 @@ }

@@ -0,0 +0,0 @@ import * as rbac from '../rbac';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export declare class FunctionMap {

@@ -0,0 +0,0 @@ "use strict";

export * from './assertion';
export * from './functionMap';
export * from './model';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as rbac from '../rbac';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Model } from '../model';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { FilteredAdapter } from './filteredAdapter';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Adapter } from './adapter';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Model } from '../model';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ import { Model } from '../model';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export * from './adapter';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface Watcher {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { RoleManager } from './roleManager';

@@ -0,0 +0,0 @@ "use strict";

export * from './defaultRoleManager';
export * from './roleManager';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface RoleManager {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as rbac from '../rbac';

@@ -0,0 +0,0 @@ "use strict";

export * from './builtinOperators';
export * from './util';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ declare function escapeAssertion(s: string): string;

@@ -0,0 +0,0 @@ "use strict";

{
"name": "casbin",
"version": "2.0.1",
"version": "2.0.2",
"description": "An authorization library that supports access control models like ACL, RBAC, ABAC in Node.JS",

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

"precommit": "lint-staged",
"prepublish": "yarn run lint && yarn run test && yarn build",
"prepublishOnly": "yarn run lint && yarn run test && yarn build",
"build": "rimraf lib && tsc",
"lint": "tslint \"src/**/*.ts\"",
"fix": "tslint \"src/**/*.ts\" --fix",
"test": "jest"

@@ -52,3 +51,3 @@ },

"*.{ts,js}": [
"tslint --fix",
"yarn lint",
"git add"

@@ -63,3 +62,3 @@ ]

"testMatch": [
"**/test/*.+(ts|tsx)"
"**/test/**/*.+(ts|tsx)"
],

@@ -66,0 +65,0 @@ "moduleFileExtensions": [

@@ -88,2 +88,3 @@ node-Casbin

- [Examples](#examples)
- [Middlewares](#middlewares)
- [Our adopters](#our-adopters)

@@ -172,4 +173,4 @@

- [Management API](https://github.com/casbin/node-casbin/blob/master/src/managementEnforcer.ts): the primitive API that provides full support for node-Casbin policy management. See [here](https://github.com/casbin/node-casbin/blob/master/src/test/java/org/casbin/node-casbin/main/ManagementAPIUnitTest.java) for examples.
- [RBAC API](https://github.com/casbin/node-casbin/blob/master/src/enforcer.ts): a more friendly API for RBAC. This API is a subset of Management API. The RBAC users could use this API to simplify the code. See [here](https://github.com/casbin/node-casbin/blob/master/src/test/java/org/casbin/node-casbin/main/RbacAPIUnitTest.java) for examples.
- [Management API](https://casbin.org/docs/en/management-api): the primitive API that provides full support for node-Casbin policy management.
- [RBAC API](https://casbin.org/docs/en/management-api): a more friendly API for RBAC. This API is a subset of Management API. The RBAC users could use this API to simplify the code.

@@ -184,24 +185,8 @@ We also provide a web-based UI for model management and policy management:

In node-Casbin, the policy storage is implemented as an adapter (aka middleware for node-Casbin). To keep light-weight, we don't put adapter code in the main library (except the default file adapter). A complete list of node-Casbin adapters is provided as below. Any 3rd-party contribution on a new adapter is welcomed, please inform us and I will put it in this list:)
https://casbin.org/docs/en/adapters
Adapter | Type | Author | Description
----|------|----|----
[File Adapter (built-in)](https://github.com/casbin/casbin/wiki/Policy-persistence#file-adapter) | File | Casbin | Persistence for [.CSV (Comma-Separated Values)](https://en.wikipedia.org/wiki/Comma-separated_values) files
[Sequelize Adapter](https://github.com/node-casbin/sequelize-adapter) | ORM | Casbin | MySQL, PostgreSQL, SQLite, Microsoft SQL Server are supported by [Sequelize](https://github.com/sequelize/sequelize)
[Waterline Adapter](https://github.com/node-casbin/waterline-adapter) | ORM | Casbin | MySQL, MongoDB, neDB, Postgres are supported by [Waterline](https://github.com/balderdashy/waterline)
[TypeORM Adapter](https://github.com/node-casbin/typeorm-adapter) | ORM | Casbin | MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL, MongoDB are supported by [TypeORM](https://github.com/typeorm/typeorm)
[Mongoose Adapter](https://github.com/elasticio/casbin-mongoose-adapter) | ORM | [elastic.io](https://github.com/elasticio) | MongoDB is supported by [Mongoose](https://mongoosejs.com/)
For details of adapters, please refer to the documentation: https://github.com/casbin/casbin/wiki/Policy-persistence
## Role manager
The role manager is used to manage the RBAC role hierarchy (user-role mapping) in node-Casbin. A role manager can retrieve the role data from node-Casbin policy rules or external sources such as LDAP, Okta, Auth0, Azure AD, etc. We support different implementations of a role manager. To keep light-weight, we don't put role manager code in the main library (except the default role manager). A complete list of node-Casbin role managers is provided as below. Any 3rd-party contribution on a new role manager is welcomed, please inform us and I will put it in this list:)
https://casbin.org/docs/en/role-managers
Role manager | Author | Description
----|----|----
[Default Role Manager (built-in)](https://github.com/casbin/node-casbin/blob/master/src/rbac/defaultRoleManager.ts) | Casbin | Supports role hierarchy stored in node-Casbin policy
For developers: all role managers must implement the [RoleManager](https://github.com/casbin/node-casbin/blob/master/src/rbac/roleManager.ts) interface. [Default Role Manager](https://github.com/casbin/node-casbin/blob/master/src/rbac/defaultRoleManager.ts) can be used as a reference implementation.
## Examples

@@ -223,11 +208,9 @@

## Our adopters
## Middlewares
### Web frameworks
Authz middlewares for web frameworks: https://casbin.org/docs/en/middlewares
- [Express](https://github.com/expressjs/express): Fast, unopinionated, minimalist web framework for node, via plugin: [express-authz](https://github.com/node-casbin/express-authz)
- [Koa](https://github.com/koajs/koa): Expressive middleware for node.js using ES2017 async functions, via plugin: [koa-authz](https://github.com/node-casbin/koa-authz)
- [Egg](https://github.com/eggjs/egg): Born to build better enterprise frameworks and apps with Node.js & Koa, via plugin: [egg-authz](https://github.com/node-casbin/egg-authz)
- [Casbin JWT Express](https://github.com/tiagostutz/casbin-jwt-express): Authorization middleware that uses stateless JWT token to validate ACL rules using Casbin
## Our adopters
https://casbin.org/docs/en/adopters

@@ -234,0 +217,0 @@ ## License

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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