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

@cobuildlab/rbac

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cobuildlab/rbac - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

1

lib/rbac.d.ts

@@ -40,2 +40,3 @@ import { ValidatorFunctionType } from './types';

check(role: R | null, permission: P, data?: D[P]): [boolean, string?];
simpleCheck(role: R | null, permission: P, data?: D[P]): boolean;
}

@@ -101,4 +101,7 @@ "use strict";

};
RBAC.prototype.simpleCheck = function (role, permission, data) {
return this.check(role, permission, data)[0];
};
return RBAC;
}());
exports.RBAC = RBAC;

2

package.json
{
"name": "@cobuildlab/rbac",
"version": "0.2.1",
"version": "0.3.0",
"description": "",

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

@@ -95,1 +95,27 @@ import { test, expect } from '@jest/globals';

});
test('Test simple Check', () => {
enum Roles {
ADMIN = 'ADMIN',
MANAGER = 'MANAGER',
}
enum Permissions {
DASHBOARD = 'DASHBOARD',
SETTINGS = 'SETTINGS',
}
const staticRules = new RBAC<Roles, Permissions>(Roles.ADMIN);
staticRules.createRule(Roles.ADMIN, Permissions.DASHBOARD, true);
staticRules.createRule(Roles.ADMIN, Permissions.SETTINGS, true);
staticRules.createRule(Roles.MANAGER, Permissions.DASHBOARD, false);
expect(
staticRules.simpleCheck(Roles.ADMIN, Permissions.DASHBOARD),
).toStrictEqual(true);
expect(
staticRules.simpleCheck(Roles.ADMIN, Permissions.SETTINGS),
).toStrictEqual(true);
expect(
staticRules.simpleCheck(Roles.MANAGER, Permissions.DASHBOARD),
).toStrictEqual(false);
});

@@ -120,2 +120,6 @@ /* eslint-disable @typescript-eslint/ban-types */

}
simpleCheck(role: R | null, permission: P, data?: D[P]): boolean {
return this.check(role, permission, data)[0];
}
}
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