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

@casl/angular

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@casl/angular - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

casl-angular-0.3.1.tgz

14

CHANGELOG.md

@@ -5,2 +5,16 @@ # Change Log

# [@casl/angular-v0.4.0](https://github.com/stalniy/casl/compare/@casl/angular@0.3.1...@casl/angular@0.4.0) (2018-11-11)
### Bug Fixes
* **angular:** converts source to typescript ([565936d](https://github.com/stalniy/casl/commit/565936d)), closes [#126](https://github.com/stalniy/casl/issues/126)
* **README:** changes links to [@casl](https://github.com/casl)/ability to point to npm package instead to git root [skip ci] ([a74086b](https://github.com/stalniy/casl/commit/a74086b)), closes [#102](https://github.com/stalniy/casl/issues/102)
* **semantic-release:** test ([cab3f4b](https://github.com/stalniy/casl/commit/cab3f4b)), closes [#94](https://github.com/stalniy/casl/issues/94)
### Features
* **react:can:** updates typescript declarations ([213dcde](https://github.com/stalniy/casl/commit/213dcde))
<a name="@casl/angular-v0.3.1"></a>

@@ -7,0 +21,0 @@ # [@casl/angular-v0.3.1](https://github.com/stalniy/casl/compare/@casl/angular@0.3.0...@casl/angular@0.3.1) (2018-07-02)

99

dist/es5m/index.js
import { Pipe, ChangeDetectorRef, NgModule } from '@angular/core';
import { Ability } from '@casl/ability';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function __decorate(decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
var classCallCheck = function (instance, Constructor) {

@@ -11,50 +38,50 @@ if (!(instance instanceof Constructor)) {

var noop = function noop() {};
var ɵ0 = noop;
// TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041
var CanPipe = function () {
function CanPipe(ability, cd) {
classCallCheck(this, CanPipe);
function CanPipe(ability, cd) {
classCallCheck(this, CanPipe);
this.ability = ability;
this.cd = cd;
this.unsubscribeFromAbility = noop;
}
this.ability = ability;
this.cd = cd;
this.unsubscribeFromAbility = noop;
}
CanPipe.prototype.transform = function transform(resource, action, field) {
var _this = this;
CanPipe.prototype.transform = function transform(resource, action, field) {
var _this = this;
if (this.unsubscribeFromAbility === noop) {
this.unsubscribeFromAbility = this.ability.on('updated', function () {
return _this.cd.markForCheck();
});
}
if (this.unsubscribeFromAbility === noop) {
this.unsubscribeFromAbility = this.ability.on('updated', function () {
return _this.cd.markForCheck();
});
}
return this.can(action, resource, field);
};
return this.can(action, resource, field);
};
CanPipe.prototype.can = function can() {
var _ability;
CanPipe.prototype.can = function can() {
var _ability;
return (_ability = this.ability).can.apply(_ability, arguments);
};
return (_ability = this.ability).can.apply(_ability, arguments);
};
CanPipe.prototype.ngOnDestroy = function ngOnDestroy() {
this.unsubscribeFromAbility();
};
CanPipe.prototype.ngOnDestroy = function ngOnDestroy() {
this.unsubscribeFromAbility();
};
return CanPipe;
return CanPipe;
}();
CanPipe.parameters = [[Ability], [ChangeDetectorRef]];
CanPipe.annotations = [
// TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041
new Pipe({ name: 'can', pure: false })];
CanPipe = __decorate([Pipe({ name: 'can', pure: false }), __metadata("design:paramtypes", [Ability, ChangeDetectorRef])], CanPipe);
function createAbility() {
return new Ability([]);
}
var AbilityModule = function AbilityModule() {
classCallCheck(this, AbilityModule);
classCallCheck(this, AbilityModule);
};
AbilityModule.annotations = [new NgModule({
declarations: [CanPipe],
exports: [CanPipe],
providers: [{ provide: Ability, useValue: new Ability([]) }]
})];
AbilityModule = __decorate([NgModule({
declarations: [CanPipe],
exports: [CanPipe],
providers: [{ provide: Ability, useFactory: createAbility }]
})], AbilityModule);
export { CanPipe, AbilityModule };
export { CanPipe, ɵ0, createAbility, AbilityModule };
import { Pipe, ChangeDetectorRef, NgModule } from '@angular/core';
import { Ability } from '@casl/ability';
const noop = () => {};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
class CanPipe {
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
constructor(ability, cd) {
this.ability = ability;
this.cd = cd;
this.unsubscribeFromAbility = noop;
}
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
transform(resource, action, field) {
if (this.unsubscribeFromAbility === noop) {
this.unsubscribeFromAbility = this.ability.on('updated', () => this.cd.markForCheck());
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
return this.can(action, resource, field);
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
can(...args) {
return this.ability.can(...args);
}
const noop = () => {};
const ɵ0 = noop;
// TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041
let CanPipe = class CanPipe {
constructor(ability, cd) {
this.ability = ability;
this.cd = cd;
this.unsubscribeFromAbility = noop;
}
transform(resource, action, field) {
if (this.unsubscribeFromAbility === noop) {
this.unsubscribeFromAbility = this.ability.on('updated', () => this.cd.markForCheck());
}
return this.can(action, resource, field);
}
can(...args) {
return this.ability.can(...args);
}
ngOnDestroy() {
this.unsubscribeFromAbility();
}
};
CanPipe = __decorate([Pipe({ name: 'can', pure: false }), __metadata("design:paramtypes", [Ability, ChangeDetectorRef])], CanPipe);
ngOnDestroy() {
this.unsubscribeFromAbility();
}
function createAbility() {
return new Ability([]);
}
CanPipe.parameters = [[Ability], [ChangeDetectorRef]];
CanPipe.annotations = [
// TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041
new Pipe({ name: 'can', pure: false })];
let AbilityModule = class AbilityModule {};
AbilityModule = __decorate([NgModule({
declarations: [CanPipe],
exports: [CanPipe],
providers: [{ provide: Ability, useFactory: createAbility }]
})], AbilityModule);
class AbilityModule {}
AbilityModule.annotations = [new NgModule({
declarations: [CanPipe],
exports: [CanPipe],
providers: [{ provide: Ability, useValue: new Ability([]) }]
})];
export { CanPipe, AbilityModule };
export { CanPipe, ɵ0, createAbility, AbilityModule };

@@ -1,1 +0,1 @@

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@angular/core"),require("@casl/ability")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@casl/ability"],i):i((t.casl=t.casl||{},t.casl.ng={}),t.ng.core,t.casl)}(this,function(t,i,n){"use strict";var e=function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")},r=function(){},o=function(){function n(t,i){e(this,n),this.ability=t,this.cd=i,this.unsubscribeFromAbility=r}return n.prototype.transform=function(t,i,n){var e=this;return this.unsubscribeFromAbility===r&&(this.unsubscribeFromAbility=this.ability.on("updated",function(){return e.cd.markForCheck()})),this.can(i,t,n)},n.prototype.can=function(){var t;return(t=this.ability).can.apply(t,arguments)},n.prototype.ngOnDestroy=function(){this.unsubscribeFromAbility()},n}();o.parameters=[[n.Ability],[i.ChangeDetectorRef]],o.annotations=[new i.Pipe({name:"can",pure:!1})];var a=function t(){e(this,t)};a.annotations=[new i.NgModule({declarations:[o],exports:[o],providers:[{provide:n.Ability,useValue:new n.Ability([])}]})],t.CanPipe=o,t.AbilityModule=a,Object.defineProperty(t,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@casl/ability")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@casl/ability"],t):t((e.casl=e.casl||{},e.casl.ng={}),e.ng.core,e.casl)}(this,function(e,t,i){"use strict";function n(e,t,i,n){var r,o=arguments.length,c=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;0<=a;a--)(r=e[a])&&(c=(o<3?r(c):3<o?r(t,i,c):r(t,i))||c);return 3<o&&c&&Object.defineProperty(t,i,c),c}var r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},o=function(){},c=o;function a(){return new i.Ability([])}e.CanPipe=function(){function i(e,t){r(this,i),this.ability=e,this.cd=t,this.unsubscribeFromAbility=o}return i.prototype.transform=function(e,t,i){var n=this;return this.unsubscribeFromAbility===o&&(this.unsubscribeFromAbility=this.ability.on("updated",function(){return n.cd.markForCheck()})),this.can(t,e,i)},i.prototype.can=function(){var e;return(e=this.ability).can.apply(e,arguments)},i.prototype.ngOnDestroy=function(){this.unsubscribeFromAbility()},i}(),e.CanPipe=n([t.Pipe({name:"can",pure:!1}),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[i.Ability,t.ChangeDetectorRef])],e.CanPipe),e.AbilityModule=function e(){r(this,e)},e.AbilityModule=n([t.NgModule({declarations:[e.CanPipe],exports:[e.CanPipe],providers:[{provide:i.Ability,useFactory:a}]})],e.AbilityModule),e.ɵ0=c,e.createAbility=a,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -1,19 +0,1 @@

import { ChangeDetectorRef, OnDestroy } from '@angular/core'
import { Ability } from '@casl/ability'
/**
* The module that provides `can` pipe and empty `Ability` instance
*
*/
export declare class AbilityModule {
}
export declare class CanPipe implements OnDestroy {
constructor(ability: Ability, cd: ChangeDetectorRef)
transform(subject: any, action: string): boolean
can(action: string, subject: any): boolean
ngOnDestroy(): void
}
export * from './dist/types/angular';
{
"name": "@casl/angular",
"version": "0.3.1",
"version": "0.4.0",
"description": "Angular module for CASL which makes it easy to add permissions in any Angular application",

@@ -8,2 +8,3 @@ "main": "dist/umd/index.js",

"es2015": "dist/es6/index.js",
"typings": "dist/types/angular.d.ts",
"repository": {

@@ -18,7 +19,10 @@ "type": "git",

"rollup": "rollup -g @angular/core:ng.core,@casl/ability:casl",
"build.es": "npm run rollup -- -c ../../tools/rollup.es.js",
"build.umd": "npm run rollup -- -c ../../tools/rollup.umd.js -n casl.ng",
"build.es5m": "npm run rollup -- -c ../../tools/rollup.es5m.js",
"build.es": "npm run rollup -- -c ../../tools/rollup.es.js -i dist/types/index.js",
"build.umd": "npm run rollup -- -c ../../tools/rollup.umd.js -n casl.ng -i dist/types/index.js",
"build.es5m": "npm run rollup -- -c ../../tools/rollup.es5m.js -i dist/types/index.js",
"prebuild": "ngc",
"build": "npm run build.es && npm run build.umd && npm run build.es5m",
"postbuild": "rm -f dist/types/*.{js,js.map}",
"test": "NODE_ENV=test jest --config ../../tools/jest.config.js",
"lint": "node -p -e '`Skip linting for typescript`' ",
"prerelease": "npm test && NODE_ENV=production npm run build",

@@ -43,11 +47,12 @@ "release": "semantic-release -e semantic-release-monorepo -e ../../tools/semantic-release"

"peerDependencies": {
"@angular/core": "^2.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0",
"@casl/ability": "^2.0.0-alpha.1"
"@angular/core": "^2.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
"@casl/ability": "^2.0.0"
},
"devDependencies": {
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/core": "latest",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@angular/common": "^7.0.0",
"@angular/compiler": "^7.0.3",
"@angular/compiler-cli": "^7.0.3",
"@angular/core": "^7.0.0",
"@angular/platform-browser": "^7.0.0",
"@angular/platform-browser-dynamic": "^7.0.0",
"@casl/ability": "^2.0.0",

@@ -54,0 +59,0 @@ "jest-zone-patch": "0.0.8",

# CASL Angular [![@casl/angular NPM version](https://badge.fury.io/js/%40casl%2Fangular.svg)](https://badge.fury.io/js/%40casl%2Fangular) [![CASL Documentation](https://img.shields.io/badge/documentation-available-brightgreen.svg)](https://stalniy.github.io/casl/) [![CASL Join the chat at https://gitter.im/stalniy-casl/casl](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/stalniy-casl/casl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
This package allows to integrate [@casl/ability](/packages/casl-ability) into [Angular][angular] application. So, you can show or hide some components, buttons, etc based on user ability to see them.
This package allows to integrate [@casl/ability][casl-ability] into [Angular][angular] application. So, you can show or hide some components, buttons, etc based on user ability to see them.

@@ -99,3 +99,3 @@ ## Installation

See [@casl/ability](/packages/casl-ability) package for more information on how to define abilities.
See [@casl/ability][casl-ability] package for more information on how to define abilities.

@@ -169,1 +169,2 @@ ### 3. Check permissios in templates

[update-ability]: https://stalniy.github.io/casl/abilities/2017/07/20/define-abilities.html#update-abilities
[casl-ability]: http://npmjs.com/package/@casl/ability
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