@invect/rbac 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +103 -0
  3. package/dist/backend/index.cjs +1365 -0
  4. package/dist/backend/index.cjs.map +1 -0
  5. package/dist/backend/index.d.ts +3 -0
  6. package/dist/backend/index.d.ts.map +1 -0
  7. package/dist/backend/index.mjs +1363 -0
  8. package/dist/backend/index.mjs.map +1 -0
  9. package/dist/backend/plugin.d.ts +60 -0
  10. package/dist/backend/plugin.d.ts.map +1 -0
  11. package/dist/frontend/components/AccessControlPage.d.ts +2 -0
  12. package/dist/frontend/components/AccessControlPage.d.ts.map +1 -0
  13. package/dist/frontend/components/FlowAccessPanel.d.ts +10 -0
  14. package/dist/frontend/components/FlowAccessPanel.d.ts.map +1 -0
  15. package/dist/frontend/components/ShareButton.d.ts +9 -0
  16. package/dist/frontend/components/ShareButton.d.ts.map +1 -0
  17. package/dist/frontend/components/ShareFlowModal.d.ts +12 -0
  18. package/dist/frontend/components/ShareFlowModal.d.ts.map +1 -0
  19. package/dist/frontend/components/TeamsPage.d.ts +5 -0
  20. package/dist/frontend/components/TeamsPage.d.ts.map +1 -0
  21. package/dist/frontend/components/UserMenuSection.d.ts +14 -0
  22. package/dist/frontend/components/UserMenuSection.d.ts.map +1 -0
  23. package/dist/frontend/components/access-control/AccessControlPage.d.ts +2 -0
  24. package/dist/frontend/components/access-control/AccessControlPage.d.ts.map +1 -0
  25. package/dist/frontend/components/access-control/AccessTable.d.ts +17 -0
  26. package/dist/frontend/components/access-control/AccessTable.d.ts.map +1 -0
  27. package/dist/frontend/components/access-control/FlowDetailPanel.d.ts +11 -0
  28. package/dist/frontend/components/access-control/FlowDetailPanel.d.ts.map +1 -0
  29. package/dist/frontend/components/access-control/FormDialog.d.ts +7 -0
  30. package/dist/frontend/components/access-control/FormDialog.d.ts.map +1 -0
  31. package/dist/frontend/components/access-control/MemberCombobox.d.ts +8 -0
  32. package/dist/frontend/components/access-control/MemberCombobox.d.ts.map +1 -0
  33. package/dist/frontend/components/access-control/MoveConfirmationDialog.d.ts +9 -0
  34. package/dist/frontend/components/access-control/MoveConfirmationDialog.d.ts.map +1 -0
  35. package/dist/frontend/components/access-control/PrincipalCombobox.d.ts +11 -0
  36. package/dist/frontend/components/access-control/PrincipalCombobox.d.ts.map +1 -0
  37. package/dist/frontend/components/access-control/ScopeDetailPanel.d.ts +11 -0
  38. package/dist/frontend/components/access-control/ScopeDetailPanel.d.ts.map +1 -0
  39. package/dist/frontend/components/access-control/index.d.ts +4 -0
  40. package/dist/frontend/components/access-control/index.d.ts.map +1 -0
  41. package/dist/frontend/components/access-control/types.d.ts +36 -0
  42. package/dist/frontend/components/access-control/types.d.ts.map +1 -0
  43. package/dist/frontend/components/access-control/useUsers.d.ts +3 -0
  44. package/dist/frontend/components/access-control/useUsers.d.ts.map +1 -0
  45. package/dist/frontend/hooks/useFlowAccess.d.ts +15 -0
  46. package/dist/frontend/hooks/useFlowAccess.d.ts.map +1 -0
  47. package/dist/frontend/hooks/useScopes.d.ts +15 -0
  48. package/dist/frontend/hooks/useScopes.d.ts.map +1 -0
  49. package/dist/frontend/hooks/useTeams.d.ts +25 -0
  50. package/dist/frontend/hooks/useTeams.d.ts.map +1 -0
  51. package/dist/frontend/index.cjs +2928 -0
  52. package/dist/frontend/index.cjs.map +1 -0
  53. package/dist/frontend/index.d.ts +23 -0
  54. package/dist/frontend/index.d.ts.map +1 -0
  55. package/dist/frontend/index.mjs +2899 -0
  56. package/dist/frontend/index.mjs.map +1 -0
  57. package/dist/frontend/providers/RbacProvider.d.ts +33 -0
  58. package/dist/frontend/providers/RbacProvider.d.ts.map +1 -0
  59. package/dist/frontend/stores/accessControlStore.d.ts +49 -0
  60. package/dist/frontend/stores/accessControlStore.d.ts.map +1 -0
  61. package/dist/frontend/types.d.ts +95 -0
  62. package/dist/frontend/types.d.ts.map +1 -0
  63. package/dist/shared/types.cjs +0 -0
  64. package/dist/shared/types.d.ts +172 -0
  65. package/dist/shared/types.d.ts.map +1 -0
  66. package/dist/shared/types.mjs +1 -0
  67. package/package.json +107 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 @robase
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # @invect/rbac
2
+
3
+ RBAC (Role-Based Access Control) plugin for Invect — adds flow sharing, permission management UI, and access control panels.
4
+
5
+ ## Requirements
6
+
7
+ This plugin **requires** the `@invect/user-auth` plugin to be loaded for session resolution. RBAC handles *authorization* on top of the authentication layer that `@invect/user-auth` provides.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pnpm add @invect/rbac
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Backend
18
+
19
+ ```typescript
20
+ import { betterAuthPlugin } from '@invect/user-auth';
21
+ import { rbacPlugin } from '@invect/rbac';
22
+
23
+ app.use('/invect', createInvectRouter({
24
+ databaseUrl: 'sqlite://...',
25
+ auth: {
26
+ enabled: true,
27
+ useFlowAccessTable: true,
28
+ },
29
+ plugins: [
30
+ betterAuthPlugin({ auth }), // Auth MUST be registered first
31
+ rbacPlugin({
32
+ useFlowAccessTable: true,
33
+ }),
34
+ ],
35
+ }));
36
+ ```
37
+
38
+ ### Frontend
39
+
40
+ ```tsx
41
+ import { Invect } from '@invect/frontend';
42
+ import { rbacFrontendPlugin } from '@invect/rbac/ui';
43
+
44
+ function App() {
45
+ return (
46
+ <Invect
47
+ apiBaseUrl="http://localhost:3000/invect"
48
+ plugins={[rbacFrontendPlugin]} // When plugin system is wired
49
+ />
50
+ );
51
+ }
52
+ ```
53
+
54
+ ### Using components directly (before plugin system is wired)
55
+
56
+ ```tsx
57
+ import { RbacProvider, useRbac, ShareFlowModal, FlowAccessPanel } from '@invect/rbac/ui';
58
+ ```
59
+
60
+ ## What's Included
61
+
62
+ ### Backend Plugin (`@invect/rbac`)
63
+ - Plugin endpoints for flow access management (namespaced under `/rbac/`)
64
+ - UI manifest endpoint (`GET /rbac/ui-manifest`)
65
+ - Authorization hooks for flow-level ACL enforcement
66
+ - Auth dependency checking (warns if `@invect/user-auth` is missing)
67
+
68
+ ### Frontend Plugin (`@invect/rbac/ui`)
69
+ - **RbacProvider** — Context provider that fetches and caches user identity/permissions
70
+ - **useRbac()** — Hook for checking permissions in components
71
+ - **ShareButton** — Flow header action that opens the share modal
72
+ - **ShareFlowModal** — Modal for granting/revoking flow access
73
+ - **FlowAccessPanel** — Flow editor panel tab showing access records
74
+ - **AccessControlPage** — Admin page for viewing roles and permissions
75
+ - **UserMenuSection** — Sidebar component showing current user info
76
+
77
+ ### Shared Types (`@invect/rbac/types`)
78
+ - `FlowAccessRecord`, `GrantFlowAccessRequest`, `FlowAccessPermission`
79
+ - `AuthMeResponse`, `RolePermissionEntry`
80
+ - Plugin UI manifest types
81
+
82
+ ## Package Exports
83
+
84
+ | Entry Point | Import | Content |
85
+ |-------------|--------|---------|
86
+ | `@invect/rbac` | `import { rbacPlugin } from '@invect/rbac'` | Backend plugin (Node.js) |
87
+ | `@invect/rbac/ui` | `import { rbacFrontendPlugin } from '@invect/rbac/ui'` | Frontend plugin (Browser) |
88
+ | `@invect/rbac/types` | `import type { FlowAccessRecord } from '@invect/rbac/types'` | Shared types |
89
+
90
+ ## Architecture
91
+
92
+ ```
93
+ @invect/user-auth (authentication)
94
+
95
+ │ provides InvectIdentity via session resolution
96
+
97
+
98
+ @invect/rbac (authorization)
99
+ ├── backend: hooks + endpoints
100
+ │ └── delegates to core's FlowAccessService + AuthorizationService
101
+ └── frontend: provider + components
102
+ └── fetches /auth/me, renders access management UI
103
+ ```