New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fusion.io/authorization

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fusion.io/authorization - npm Package Compare versions

Comparing version 3.0.1-alpha.33 to 3.0.1-alpha.34

lib/CombinedPolicy.d.ts

17

lib/Authorizer.d.ts
import { Manager } from "@fusion.io/core";
import { Policy } from "./Contracts";
/**
* The user's friendly configuration
*/
export declare type AuthorizerConfiguration = {
default: string;
policies: {
[resource: string]: {
policy: string;
[policy: string]: {
driver: string;
options: any;

@@ -34,2 +37,12 @@ };

/**
* Check if given identity can perform
* an action by a given policy.
* If fail, will throw an UnAuthorized error
*
* @param identity
* @param action
* @param byPolicy
*/
verify(identity: any, action: string, byPolicy?: string): Promise<void>;
/**
* Get actions that an identity can

@@ -36,0 +49,0 @@ * perform by given policy

@@ -8,4 +8,16 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@fusion.io/core");
const UnAuthorized_1 = __importDefault(require("./UnAuthorized"));
let Authorizer = class Authorizer extends core_1.Manager {

@@ -17,3 +29,4 @@ /**

bootstrap(config) {
const standardAdapterConfig = Object.entries(config.policies).reduce((merged, [resource, { policy, options }]) => (Object.assign({}, merged, { [resource]: { driver: policy, options } })), {});
const standardAdapterConfig = Object.entries(config.policies)
.reduce((merged, [resource, { driver, options }]) => (Object.assign({}, merged, { [resource]: { driver: driver, options } })), {});
this.configure({

@@ -44,2 +57,19 @@ default: config.default,

/**
* Check if given identity can perform
* an action by a given policy.
* If fail, will throw an UnAuthorized error
*
* @param identity
* @param action
* @param byPolicy
*/
verify(identity, action, byPolicy) {
return __awaiter(this, void 0, void 0, function* () {
const accepted = yield this.policy(byPolicy).check(identity, action);
if (!accepted) {
throw new UnAuthorized_1.default("UnAuthorized");
}
});
}
/**
* Get actions that an identity can

@@ -46,0 +76,0 @@ * perform by given policy

3

lib/index.d.ts
import ACLConfigPolicy, { ACLConfiguration, HavingRoles, ACLIdentityOrRole } from "./ACLConfigPolicy";
import Plasma from "./Plasma";
import UnAuthorized from "./UnAuthorized";
export { Authorizer, AuthorizerConfiguration } from "./Authorizer";
export { GrantablePolicy, Policy } from "./Contracts";
export { ACLConfigPolicy, ACLConfiguration, HavingRoles, ACLIdentityOrRole, Plasma };
export { ACLConfigPolicy, ACLConfiguration, HavingRoles, ACLIdentityOrRole, UnAuthorized, Plasma };

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

exports.Plasma = Plasma_1.default;
const UnAuthorized_1 = __importDefault(require("./UnAuthorized"));
exports.UnAuthorized = UnAuthorized_1.default;
var Authorizer_1 = require("./Authorizer");
exports.Authorizer = Authorizer_1.Authorizer;
//# sourceMappingURL=index.js.map

@@ -18,5 +18,20 @@ "use strict";

const ACLConfigPolicy_1 = __importDefault(require("./ACLConfigPolicy"));
const GroupedPolicy_1 = __importDefault(require("./GroupedPolicy"));
const CombinedPolicy_1 = __importDefault(require("./CombinedPolicy"));
const ComposedPolicy_1 = __importDefault(require("./ComposedPolicy"));
class Plasma extends core_1.Plasma {
compose(authorizer) {
authorizer.supporting('acl', (options => new ACLConfigPolicy_1.default(options)));
authorizer
.supporting('config', (options => {
return new ACLConfigPolicy_1.default(options);
}))
.supporting('grouped', ({ policies }) => {
return new GroupedPolicy_1.default(policies.map(policy => authorizer.policy(policy)));
})
.supporting('combined', ({ policies }) => {
return new CombinedPolicy_1.default(policies.map(policy => authorizer.policy(policy)));
})
.supporting('composed', (composeFunction) => {
return new ComposedPolicy_1.default(composeFunction, authorizer);
});
}

@@ -23,0 +38,0 @@ boot(authorizer) {

{
"name": "@fusion.io/authorization",
"version": "3.0.1-alpha.33",
"version": "3.0.1-alpha.34",
"description": "The Authorization library for the Geeks, by the Geeks.",

@@ -32,5 +32,5 @@ "author": "rikky <son.levuthai@gmail.com>",

"dependencies": {
"@fusion.io/core": "^3.0.1-alpha.33"
"@fusion.io/core": "^3.0.1-alpha.34"
},
"gitHead": "5f9e7e8ac29491315262e176196d6a1350c10ff9"
"gitHead": "345c7d1478212d687cf5750fd02d9a08c8744d01"
}

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