hapi-crud-acl
Advanced tools
Comparing version 0.1.0 to 1.0.0
{ | ||
"name": "hapi-crud-acl", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Hapi Crud Plugin", | ||
@@ -12,16 +12,17 @@ "engines": { | ||
"@types/hapi__boom": "^9.0.0", | ||
"@types/hapi__hapi": "^19.0.0", | ||
"@types/jest": "^24.9.0", | ||
"@types/lodash": "^4.14.149", | ||
"@types/node": "^13.1.7", | ||
"jest": "^25.1.0", | ||
"prettier": "^1.19.1", | ||
"rimraf": "^3.0.0", | ||
"shx": "^0.3.2", | ||
"ts-jest": "^25.0.0", | ||
"tslint": "^5.20.1", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-microsoft-contrib": "^6.2.0", | ||
"tsutils": "^3.17.1", | ||
"typescript": "^3.7.4" | ||
"@types/hapi__hapi": "^20.0.5", | ||
"@types/jest": "^26.0.20", | ||
"@types/lodash": "^4.14.168", | ||
"@types/node": "^14.14.31", | ||
"@typescript-eslint/eslint-plugin": "^4.15.1", | ||
"@typescript-eslint/parser": "^4.15.1", | ||
"eslint": "^7.20.0", | ||
"eslint-config-prettier": "^8.0.0", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"rimraf": "^3.0.2", | ||
"shx": "^0.3.3", | ||
"ts-jest": "^26.5.1", | ||
"tsutils": "^3.20.0", | ||
"typescript": "^4.1.5" | ||
}, | ||
@@ -35,3 +36,3 @@ "_files": [ | ||
"build:watch": "tsc -w -p tsconfig.release.json", | ||
"lint": "tslint -t stylish --project \"tsconfig.json\"", | ||
"lint": "eslint . && prettier --check .", | ||
"test": "jest --coverage", | ||
@@ -45,7 +46,7 @@ "test:watch": "jest --watch", | ||
"dependencies": { | ||
"@hapi/boom": "^9.0.0", | ||
"@hapi/hapi": "^19.0.4", | ||
"lodash": "^4.17.15", | ||
"tslib": "^1.10.0" | ||
"@hapi/boom": "^9.1.1", | ||
"@hapi/hapi": "^20.1.0", | ||
"lodash": "^4.17.21", | ||
"tslib": "^2.1.0" | ||
} | ||
} |
@@ -0,2 +1,8 @@ | ||
export declare class PermissionsFuncMissingError extends Error { | ||
message: string; | ||
} | ||
export declare class MalFormedPermissionsError extends Error { | ||
message: string; | ||
} | ||
declare const _default: any; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MalFormedPermissionsError = exports.PermissionsFuncMissingError = void 0; | ||
const tslib_1 = require("tslib"); | ||
const Boom = tslib_1.__importStar(require("@hapi/boom")); | ||
const pkg = tslib_1.__importStar(require("../package.json")); | ||
let internals = { | ||
implementation: null, | ||
permissionsFunc: null, | ||
class PermissionsFuncMissingError extends Error { | ||
constructor() { | ||
super(...arguments); | ||
this.message = 'permissionsFunc is required'; | ||
} | ||
} | ||
exports.PermissionsFuncMissingError = PermissionsFuncMissingError; | ||
class MalFormedPermissionsError extends Error { | ||
constructor() { | ||
super(...arguments); | ||
this.message = 'permission must be formatted: [routeName]:[create|read|update|delete]'; | ||
} | ||
} | ||
exports.MalFormedPermissionsError = MalFormedPermissionsError; | ||
const internals = { | ||
permissionsFunc: () => ({}), | ||
implementation: () => ({}), | ||
}; | ||
@@ -13,3 +28,3 @@ exports.plugin = { | ||
if (!options.permissionsFunc) { | ||
throw Error('permissionsFunc is required'); | ||
throw new PermissionsFuncMissingError(); | ||
} | ||
@@ -29,2 +44,5 @@ internals.permissionsFunc = options.permissionsFunc; | ||
.every(([name, crud]) => { | ||
if (!crud) { | ||
throw new MalFormedPermissionsError(); | ||
} | ||
if (!has[name]) { | ||
@@ -37,8 +55,9 @@ return false; | ||
internals.implementation = (request, h) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const settings = request.route.settings.plugins[name]; | ||
if (!settings) { | ||
const plugins = request.route.settings.plugins; | ||
if (!plugins || !plugins[name]) { | ||
return h.continue; | ||
} | ||
const requiredPermissions = settings.permissions; | ||
if (!requiredPermissions) { | ||
const pluginSettings = plugins[name]; | ||
const requiredPermissions = pluginSettings.permissions; | ||
if (!requiredPermissions || requiredPermissions.length === 0) { | ||
return h.continue; | ||
@@ -45,0 +64,0 @@ } |
{ | ||
"name": "hapi-crud-acl", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Hapi Crud Plugin", | ||
@@ -12,16 +12,17 @@ "engines": { | ||
"@types/hapi__boom": "^9.0.0", | ||
"@types/hapi__hapi": "^19.0.0", | ||
"@types/jest": "^24.9.0", | ||
"@types/lodash": "^4.14.149", | ||
"@types/node": "^13.1.7", | ||
"jest": "^25.1.0", | ||
"prettier": "^1.19.1", | ||
"rimraf": "^3.0.0", | ||
"shx": "^0.3.2", | ||
"ts-jest": "^25.0.0", | ||
"tslint": "^5.20.1", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-microsoft-contrib": "^6.2.0", | ||
"tsutils": "^3.17.1", | ||
"typescript": "^3.7.4" | ||
"@types/hapi__hapi": "^20.0.5", | ||
"@types/jest": "^26.0.20", | ||
"@types/lodash": "^4.14.168", | ||
"@types/node": "^14.14.31", | ||
"@typescript-eslint/eslint-plugin": "^4.15.1", | ||
"@typescript-eslint/parser": "^4.15.1", | ||
"eslint": "^7.20.0", | ||
"eslint-config-prettier": "^8.0.0", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"rimraf": "^3.0.2", | ||
"shx": "^0.3.3", | ||
"ts-jest": "^26.5.1", | ||
"tsutils": "^3.20.0", | ||
"typescript": "^4.1.5" | ||
}, | ||
@@ -35,3 +36,3 @@ "files": [ | ||
"build:watch": "tsc -w -p tsconfig.release.json", | ||
"lint": "tslint -t stylish --project \"tsconfig.json\"", | ||
"lint": "eslint . && prettier --check .", | ||
"test": "jest --coverage", | ||
@@ -45,7 +46,7 @@ "test:watch": "jest --watch", | ||
"dependencies": { | ||
"@hapi/boom": "^9.0.0", | ||
"@hapi/hapi": "^19.0.4", | ||
"lodash": "^4.17.15", | ||
"tslib": "^1.10.0" | ||
"@hapi/boom": "^9.1.1", | ||
"@hapi/hapi": "^20.1.0", | ||
"lodash": "^4.17.21", | ||
"tslib": "^2.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
25249
25
126
1
1
167
16
+ Added@hapi/hapi@20.3.0(transitive)
+ Added@hapi/mimos@6.0.0(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@hapi/address@4.1.0(transitive)
- Removed@hapi/formula@2.0.0(transitive)
- Removed@hapi/hapi@19.2.0(transitive)
- Removed@hapi/joi@17.1.1(transitive)
- Removed@hapi/mimos@5.0.0(transitive)
- Removed@hapi/pinpoint@2.0.1(transitive)
- Removed@hapi/teamwork@4.0.0(transitive)
- Removedtslib@1.14.1(transitive)
Updated@hapi/boom@^9.1.1
Updated@hapi/hapi@^20.1.0
Updatedlodash@^4.17.21
Updatedtslib@^2.1.0