{"id":15679264,"url":"https://github.com/johannschopplich/unacl","last_synced_at":"2025-03-10T23:33:02.893Z","repository":{"id":57385755,"uuid":"464901113","full_name":"johannschopplich/unacl","owner":"johannschopplich","description":"🙅‍♀️🙆‍♂️ Minimal, type-safe and reactive access control","archived":false,"fork":false,"pushed_at":"2023-04-18T16:00:11.000Z","size":270,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-04T16:27:54.380Z","etag":null,"topics":["acl","authorization","permissions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johannschopplich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-01T13:19:24.000Z","updated_at":"2023-09-10T10:22:05.000Z","dependencies_parsed_at":"2023-01-29T04:15:44.509Z","dependency_job_id":null,"html_url":"https://github.com/johannschopplich/unacl","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannschopplich%2Funacl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannschopplich%2Funacl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannschopplich%2Funacl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannschopplich%2Funacl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johannschopplich","download_url":"https://codeload.github.com/johannschopplich/unacl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221197724,"owners_count":16774576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acl","authorization","permissions"],"created_at":"2024-10-03T16:27:56.654Z","updated_at":"2024-10-23T12:38:10.474Z","avatar_url":"https://github.com/johannschopplich.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# unacl\n\n\u003e Minimal, type-safe and reactive ACL implementation.\n\nThis library doesn't replace a full-featured ACL system, like [CASL](https://github.com/stalniy/casl/). It rather serves a lightweight base for simple access control requirements, like SPAs.\n\n`unacl` utilizes [@vue/reactivity](https://www.npmjs.com/package/@vue/reactivity) under the hood and wraps `roles` and `persmissions` into reactive sets. Thus, you can pair it with Vue in an instant. Of course, you don't have to.\n\n## Key Features\n\n- 🧩 Reactive `roles` and `permissions` sets\n- 🙆‍♂️ Including checks, like `can`, `is`, `hasEveryRole`\n- 🙅‍♀️ Excluding checks, like `missesSomePermissions`\n- 🪶 About 100 loc\n\n## Example\n\n```ts\nimport { ACL } from 'unacl'\n\n// Setup the acl instance\nconst acl = new ACL({\n  permissions: ['read'],\n  roles: ['admin', 'editor'],\n})\n\nconst isEditor = acl.is('editor') // `true`\n\nif (acl.can('archive'))\n  console.log('You are not allowed to archive this entity')\n\n// Change permissions, say after sign in\nif (acl.has('admin'))\n  acl.addPermissions(['create', 'update', 'delete'])\nelse\n  acl.addPermissions(['update'])\n```\n\n## Installation\n\nRun the following command to add `unacl` to your project.\n\n```bash\npnpm install unacl # or npm or yarn\n```\n\n## Configuration\n\n```ts\ninterface AclConfig\u003cT = string, U = string\u003e {\n  roles?: Array\u003cT\u003e\n  permissions?: Array\u003cU\u003e\n}\n```\n\n## Usage\n\nThere are also a number of methods you can leverage on the `ACL` instance:\n\n| Method                    | Description                                                        |\n| ------------------------- | ------------------------------------------------------------------ |\n| `can()`                   | Shorthand accessor for `hasEveryPermission()`.                     |\n| `hasEveryPermission()`    | Assert the store has every given permission(s).                    |\n| `hasSomePermissions()`    | Assert the store has some of the given permission(s).              |\n| `missesEveryPermission()` | Assert the store is missing every given permission(s).             |\n| `missesSomePermissions()` | Assert the store is missing at least 1 of the given permission(s). |\n| `has()` \u0026 `is()`          | Shorthand accessor for `hasEveryRole()`.                           |\n| `hasEveryRole()`          | Assert the store has every given role(s).                          |\n| `hasSomeRoles()`          | Assert the store has some of the given role(s).                    |\n| `missesEveryRole()`       | Assert the store is missing every given role(s).                   |\n| `missesSomeRoles()`       | Assert the store is missing at least 1 of the given role(s).       |\n| `getRoles()`              | Gets the array of currently stored roles.                          |\n| `getPermissions()`        | Gets the array of currently stored permissions.                    |\n| `setRoles()`              | Overwrites the role store with the given new roles.                |\n| `setPermissions()`        | Overwrites the permission store with the given new permissions.    |\n| `addRoles()`              | Adds the given role(s) to the role store.                          |\n| `addPermissions()`        | Adds the given permission(s) to the permission store.              |\n| `clearRoles()`            | Clears the currently stored roles.                                 |\n| `clearPermissions()`      | Clears the currently stored permissions.                           |\n| `clear()`                 | Clears both the role and permission store.                         |\n\n## Credits\n\n- [@fullstackfool](https://github.com/fullstackfool) for [vacl](https://github.com/fullstackfool/vacl) which served as inspiration and base for this project.\n\n## License\n\n[MIT](./LICENSE) License © 2022-present [Johann Schopplich](https://github.com/johannschopplich)\n\n[MIT](./LICENSE) License © 2019 [Karl Davies](https://github.com/fullstackfool)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohannschopplich%2Funacl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohannschopplich%2Funacl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohannschopplich%2Funacl/lists"}