{"_id":"@captemulation/react-redux-permissions","_rev":"3-4946823f30e9144fa1321de00211e125","name":"@captemulation/react-redux-permissions","dist-tags":{"latest":"1.3.0"},"versions":{"1.1.0":{"name":"@captemulation/react-redux-permissions","version":"1.1.0","description":"A permissions library for react and redux applications.","main":"dist/index.js","scripts":{"build":"babel src --out-dir dist","lint":"eslint src","test":"jest","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/shizpi/react-redux-permissions.git"},"keywords":["react","reactjs","redux","lib","permissions","roles"],"author":{"name":"Fabio Santos"},"collaborators":["John Dean <jdean@shutterstock.com>"],"license":"MIT","bugs":{"url":"https://github.com/jdean/react-redux-permissions/issues"},"homepage":"https://github.com/jdean/react-redux-permissions#readme","dependencies":{"prop-types":"^15.6.2"},"devDependencies":{"babel-cli":"^6.8.0","babel-eslint":"^9.0.0","babel-preset-env":"^1.7.0","babel-preset-react":"^6.24.1","babel-preset-stage-2":"^6.24.1","eslint":"^5.5.0","eslint-config-airbnb":"^17.1.0","eslint-plugin-babel":"^5.2.0","eslint-plugin-import":"^2.14.0","eslint-plugin-jsx-a11y":"^6.1.1","eslint-plugin-react":"^7.11.1","jest":"^22.0.5","react":"^16.5.0","react-redux":"^5.0.7","redux":"^3.7.2"},"peerDependencies":{"react":"^16","react-redux":"^5","redux":"^3.7"},"gitHead":"17d2945a01f490d46afa925b52d91bc43139e2e6","_id":"@captemulation/react-redux-permissions@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"captemulation","email":"john.holmes.dean@gmail.com"},"dist":{"integrity":"sha512-jV6Ve6hNNlJQUPdwddMP/bK+KA+ciXyIL7yLkuFQ7PHnEfVu08gBdfN14LE82M3x89x7kBPPe0V/nD5OOc3Rzg==","shasum":"68a877b7c0a0760fa843912ae6f3c9ad9a6ee2cd","tarball":"https://registry.npmjs.org/@captemulation/react-redux-permissions/-/react-redux-permissions-1.1.0.tgz","fileCount":21,"unpackedSize":20940,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbktyrCRA9TVsSAnZWagAA+UQQAJ13ja+DSzknekk13Y4m\nDbN90OS2/w95GD+xUR2gX/hRrhkBOA/3dWhdkZ2DXppgokY4eTDdaoqe8Bqe\nmCGo0xFXzji1jWdJe0C2365xqfXbhJNDJ3bk4Qo6Y/bxFazfZi1FQ6/4XZRK\nmB918tDeFfYVkBN5tcAiixS+ND1Z+IIRhmP9Jee5lOJLdinurd/Efv822Mgm\nARMhAI0oPwKLv0HoHAEW1MirrDYiI/EA2x4geHAE7UUXjsv8K5yPUoEkcotM\nerR3axkMftsSZ+G+bOf7dWq1uC6kPuwTpKL54H4FMJYSc+3AfNhEZqj3n+wr\nHKODZ0VdvOtpTJqNwTMjfIXm6pLgWrqYU00YPRNSB/9pV/Uif0o/IYZrO6Fa\nBJVDqjCaHsNwuK53lzAbCJj33zskx58Q/U9fK0L5ReRRo1HZX5yJdE78Av44\neyMq+rkN6jls7FkR1GJWHnJVChdrryWo6Cu/XEBLYrEyCI0psIH+zi8KH6+T\ng9jHOix9JysixBCFFgjR1eMf0OVeEGEcJDn0og3yrOeY2cHADa5vrii/sW1g\nYgIA+U+Ye1Mdf1xiWr/8Oi4kCvuKPxZgj2C4lRxwMnO+sQvuAlEvbJiaO2iH\n6dp4+VYel75HjYqNmqp2BUh5bZbo2PbKRv3A98oRmY6YQgjACknIMkRINGgq\nE+00\r\n=jvGD\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIApbIOYmknEhjG4v9wck4+7IaFQa2hVvyKZ6hB3XCMKRAiEAi86kicuWMscZNjRPX5k9BjeXYSE6iEFk9MJbVslRxEQ="}]},"maintainers":[{"name":"captemulation","email":"john.holmes.dean@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-redux-permissions_1.1.0_1536351402672_0.8243070133828232"},"_hasShrinkwrap":false},"1.2.0":{"name":"@captemulation/react-redux-permissions","version":"1.2.0","description":"A permissions library for react and redux applications.","main":"dist/index.js","scripts":{"build":"babel src --out-dir dist","lint":"eslint src","test":"jest","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/shizpi/react-redux-permissions.git"},"keywords":["react","reactjs","redux","lib","permissions","roles"],"author":{"name":"Fabio Santos"},"collaborators":["John Dean <jdean@shutterstock.com>"],"license":"MIT","bugs":{"url":"https://github.com/jdean/react-redux-permissions/issues"},"homepage":"https://github.com/jdean/react-redux-permissions#readme","dependencies":{"prop-types":"^15.6.2"},"jest":{"testURL":"http://localhost/"},"devDependencies":{"babel-cli":"^6.8.0","babel-eslint":"^9.0.0","babel-preset-env":"^1.7.0","babel-preset-react":"^6.24.1","babel-preset-stage-2":"^6.24.1","eslint":"^5.5.0","eslint-config-airbnb":"^17.1.0","eslint-plugin-babel":"^5.2.0","eslint-plugin-import":"^2.14.0","eslint-plugin-jsx-a11y":"^6.1.1","eslint-plugin-react":"^7.11.1","jest":"^22.0.5","react":"^16.5.0","react-redux":"^5.0.7","redux":"^3.7.2"},"peerDependencies":{"react":"^16","react-redux":"^5","redux":"^3.7"},"gitHead":"8f8f5bbce41706718b66ca45585d0a10c415e202","_id":"@captemulation/react-redux-permissions@1.2.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"captemulation","email":"john.holmes.dean@gmail.com"},"dist":{"integrity":"sha512-GGPyCU6yjhYHvPfhoINPUCZAXboNpw1E1x3Pe7rwxwcZB7neDJwjEa+MEAjFH+PRw9iNvby+v9SvTGFX7CQjSg==","shasum":"b45d75b8e2f8d91d59d2ed39c48f418c6a7e38d9","tarball":"https://registry.npmjs.org/@captemulation/react-redux-permissions/-/react-redux-permissions-1.2.0.tgz","fileCount":25,"unpackedSize":24720,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbku5ICRA9TVsSAnZWagAAahEQAI65rFPiRPcwObLT85Yi\nXFpbK9I6n8LDxH/9L+2Kg/aawkWI2vcMrWsIBs6vOr+dCRPOnOpy+J0z53d6\ncoJ4KdSqt2vBus56KoT/ZXNerUwrb808b32fTDzlctkYxiN9s/7ncGtRQJpb\nY3ozk4JglKxBoM6AXtlkEGz1xyKtYVuiFlTkRaicc15VRKdnxJaQrLqOOgfH\nEygLvIuwJvevJ1uAqohdiih5usOAYuvoAJqmJdg6iPOkmLWDWf/WMgb/DbkC\nVPOdy3pFrENokpy9np2BprTN0dy2Loqt4GvZzcoRxuanh2KPWGlnLVFmsO7A\nnCGDYx5D3dFjGAKc/IsQbeOAWjzWxX2YJ2Ze8kBPnZV7Lh94z2UG32buis77\nymq5AUfT1NCCeLDPln9ATUxq5IrhWEuocNucIGV/G1l5Bpzur++l/r+AMzPc\nfgu0Xp+AMvInPCVv532d7WUVbqCXakyeVWrwfTNgSxEEiQTtxgv+b2q1IspR\n5jyHxyETiWa52vOuDB07bvCfnOA9Xyh6mKD7BfT4OpP10r+ZzDvqPEHHv07C\nVlMaVUCUIl3Ws97r0QBSdso7NL6uMmjWROcoGcyVXG/F6snYgeg5CDJArmmD\n/CqTLRR9XvAySyHpyW+iC3h73Rf+dN9Tpv+IFUcNHCWZN5O3lmbWsLHAXGfX\n14F5\r\n=Vxfa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHqsPQILh3qXHECGXzvwP/ZqMODmSMgXY6FHU8/LcYIvAiEAxIHoSIjNgL3j5ma9JtZrO/WtRwt/tlalci491V7tuWc="}]},"maintainers":[{"name":"captemulation","email":"john.holmes.dean@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-redux-permissions_1.2.0_1536355911882_0.0608579593048888"},"_hasShrinkwrap":false},"1.3.0":{"name":"@captemulation/react-redux-permissions","version":"1.3.0","description":"A permissions library for react and redux applications.","main":"dist/index.js","scripts":{"build":"babel src --out-dir dist","lint":"eslint src","test":"jest","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/shizpi/react-redux-permissions.git"},"keywords":["react","reactjs","redux","lib","permissions","roles"],"author":{"name":"Fabio Santos"},"collaborators":["John Dean <jdean@shutterstock.com>"],"license":"MIT","bugs":{"url":"https://github.com/jdean/react-redux-permissions/issues"},"homepage":"https://github.com/jdean/react-redux-permissions#readme","dependencies":{"prop-types":"^15.6.2"},"jest":{"testURL":"http://localhost/"},"devDependencies":{"babel-cli":"^6.8.0","babel-eslint":"^9.0.0","babel-preset-env":"^1.7.0","babel-preset-react":"^6.24.1","babel-preset-stage-2":"^6.24.1","eslint":"^5.5.0","eslint-config-airbnb":"^17.1.0","eslint-plugin-babel":"^5.2.0","eslint-plugin-import":"^2.14.0","eslint-plugin-jsx-a11y":"^6.1.1","eslint-plugin-react":"^7.11.1","jest":"^22.0.5","react":"^16.5.0","react-redux":"^5.0.7","redux":"^3.7.2"},"peerDependencies":{"react":"^16","react-redux":"^5","redux":"^3.7"},"gitHead":"43c8f0017fa9e5baf3f7e7ccfa279c149a72c915","_id":"@captemulation/react-redux-permissions@1.3.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"captemulation","email":"john.holmes.dean@gmail.com"},"dist":{"integrity":"sha512-ho0h/YrHYVxNNaplhwxFqegxaob4CnFlFN40rS79AQ7ZvtpZ+xq4crSwi6kP+6Id7W4Q2pcahYqv9G4Q0F9HtA==","shasum":"597dadb7f736d9b22f884ec2382f515887d2faa0","tarball":"https://registry.npmjs.org/@captemulation/react-redux-permissions/-/react-redux-permissions-1.3.0.tgz","fileCount":25,"unpackedSize":29397,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbk14OCRA9TVsSAnZWagAAORMQAKLG1M4KLPLEpBRNYK5S\nn4qrAMGfY9EELTg0idP3PwNKlyIJebp0qHaPKbESG2xhf2ntAkvdJlJrtp01\nOnKlugz8+RtrPLtFAPGtRCBN1Mgr2pT3hhOa1bnGTFi5oiE3hK6Ge1diDy9c\nYK+qc4TKbIZq0MTRAy4dKZaKGRLAra/+P7/TDfpp1drfaFpQ/vfBj4AYfTDL\nEZl1WW4SCmBdOl2Ta0N8EYx4yjpYioVhAtny45CPSAYyaOeaWC6ykygC9Xte\nXGuikbPmgmAKozUZLEGOozhQtz/TqNIDi3NjZKAY/JRfIgPehmoaIx9tR57Z\nmmU0T5gzs1g1lcsovIUd5aC30aCmeu1w5t9q7+rgvvjvSfATh05pvQ9MNOsi\nUMeCILusCwdrCxqUAbG1ggwDY2P2qZ7bS2lbkc62lWwlfZCqu9g+SlI0yHk8\nl4LDB0b5HV0FOo8IcF7FFTKrkSlt5XQjm64lNkz0V4CyUrfjDywUbebXPL4R\nRT/tuvayUhjVriLDOuwKcWv3hidXfm2t4x7Cr3JS6jI2EdV15FgxonW5x5AT\nWd4HOQegCC6ReOzWUXATPGPl1VpWFjBz9nzXElWrjymQukwL7B7cQGMdHBBf\nJqMLhOxsGJB6LreZzQfolt8hBFzqst1x0tvA/YFLicaCmxbgpdVxtdZ8iIMd\nSSLe\r\n=7Ack\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCvvUdVEmpfmBklf5+i/+dA9AbXJBMhYUeuKGHkeliyXQIgFxmv75gT2XUJ99ae2+JitXiz8qf706Xg1Bk7/C6zLyM="}]},"maintainers":[{"name":"captemulation","email":"john.holmes.dean@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-redux-permissions_1.3.0_1536384525385_0.5445656545330038"},"_hasShrinkwrap":false}},"time":{"created":"2018-09-07T20:16:42.514Z","1.1.0":"2018-09-07T20:16:42.783Z","modified":"2022-04-04T21:47:07.922Z","1.2.0":"2018-09-07T21:31:51.995Z","1.3.0":"2018-09-08T05:28:45.552Z"},"maintainers":[{"name":"captemulation","email":"john.holmes.dean@gmail.com"}],"description":"A permissions library for react and redux applications.","homepage":"https://github.com/jdean/react-redux-permissions#readme","keywords":["react","reactjs","redux","lib","permissions","roles"],"repository":{"type":"git","url":"git+https://github.com/shizpi/react-redux-permissions.git"},"author":{"name":"Fabio Santos"},"bugs":{"url":"https://github.com/jdean/react-redux-permissions/issues"},"license":"MIT","readme":"**react-redux-permissions** is a simple library to handle your react application permissions using redux.\n\n## Installation\n\n```\nnpm i react-redux-permissions --save\n```\n\nor \n\n```\nyarn add react-redux-permissions\n```\n\n## Features\n\n* Disable views and components\n* Provide a fallback component for users without permission\n* Designed for react-redux\n* High Order Component option\n\n## Requirements\n\n* node >= 4.0.0\n\n## Usage\n\n### Reducer\n\nImport the reducer and pass it to your store:\n\n``` javascript\nimport { createStore, combineReducers } from 'redux';\n\nimport { reducer as permissions } from \"react-redux-permissions\"\n\nexport function configureStore(initialState = {}) {\n  return createStore(\n    combineReducers({\n      permissions\n    }),\n    initialState\n  );\n}\n```  \n### Actions\nAdd roles to the current user:\n\n```javascript\nimport { add } from \"react-redux-permissions\"\n\ndispatch(add(\"manager\"))\ndispatch(add(\"canSeeMessages\")) // Pretty much anything\n```\nRemove roles from the current user:\n\n```javascript\nimport { remove } from \"react-redux-permissions\"\n\ndispatch(remove(\"canSeeMessages\"))\n```\n\nRemove all roles. Useful once you logout.\n```javascript\nimport { clear } from \"react-redux-permissions\"\n\ndispatch(clear())\n```\n\n### Component\n\nYou can limit access to your views using the default Permissions component.\n\n#### allowed\nWith the `allowed` prop, only users with one of the permissions will be able to see child components.\n```javascript\nimport Permissions from \"react-redux-permissions\"\n\n...\n\n<Permissions\n  allowed={[\"paying\"]}\n>\n  <Route path=\"/dashboard\" component={DashboardView} />\n</Permissions>\n```\n#### except\nWith the `except` prop, every user except the ones with the passed permission will be able to see child components.\n```javascript\nimport Permissions from \"react-redux-permissions\"\n\n...\n\n<Permissions\n  except={[\"paying\"]}\n>\n  <Route path=\"/dashboard\" component={DashboardView} />\n</Permissions>\n```\n\n#### fallbackElement\nYou can send a `fallbackElement` to show an alternative view for users without permission\n```javascript\nimport Permissions from \"react-redux-permissions\"\n\n...\n\n<Permissions\n  except={[\"paying\"]}\n  fallbackElement={<DashboardDisabled />}\n>\n  <Route path=\"/dashboard\" component={DashboardView} />\n</Permissions>\n```\n\n### HOC\nYou can also use a High Order Component to disable views and components:\n\nSend allowed roles as the first argument and disallowed as the second argument.\nYou can also provide a fallback component as second argument of the second function.\n```javascript\nimport { HOC as Permissions } from \"react-redux-permissions\"\n\nconst DashboardView = Permissions(\n  [\"admin\", \"paying\"],\n  [\"trial\"]\n)(Dashboard, <ModuleDisabled view=\"Dashboard\" />)\n\n...\n\n<Route path=\"/dashboard\" component={DashboardView} />\n```\n\nAvoid using it like:\n```javascript\nimport { HOC as Permissions } from \"react-redux-permissions\"\n\nconst DashboardView = Permissions([\"admin\", \"paying\"], [\"trial\"])\n\n...\nrender() {\n  return (\n    ...\n    <Route path=\"/dashboard\" component={DashboardView(Dashboard, <ModuleDisabled view=\"Dashboard\" />)} />\n    ...\n  )\n}\n```\nThis approach inside render will make react mount the component again and cause undesired effects.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/shizpi/react-redux-permissions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n \n","readmeFilename":"README.md"}