@jini-ai/user-management 0.2.0

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 (190) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/LICENSE +201 -0
  3. package/README.md +104 -0
  4. package/dist/admin/adapters/http.d.ts +29 -0
  5. package/dist/admin/adapters/http.js +69 -0
  6. package/dist/admin/adapters/memory.d.ts +61 -0
  7. package/dist/admin/adapters/memory.js +217 -0
  8. package/dist/admin/auth.module.d.ts +30 -0
  9. package/dist/admin/auth.module.js +12 -0
  10. package/dist/admin/conformance/index.d.ts +56 -0
  11. package/dist/admin/conformance/index.js +156 -0
  12. package/dist/admin/controllers/auth.controller.d.ts +23 -0
  13. package/dist/admin/controllers/auth.controller.js +33 -0
  14. package/dist/admin/controllers/controller-store.d.ts +18 -0
  15. package/dist/admin/controllers/controller-store.js +23 -0
  16. package/dist/admin/controllers/members.controller.d.ts +33 -0
  17. package/dist/admin/controllers/members.controller.js +119 -0
  18. package/dist/admin/controllers/roles.controller.d.ts +47 -0
  19. package/dist/admin/controllers/roles.controller.js +282 -0
  20. package/dist/admin/controllers/users.controller.d.ts +53 -0
  21. package/dist/admin/controllers/users.controller.js +220 -0
  22. package/dist/admin/index.d.ts +21 -0
  23. package/dist/admin/index.js +15 -0
  24. package/dist/admin/members.module.d.ts +34 -0
  25. package/dist/admin/members.module.js +13 -0
  26. package/dist/admin/messages.en.d.ts +37 -0
  27. package/dist/admin/messages.en.js +21 -0
  28. package/dist/admin/models.d.ts +133 -0
  29. package/dist/admin/models.js +2 -0
  30. package/dist/admin/people.rules.d.ts +29 -0
  31. package/dist/admin/people.rules.js +51 -0
  32. package/dist/admin/ports.d.ts +187 -0
  33. package/dist/admin/ports.js +17 -0
  34. package/dist/admin/react/components/DestructiveDialog.d.ts +5 -0
  35. package/dist/admin/react/components/DestructiveDialog.js +6 -0
  36. package/dist/admin/react/components/MemberRow.d.ts +5 -0
  37. package/dist/admin/react/components/MemberRow.js +8 -0
  38. package/dist/admin/react/components/MembersConfirmation.d.ts +2 -0
  39. package/dist/admin/react/components/MembersConfirmation.js +8 -0
  40. package/dist/admin/react/components/PermissionPanel.d.ts +5 -0
  41. package/dist/admin/react/components/PermissionPanel.js +9 -0
  42. package/dist/admin/react/components/PolicyRow.d.ts +5 -0
  43. package/dist/admin/react/components/PolicyRow.js +11 -0
  44. package/dist/admin/react/components/RoleRow.d.ts +5 -0
  45. package/dist/admin/react/components/RoleRow.js +10 -0
  46. package/dist/admin/react/components/UserRow.d.ts +5 -0
  47. package/dist/admin/react/components/UserRow.js +8 -0
  48. package/dist/admin/react/components/UsersConfirmation.d.ts +3 -0
  49. package/dist/admin/react/components/UsersConfirmation.js +9 -0
  50. package/dist/admin/react/hooks/AuthBinding.hooks.d.ts +39 -0
  51. package/dist/admin/react/hooks/AuthBinding.hooks.js +21 -0
  52. package/dist/admin/react/hooks/LoginPage.hooks.d.ts +54 -0
  53. package/dist/admin/react/hooks/LoginPage.hooks.js +23 -0
  54. package/dist/admin/react/hooks/MembersBinding.hooks.d.ts +35 -0
  55. package/dist/admin/react/hooks/MembersBinding.hooks.js +21 -0
  56. package/dist/admin/react/hooks/MembersPage.hooks.d.ts +99 -0
  57. package/dist/admin/react/hooks/MembersPage.hooks.js +38 -0
  58. package/dist/admin/react/hooks/PeopleController.hooks.d.ts +18 -0
  59. package/dist/admin/react/hooks/PeopleController.hooks.js +20 -0
  60. package/dist/admin/react/hooks/PermissionPanel.hooks.d.ts +30 -0
  61. package/dist/admin/react/hooks/PermissionPanel.hooks.js +15 -0
  62. package/dist/admin/react/hooks/PoliciesTab.hooks.d.ts +47 -0
  63. package/dist/admin/react/hooks/PoliciesTab.hooks.js +26 -0
  64. package/dist/admin/react/hooks/RolesBinding.hooks.d.ts +39 -0
  65. package/dist/admin/react/hooks/RolesBinding.hooks.js +23 -0
  66. package/dist/admin/react/hooks/RolesController.hooks.d.ts +43 -0
  67. package/dist/admin/react/hooks/RolesController.hooks.js +25 -0
  68. package/dist/admin/react/hooks/RolesPage.hooks.d.ts +105 -0
  69. package/dist/admin/react/hooks/RolesPage.hooks.js +33 -0
  70. package/dist/admin/react/hooks/RolesTab.hooks.d.ts +35 -0
  71. package/dist/admin/react/hooks/RolesTab.hooks.js +19 -0
  72. package/dist/admin/react/hooks/UsersBinding.hooks.d.ts +36 -0
  73. package/dist/admin/react/hooks/UsersBinding.hooks.js +21 -0
  74. package/dist/admin/react/hooks/UsersPage.hooks.d.ts +106 -0
  75. package/dist/admin/react/hooks/UsersPage.hooks.js +22 -0
  76. package/dist/admin/react/hooks/UsersTab.hooks.d.ts +101 -0
  77. package/dist/admin/react/hooks/UsersTab.hooks.js +53 -0
  78. package/dist/admin/react/index.d.ts +203 -0
  79. package/dist/admin/react/index.js +32 -0
  80. package/dist/admin/react/pages/LoginPage.d.ts +3 -0
  81. package/dist/admin/react/pages/LoginPage.js +13 -0
  82. package/dist/admin/react/pages/MembersPage.d.ts +3 -0
  83. package/dist/admin/react/pages/MembersPage.js +19 -0
  84. package/dist/admin/react/pages/RolesPage.d.ts +3 -0
  85. package/dist/admin/react/pages/RolesPage.js +19 -0
  86. package/dist/admin/react/pages/UsersPage.d.ts +3 -0
  87. package/dist/admin/react/pages/UsersPage.js +19 -0
  88. package/dist/admin/react/tabs/AuthTab.d.ts +4 -0
  89. package/dist/admin/react/tabs/AuthTab.js +8 -0
  90. package/dist/admin/react/tabs/MembersTab.d.ts +4 -0
  91. package/dist/admin/react/tabs/MembersTab.js +9 -0
  92. package/dist/admin/react/tabs/PoliciesTab.d.ts +4 -0
  93. package/dist/admin/react/tabs/PoliciesTab.js +9 -0
  94. package/dist/admin/react/tabs/RolesTab.d.ts +4 -0
  95. package/dist/admin/react/tabs/RolesTab.js +9 -0
  96. package/dist/admin/react/tabs/UsersTab.d.ts +4 -0
  97. package/dist/admin/react/tabs/UsersTab.js +9 -0
  98. package/dist/admin/roles.module.d.ts +48 -0
  99. package/dist/admin/roles.module.js +15 -0
  100. package/dist/admin/rules.d.ts +32 -0
  101. package/dist/admin/rules.js +32 -0
  102. package/dist/admin/users.module.d.ts +39 -0
  103. package/dist/admin/users.module.js +14 -0
  104. package/dist/core/builtin-permissions.d.ts +10 -0
  105. package/dist/core/builtin-permissions.js +402 -0
  106. package/dist/core/index.d.ts +6 -0
  107. package/dist/core/index.js +9 -0
  108. package/dist/core/permissions.d.ts +40 -0
  109. package/dist/core/permissions.js +52 -0
  110. package/dist/core/ports.d.ts +237 -0
  111. package/dist/core/ports.js +2 -0
  112. package/dist/core/runtime-ports.d.ts +8 -0
  113. package/dist/core/runtime-ports.js +2 -0
  114. package/dist/core/types.d.ts +224 -0
  115. package/dist/core/types.js +93 -0
  116. package/dist/react/auth/Login.d.ts +9 -0
  117. package/dist/react/auth/Login.js +8 -0
  118. package/dist/react/auth/hooks/use-login.hooks.d.ts +22 -0
  119. package/dist/react/auth/hooks/use-login.hooks.js +24 -0
  120. package/dist/react/errors.d.ts +10 -0
  121. package/dist/react/errors.js +13 -0
  122. package/dist/react/index.d.ts +18 -0
  123. package/dist/react/index.js +9 -0
  124. package/dist/react/members/Members.d.ts +6 -0
  125. package/dist/react/members/Members.js +38 -0
  126. package/dist/react/members/hooks/use-members.hooks.d.ts +32 -0
  127. package/dist/react/members/hooks/use-members.hooks.js +120 -0
  128. package/dist/react/members/rules.d.ts +26 -0
  129. package/dist/react/members/rules.js +35 -0
  130. package/dist/react/models.d.ts +50 -0
  131. package/dist/react/models.js +2 -0
  132. package/dist/react/ports.d.ts +157 -0
  133. package/dist/react/ports.js +2 -0
  134. package/dist/react/roles/Roles.d.ts +100 -0
  135. package/dist/react/roles/Roles.hooks.d.ts +17 -0
  136. package/dist/react/roles/Roles.hooks.js +40 -0
  137. package/dist/react/roles/Roles.js +150 -0
  138. package/dist/react/roles/hooks/use-roles.hooks.d.ts +80 -0
  139. package/dist/react/roles/hooks/use-roles.hooks.js +303 -0
  140. package/dist/react/roles/rules.d.ts +35 -0
  141. package/dist/react/roles/rules.js +31 -0
  142. package/dist/react/roles/text.d.ts +27 -0
  143. package/dist/react/roles/text.js +13 -0
  144. package/dist/react/testing.d.ts +51 -0
  145. package/dist/react/testing.js +275 -0
  146. package/dist/react/users/Users.d.ts +72 -0
  147. package/dist/react/users/Users.js +129 -0
  148. package/dist/react/users/hooks/use-reset-password-fields.hooks.d.ts +16 -0
  149. package/dist/react/users/hooks/use-reset-password-fields.hooks.js +21 -0
  150. package/dist/react/users/hooks/use-users.hooks.d.ts +77 -0
  151. package/dist/react/users/hooks/use-users.hooks.js +286 -0
  152. package/dist/react/users/rules.d.ts +33 -0
  153. package/dist/react/users/rules.js +61 -0
  154. package/dist/server/admin-crud-service.d.ts +295 -0
  155. package/dist/server/admin-crud-service.js +561 -0
  156. package/dist/server/agent-tool-input.d.ts +58 -0
  157. package/dist/server/agent-tool-input.js +158 -0
  158. package/dist/server/agent-tool-registrations.d.ts +51 -0
  159. package/dist/server/agent-tool-registrations.js +417 -0
  160. package/dist/server/agent-tools.d.ts +88 -0
  161. package/dist/server/agent-tools.js +229 -0
  162. package/dist/server/auth-service.d.ts +107 -0
  163. package/dist/server/auth-service.js +170 -0
  164. package/dist/server/authorize.d.ts +92 -0
  165. package/dist/server/authorize.js +96 -0
  166. package/dist/server/grant-service.d.ts +219 -0
  167. package/dist/server/grant-service.js +419 -0
  168. package/dist/server/hasher.d.ts +64 -0
  169. package/dist/server/hasher.js +53 -0
  170. package/dist/server/identity-transaction.d.ts +9 -0
  171. package/dist/server/identity-transaction.js +8 -0
  172. package/dist/server/index.d.ts +18 -0
  173. package/dist/server/index.js +20 -0
  174. package/dist/server/messages.d.ts +7 -0
  175. package/dist/server/messages.js +5 -0
  176. package/dist/server/password-policy.d.ts +59 -0
  177. package/dist/server/password-policy.js +66 -0
  178. package/dist/server/permission-migrations.d.ts +84 -0
  179. package/dist/server/permission-migrations.js +77 -0
  180. package/dist/server/repo.memory-transactions.d.ts +16 -0
  181. package/dist/server/repo.memory-transactions.js +79 -0
  182. package/dist/server/repo.memory.d.ts +186 -0
  183. package/dist/server/repo.memory.js +230 -0
  184. package/dist/server/seed.d.ts +56 -0
  185. package/dist/server/seed.js +435 -0
  186. package/dist/server/session-tokens.d.ts +10 -0
  187. package/dist/server/session-tokens.js +12 -0
  188. package/dist/server/username.d.ts +14 -0
  189. package/dist/server/username.js +14 -0
  190. package/package.json +144 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,77 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 — 2026-10-02
4
+
5
+ ### BREAKING
6
+
7
+ - Canonical package replaces the retired identity surface; user tools live in ./server, primitive ports come from core, and session lifetime and tenancy are configurable.
8
+ - Distribution includes runtime output, release documentation and required assets only. Process records and per-job neutrality checks are no longer part of the package surface.
9
+
10
+ ## Unreleased
11
+
12
+ ### Compilation fixes
13
+
14
+ - Import the consolidated tab-strip barrel (requires the UI peer to export that
15
+ entry) and use the timestamp argument object.
16
+ - Complete policy fixtures, preserve concrete spy signatures, and check optional
17
+ roster entries and tool inputs without weakening assertions or public types.
18
+ - Preserve the required policy name in the React fake when optional updates
19
+ omit it or supply `undefined`; add a regression case for that behavior.
20
+
21
+ ### Breaking architecture boundaries
22
+
23
+ - Export identity registration composition from `./server`; generic wiring uses core rather than CMS.
24
+ - Replace local runtime and catalog types with core contracts; ID generation uses a zero-argument getter.
25
+ - Make `IdentityRepos.transactions` and registration transaction/token ports required.
26
+ - Add `sessionTtlMs` and replaceable authentication messages options; preserve the 30-day default. Invalid lifetimes raise RangeError before persistence. Sessions retain required workspace scope because repositories require it.
27
+ - Merge the job-specific test configuration into the existing config and rename its setup file.
28
+
29
+
30
+ - Remove specification identifiers from admin safety errors and direct-grant tool text; authorization and ownership checks retain their behavior.
31
+
32
+ - Reject reserved wildcard registration with a typed validation error and converge
33
+ interrupted seeds using only unconstrained, unscoped permission rows.
34
+ - **BEHAVIOR CHANGE:** Guarded authorization mutations and migration fan-out require
35
+ a shared identity transaction port and fail closed when it is absent. Add a
36
+ transactional memory adapter; migration failures roll back all prior additions.
37
+ - Validate complete tool schemas eagerly and implement JSON Schema `minLength`
38
+ using raw Unicode code points. Whitespace counts toward length; unsupported
39
+ schema shapes fail before input inspection. Preserve not-found grant errors and
40
+ the `principal_disabled` reason for unknown principals, with corrected documentation.
41
+
42
+ - **BREAKING:** Rename the package and folder to `@jini-ai/user-management` and
43
+ `packages/user-management`, reflecting users, members, roles, permissions,
44
+ grants and authentication. No alias is provided; runtime entry points, public
45
+ symbols, argument conventions and version remain unchanged.
46
+
47
+ - Integrate the universal root, Node `./server`, browser `./react` and
48
+ `./react/testing` entries with matching runtime metadata and complete barrels.
49
+ - Add Login, Users, Roles and Members screens, controller hooks, browser DTOs,
50
+ injected transport/refresh ports and generalized in-memory React testing ports.
51
+ Branding, translations, navigation and query scope remain host inputs.
52
+ - Declare optional React/React DOM, UI, admin and agentic peers and development
53
+ dependencies; route browser suites through jsdom and preserve headless guards.
54
+ - Reconcile agent handles, query mutation input/options, async actions, settlement
55
+ generations, tabs and translated placeholders with dependency API conversions.
56
+ The fake roles port preserves optional permission resource scope.
57
+ - **BREAKING:** Existing public identity functions, constructors and scalar port
58
+ methods use required argument objects and a separate optional argument object.
59
+ Hashing uses `hash({ password })` and `verify({ hash, password })`; memory
60
+ repositories use `new InMemoryPrincipalRepo({}, { initialRows })` (and the
61
+ corresponding shape for the other repository constructors).
62
+ - **BREAKING:** Optional user/policy fields, request metadata and authorization
63
+ resource context move to the second argument. `seedIdentity` requires explicit
64
+ `input.ownerUsername`; clock and ID ports receive `{}`.
65
+ - **BREAKING:** `AuthServiceDeps` requires `SessionTokenPort`; `NodeSessionTokens`
66
+ retains the 32-byte hex bearer and SHA-256 digest. `Argon2PasswordHasher` requires
67
+ an injected `loadBinding`; `loadArgon2Binding({})` adapts the optional native peer.
68
+ - **BREAKING:** Domain controller ID actions use named targets: user grants/email
69
+ use `{ principalId }`, role saves use `{ roleId }`, policy saves/form/writes use
70
+ `{ policyId }`, permission removal uses `{ policyId, policyPermissionId }`, and
71
+ member row-state lookup uses `{ id }`. React event/setter callbacks are preserved.
72
+ - Preserve public export names, catalog values, migration pairs, hashing costs,
73
+ error messages and React framework callback signatures. No version bump.
74
+
75
+ ## 0.1.0 — 2026-10-01
76
+
77
+ Initial additive identity package, with universal records/ports/permissions and a Node server entry for authentication, sessions, authorization, grants, operator administration, hashing, seeding, migrations, memory repositories, and independent tool metadata/input parsing. Existing source entry points and consumers are migrated separately.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
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 describing the origin of the Work and
141
+ 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 Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
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 2026 Open Design contributors
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.
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # Integrated user management API
2
+
3
+ `@jini-ai/user-management` owns users, members, roles, permissions, grants, authentication and optional admin screens.
4
+ All current entries are included in the unchanged 0.1.0 package version:
5
+
6
+ | Import | Runtime | Contents |
7
+ |---|---|---|
8
+ | `@jini-ai/user-management` | Universal | Records, errors, repository/runtime ports, permission catalog |
9
+ | `@jini-ai/user-management/server` | Node | Auth, sessions, grants, administration, hashing, memory repos, seeding, migrations, tool metadata/parser and registration composition |
10
+ | `@jini-ai/user-management/react` | Browser | Login, Users, Members, hooks, browser DTOs and typed host ports |
11
+ | `@jini-ai/user-management/react/testing` | Browser | Generalized fake login/users/roles/members ports |
12
+ | `@jini-ai/user-management/admin/react` | Browser | Composable roles/policies module and lazy screens using ui-kit |
13
+
14
+ Every public function/factory takes a required argument object and, where needed,
15
+ a second optional argument object. Repository `save` accepts a complete record.
16
+ React props, event handlers, state setters and translation callbacks retain their
17
+ framework contracts. See [invocation and migration examples](./args-convention.md).
18
+ Hosts provide repositories, `clock.nowMs()`, `idGen.newId()`, hashing and
19
+ session-token ports. The Node token adapter preserves the original bearer/digest
20
+ formats. Native Argon2 is optional; construct its adapter with
21
+ `new Argon2PasswordHasher({ loadBinding: loadArgon2Binding }, { memoryCost: 19456 })`.
22
+ Server entry imports never pull in React or a native binding eagerly.
23
+
24
+ React consumers install compatible React/React DOM and `@jini-ai/{ui,admin,agentic}`
25
+ peers. These peers are optional for universal/server consumers. Mount Users
26
+ inside `FetchQueryProvider` from `@jini-ai/ui/panel-kit`; the current provider owns
27
+ its cache directly. The roles/policies module uses `@jini-ai/ui-kit` and its React facades;
28
+ see [roles administration wiring and cleanup](./src/admin/PORT.md).
29
+ Member timestamps use `formatTimestamp({ iso })` from `@jini-ai/ui/panel-kit`.
30
+ Supply `port`, `translate` and a session/workspace `queryScope`.
31
+ Login requires `productName`. Members optionally accepts a host-filtered refresh port.
32
+ Screen ports use object IDs and separate optional fields. The fake roles port
33
+ retains a policy's name when an update omits it or supplies `undefined`.
34
+ Remount screens when switching sessions/workspaces. The host supplies styles and dictionaries; see
35
+ [React integration](./REACT-w7a.md). No HTTP transport or router is chosen here.
36
+
37
+ User-management registration composition is exported by this package's server entry; persistence,
38
+ HTTP routes/cookies and complete end-user member authentication are host/follow-up
39
+ boundaries. Members backend extraction remains deferred for mail/origin/token
40
+ transaction semantics, rather than shared-file ownership.
41
+
42
+ The earlier extraction/conversion reports are historical. This integration
43
+ applies the identity manifest/changelog/barrel requests and reconciles internal
44
+ calls. [Integration report](./integration-report.md) contains the current file map,
45
+ caller ledger, remaining cross-package requests and every NOT RUN command.
46
+ Tests, typechecks, builds and packing were **not run (owner directive)**.
47
+
48
+ ## Historical Stage A record
49
+
50
+ The original text below records the initial headless extraction before the React
51
+ and argument-convention jobs; its release-scope/signature statements are historical.
52
+
53
+ # @jini-ai/user-management
54
+
55
+ Framework-independent operator identity, with separate universal and Node entry points.
56
+
57
+ - `@jini-ai/user-management`: records, errors, repository and runtime ports, permission catalog.
58
+ - `@jini-ai/user-management/server`: login/logout/session validation, authorization, grants, operator administration, password policy and hashing, in-memory repositories, seeding, permission migrations, and framework-free tool descriptions/input parsing.
59
+
60
+ Version 0.1.0; Apache-2.0. There is no React entry point in this release.
61
+
62
+ ```ts
63
+ import type { IdentityRepos } from '@jini-ai/user-management';
64
+ import type { Clock, IdGenerator } from '@jini-ai/core/primitives';
65
+ import { login, Argon2PasswordHasher } from '@jini-ai/user-management/server';
66
+ ```
67
+
68
+ Hosts supply workspace IDs, repositories, a clock, an ID generator, and a password hasher. Hosts share core `Clock.nowMs()` and `IdGenerator.newId()` contracts. No CMS dependency or host persistence adapter is included.
69
+
70
+ The optional `argon2@^0.44.0` peer is needed only when using `Argon2PasswordHasher`. Its native binding loads on first hashing/verification call; importing the server entry with a host-provided hasher does not require it. Passwords, Argon2id costs, session TTLs, token hashing, authorization rules, grant clamps, and seeded permissions retain their source behavior.
71
+
72
+ The built-in permission catalog and migration registry initialize from explicit arrays. They require no side-effect-only imports, so `sideEffects: false` is safe. Permission descriptors and migration pairs are retained, including deprecated vocabulary. Hosts should register extensions before starting services; permission registries remain process-wide as in the source implementation.
73
+
74
+ ## Stage A specification and decision
75
+
76
+ The owner-approved 2026-10-01 x5 dispatch is the specification: create an additive 0.1.0 package, preserve the current source and tests, split runtime entries, prohibit imports from CMS/admin/MCP/UI or application code, and leave source deletion and consumer rewiring to stage B. The implementation is a ports/adapters extraction; the current CMS domain code remains operational throughout stage A.
77
+
78
+ Decision: copy framework-independent behavior and pure tool metadata, define local structural clock/ID ports and string primitives, keep registration machinery in its current package, and represent built-in registrations as data to keep the universal import graph independent of Node services. Alternative: import CMS's shared ports or registration kit. Rejected because it creates a package back-edge and defeats identity's ownership. Rollback: discard this additive package; no existing consumer is changed.
79
+
80
+ Members are deferred as a complete backend extraction, not partially implemented here. The migration report specifies the mail/origin/transaction boundaries and required contract tests. Storage, HTTP cookies/routes, registration machinery, and UI composition remain host responsibilities.
81
+
82
+ See [stage-B checklist and source map](./stage-b-report.md) and [validation evidence](./validation.md). Build with `tsc -p tsconfig.json`; test with `vitest run` from this directory.
83
+
84
+ ## Design decisions
85
+
86
+ - [Identity, authorization and sessions fail closed](docs/decisions/DR-001-identity-and-session-boundary.md).
87
+ - [Administration cannot grant authority the issuer lacks](docs/decisions/DR-002-grant-authority-and-admin-safety.md).
88
+ - [Permission renames add grants before retiring vocabulary](docs/decisions/DR-003-additive-permission-migration.md).
89
+
90
+ ## Registration and session policy
91
+
92
+ `buildIdentityRegistrations`, `identityDerivedRisk` and `IdentityToolDeps` are exported by
93
+ `@jini-ai/user-management/server`. Hosts provide `IdentityToolDeps.transactions` and session
94
+ token generation/hash ports alongside repositories. `IdentityRepos.transactions` is required;
95
+ all competing grant/status writers and guard reads must share its isolation boundary.
96
+ The memory transaction factory accepts an unbound repository bag and returns a fully bound bag.
97
+
98
+ `createSessionForPrincipal({ deps, input }, { sessionTtlMs, ip, userAgent, messages })` and
99
+ `login({ deps, input }, { sessionTtlMs, ip, userAgent, messages })` default to an absolute 30-day
100
+ lifetime. Nonpositive or nonfinite lifetimes raise `RangeError` before persistence. Hosts may
101
+ replace authentication prose through `defaultUserManagementMessages` and the `messages` option.
102
+ Session `workspaceId` remains required: session and principal repositories address records by
103
+ composite tenant/record keys and session validation must not cross tenant boundaries. It is an
104
+ opaque host scope in meaning, but renaming or making it optional would violate that store contract.
@@ -0,0 +1,29 @@
1
+ import type { RolesApiPort, RolesHttpTransport } from '../ports.js';
2
+ /** Host transport owns cookies/authentication, API prefix, typed errors and server authorization.
3
+ * These resource routes intentionally retain their response envelopes and workspace scope. */
4
+ export declare function createHttpRolesApi({ transport, workspaceId }: {
5
+ transport: RolesHttpTransport;
6
+ workspaceId: string;
7
+ }, { basePath }?: {
8
+ basePath?: string;
9
+ }): RolesApiPort;
10
+ /** All HTTP adapters use the same public host transport. No fetch global or auth policy leaks in. */
11
+ export declare function createHttpUsersApi({ transport, workspaceId }: {
12
+ transport: RolesHttpTransport;
13
+ workspaceId: string;
14
+ }, { basePath, authPath }?: {
15
+ basePath?: string;
16
+ authPath?: string;
17
+ }): import('../ports.js').UsersApiPort;
18
+ export declare function createHttpMembersApi({ transport, workspaceId }: {
19
+ transport: RolesHttpTransport;
20
+ workspaceId: string;
21
+ }, { basePath }?: {
22
+ basePath?: string;
23
+ }): import('../ports.js').MembersApiPort;
24
+ export declare function createHttpAuthApi({ transport }: {
25
+ transport: RolesHttpTransport;
26
+ }, { authPath }?: {
27
+ authPath?: string;
28
+ }): import('../ports.js').AuthApiPort;
29
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1,69 @@
1
+ /** Host transport owns cookies/authentication, API prefix, typed errors and server authorization.
2
+ * These resource routes intentionally retain their response envelopes and workspace scope. */
3
+ export function createHttpRolesApi({ transport, workspaceId }, { basePath = '/workspaces' } = {}) {
4
+ const root = `${basePath.replace(/\/$/, '')}/${encodeURIComponent(workspaceId)}`;
5
+ const role = (id) => `${root}/roles/${encodeURIComponent(id)}`;
6
+ const policy = (id) => `${root}/policies/${encodeURIComponent(id)}`;
7
+ const request = async (path, method, o, body) => {
8
+ o.signal?.throwIfAborted();
9
+ return transport.request({ path, method, ...(body ? { body } : {}) }, o.signal ? { signal: o.signal } : {});
10
+ };
11
+ return {
12
+ listRoles: (_r, o = {}) => request(`${root}/roles`, 'GET', o),
13
+ listPolicies: (_r, o = {}) => request(`${root}/policies`, 'GET', o),
14
+ createRole: (r, o = {}) => request(`${root}/roles`, 'POST', o, { name: r.name }),
15
+ updateRole: (r, o = {}) => request(role(r.roleId), 'PATCH', o, { name: r.name }),
16
+ deleteRole: (r, o = {}) => request(role(r.roleId), 'DELETE', o),
17
+ createPolicy: (r, o = {}) => request(`${root}/policies`, 'POST', o, { name: r.name, ...(o.description !== undefined ? { description: o.description } : {}) }),
18
+ updatePolicy: (r, o = {}) => request(policy(r.policyId), 'PATCH', o, { ...(o.name !== undefined ? { name: o.name } : {}), ...(o.description !== undefined ? { description: o.description } : {}) }),
19
+ deletePolicy: (r, o = {}) => request(policy(r.policyId), 'DELETE', o),
20
+ listPolicyPermissions: (r, o = {}) => request(`${policy(r.policyId)}/permissions`, 'GET', o),
21
+ writePolicyPermission: (r, o = {}) => request(`${policy(r.policyId)}/permissions`, 'POST', o, { permission: r.permission, ...(o.resourceType ? { resourceType: o.resourceType } : {}) }),
22
+ removePolicyPermission: (r, o = {}) => request(`${policy(r.policyId)}/permissions/${encodeURIComponent(r.policyPermissionId)}`, 'DELETE', o),
23
+ };
24
+ }
25
+ /** All HTTP adapters use the same public host transport. No fetch global or auth policy leaks in. */
26
+ export function createHttpUsersApi({ transport, workspaceId }, { basePath = '/workspaces', authPath = '/auth' } = {}) {
27
+ const root = `${basePath.replace(/\/$/, '')}/${encodeURIComponent(workspaceId)}`;
28
+ const user = (id) => `${root}/users/${encodeURIComponent(id)}`;
29
+ const request = async (path, method, o, body) => {
30
+ o.signal?.throwIfAborted();
31
+ return transport.request({ path, method, ...(body ? { body } : {}) }, o.signal ? { signal: o.signal } : {});
32
+ };
33
+ return {
34
+ listUsers: (_r, o = {}) => request(`${root}/users`, 'GET', o),
35
+ listRoles: (_r, o = {}) => request(`${root}/roles`, 'GET', o),
36
+ listPolicies: (_r, o = {}) => request(`${root}/policies`, 'GET', o),
37
+ me: (_r, o = {}) => request(`${authPath.replace(/\/$/, '')}/me`, 'GET', o),
38
+ createUser: (r, o = {}) => request(`${root}/users`, 'POST', o, { ...r, ...(o.email !== undefined ? { email: o.email } : {}) }),
39
+ updateUser: (r, o = {}) => request(user(r.principalId), 'PATCH', o, { ...(o.email !== undefined ? { email: o.email } : {}) }),
40
+ disableUser: (r, o = {}) => request(`${user(r.principalId)}/disable`, 'POST', o),
41
+ enableUser: (r, o = {}) => request(`${user(r.principalId)}/enable`, 'POST', o),
42
+ resetUserPassword: (r, o = {}) => request(`${user(r.principalId)}/reset-password`, 'POST', o, { password: r.password }),
43
+ assignRole: (r, o = {}) => request(`${user(r.principalId)}/roles`, 'POST', o, { roleId: r.roleId }),
44
+ attachPolicy: (r, o = {}) => request(`${user(r.principalId)}/policies`, 'POST', o, { policyId: r.policyId }),
45
+ deleteUser: (r, o = {}) => request(user(r.principalId), 'DELETE', o),
46
+ };
47
+ }
48
+ export function createHttpMembersApi({ transport, workspaceId }, { basePath = '/workspaces' } = {}) {
49
+ const root = `${basePath.replace(/\/$/, '')}/${encodeURIComponent(workspaceId)}/members`;
50
+ const request = async (path, method, o, body) => {
51
+ o.signal?.throwIfAborted();
52
+ return transport.request({ path, method, ...(body ? { body } : {}) }, o.signal ? { signal: o.signal } : {});
53
+ };
54
+ return {
55
+ listMembers: (_r, o = {}) => { const query = new URLSearchParams(); if (o.afterId !== undefined)
56
+ query.set('afterId', o.afterId); if (o.limit !== undefined)
57
+ query.set('limit', String(o.limit)); return request(`${root}${query.size ? `?${query}` : ''}`, 'GET', o); },
58
+ getMember: (r, o = {}) => request(`${root}/${encodeURIComponent(r.id)}`, 'GET', o),
59
+ disableMember: (r, o = {}) => request(`${root}/${encodeURIComponent(r.id)}/disable`, 'POST', o),
60
+ requestMemberMagicLink: (r, o = {}) => request(`${root}/request-magic-link`, 'POST', o, { email: r.email, ...(o.redirectPath !== undefined ? { redirectPath: o.redirectPath } : {}) }),
61
+ };
62
+ }
63
+ export function createHttpAuthApi({ transport }, { authPath = '/auth' } = {}) {
64
+ return { login: async (r, o = {}) => {
65
+ o.signal?.throwIfAborted();
66
+ return transport.request({ path: `${authPath.replace(/\/$/, '')}/login`, method: 'POST', body: { username: r.username, password: r.password } }, o.signal ? { signal: o.signal } : {});
67
+ } };
68
+ }
69
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1,61 @@
1
+ import type { RolesApiPort } from '../ports.js';
2
+ import type { RoleRecord, PolicyRecord, PolicyPermissionRecord } from '../models.js';
3
+ export interface MemoryRolesOptions {
4
+ readonly permissions?: readonly string[];
5
+ readonly catalog?: readonly string[];
6
+ readonly roles?: readonly RoleRecord[];
7
+ readonly policies?: readonly PolicyRecord[];
8
+ readonly policyPermissions?: readonly PolicyPermissionRecord[];
9
+ /** Test host reference data: memory intentionally does not implement user assignment. */
10
+ readonly referencedRoleIds?: readonly string[];
11
+ readonly referencedPolicyIds?: readonly string[];
12
+ }
13
+ /** Isolated fake of the server wire contract, including immutable and issuer guards.
14
+ * It is not a production authorizer or a persistent identity repository. */
15
+ export declare function createMemoryRolesApi({ workspaceId }: {
16
+ workspaceId: string;
17
+ }, options?: MemoryRolesOptions): RolesApiPort;
18
+ import type { UsersApiPort, UsersSafetyPort, MembersApiPort, AuthApiPort } from '../ports.js';
19
+ import type { AdminOperator, AdminMember, CallerInfo } from '../models.js';
20
+ /** Complete fake ownership data. Production hosts must resolve effective unconstrained wildcard
21
+ * grants, never role display names. Unknown ids deliberately fail closed. */
22
+ export declare function createMemoryUsersSafety({ principalIds, ownerPrincipalIds, seededOwnerPrincipalId }: {
23
+ principalIds: readonly string[];
24
+ ownerPrincipalIds: readonly string[];
25
+ seededOwnerPrincipalId: string | null;
26
+ }, _optional?: Record<string, never>): UsersSafetyPort;
27
+ export interface MemoryUsersOptions {
28
+ readonly permissions?: readonly string[];
29
+ readonly users?: readonly AdminOperator[];
30
+ readonly roles?: readonly RoleRecord[];
31
+ readonly policies?: readonly PolicyRecord[];
32
+ readonly caller?: CallerInfo;
33
+ readonly ownerPrincipalIds?: readonly string[];
34
+ readonly seededOwnerPrincipalId?: string;
35
+ /** Grant contents for issuer-clamp tests; unknown content fails closed for non-owners. */
36
+ readonly rolePermissions?: Readonly<Record<string, readonly string[]>>;
37
+ readonly policyPermissions?: Readonly<Record<string, readonly string[]>>;
38
+ readonly onPasswordReset?: (required: {
39
+ principalId: string;
40
+ password: string;
41
+ }, optional?: Record<string, never>) => void;
42
+ }
43
+ /** Fake wire backend only: no persistent password storage, real sessions, audit or Trash service. */
44
+ export declare function createMemoryUsersApi({ workspaceId }: {
45
+ workspaceId: string;
46
+ }, options?: MemoryUsersOptions): UsersApiPort;
47
+ export declare function createMemoryMembersApi({ workspaceId }: {
48
+ workspaceId: string;
49
+ }, { members, permissions }?: {
50
+ members?: readonly AdminMember[];
51
+ permissions?: readonly string[];
52
+ }): MembersApiPort;
53
+ /** Deterministic credential fake; production hashing/session policy stays in the server entry. */
54
+ export declare function createMemoryAuthApi({ accounts }: {
55
+ accounts: readonly {
56
+ user: import('../models.js').AdminAccount;
57
+ password: string;
58
+ disabled?: boolean;
59
+ }[];
60
+ }, _optional?: Record<string, never>): AuthApiPort;
61
+ //# sourceMappingURL=memory.d.ts.map