Skip to content

Latest commit

 

History

History
92 lines (63 loc) · 2.63 KB

README.md

File metadata and controls

92 lines (63 loc) · 2.63 KB

Generic Permission Service

Generic Permission Service with Jest Test via Paraboly

npm version npm Platform - Platform Free Web License: MIT

Architecture of Using Permission Service

Types Values Example Example2
NAMESPACE 0 permission permission
MODULE 1 system system
PAGE 2 globalMap globalMap
COMPONENT 3 * button
COMPONENT ID 4 * delete_button
PERMISSION VALUE 5 7 0

Installation

npm i @paraboly/pwc-permission-service

Usage

Import

import PermissionService from "@paraboly/pwc-permission-service";

Basic Usage

Generate Permission Object from Encoded Permission String

Generate (Decode) the given encoded permission string to usable object

const {
  generatePermissionObj,
} = PermissionService;

const permissionObj = generatePermissionObj(permission);
console.log("Permission Object: ", permissionObj);

Decode Selected Permission

Please check the permission architecture about the permission of the each type.

const {
  decodeSelectedPermission
} = PermissionService;

const module = decodeSelectedPermission(1, permission);
const page = decodeSelectedPermission(2, permission);
const permissionValue = decodeSelectedPermission(
  5,
  permission
);

Generate Permission Encode

Generate the fundamental encoded permission string with given parameters

PermissionService.generatePermissionEncode(
  "permission",
  "system",
  "globalMap",
  "*",
  "delete_button",
  7
)

Authors

FreakyCoder, [email protected] | [email protected]

License

Permission Service is available under the Apache License 2.0 license. See the LICENSE file for more info.