├── .gitignore ├── LICENSE ├── README.md ├── docs ├── .nojekyll ├── assets │ ├── hierarchy.js │ ├── highlight.css │ ├── icons.js │ ├── icons.svg │ ├── main.js │ ├── material-style.css │ ├── navigation.js │ ├── search.js │ └── style.css ├── classes │ ├── gatehouse.PermissionChecker.html │ ├── gatehouse.PolicyBuilder.html │ └── gatehouse.PolicyEvalResult.html ├── documents │ ├── Examples.html │ └── README.html ├── functions │ ├── gatehouse.buildAbacPolicy.html │ ├── gatehouse.buildAndPolicy.html │ ├── gatehouse.buildNotPolicy.html │ ├── gatehouse.buildOrPolicy.html │ ├── gatehouse.buildRbacPolicy.html │ └── gatehouse.buildRebacPolicy.html ├── hierarchy.html ├── index.html ├── interfaces │ └── gatehouse.Policy.html ├── modules.html ├── modules │ └── gatehouse.html ├── types │ ├── gatehouse.EvaluateAccess.html │ └── gatehouse.IntendedEffect.html └── variables │ ├── gatehouse.CombineOp.html │ └── gatehouse.Effect.html ├── package-lock.json ├── package.json ├── src └── gatehouse.ts ├── tests ├── index.test.ts └── originalTests.test.ts ├── tsconfig.json ├── typedoc.json └── usage_examples.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # vitepress build output 108 | **/.vitepress/dist 109 | 110 | # vitepress cache directory 111 | **/.vitepress/cache 112 | 113 | # Docusaurus cache and generated files 114 | .docusaurus 115 | 116 | # Serverless directories 117 | .serverless/ 118 | 119 | # FuseBox cache 120 | .fusebox/ 121 | 122 | # DynamoDB Local files 123 | .dynamodb/ 124 | 125 | # TernJS port file 126 | .tern-port 127 | 128 | # Stores VSCode versions used for testing VSCode extensions 129 | .vscode-test 130 | 131 | # yarn v2 132 | .yarn/cache 133 | .yarn/unplugged 134 | .yarn/build-state.yml 135 | .yarn/install-state.gz 136 | .pnp.* 137 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gatehouse-TS 2 | 3 | Gatehouse-TS is a flexible, zero-dependencies authorization library written in TypeScript. It combines role-based (RBAC), attribute-based (ABAC), and relationship-based (ReBAC) access control policies. Port of the [Gatehouse authorization library for Rust](https://github.com/thepartly/gatehouse/). The original authors did a fantastic job at creating an easy to use API, and were kind enough to let this library be named after Gatehouse. 4 | 5 | Credits for the original API design, Rust implementation and usage instructions go to [Hardbyte](https://hardbyte.nz/) and [Partly](https://partly.com/). 6 | 7 | ## Features 8 | - **Multi-paradigm Authorization**: Support for RBAC, ABAC, and ReBAC patterns 9 | - **Policy Composition**: Combine policies with logical operators (`AND`, `OR`, `NOT`) 10 | - **No additional runtime dependencies**: this library doesn't depend on any third-party libraries. 11 | - **Trivially embeddable**: all the implementation resides inside the `src/index.ts` file, written in easy-to-follow TypeScript. Feel free to copy it directly to your project and modify it to better suit your needs. 12 | - **Detailed Evaluation Tracing**: Complete decision trace for debugging and auditing. 13 | - **Fluent Builder API**: Construct custom policies with a PolicyBuilder. 14 | - **Type Safety**: Strongly typed resources/actions/contexts. 15 | 16 | ### Documentation 17 | 18 | [Click here](https://9morello.github.io/gatehouse-ts/) to browse the documentation. 19 | 20 | ## Quick Start 21 | 22 | Here is an example of how to build a role-based `Policy` and evaluate access with it. 23 | 24 | ```typescript 25 | import { 26 | buildRbacPolicy, 27 | PermissionChecker 28 | } from 'gatehouse-ts'; 29 | 30 | type User = { 31 | id: number; 32 | roles: string[]; // e.g., ["admin", "editor", "viewer"] 33 | department: string; 34 | }; 35 | 36 | type Document = { 37 | id: number; 38 | ownerId: number; 39 | isPublic: boolean; 40 | requiredDepartment: string | null; // e.g., "HR", "Engineering" 41 | }; 42 | 43 | type Action = "read" | "write" | "delete" | "comment"; 44 | 45 | type RequestContext = { 46 | ipAddress?: string; 47 | timestamp?: Date; 48 | }; 49 | 50 | const rbacPolicy = buildRbacPolicy({ 51 | name: "Standard RBAC Policy", 52 | requiredRolesResolver: (resource:Document, action:Action) => { 53 | // This function determines which roles are needed for a given resource and action. 54 | // Here, it's simplified and only depends on the action. 55 | switch (action) { 56 | case "read": 57 | return ["viewer", "editor", "admin"]; 58 | case "write": 59 | case "comment": 60 | return ["editor", "admin"]; 61 | case "delete": 62 | return ["admin"]; 63 | default: 64 | return []; // Deny unknown actions 65 | } 66 | }, 67 | // This function extracts the roles from the subject (User). 68 | userRolesResolver: (subject:User) => subject.roles, 69 | }); 70 | 71 | const permissionChecker = new PermissionChecker(); 72 | 73 | // Add the policy to the checker 74 | permissionChecker.addPolicy(rbacPolicy); 75 | 76 | //mock data 77 | 78 | const editorUser: User = { 79 | id: 0, 80 | roles: ["editor"], 81 | department: "Marketing" 82 | }; 83 | 84 | const privateDoc: Document = { 85 | id: 100, 86 | ownerId: 0, 87 | isPublic: false, 88 | requiredDepartment: null 89 | }; 90 | 91 | const sampleContext: RequestContext = {}; 92 | 93 | // --- Evaluation --- 94 | // Editor tries to write to a private doc (Allowed by RBAC) 95 | let result = await permissionChecker.evaluateAccess({ 96 | subject: editorUser, 97 | resource: privateDoc, 98 | action: "write", 99 | context: sampleContext, 100 | }); 101 | console.log(`Editor write privateDoc: ${result.isGranted()}`); // Output: true 102 | ``` 103 | 104 | You can add as many policies as you want to a `PermissionChecker` instance. For example, in the code above, you could add a policy to make it so that only users with the `"admin"` role could delete documents. -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /docs/assets/hierarchy.js: -------------------------------------------------------------------------------- 1 | window.hierarchyData = "eJyrVirKzy8pVrKKjtVRKkpNy0lNLsnMzwMKVNfWAgCbHgqm" -------------------------------------------------------------------------------- /docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-hl-0: #AF00DB; 3 | --dark-hl-0: #C586C0; 4 | --light-hl-1: #000000; 5 | --dark-hl-1: #D4D4D4; 6 | --light-hl-2: #001080; 7 | --dark-hl-2: #9CDCFE; 8 | --light-hl-3: #A31515; 9 | --dark-hl-3: #CE9178; 10 | --light-hl-4: #0000FF; 11 | --dark-hl-4: #569CD6; 12 | --light-hl-5: #267F99; 13 | --dark-hl-5: #4EC9B0; 14 | --light-hl-6: #008000; 15 | --dark-hl-6: #6A9955; 16 | --light-hl-7: #0070C1; 17 | --dark-hl-7: #4FC1FF; 18 | --light-hl-8: #795E26; 19 | --dark-hl-8: #DCDCAA; 20 | --light-hl-9: #098658; 21 | --dark-hl-9: #B5CEA8; 22 | --light-hl-10: #000000FF; 23 | --dark-hl-10: #D4D4D4; 24 | --light-code-background: #FFFFFF; 25 | --dark-code-background: #1E1E1E; 26 | } 27 | 28 | @media (prefers-color-scheme: light) { :root { 29 | --hl-0: var(--light-hl-0); 30 | --hl-1: var(--light-hl-1); 31 | --hl-2: var(--light-hl-2); 32 | --hl-3: var(--light-hl-3); 33 | --hl-4: var(--light-hl-4); 34 | --hl-5: var(--light-hl-5); 35 | --hl-6: var(--light-hl-6); 36 | --hl-7: var(--light-hl-7); 37 | --hl-8: var(--light-hl-8); 38 | --hl-9: var(--light-hl-9); 39 | --hl-10: var(--light-hl-10); 40 | --code-background: var(--light-code-background); 41 | } } 42 | 43 | @media (prefers-color-scheme: dark) { :root { 44 | --hl-0: var(--dark-hl-0); 45 | --hl-1: var(--dark-hl-1); 46 | --hl-2: var(--dark-hl-2); 47 | --hl-3: var(--dark-hl-3); 48 | --hl-4: var(--dark-hl-4); 49 | --hl-5: var(--dark-hl-5); 50 | --hl-6: var(--dark-hl-6); 51 | --hl-7: var(--dark-hl-7); 52 | --hl-8: var(--dark-hl-8); 53 | --hl-9: var(--dark-hl-9); 54 | --hl-10: var(--dark-hl-10); 55 | --code-background: var(--dark-code-background); 56 | } } 57 | 58 | :root[data-theme='light'] { 59 | --hl-0: var(--light-hl-0); 60 | --hl-1: var(--light-hl-1); 61 | --hl-2: var(--light-hl-2); 62 | --hl-3: var(--light-hl-3); 63 | --hl-4: var(--light-hl-4); 64 | --hl-5: var(--light-hl-5); 65 | --hl-6: var(--light-hl-6); 66 | --hl-7: var(--light-hl-7); 67 | --hl-8: var(--light-hl-8); 68 | --hl-9: var(--light-hl-9); 69 | --hl-10: var(--light-hl-10); 70 | --code-background: var(--light-code-background); 71 | } 72 | 73 | :root[data-theme='dark'] { 74 | --hl-0: var(--dark-hl-0); 75 | --hl-1: var(--dark-hl-1); 76 | --hl-2: var(--dark-hl-2); 77 | --hl-3: var(--dark-hl-3); 78 | --hl-4: var(--dark-hl-4); 79 | --hl-5: var(--dark-hl-5); 80 | --hl-6: var(--dark-hl-6); 81 | --hl-7: var(--dark-hl-7); 82 | --hl-8: var(--dark-hl-8); 83 | --hl-9: var(--dark-hl-9); 84 | --hl-10: var(--dark-hl-10); 85 | --code-background: var(--dark-code-background); 86 | } 87 | 88 | .hl-0 { color: var(--hl-0); } 89 | .hl-1 { color: var(--hl-1); } 90 | .hl-2 { color: var(--hl-2); } 91 | .hl-3 { color: var(--hl-3); } 92 | .hl-4 { color: var(--hl-4); } 93 | .hl-5 { color: var(--hl-5); } 94 | .hl-6 { color: var(--hl-6); } 95 | .hl-7 { color: var(--hl-7); } 96 | .hl-8 { color: var(--hl-8); } 97 | .hl-9 { color: var(--hl-9); } 98 | .hl-10 { color: var(--hl-10); } 99 | pre, code { background: var(--code-background); } 100 | -------------------------------------------------------------------------------- /docs/assets/icons.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | addIcons(); 3 | function addIcons() { 4 | if (document.readyState === "loading") return document.addEventListener("DOMContentLoaded", addIcons); 5 | const svg = document.body.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); 6 | svg.innerHTML = `MMNEPVFCICPMFPCPTTAAATR`; 7 | svg.style.display = "none"; 8 | if (location.protocol === "file:") updateUseElements(); 9 | } 10 | 11 | function updateUseElements() { 12 | document.querySelectorAll("use").forEach(el => { 13 | if (el.getAttribute("href").includes("#icon-")) { 14 | el.setAttribute("href", el.getAttribute("href").replace(/.*#/, "#")); 15 | } 16 | }); 17 | } 18 | })() -------------------------------------------------------------------------------- /docs/assets/icons.svg: -------------------------------------------------------------------------------- 1 | MMNEPVFCICPMFPCPTTAAATR -------------------------------------------------------------------------------- /docs/assets/material-style.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap"); 2 | 3 | :root, 4 | :root[data-theme="light"], 5 | :root[data-theme="dark"] { 6 | --font-sans: "Space Grotesk", sans-serif; 7 | --font-mono: "Space Mono", monospace; 8 | 9 | --color-background: var(--md-sys-color-surface-container); 10 | --color-background-secondary: var(--md-sys-color-surface-container-high); 11 | --color-background-warning: var(--md-sys-color-error-container); 12 | --color-warning-text: var(--md-sys-color-on-error-container); 13 | --color-icon-background: var(--md-sys-color-on-primary); 14 | --color-accent: var(--md-sys-color-secondary-container); 15 | --color-active-menu-item: var(--md-sys-color-surface-container-highest); 16 | --color-text: var(--md-sys-color-on-surface); 17 | --color-text-aside: var(--md-sys-color-on-surface-variant); 18 | --color-link: var(--md-sys-color-primary); 19 | 20 | --color-ts-project: var(--md-sys-color-secondary); 21 | --color-ts-module: var(--color-ts-project); 22 | --color-ts-namespace: var(--color-ts-project); 23 | 24 | --color-ts-enum: var(--md-sys-color-tertiary); 25 | --color-ts-enum-member: var(--color-ts-enum); 26 | 27 | --color-ts-variable: var(--md-sys-color-primary); 28 | --color-ts-function: var(--md-sys-color-secondary); 29 | --color-ts-class: var(--md-sys-color-tertiary); 30 | --color-ts-interface: var(--md-sys-color-tertiary); 31 | 32 | --color-ts-constructor: var(--md-sys-color-inverse-primary); 33 | 34 | --color-ts-property: var(--md-sys-color-on-background); 35 | --color-ts-method: var(--color-ts-function); 36 | 37 | --color-ts-call-signature: var(--color-ts-method); 38 | --color-ts-index-signature: var(--color-ts-property); /* ? */ 39 | --color-ts-constructor-signature: var(--color-ts-function); 40 | --color-ts-parameter: var(--md-sys-color-primary); 41 | 42 | --color-ts-type-parameter: var(--md-sys-color-tertiary); 43 | --color-ts-accessor: var(--color-ts-property); 44 | --color-ts-get-signature: var(--color-ts-accessor); 45 | --color-ts-set-signature: var(--color-ts-accessor); 46 | --color-ts-type-alias: var(--md-sys-color-tertiary); 47 | 48 | /* --external-icon: var(--md-sys-external-icon); 49 | --color-scheme: var(--md-sys-color-scheme); */ 50 | 51 | --top-app-bar-height: 4.5rem; 52 | --top-app-bar-padding-vertical: .5rem; 53 | --footer-height: 3.5rem; 54 | 55 | --safe-area-inset-top: env(safe-area-inset-top); 56 | } 57 | 58 | body { 59 | font-family: var(--font-sans); 60 | } 61 | code, 62 | pre { 63 | font-family: var(--font-mono); 64 | } 65 | 66 | img { 67 | max-width: 100%; 68 | } 69 | 70 | @supports not selector(::-webkit-scrollbar) { 71 | * { 72 | scrollbar-width: thin; 73 | scrollbar-color: var(--color-accent) transparent; 74 | } 75 | } 76 | 77 | @supports selector(::-webkit-scrollbar) { 78 | *::-webkit-scrollbar { 79 | width: 8px; 80 | height: 8px; 81 | } 82 | *::-webkit-scrollbar-track { 83 | background: none; 84 | margin: 4px; 85 | } 86 | *::-webkit-scrollbar-thumb { 87 | border: none; 88 | } 89 | *::-webkit-scrollbar-thumb:hover, 90 | *::-webkit-scrollbar-thumb:active { 91 | background-color: var(--md-sys-color-secondary); 92 | } 93 | * { 94 | scrollbar-width: unset; 95 | scrollbar-color: unset; 96 | } 97 | } 98 | 99 | .container-main { 100 | min-height: calc(100vh - var(--top-app-bar-height) - var(--footer-height)); 101 | } 102 | .col-content { 103 | overflow: hidden; 104 | box-sizing: border-box; 105 | padding: 1.75rem; 106 | margin-bottom: 1.75rem; 107 | border-radius: 28px; 108 | background-color: var(--md-sys-color-surface); 109 | } 110 | .page-menu { 111 | height: fit-content; 112 | padding: 1.25rem 1.75rem; 113 | border-radius: 28px; 114 | background-color: var(--md-sys-color-surface); 115 | } 116 | .site-menu > *, 117 | .page-menu > * { 118 | position: relative; 119 | } 120 | .title { 121 | display: inline-block; 122 | white-space: nowrap; 123 | overflow: hidden; 124 | text-overflow: ellipsis; 125 | font-size: 22px; 126 | } 127 | .tsd-page-title { 128 | word-break: break-all; 129 | } 130 | .tsd-page-toolbar { 131 | padding: 1rem 0; 132 | background-color: var(--color-background); 133 | border-bottom: none; 134 | } 135 | .tsd-page-toolbar .tsd-toolbar-icon { 136 | padding: 20px 0; 137 | } 138 | #tsd-search { 139 | border-radius: 38px; 140 | } 141 | #tsd-search-input { 142 | border-radius: 22px; 143 | } 144 | #tsd-search-input:focus-visible { 145 | background-color: var(--color-accent); 146 | } 147 | #tsd-search-results > li { 148 | background: none; 149 | } 150 | #tsd-toolbar-menu-trigger, 151 | #tsd-search-trigger { 152 | border-radius: 50%; 153 | } 154 | html:not(.has-menu) .col-sidebar { 155 | padding-top: 0; 156 | margin-right: 1rem; 157 | } 158 | 159 | .tsd-signature { 160 | padding: 1rem 1.5rem; 161 | border-radius: 24px; 162 | background-color: var(--md-sys-color-surface-container); 163 | } 164 | 165 | .tsd-page-navigation ul { 166 | padding-left: 0.44rem; 167 | } 168 | .tsd-navigation a, 169 | .tsd-navigation summary > span, 170 | .tsd-page-navigation a { 171 | padding: 0.88rem; 172 | border-radius: 24px; 173 | } 174 | .tsd-navigation a:hover, 175 | .tsd-page-navigation a:hover { 176 | text-decoration: none; 177 | background-color: var(--md-sys-color-surface-container-high); 178 | } 179 | .page-menu .tsd-accordion-summary { 180 | margin-bottom: 0.5rem; 181 | } 182 | .page-menu .tsd-accordion-summary svg { 183 | position: absolute; 184 | right: 0; 185 | } 186 | .site-menu .tsd-navigation .tsd-accordion-summary { 187 | display: flex; 188 | flex-direction: row-reverse; 189 | width: 100%; 190 | } 191 | 192 | .tsd-small-nested-navigation { 193 | margin-left: 1rem; 194 | } 195 | .tsd-nested-navigation { 196 | margin-left: 2.5rem; 197 | } 198 | .tsd-nested-navigation > li > a, 199 | .tsd-nested-navigation > li > span { 200 | width: 100%; 201 | } 202 | .tsd-navigation > a, 203 | .tsd-navigation .tsd-accordion-summary { 204 | width: 100%; 205 | } 206 | .tsd-accordion .tsd-accordion-summary > svg, 207 | .tsd-index-accordion .tsd-accordion-summary > svg { 208 | position: absolute; 209 | right: 1.5rem; 210 | } 211 | .tsd-accordion-summary .tsd-kind-icon ~ span { 212 | margin-right: 2.5rem; 213 | } 214 | .tsd-accordion-summary .tsd-nested-navigation > li > a, 215 | .tsd-nested-navigation > li > span { 216 | width: calc(100% - 0.44rem); 217 | } 218 | .tsd-kind-icon ~ span { 219 | white-space: nowrap; 220 | overflow: hidden; 221 | text-overflow: ellipsis; 222 | } 223 | .tsd-generator { 224 | padding: 0; 225 | border-top: none; 226 | height: var(--footer-height); 227 | line-height: var(--footer-height); 228 | } 229 | .tsd-generator > p { 230 | padding: 0 2rem; 231 | } 232 | 233 | @media (max-width: 769px) { 234 | .col-sidebar { 235 | margin-right: 0; 236 | } 237 | } 238 | @media (min-width: 770px) { 239 | .container-main { 240 | margin: 0 auto; 241 | } 242 | .site-menu { 243 | margin-right: 0.5rem; 244 | } 245 | } 246 | @media (min-width: 1200px) { 247 | .page-menu, 248 | .site-menu { 249 | max-height: calc(100vh - var(--footer-height) - var(--top-app-bar-height)); 250 | top: var(--top-app-bar-height); 251 | } 252 | .site-menu { 253 | margin-top: 0; 254 | } 255 | .page-menu { 256 | margin-left: 1rem; 257 | } 258 | .col-sidebar { 259 | margin-right: 0; 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /docs/assets/navigation.js: -------------------------------------------------------------------------------- 1 | window.navigationData = "eJyV0s9vwiAUB/D/hbOZv6brvHWuhx02Ta/GA4XXlUihKWA0i//7WBZbqDXUI3lfPry8x+4HaThptEJpEr9/JmiEKqwLe6aSmBKEVuP/ylOhS27LByYoWkXzKFpOosuouZ+ccFlxUH3CtRYyvrGGQhoFLVJKauzNcVPyjdkIkYJxWoNAq10DbaEumVJMinUB5AB1CxKOlfLAm7D/xHTmtriVnJHzm7FvBlQ3GBaTI+YpKMN1GG2zYbfVmNBQ55j0gJ2ZLpbuXu1jxuZjYm8629XnypP8XEecvL5MFzNH/bDNCAo0yXMg+r7q50LqWpYZE7CpWvCIa4Yz/wc1Md+bu1S3sT6nrykPyf62H2eYdHeRG0G0/XCu1gn77PL5hhV0uHrNhtAvqQejTTaEburB5jUaItNHZpoOnmkKD7lwH95f9r/wBdoo" -------------------------------------------------------------------------------- /docs/assets/search.js: -------------------------------------------------------------------------------- 1 | window.searchData = "eJy9mU1v2zgQhv+LejUccyjJdm7Z1lj0sNsiWOwlCBayRDdqbcmQrDSFkf++pPXBGZGOqVjoKZHF952h+HBIUUevyH+W3u3D0fuRZol3u+CLRThbTLws2gnv1rtf3X36a+VNvKrYysskj6udyA7lTX1j+nTYbeXdeBuVpZBGnvc6Oee1eol2+61sZbq1t970g87pW3QQT3lVis5qlyeV1N90d950YqCz+iqKXVqWaZ59fBLxD1F0no0UeRptLVEm3j4qZKdImjp0wHQ34jwrD0UVH/LhQT9Q8YUETBP8NGbgdzmd/gxOplFdkwXMfD0oUZJ8zbdp/Gt4KlK6b6Wj5SOeo20lZXdxLMpyeFKtPmr1V40XpvfU1T+qdJu8TS5u91uoNQIOJZb07Bwn8UE+ojcHxMxDi0bJYa1uD8uglYwSXz7Wg3g5DB6LRjRKDmKzEfHAFDrNKBkUosyrIhYDWcCyUfIoq/V32a2BaSDVKFn8fBLZsAwaxXujmzVpJUvevSir7WUsdNPfV5l6Md9VnFAXz6ym9Ur0z6/9m2uqNaFaeqilY+VTiKjML5PRz6WTXZEH4XOTF7toMBgfOtlYeaTln0UkK+Hl+t1PJS2/dcprsgnC3rzpMkmle7GJYksyw6cJoeDMbuZSwHfsYuoeuWw1LwZ33WL2Q8JsOWeBLhIre+fVRMOhabPhD7wf9rPsX5aIZEVXyn5Y2mx4WK4jfsx36zQTX/ZdsOeoSKM1fU3qWl0Vq9crW6D39ij06U7rbh3FvZmyqbJ6S4fC9dqOEDfrv5KcD9s2vT7q3/nBNWrX9PqoXwrXoG3L62PeDxjX+xHH9V4MCSyGR36cyOKWiBfv9ug9i0K908kGMOXTpVRsUrFN1AlMWw7jfKfOROR/7fGI99g0+1eo7YlqXLe+mXmTh9mEw3QWBI+Pk4dWfLpx+qH10L+chExeMZuQGUJGhCCvwCYEQwhEyOUVtwm5IeRE6MsrfwJ8GiyACH1D6BNhIK+CCYTTpR8SYWAIAyIM5VVoSzU0hCERzuXV3Jbq3BDOiXAhrxa2iAtDuCDC5bmHszSESwqA4mFpJcBkh/XgOdFj5Y5Z+KEAMYUFs7NnMsQoREyhITf8lkFlJkeMgsQUHszKIDNZYhQmphBhvlVs8sQoUExhwgKr2GSKUaiYQoVZeWQmV4yCxRbnAGEmWoyyxRQxbG4NbOLFKF+gkGFWpsEEDChgcALMSieYgEGvQp1KlJVOsBQpChgoZMBKJ5iAAQUM/HPzH0y+gPIFZ6sVmHgBxQvCs3FNuoDSBYoXsFd0ky6gdIECBqwzCky8gOIFy7NzGUy8gOLFFTBgnY7cxItTvLgCBqzTkZt4cYoXP+FlnY7cxIv3FsETXtYpxS3rIMWLK2LAOqW4yRenfHGFDFinFDcBa3467VzklkW+5X6udzBy49Gdnh69/5p9zbLdUR09uVTcHl9f9TZGXqGdjLqnIqFDem0TapvQyaU5RtUOclHSmTB3j0ju6sx89Kvq0eNu/ardMkvnJG/abEBqWX6wmKFHJRFzNssLi9cceXF3r8L+zBbIzR/gJux2CC0JpYtdXL/Q5nviw7WPrENuPuhAUDshJvxauaz/MGfb+uAdUcsQtW6j2Z6dIxNAJryWwdLNrHeso00RGvPGsuk0uM1Q0X3yRZmiRJ1M2lM/ZIGwADcT9MkYYYFsnFzS5njGfP6AveZuZvoIEfmgEgZuSdUvjtoCVZqgGS23qbPvPjrG7adw7YpmkFuVsMxmNPQwxGTdft/UXqjOuE282kmxXjRfJRBPqJ4yt8HDx/PICM0Y5jb7ChEldPwQAW6rTns8j/JAjwdcTbovYcgHjTpzK+f6UxayQVWTubFYf49CFohq5lB85N5ln+7FVi4Fctvy+Pr6PymNfMo="; -------------------------------------------------------------------------------- /docs/functions/gatehouse.buildAbacPolicy.html: -------------------------------------------------------------------------------- 1 | buildAbacPolicy | gatehouse-ts
gatehouse-ts
    Preparing search index...

    Function buildAbacPolicy

    • Creates an Attribute-Based Access Control policy. 160 | Grants access based on attributes of the subject, resource, action, and context.

      161 |

      Type Parameters

      • Sub

        Subject type

        162 |
      • Res

        Resource type

        163 |
      • Act

        Action type

        164 |
      • Ctx

        Context type

        165 |

      Parameters

      • condition: { condition: Condition<Sub, Res, Act, Ctx>; name?: string }

        Function that evaluates attributes and returns true if access should be granted

        166 |

      Returns AttributeBasedPolicy<Sub, Res, Act, Ctx>

      An ABAC policy

      167 |
      const abacPolicy = buildAbacPolicy<User, Document, string, Context>(
      ({subject, resource}) =>
      resource.isPublic || subject.id === resource.ownerId
      ); 168 |
      169 | 170 |
    186 | -------------------------------------------------------------------------------- /docs/functions/gatehouse.buildAndPolicy.html: -------------------------------------------------------------------------------- 1 | buildAndPolicy | gatehouse-ts
    gatehouse-ts
      Preparing search index...

      Function buildAndPolicy

      • Creates a policy that requires all sub-policies to grant access.

        160 |

        Type Parameters

        • Sub

          Subject type

          161 |
        • Res

          Resource type

          162 |
        • Act

          Action type

          163 |
        • Ctx

          Context type

          164 |

        Parameters

        • policies: { name?: string; policies: Policy<Sub, Res, Act, Ctx>[] }

          Array of policies that all must grant access

          165 |

        Returns AndPolicy<Sub, Res, Act, Ctx>

        A combined AND policy

        166 |
        const policy = buildAndPolicy([adminRolePolicy, documentOwnerPolicy]);
        167 | 
        168 | 169 |
      185 | -------------------------------------------------------------------------------- /docs/functions/gatehouse.buildNotPolicy.html: -------------------------------------------------------------------------------- 1 | buildNotPolicy | gatehouse-ts
      gatehouse-ts
        Preparing search index...

        Function buildNotPolicy

        • Creates a policy that inverts the result of another policy.

          160 |

          Type Parameters

          • Sub

            Subject type

            161 |
          • Res

            Resource type

            162 |
          • Act

            Action type

            163 |
          • Ctx

            Context type

            164 |

          Parameters

          Returns NotPolicy<Sub, Res, Act, Ctx>

          A NOT policy that grants access when the original would deny it

          166 |
          // Grant access to non-public resources
          const policy = buildNotPolicy(publicResourcePolicy); 167 |
          168 | 169 |
        185 | -------------------------------------------------------------------------------- /docs/functions/gatehouse.buildOrPolicy.html: -------------------------------------------------------------------------------- 1 | buildOrPolicy | gatehouse-ts
        gatehouse-ts
          Preparing search index...

          Function buildOrPolicy

          • Creates a policy that grants access if any sub-policy grants access.

            160 |

            Type Parameters

            • Sub

              Subject type

              161 |
            • Res

              Resource type

              162 |
            • Act

              Action type

              163 |
            • Ctx

              Context type

              164 |

            Parameters

            • policies: { name?: string; policies: Policy<Sub, Res, Act, Ctx>[] }

              Array of policies where any one can grant access

              165 |

            Returns OrPolicy<Sub, Res, Act, Ctx>

            A combined OR policy

            166 |
            const policy = buildOrPolicy([adminRolePolicy, documentOwnerPolicy]);
            167 | 
            168 | 169 |
          185 | -------------------------------------------------------------------------------- /docs/hierarchy.html: -------------------------------------------------------------------------------- 1 | gatehouse-ts
          gatehouse-ts
            Preparing search index...

            gatehouse-ts

            Hierarchy Summary

            175 | -------------------------------------------------------------------------------- /docs/modules.html: -------------------------------------------------------------------------------- 1 | gatehouse-ts
            gatehouse-ts
              Preparing search index...

                gatehouse-ts

                Guides

                Examples

                Other

                README
                gatehouse
                175 | -------------------------------------------------------------------------------- /docs/types/gatehouse.EvaluateAccess.html: -------------------------------------------------------------------------------- 1 | EvaluateAccess | gatehouse-ts
                gatehouse-ts
                  Preparing search index...

                  Type Alias EvaluateAccess<Subject, Resource, Action, Context>

                  EvaluateAccess: (
                      { 160 | subject, 161 | resource, 162 | action, 163 | context, 164 | }: {
                          action: Action;
                          context: Context;
                          resource: Resource;
                          subject: Subject;
                      },
                  ) => PolicyEvalResult
                  | Promise<PolicyEvalResult>

                  Function type for evaluating access based on subject, resource, action, and context.

                  165 |

                  Type Parameters

                  • Subject

                    The type of the subject requesting access

                    166 |
                  • Resource

                    The type of resource being accessed

                    167 |
                  • Action

                    The type of action being performed

                    168 |
                  • Context

                    Additional contextual information

                    169 |

                  Type declaration

                  195 | -------------------------------------------------------------------------------- /docs/types/gatehouse.IntendedEffect.html: -------------------------------------------------------------------------------- 1 | IntendedEffect | gatehouse-ts
                  gatehouse-ts
                    Preparing search index...

                    Type Alias IntendedEffect

                    IntendedEffect: typeof Effect[keyof typeof Effect]
                    175 | -------------------------------------------------------------------------------- /docs/variables/gatehouse.CombineOp.html: -------------------------------------------------------------------------------- 1 | CombineOp | gatehouse-ts
                    gatehouse-ts
                      Preparing search index...

                      Variable CombineOpConst

                      CombineOp: Readonly<{ And: "AND"; Not: "NOT"; Or: "OR" }> = ...

                      Operation types for combining policies.

                      160 |
                      176 | -------------------------------------------------------------------------------- /docs/variables/gatehouse.Effect.html: -------------------------------------------------------------------------------- 1 | Effect | gatehouse-ts
                      gatehouse-ts
                        Preparing search index...

                        Variable EffectConst

                        Effect: Readonly<{ Allow: "Allow"; Deny: "Deny" }> = ...

                        Represents the intended effect of a policy. 160 | Allow means the policy grants access; Deny means it denies access.

                        161 |
                        177 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gatehouse-ts", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "gatehouse-ts", 9 | "version": "1.0.0", 10 | "devDependencies": { 11 | "@types/bun": "latest", 12 | "typedoc": "0.28.2", 13 | "typedoc-material-theme": "1.4.0", 14 | "typescript": "^5" 15 | } 16 | }, 17 | "node_modules/@gerrit0/mini-shiki": { 18 | "version": "3.2.3", 19 | "resolved": "https://registry.npmjs.org/@gerrit0/mini-shiki/-/mini-shiki-3.2.3.tgz", 20 | "integrity": "sha512-yemSYr0Oiqk5NAQRfbD5DKUTlThiZw1MxTMx/YpQTg6m4QRJDtV2JTYSuNevgx1ayy/O7x+uwDjh3IgECGFY/Q==", 21 | "dev": true, 22 | "license": "MIT", 23 | "dependencies": { 24 | "@shikijs/engine-oniguruma": "^3.2.2", 25 | "@shikijs/langs": "^3.2.2", 26 | "@shikijs/themes": "^3.2.2", 27 | "@shikijs/types": "^3.2.2", 28 | "@shikijs/vscode-textmate": "^10.0.2" 29 | } 30 | }, 31 | "node_modules/@material/material-color-utilities": { 32 | "version": "0.3.0", 33 | "resolved": "https://registry.npmjs.org/@material/material-color-utilities/-/material-color-utilities-0.3.0.tgz", 34 | "integrity": "sha512-ztmtTd6xwnuh2/xu+Vb01btgV8SQWYCaK56CkRK8gEkWe5TuDyBcYJ0wgkMRn+2VcE9KUmhvkz+N9GHrqw/C0g==", 35 | "dev": true, 36 | "license": "Apache-2.0" 37 | }, 38 | "node_modules/@shikijs/engine-oniguruma": { 39 | "version": "3.2.2", 40 | "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.2.2.tgz", 41 | "integrity": "sha512-vyXRnWVCSvokwbaUD/8uPn6Gqsf5Hv7XwcW4AgiU4Z2qwy19sdr6VGzMdheKKN58tJOOe5MIKiNb901bgcUXYQ==", 42 | "dev": true, 43 | "license": "MIT", 44 | "dependencies": { 45 | "@shikijs/types": "3.2.2", 46 | "@shikijs/vscode-textmate": "^10.0.2" 47 | } 48 | }, 49 | "node_modules/@shikijs/langs": { 50 | "version": "3.2.2", 51 | "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-3.2.2.tgz", 52 | "integrity": "sha512-NY0Urg2dV9ETt3JIOWoMPuoDNwte3geLZ4M1nrPHbkDS8dWMpKcEwlqiEIGqtwZNmt5gKyWpR26ln2Bg2ecPgw==", 53 | "dev": true, 54 | "license": "MIT", 55 | "dependencies": { 56 | "@shikijs/types": "3.2.2" 57 | } 58 | }, 59 | "node_modules/@shikijs/themes": { 60 | "version": "3.2.2", 61 | "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-3.2.2.tgz", 62 | "integrity": "sha512-Zuq4lgAxVKkb0FFdhHSdDkALuRpsj1so1JdihjKNQfgM78EHxV2JhO10qPsMrm01FkE3mDRTdF68wfmsqjt6HA==", 63 | "dev": true, 64 | "license": "MIT", 65 | "dependencies": { 66 | "@shikijs/types": "3.2.2" 67 | } 68 | }, 69 | "node_modules/@shikijs/types": { 70 | "version": "3.2.2", 71 | "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-3.2.2.tgz", 72 | "integrity": "sha512-a5TiHk7EH5Lso8sHcLHbVNNhWKP0Wi3yVnXnu73g86n3WoDgEra7n3KszyeCGuyoagspQ2fzvy4cpSc8pKhb0A==", 73 | "dev": true, 74 | "license": "MIT", 75 | "dependencies": { 76 | "@shikijs/vscode-textmate": "^10.0.2", 77 | "@types/hast": "^3.0.4" 78 | } 79 | }, 80 | "node_modules/@shikijs/vscode-textmate": { 81 | "version": "10.0.2", 82 | "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz", 83 | "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==", 84 | "dev": true, 85 | "license": "MIT" 86 | }, 87 | "node_modules/@types/bun": { 88 | "version": "1.2.9", 89 | "resolved": "https://registry.npmjs.org/@types/bun/-/bun-1.2.9.tgz", 90 | "integrity": "sha512-epShhLGQYc4Bv/aceHbmBhOz1XgUnuTZgcxjxk+WXwNyDXavv5QHD1QEFV0FwbTSQtNq6g4ZcV6y0vZakTjswg==", 91 | "dev": true, 92 | "license": "MIT", 93 | "dependencies": { 94 | "bun-types": "1.2.9" 95 | } 96 | }, 97 | "node_modules/@types/hast": { 98 | "version": "3.0.4", 99 | "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", 100 | "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", 101 | "dev": true, 102 | "license": "MIT", 103 | "dependencies": { 104 | "@types/unist": "*" 105 | } 106 | }, 107 | "node_modules/@types/node": { 108 | "version": "22.14.1", 109 | "resolved": "https://registry.npmjs.org/@types/node/-/node-22.14.1.tgz", 110 | "integrity": "sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==", 111 | "dev": true, 112 | "license": "MIT", 113 | "dependencies": { 114 | "undici-types": "~6.21.0" 115 | } 116 | }, 117 | "node_modules/@types/unist": { 118 | "version": "3.0.3", 119 | "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", 120 | "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", 121 | "dev": true, 122 | "license": "MIT" 123 | }, 124 | "node_modules/@types/ws": { 125 | "version": "8.18.1", 126 | "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", 127 | "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", 128 | "dev": true, 129 | "license": "MIT", 130 | "dependencies": { 131 | "@types/node": "*" 132 | } 133 | }, 134 | "node_modules/argparse": { 135 | "version": "2.0.1", 136 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 137 | "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", 138 | "dev": true, 139 | "license": "Python-2.0" 140 | }, 141 | "node_modules/balanced-match": { 142 | "version": "1.0.2", 143 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 144 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", 145 | "dev": true, 146 | "license": "MIT" 147 | }, 148 | "node_modules/brace-expansion": { 149 | "version": "2.0.1", 150 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", 151 | "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", 152 | "dev": true, 153 | "license": "MIT", 154 | "dependencies": { 155 | "balanced-match": "^1.0.0" 156 | } 157 | }, 158 | "node_modules/bun-types": { 159 | "version": "1.2.9", 160 | "resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.2.9.tgz", 161 | "integrity": "sha512-dk/kOEfQbajENN/D6FyiSgOKEuUi9PWfqKQJEgwKrCMWbjS/S6tEXp178mWvWAcUSYm9ArDlWHZKO3T/4cLXiw==", 162 | "dev": true, 163 | "license": "MIT", 164 | "dependencies": { 165 | "@types/node": "*", 166 | "@types/ws": "*" 167 | } 168 | }, 169 | "node_modules/entities": { 170 | "version": "4.5.0", 171 | "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", 172 | "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", 173 | "dev": true, 174 | "license": "BSD-2-Clause", 175 | "engines": { 176 | "node": ">=0.12" 177 | }, 178 | "funding": { 179 | "url": "https://github.com/fb55/entities?sponsor=1" 180 | } 181 | }, 182 | "node_modules/linkify-it": { 183 | "version": "5.0.0", 184 | "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", 185 | "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", 186 | "dev": true, 187 | "license": "MIT", 188 | "dependencies": { 189 | "uc.micro": "^2.0.0" 190 | } 191 | }, 192 | "node_modules/lunr": { 193 | "version": "2.3.9", 194 | "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", 195 | "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", 196 | "dev": true, 197 | "license": "MIT" 198 | }, 199 | "node_modules/markdown-it": { 200 | "version": "14.1.0", 201 | "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", 202 | "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", 203 | "dev": true, 204 | "license": "MIT", 205 | "dependencies": { 206 | "argparse": "^2.0.1", 207 | "entities": "^4.4.0", 208 | "linkify-it": "^5.0.0", 209 | "mdurl": "^2.0.0", 210 | "punycode.js": "^2.3.1", 211 | "uc.micro": "^2.1.0" 212 | }, 213 | "bin": { 214 | "markdown-it": "bin/markdown-it.mjs" 215 | } 216 | }, 217 | "node_modules/mdurl": { 218 | "version": "2.0.0", 219 | "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", 220 | "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", 221 | "dev": true, 222 | "license": "MIT" 223 | }, 224 | "node_modules/minimatch": { 225 | "version": "9.0.5", 226 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", 227 | "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", 228 | "dev": true, 229 | "license": "ISC", 230 | "dependencies": { 231 | "brace-expansion": "^2.0.1" 232 | }, 233 | "engines": { 234 | "node": ">=16 || 14 >=14.17" 235 | }, 236 | "funding": { 237 | "url": "https://github.com/sponsors/isaacs" 238 | } 239 | }, 240 | "node_modules/punycode.js": { 241 | "version": "2.3.1", 242 | "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", 243 | "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", 244 | "dev": true, 245 | "license": "MIT", 246 | "engines": { 247 | "node": ">=6" 248 | } 249 | }, 250 | "node_modules/typedoc": { 251 | "version": "0.28.2", 252 | "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.28.2.tgz", 253 | "integrity": "sha512-9Giuv+eppFKnJ0oi+vxqLM817b/IrIsEMYgy3jj6zdvppAfDqV3d6DXL2vXUg2TnlL62V48th25Zf/tcQKAJdg==", 254 | "dev": true, 255 | "license": "Apache-2.0", 256 | "dependencies": { 257 | "@gerrit0/mini-shiki": "^3.2.2", 258 | "lunr": "^2.3.9", 259 | "markdown-it": "^14.1.0", 260 | "minimatch": "^9.0.5", 261 | "yaml": "^2.7.1" 262 | }, 263 | "bin": { 264 | "typedoc": "bin/typedoc" 265 | }, 266 | "engines": { 267 | "node": ">= 18", 268 | "pnpm": ">= 10" 269 | }, 270 | "peerDependencies": { 271 | "typescript": "5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x" 272 | } 273 | }, 274 | "node_modules/typedoc-material-theme": { 275 | "version": "1.4.0", 276 | "resolved": "https://registry.npmjs.org/typedoc-material-theme/-/typedoc-material-theme-1.4.0.tgz", 277 | "integrity": "sha512-TBoBpX/4zWO6l74/wBLivXHC2rIiD70KXMliYrw1KhcqdybyxkVBLP5z8KiJuNV8aQIeS+rK2QG6GSucQHJQDQ==", 278 | "dev": true, 279 | "funding": [ 280 | { 281 | "type": "individual", 282 | "url": "https://paypal.me/dmnsgn" 283 | }, 284 | { 285 | "type": "individual", 286 | "url": "https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3" 287 | } 288 | ], 289 | "license": "MIT", 290 | "dependencies": { 291 | "@material/material-color-utilities": "^0.3.0" 292 | }, 293 | "engines": { 294 | "node": ">=18.0.0", 295 | "npm": ">=8.6.0" 296 | }, 297 | "peerDependencies": { 298 | "typedoc": "^0.25.13 || ^0.26.x || ^0.27.x || ^0.28.x" 299 | } 300 | }, 301 | "node_modules/typescript": { 302 | "version": "5.8.3", 303 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", 304 | "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", 305 | "dev": true, 306 | "license": "Apache-2.0", 307 | "bin": { 308 | "tsc": "bin/tsc", 309 | "tsserver": "bin/tsserver" 310 | }, 311 | "engines": { 312 | "node": ">=14.17" 313 | } 314 | }, 315 | "node_modules/uc.micro": { 316 | "version": "2.1.0", 317 | "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", 318 | "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", 319 | "dev": true, 320 | "license": "MIT" 321 | }, 322 | "node_modules/undici-types": { 323 | "version": "6.21.0", 324 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", 325 | "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", 326 | "dev": true, 327 | "license": "MIT" 328 | }, 329 | "node_modules/yaml": { 330 | "version": "2.7.1", 331 | "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.1.tgz", 332 | "integrity": "sha512-10ULxpnOCQXxJvBgxsn9ptjq6uviG/htZKk9veJGhlqn3w/DxQ631zFF+nlQXLwmImeS5amR2dl2U8sg6U9jsQ==", 333 | "dev": true, 334 | "license": "ISC", 335 | "bin": { 336 | "yaml": "bin.mjs" 337 | }, 338 | "engines": { 339 | "node": ">= 14" 340 | } 341 | } 342 | } 343 | } 344 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gatehouse-ts", 3 | "module": "src/gatehouse.ts", 4 | "description": "A TypeScript library for building and managing authorization policies.", 5 | "author": "gr4vityWall", 6 | "license": "Apache-2.0", 7 | "homepage": "https://github.com/9Morello/gatehouse-ts", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/9Morello/gatehouse-ts.git" 11 | }, 12 | "keywords": [ 13 | "authorization", 14 | "policy", 15 | "gatehouse", 16 | "typescript" 17 | ], 18 | "version": "1.0.0", 19 | "type": "module", 20 | "main": "dist/gatehouse.js", 21 | "types": "dist/gatehouse.d.ts", 22 | "files": [ 23 | "dist" 24 | ], 25 | "exports": { 26 | ".": { 27 | "types": "./dist/gatehouse.d.ts", 28 | "default": "./dist/gatehouse.js" 29 | } 30 | }, 31 | "scripts": { 32 | "build": "tsc", 33 | "test": "bun test", 34 | "docs": "npx typedoc src/gatehouse.ts --plugin typedoc-material-theme --themeColor '#cb9820'" 35 | }, 36 | "devDependencies": { 37 | "@types/bun": "latest", 38 | "typedoc": "0.28.2", 39 | "typedoc-material-theme": "1.4.0", 40 | "typescript": "^5" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // Environment setup & latest features 4 | "lib": ["ESNext"], 5 | "target": "ES2020", 6 | "module": "ESNext", 7 | "moduleDetection": "force", 8 | "allowJs": true, 9 | "declaration": true, 10 | "outDir": "dist", 11 | 12 | // Bundler mode 13 | "moduleResolution": "bundler", 14 | "verbatimModuleSyntax": true, 15 | 16 | // Best practices 17 | "strict": true, 18 | "skipLibCheck": true, 19 | "noFallthroughCasesInSwitch": true, 20 | "noUncheckedIndexedAccess": true, 21 | 22 | // Some stricter flags (disabled by default) 23 | "noUnusedLocals": true, 24 | "noUnusedParameters": false, 25 | "noPropertyAccessFromIndexSignature": false 26 | }, 27 | "include": ["src/**/*.ts"] 28 | } 29 | -------------------------------------------------------------------------------- /typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "projectDocuments": ["README.md", "usage_examples.md"], 3 | "entryPointStrategy": "expand", 4 | "entryPoints": ["src/index.ts"], 5 | "out": "docs", 6 | "excludeInternal": true, 7 | "excludePrivate": true, 8 | "excludeProtected": true 9 | } --------------------------------------------------------------------------------