{"id":17159130,"url":"https://github.com/scull7/empower-permission","last_synced_at":"2026-07-03T11:39:54.511Z","repository":{"id":57224927,"uuid":"45263427","full_name":"scull7/empower-permission","owner":"scull7","description":"Given a permission set and a request return a permission token.","archived":false,"fork":false,"pushed_at":"2015-11-04T23:28:55.000Z","size":164,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T14:45:39.003Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","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/scull7.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":"2015-10-30T16:36:27.000Z","updated_at":"2015-11-01T17:57:24.000Z","dependencies_parsed_at":"2022-09-06T13:13:24.917Z","dependency_job_id":null,"html_url":"https://github.com/scull7/empower-permission","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scull7%2Fempower-permission","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scull7%2Fempower-permission/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scull7%2Fempower-permission/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scull7%2Fempower-permission/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scull7","download_url":"https://codeload.github.com/scull7/empower-permission/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245294723,"owners_count":20591898,"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":[],"created_at":"2024-10-14T22:13:23.921Z","updated_at":"2026-07-03T11:39:49.490Z","avatar_url":"https://github.com/scull7.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/scull7/empower-permission.svg?branch=master)](https://travis-ci.org/scull7/empower-permission)\n[![Coverage Status](https://coveralls.io/repos/scull7/empower-permission/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/scull7/empower-permission?branch=master)\n\n# empower-permission\nGiven a permission set and a request return a permission token.\n\nit will look in the `PermissionMap` for for a url that matches the given URL.\nIf found, then it will return the token string associated with that path.\nOtherwise, it will return the `GeneralAccessToken` or  _'*'_.  \n\nPaths will be parsed using the `pathToRegexp` module.\ng\n## PermissionToken\n\nExample Token Strings:\n```javascript\n'token:entity:create'\n'token:entity:update'\n'token:entity:sub-entity:read'\n```\n\n## PermissionMap\n\nThis is a map of path strings to `PermissionTokens`\n\nExample Map:\n```json\n{\n  \"/url/token/entity/:entityId\": \"url:token:entity\",\n  \"/url/token/:tokenId\": \"url:token\",\n  \"/url/token\": \"url:token:list\",\n  \"/url/token/:tokenId/action\": \"url:token:action\"\n}\n```\n\n## Usage\n\n### Building the Map from JSON\n```javascript\n\nvar PermissionMap = require('empower-permission');\nvar map = PermissionMap.fromJson({\n  \"/url/token/entity/:entityId\": \"url:token:entity\",\n  \"/url/token/:tokenId\": \"url:token\",\n  \"/url/token\": \"url:token:list\",\n  \"/url/token/:tokenId/action\": \"url:token:action\"\n}}\n\nvar token = map.getToken(\"/url/token/entity/1234\");\n\nconsole.log(token); // will output \"url:token:entity\"\n\n```\n\n### Building the Map Programmatically\n```javascript\n\nvar PermissionMap = require('empower-permission');\nvar map = PermissionMap();\n\nmap\n  .addToken(\"/url/token/entity/:entityId\", \"url:token:entity\")\n  .addToken(\"/url/token/:tokenId\", \"url:token\")\n  .addToken(\"/url/token\", \"url:token:list\")\n  .addToken(\"/url/token/:tokenId/action\", \"url:token:action\")\n\nvar token = map.getToken(\"/url/token\");\n\nconsole.log(token); // will output \"url:token:list\"\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscull7%2Fempower-permission","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscull7%2Fempower-permission","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscull7%2Fempower-permission/lists"}