{"id":17133383,"url":"https://github.com/chronark/access","last_synced_at":"2025-07-26T00:33:49.291Z","repository":{"id":168306270,"uuid":"633131247","full_name":"chronark/access","owner":"chronark","description":"E2E Typed Access Control","archived":false,"fork":false,"pushed_at":"2023-08-03T07:58:50.000Z","size":136,"stargazers_count":68,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-19T04:41:35.454Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/chronark.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-26T21:08:53.000Z","updated_at":"2025-05-25T12:05:04.000Z","dependencies_parsed_at":"2023-11-27T08:15:25.672Z","dependency_job_id":null,"html_url":"https://github.com/chronark/access","commit_stats":null,"previous_names":["chronark/access"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chronark/access","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronark%2Faccess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronark%2Faccess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronark%2Faccess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronark%2Faccess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chronark","download_url":"https://codeload.github.com/chronark/access/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronark%2Faccess/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267093821,"owners_count":24034952,"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","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-14T19:42:02.974Z","updated_at":"2025-07-26T00:33:49.263Z","avatar_url":"https://github.com/chronark.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1 align=\"center\"\u003e@chronark/access-*\u003c/h1\u003e\n    \u003ch5\u003eE2E Typed Access Control\u003c/h5\u003e\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\nA minimal library for access control. It is designed to be used together with\nopaque access tokens by providing a simple interface to define roles with\ndifferent access permissions and verifying requests to resources.\n\n- Fully typed\n- Zero dependencies\n- Serializable to store in a database\n\n## Install\n\n```\nnpm i @chronark/access-policies\n```\n\n## Usage\n\n```ts\n\ntype Resources = {\n  team: [\"create\", \"invite\" /* more */];\n  joke: [\"create\", \"read\", \"vote\"];\n};\n\n/**\n * User or team id\n */\ntype TenantId = string;\n\n/**\n * Just some uuid\n */\ntype JokeId = string;\n\ntype ResourceIdentifier = `${TenantId}-${keyof Resources}-${JokeId}`;\n\n/**\n * Allow the policy owner to create jokes inside the vercel tenant\n */\nconst createJokesInVercel = new Policy\u003cResources, ResourceIdentifier\u003e({\n  resources: {\n    joke: {\n      \"vercel-joke-*\": [\"create\"],\n    },\n  },\n});\n\n/**\n * Or\n * \n * Allow the policy owner to read and vote on all jokes across all tenants\n */\nconst readAndVoteJokesInAllTeams = new Policy\u003cResources, ResourceIdentifier\u003e({\n  resources: {\n    joke: {\n      \"*-joke-*\": [\"read\", \"vote\"],\n    },\n  },\n});\n\n\n\n\n/**\n * Verifying a request\n */\nconst { valid, error } = readAndVoteJokesInAllTeams.validate(\"joke:read\", \"vercel-joke-jokeId\")\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchronark%2Faccess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchronark%2Faccess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchronark%2Faccess/lists"}