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.8.0-alpha.0 to 0.8.0-alpha.1

2

dist/src/AccessNode.js

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

async isAllowed(accessEvaluator, action) {
if (this.nodes.length) {
if (this.nodes.length === 0) {
return Promise.resolve(false);

@@ -28,0 +28,0 @@ }

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

type Privilege = string;
type Action = {
type Action<Meta = undefined> = Meta extends undefined ? {
resource: Resource;
privilege: Privilege;
} : {
resource: Resource;
privilege: Privilege;
meta: Meta;
};
const createAction: (resource: string, privilege: string) => Action;
function createAction(resource: Resource, privilege: Privilege): Action<undefined>;
function createAction<Meta>(resource: Resource, privilege: Privilege, meta: Meta): Action<Meta>;
class Default<Identity extends Authorizator.Identity> implements Authorizator<Identity> {

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

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

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

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

{
"name": "@contember/authorization",
"version": "0.8.0-alpha.0",
"version": "0.8.0-alpha.1",
"license": "Apache-2.0",

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

},
"gitHead": "e8480ed2e4f612537e229c6017565ec43917618e"
"gitHead": "c20d28db4163768b7e479fabf8ffb2d15a7fc153"
}

@@ -33,3 +33,3 @@ import AccessEvaluator from './AccessEvaluator'

public async isAllowed(accessEvaluator: AccessEvaluator, action: Authorizator.Action): Promise<boolean> {
if (this.nodes.length) {
if (this.nodes.length === 0) {
return Promise.resolve(false)

@@ -36,0 +36,0 @@ }

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

export type Privilege = string
export type Action = { resource: Resource; privilege: Privilege }
export type Action<Meta = undefined> = Meta extends undefined
? { resource: Resource; privilege: Privilege }
: { resource: Resource; privilege: Privilege; meta: Meta }
export const createAction = (resource: Resource, privilege: Privilege): Action => ({ resource, privilege })
type ActionCreator =
| ((resource: Resource, privilege: Privilege) => Action)
| (<Meta>(resource: Resource, privilege: Privilege, meta: Meta) => Action<Meta>)
export function createAction(resource: Resource, privilege: Privilege): Action<undefined>
export function createAction<Meta>(resource: Resource, privilege: Privilege, meta: Meta): Action<Meta>
export function createAction<Meta>(resource: Resource, privilege: Privilege, meta?: Meta) {
return {
resource,
privilege,
meta,
}
}
export class Default<Identity extends Authorizator.Identity> implements Authorizator<Identity> {

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

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