{"_id":"@biswarup598/authz","name":"@biswarup598/authz","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@biswarup598/authz","version":"1.0.0","description":"This is a package that covers a simple authorization solution.","main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/biswarup-naha/Authz-npm.git"},"author":{"name":"Biswarup Naha"},"license":"MIT","bugs":{"url":"https://github.com/biswarup-naha/Authz-npm/issues"},"homepage":"https://github.com/biswarup-naha/Authz-npm#readme","_id":"@biswarup598/authz@1.0.0","gitHead":"3f1b544a5d60cabc467dc26c2f8a6fc7901cb061","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-bsRXBl16gZiCnb8vQWsjn7KecVbNY2TCLm5gmcCS2wbzMWUfGaCO9XI8jIBJW1KLXAk9rrZcWXpumET4RjtewA==","shasum":"6108854324f0299b0d248ca33261762d5a54fc63","tarball":"https://registry.npmjs.org/@biswarup598/authz/-/authz-1.0.0.tgz","fileCount":4,"unpackedSize":7517,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDaEhEEbrAiN/MeT34bL2cnu6aKoVlERzFZA/9hAz3FQAiEA9EoWQGZl/9cSrqHfBN/2QOUHmODFBqOv72h7NFjGDxA="}]},"_npmUser":{"name":"biswarup598","email":"jeeeeet6902@gmail.com"},"directories":{},"maintainers":[{"name":"biswarup598","email":"jeeeeet6902@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/authz_1.0.0_1742475625304_0.9766955872255116"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-20T13:00:25.195Z","1.0.0":"2025-03-20T13:00:25.460Z","modified":"2025-03-20T13:00:25.708Z"},"maintainers":[{"name":"biswarup598","email":"jeeeeet6902@gmail.com"}],"description":"This is a package that covers a simple authorization solution.","homepage":"https://github.com/biswarup-naha/Authz-npm#readme","repository":{"type":"git","url":"git+https://github.com/biswarup-naha/Authz-npm.git"},"author":{"name":"Biswarup Naha"},"bugs":{"url":"https://github.com/biswarup-naha/Authz-npm/issues"},"license":"MIT","readme":"# Authorization Checker - NPM Package\r\n\r\nA lightweight Node.js package to check user authorization based on predefined roles and permissions.\r\n\r\n## Features\r\n- Role-based access control (RBAC)\r\n- Supports Admin, Moderator, and User roles\r\n- Customizable permissions\r\n- Simple and easy-to-use API\r\n\r\n## Installation\r\n\r\nInstall the package using npm:\r\n```sh\r\nnpm install @biswarup598/authz\r\n```\r\n\r\nor using yarn:\r\n```sh\r\nyarn add @biswarup598/authz\r\n```\r\n\r\n## Usage\r\n\r\n### Import the module\r\n```javascript\r\nimport { checkPermission } from '@biswarup598/authz';\r\n```\r\n\r\n### Define User Roles\r\nEach user should have a `role` assigned (e.g., `admin`, `moderator`, `user`).\r\n\r\n### Checking Permissions\r\n```javascript\r\nconst user = { role: 'admin' };\r\nconst action = 'create';\r\nconst resource = 'post';\r\n\r\nif (checkPermission(user, action, resource)) {\r\n    console.log('Access granted');\r\n} else {\r\n    console.log('Access denied');\r\n}\r\n```\r\n\r\n## Roles and Permissions\r\n\r\n### Admin Permissions\r\n- View, create, update, and delete posts, comments, likes, reports, follows, unfollows, blocks, unblocks, admins, moderators, and users.\r\n\r\n### Moderator Permissions\r\n- Same as Admin except cannot manage admins.\r\n\r\n### User Permissions\r\n- Can view, create, update, and delete posts, comments, likes, reports, follows, unfollows, blocks, and unblocks.\r\n\r\n## API Reference\r\n\r\n### `checkPermission(user, action, resource)`\r\n- **user**: An object containing the `role` property.\r\n- **action**: The action to be performed (e.g., `create`, `update`, `delete`).\r\n- **resource**: The resource on which the action is performed (e.g., `post`, `comment`).\r\n- **Returns**: `true` if the user has permission, otherwise `false`.\r\n\r\n## License\r\nThis project is licensed under the MIT License.","readmeFilename":"README.md","_rev":"1-afa0e818c0cb09311a546ba3bc4f54e0"}