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

@contember/authorization

Package Overview
Dependencies
Maintainers
5
Versions
263
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/authorization - npm Package Compare versions

Comparing version 0.6.11 to 0.7.1

2

dist/src/AccessEvaluator.d.ts

@@ -11,3 +11,3 @@ import Permissions from './Permissions';

constructor(permissions: Permissions);
evaluate(accessNode: AccessNode, action: Authorizator.Action): Promise<boolean>;
evaluate(accessNode: AccessNode, { resource, privilege }: Authorizator.Action): Promise<boolean>;
}

@@ -14,0 +14,0 @@ }

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

}
async evaluate(accessNode, action) {
async evaluate(accessNode, { resource, privilege }) {
if (!(accessNode instanceof AccessNode_1.default.Roles)) {

@@ -16,3 +16,3 @@ throw new UnsupportedAccessNodeError();

for (let role of accessNode.roles) {
if (this.permissions.isAllowed(role, ...action)) {
if (this.permissions.isAllowed(role, resource, privilege)) {
return true;

@@ -19,0 +19,0 @@ }

@@ -9,3 +9,7 @@ import AuthorizationScope from './AuthorizationScope';

type Privilege = string;
type Action = [Resource, Privilege];
type Action = {
resource: Resource;
privilege: Privilege;
};
const createAction: (resource: string, privilege: string) => Action;
class Default<Identity extends Authorizator.Identity> implements Authorizator<Identity> {

@@ -12,0 +16,0 @@ private readonly accessEvaluator;

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

(function (Authorizator) {
Authorizator.createAction = (resource, privilege) => ({ resource, privilege });
class Default {

@@ -8,0 +9,0 @@ constructor(accessEvaluator) {

@@ -0,4 +1,5 @@

import Authorizator from './Authorizator';
declare class Permissions {
private permissions;
allow(role: string, resource: string | typeof Permissions.ALL, privilege: string | typeof Permissions.ALL): void;
allow(role: string, { resource, privilege }: Authorizator.Action): void;
isAllowed(role: string, resource: string, action: string): boolean;

@@ -5,0 +6,0 @@ }

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

}
allow(role, resource, privilege) {
allow(role, { resource, privilege }) {
if (!this.permissions[role]) {

@@ -10,0 +10,0 @@ this.permissions[role] = {};

{
"name": "@contember/authorization",
"version": "0.6.11",
"version": "0.7.1",
"license": "Apache-2.0",

@@ -11,3 +11,3 @@ "main": "dist/src/index.js",

},
"gitHead": "30c5bca7073e8d43cdab2425e43770fc96564dfd"
"gitHead": "0d5237b69be564e887d3f308bb46b1686098395d"
}

@@ -13,3 +13,3 @@ import Permissions from './Permissions'

async evaluate(accessNode: AccessNode, action: Authorizator.Action): Promise<boolean> {
async evaluate(accessNode: AccessNode, { resource, privilege }: Authorizator.Action): Promise<boolean> {
if (!(accessNode instanceof AccessNode.Roles)) {

@@ -19,3 +19,3 @@ throw new UnsupportedAccessNodeError()

for (let role of accessNode.roles) {
if (this.permissions.isAllowed(role, ...action)) {
if (this.permissions.isAllowed(role, resource, privilege)) {
return true

@@ -22,0 +22,0 @@ }

@@ -12,4 +12,6 @@ import AuthorizationScope from './AuthorizationScope'

export type Privilege = string
export type Action = [Resource, Privilege]
export type Action = { resource: Resource; privilege: Privilege }
export const createAction = (resource: Resource, privilege: Privilege): Action => ({ resource, privilege })
export class Default<Identity extends Authorizator.Identity> implements Authorizator<Identity> {

@@ -16,0 +18,0 @@ constructor(private readonly accessEvaluator: AccessEvaluator) {}

@@ -0,5 +1,7 @@

import Authorizator from './Authorizator'
class Permissions {
private permissions: Permissions.PermissionsMap = {}
public allow(role: string, resource: string | typeof Permissions.ALL, privilege: string | typeof Permissions.ALL) {
public allow(role: string, { resource, privilege }: Authorizator.Action) {
if (!this.permissions[role]) {

@@ -6,0 +8,0 @@ this.permissions[role] = {}

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