@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.
- package/CHANGELOG.md +77 -0
- package/LICENSE +201 -0
- package/README.md +104 -0
- package/dist/admin/adapters/http.d.ts +29 -0
- package/dist/admin/adapters/http.js +69 -0
- package/dist/admin/adapters/memory.d.ts +61 -0
- package/dist/admin/adapters/memory.js +217 -0
- package/dist/admin/auth.module.d.ts +30 -0
- package/dist/admin/auth.module.js +12 -0
- package/dist/admin/conformance/index.d.ts +56 -0
- package/dist/admin/conformance/index.js +156 -0
- package/dist/admin/controllers/auth.controller.d.ts +23 -0
- package/dist/admin/controllers/auth.controller.js +33 -0
- package/dist/admin/controllers/controller-store.d.ts +18 -0
- package/dist/admin/controllers/controller-store.js +23 -0
- package/dist/admin/controllers/members.controller.d.ts +33 -0
- package/dist/admin/controllers/members.controller.js +119 -0
- package/dist/admin/controllers/roles.controller.d.ts +47 -0
- package/dist/admin/controllers/roles.controller.js +282 -0
- package/dist/admin/controllers/users.controller.d.ts +53 -0
- package/dist/admin/controllers/users.controller.js +220 -0
- package/dist/admin/index.d.ts +21 -0
- package/dist/admin/index.js +15 -0
- package/dist/admin/members.module.d.ts +34 -0
- package/dist/admin/members.module.js +13 -0
- package/dist/admin/messages.en.d.ts +37 -0
- package/dist/admin/messages.en.js +21 -0
- package/dist/admin/models.d.ts +133 -0
- package/dist/admin/models.js +2 -0
- package/dist/admin/people.rules.d.ts +29 -0
- package/dist/admin/people.rules.js +51 -0
- package/dist/admin/ports.d.ts +187 -0
- package/dist/admin/ports.js +17 -0
- package/dist/admin/react/components/DestructiveDialog.d.ts +5 -0
- package/dist/admin/react/components/DestructiveDialog.js +6 -0
- package/dist/admin/react/components/MemberRow.d.ts +5 -0
- package/dist/admin/react/components/MemberRow.js +8 -0
- package/dist/admin/react/components/MembersConfirmation.d.ts +2 -0
- package/dist/admin/react/components/MembersConfirmation.js +8 -0
- package/dist/admin/react/components/PermissionPanel.d.ts +5 -0
- package/dist/admin/react/components/PermissionPanel.js +9 -0
- package/dist/admin/react/components/PolicyRow.d.ts +5 -0
- package/dist/admin/react/components/PolicyRow.js +11 -0
- package/dist/admin/react/components/RoleRow.d.ts +5 -0
- package/dist/admin/react/components/RoleRow.js +10 -0
- package/dist/admin/react/components/UserRow.d.ts +5 -0
- package/dist/admin/react/components/UserRow.js +8 -0
- package/dist/admin/react/components/UsersConfirmation.d.ts +3 -0
- package/dist/admin/react/components/UsersConfirmation.js +9 -0
- package/dist/admin/react/hooks/AuthBinding.hooks.d.ts +39 -0
- package/dist/admin/react/hooks/AuthBinding.hooks.js +21 -0
- package/dist/admin/react/hooks/LoginPage.hooks.d.ts +54 -0
- package/dist/admin/react/hooks/LoginPage.hooks.js +23 -0
- package/dist/admin/react/hooks/MembersBinding.hooks.d.ts +35 -0
- package/dist/admin/react/hooks/MembersBinding.hooks.js +21 -0
- package/dist/admin/react/hooks/MembersPage.hooks.d.ts +99 -0
- package/dist/admin/react/hooks/MembersPage.hooks.js +38 -0
- package/dist/admin/react/hooks/PeopleController.hooks.d.ts +18 -0
- package/dist/admin/react/hooks/PeopleController.hooks.js +20 -0
- package/dist/admin/react/hooks/PermissionPanel.hooks.d.ts +30 -0
- package/dist/admin/react/hooks/PermissionPanel.hooks.js +15 -0
- package/dist/admin/react/hooks/PoliciesTab.hooks.d.ts +47 -0
- package/dist/admin/react/hooks/PoliciesTab.hooks.js +26 -0
- package/dist/admin/react/hooks/RolesBinding.hooks.d.ts +39 -0
- package/dist/admin/react/hooks/RolesBinding.hooks.js +23 -0
- package/dist/admin/react/hooks/RolesController.hooks.d.ts +43 -0
- package/dist/admin/react/hooks/RolesController.hooks.js +25 -0
- package/dist/admin/react/hooks/RolesPage.hooks.d.ts +105 -0
- package/dist/admin/react/hooks/RolesPage.hooks.js +33 -0
- package/dist/admin/react/hooks/RolesTab.hooks.d.ts +35 -0
- package/dist/admin/react/hooks/RolesTab.hooks.js +19 -0
- package/dist/admin/react/hooks/UsersBinding.hooks.d.ts +36 -0
- package/dist/admin/react/hooks/UsersBinding.hooks.js +21 -0
- package/dist/admin/react/hooks/UsersPage.hooks.d.ts +106 -0
- package/dist/admin/react/hooks/UsersPage.hooks.js +22 -0
- package/dist/admin/react/hooks/UsersTab.hooks.d.ts +101 -0
- package/dist/admin/react/hooks/UsersTab.hooks.js +53 -0
- package/dist/admin/react/index.d.ts +203 -0
- package/dist/admin/react/index.js +32 -0
- package/dist/admin/react/pages/LoginPage.d.ts +3 -0
- package/dist/admin/react/pages/LoginPage.js +13 -0
- package/dist/admin/react/pages/MembersPage.d.ts +3 -0
- package/dist/admin/react/pages/MembersPage.js +19 -0
- package/dist/admin/react/pages/RolesPage.d.ts +3 -0
- package/dist/admin/react/pages/RolesPage.js +19 -0
- package/dist/admin/react/pages/UsersPage.d.ts +3 -0
- package/dist/admin/react/pages/UsersPage.js +19 -0
- package/dist/admin/react/tabs/AuthTab.d.ts +4 -0
- package/dist/admin/react/tabs/AuthTab.js +8 -0
- package/dist/admin/react/tabs/MembersTab.d.ts +4 -0
- package/dist/admin/react/tabs/MembersTab.js +9 -0
- package/dist/admin/react/tabs/PoliciesTab.d.ts +4 -0
- package/dist/admin/react/tabs/PoliciesTab.js +9 -0
- package/dist/admin/react/tabs/RolesTab.d.ts +4 -0
- package/dist/admin/react/tabs/RolesTab.js +9 -0
- package/dist/admin/react/tabs/UsersTab.d.ts +4 -0
- package/dist/admin/react/tabs/UsersTab.js +9 -0
- package/dist/admin/roles.module.d.ts +48 -0
- package/dist/admin/roles.module.js +15 -0
- package/dist/admin/rules.d.ts +32 -0
- package/dist/admin/rules.js +32 -0
- package/dist/admin/users.module.d.ts +39 -0
- package/dist/admin/users.module.js +14 -0
- package/dist/core/builtin-permissions.d.ts +10 -0
- package/dist/core/builtin-permissions.js +402 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +9 -0
- package/dist/core/permissions.d.ts +40 -0
- package/dist/core/permissions.js +52 -0
- package/dist/core/ports.d.ts +237 -0
- package/dist/core/ports.js +2 -0
- package/dist/core/runtime-ports.d.ts +8 -0
- package/dist/core/runtime-ports.js +2 -0
- package/dist/core/types.d.ts +224 -0
- package/dist/core/types.js +93 -0
- package/dist/react/auth/Login.d.ts +9 -0
- package/dist/react/auth/Login.js +8 -0
- package/dist/react/auth/hooks/use-login.hooks.d.ts +22 -0
- package/dist/react/auth/hooks/use-login.hooks.js +24 -0
- package/dist/react/errors.d.ts +10 -0
- package/dist/react/errors.js +13 -0
- package/dist/react/index.d.ts +18 -0
- package/dist/react/index.js +9 -0
- package/dist/react/members/Members.d.ts +6 -0
- package/dist/react/members/Members.js +38 -0
- package/dist/react/members/hooks/use-members.hooks.d.ts +32 -0
- package/dist/react/members/hooks/use-members.hooks.js +120 -0
- package/dist/react/members/rules.d.ts +26 -0
- package/dist/react/members/rules.js +35 -0
- package/dist/react/models.d.ts +50 -0
- package/dist/react/models.js +2 -0
- package/dist/react/ports.d.ts +157 -0
- package/dist/react/ports.js +2 -0
- package/dist/react/roles/Roles.d.ts +100 -0
- package/dist/react/roles/Roles.hooks.d.ts +17 -0
- package/dist/react/roles/Roles.hooks.js +40 -0
- package/dist/react/roles/Roles.js +150 -0
- package/dist/react/roles/hooks/use-roles.hooks.d.ts +80 -0
- package/dist/react/roles/hooks/use-roles.hooks.js +303 -0
- package/dist/react/roles/rules.d.ts +35 -0
- package/dist/react/roles/rules.js +31 -0
- package/dist/react/roles/text.d.ts +27 -0
- package/dist/react/roles/text.js +13 -0
- package/dist/react/testing.d.ts +51 -0
- package/dist/react/testing.js +275 -0
- package/dist/react/users/Users.d.ts +72 -0
- package/dist/react/users/Users.js +129 -0
- package/dist/react/users/hooks/use-reset-password-fields.hooks.d.ts +16 -0
- package/dist/react/users/hooks/use-reset-password-fields.hooks.js +21 -0
- package/dist/react/users/hooks/use-users.hooks.d.ts +77 -0
- package/dist/react/users/hooks/use-users.hooks.js +286 -0
- package/dist/react/users/rules.d.ts +33 -0
- package/dist/react/users/rules.js +61 -0
- package/dist/server/admin-crud-service.d.ts +295 -0
- package/dist/server/admin-crud-service.js +561 -0
- package/dist/server/agent-tool-input.d.ts +58 -0
- package/dist/server/agent-tool-input.js +158 -0
- package/dist/server/agent-tool-registrations.d.ts +51 -0
- package/dist/server/agent-tool-registrations.js +417 -0
- package/dist/server/agent-tools.d.ts +88 -0
- package/dist/server/agent-tools.js +229 -0
- package/dist/server/auth-service.d.ts +107 -0
- package/dist/server/auth-service.js +170 -0
- package/dist/server/authorize.d.ts +92 -0
- package/dist/server/authorize.js +96 -0
- package/dist/server/grant-service.d.ts +219 -0
- package/dist/server/grant-service.js +419 -0
- package/dist/server/hasher.d.ts +64 -0
- package/dist/server/hasher.js +53 -0
- package/dist/server/identity-transaction.d.ts +9 -0
- package/dist/server/identity-transaction.js +8 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.js +20 -0
- package/dist/server/messages.d.ts +7 -0
- package/dist/server/messages.js +5 -0
- package/dist/server/password-policy.d.ts +59 -0
- package/dist/server/password-policy.js +66 -0
- package/dist/server/permission-migrations.d.ts +84 -0
- package/dist/server/permission-migrations.js +77 -0
- package/dist/server/repo.memory-transactions.d.ts +16 -0
- package/dist/server/repo.memory-transactions.js +79 -0
- package/dist/server/repo.memory.d.ts +186 -0
- package/dist/server/repo.memory.js +230 -0
- package/dist/server/seed.d.ts +56 -0
- package/dist/server/seed.js +435 -0
- package/dist/server/session-tokens.d.ts +10 -0
- package/dist/server/session-tokens.js +12 -0
- package/dist/server/username.d.ts +14 -0
- package/dist/server/username.js +14 -0
- package/package.json +144 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file In-memory adapters for the `user-management` repo ports.
|
|
3
|
+
*
|
|
4
|
+
* Purpose:
|
|
5
|
+
* Test/dev implementations of the nine identity repo ports. Mirrors the exact
|
|
6
|
+
* style of `src/features/post/repo.memory.ts` / `src/members/repo.memory.ts`:
|
|
7
|
+
* constructor takes seed rows, methods filter/mutate an internal array. No
|
|
8
|
+
* business rules live here — that belongs to `authorize.ts`/`auth-service.ts`/
|
|
9
|
+
* `seed.ts`.
|
|
10
|
+
*
|
|
11
|
+
* Architectural role:
|
|
12
|
+
* The only adapter this pass — a SQLite adapter is a later step (see
|
|
13
|
+
* `ports.ts` header and `server/deps.ts` comments), matching the disclosed
|
|
14
|
+
* precedent of members/navigation/integrations/analytics.
|
|
15
|
+
*/
|
|
16
|
+
/** Snapshot seam used only by the memory transaction adapter; no business rules live here. */
|
|
17
|
+
export class InMemoryIdentityRows {
|
|
18
|
+
rows;
|
|
19
|
+
constructor(required, optional = {}) {
|
|
20
|
+
this.rows = [...(optional.initialRows ?? [])];
|
|
21
|
+
}
|
|
22
|
+
/** Detached state so rollback also restores in-place changes such as session revocation. */
|
|
23
|
+
snapshotRows(required) {
|
|
24
|
+
return structuredClone(this.rows);
|
|
25
|
+
}
|
|
26
|
+
/** Restore a detached snapshot after the transaction rejects. */
|
|
27
|
+
restoreRows(required) {
|
|
28
|
+
this.rows = required.rows;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class InMemoryPrincipalRepo extends InMemoryIdentityRows {
|
|
32
|
+
constructor(_required, { initialRows = [] } = {}) {
|
|
33
|
+
super(_required, { initialRows });
|
|
34
|
+
}
|
|
35
|
+
async findById(required) {
|
|
36
|
+
return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.id === required.id) ?? null);
|
|
37
|
+
}
|
|
38
|
+
async list(required) {
|
|
39
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId);
|
|
40
|
+
}
|
|
41
|
+
async save(record) {
|
|
42
|
+
const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
|
|
43
|
+
if (index === -1) {
|
|
44
|
+
this.rows.push(record);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this.rows[index] = record;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class InMemoryUserRepo extends InMemoryIdentityRows {
|
|
51
|
+
constructor(_required, { initialRows = [] } = {}) {
|
|
52
|
+
super(_required, { initialRows });
|
|
53
|
+
}
|
|
54
|
+
async findByPrincipalId(required) {
|
|
55
|
+
return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.principalId === required.principalId) ?? null);
|
|
56
|
+
}
|
|
57
|
+
async findByUsername(required) {
|
|
58
|
+
return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.username === required.username) ?? null);
|
|
59
|
+
}
|
|
60
|
+
async list(required) {
|
|
61
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId);
|
|
62
|
+
}
|
|
63
|
+
async save(record) {
|
|
64
|
+
const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.principalId === record.principalId);
|
|
65
|
+
if (index === -1) {
|
|
66
|
+
this.rows.push(record);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.rows[index] = record;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export class InMemorySessionRepo extends InMemoryIdentityRows {
|
|
73
|
+
constructor(_required, { initialRows = [] } = {}) {
|
|
74
|
+
super(_required, { initialRows });
|
|
75
|
+
}
|
|
76
|
+
async findById(required) {
|
|
77
|
+
return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.id === required.id) ?? null);
|
|
78
|
+
}
|
|
79
|
+
async findByTokenHash(required) {
|
|
80
|
+
return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.tokenHash === required.tokenHash) ?? null);
|
|
81
|
+
}
|
|
82
|
+
async save(record) {
|
|
83
|
+
const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
|
|
84
|
+
if (index === -1) {
|
|
85
|
+
this.rows.push(record);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.rows[index] = record;
|
|
89
|
+
}
|
|
90
|
+
async revoke(required) {
|
|
91
|
+
const row = this.rows.find((candidate) => candidate.workspaceId === required.workspaceId && candidate.id === required.id);
|
|
92
|
+
if (row)
|
|
93
|
+
row.revokedAt = required.revokedAt;
|
|
94
|
+
}
|
|
95
|
+
async listByPrincipalId(required) {
|
|
96
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.principalId === required.principalId);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export class InMemoryRoleRepo extends InMemoryIdentityRows {
|
|
100
|
+
constructor(_required, { initialRows = [] } = {}) {
|
|
101
|
+
super(_required, { initialRows });
|
|
102
|
+
}
|
|
103
|
+
async findById(required) {
|
|
104
|
+
return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.id === required.id) ?? null);
|
|
105
|
+
}
|
|
106
|
+
async findByName(required) {
|
|
107
|
+
return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.name === required.name) ??
|
|
108
|
+
null);
|
|
109
|
+
}
|
|
110
|
+
async list(required) {
|
|
111
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId);
|
|
112
|
+
}
|
|
113
|
+
async save(record) {
|
|
114
|
+
const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
|
|
115
|
+
if (index === -1) {
|
|
116
|
+
this.rows.push(record);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.rows[index] = record;
|
|
120
|
+
}
|
|
121
|
+
async delete(required) {
|
|
122
|
+
this.rows = this.rows.filter((row) => !(row.workspaceId === required.workspaceId && row.id === required.id));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export class InMemoryPolicyRepo extends InMemoryIdentityRows {
|
|
126
|
+
constructor(_required, { initialRows = [] } = {}) {
|
|
127
|
+
super(_required, { initialRows });
|
|
128
|
+
}
|
|
129
|
+
async findById(required) {
|
|
130
|
+
return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.id === required.id) ?? null);
|
|
131
|
+
}
|
|
132
|
+
async findByName(required) {
|
|
133
|
+
return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.name === required.name) ??
|
|
134
|
+
null);
|
|
135
|
+
}
|
|
136
|
+
async list(required) {
|
|
137
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId);
|
|
138
|
+
}
|
|
139
|
+
async save(record) {
|
|
140
|
+
const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
|
|
141
|
+
if (index === -1) {
|
|
142
|
+
this.rows.push(record);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.rows[index] = record;
|
|
146
|
+
}
|
|
147
|
+
async delete(required) {
|
|
148
|
+
this.rows = this.rows.filter((row) => !(row.workspaceId === required.workspaceId && row.id === required.id));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export class InMemoryPolicyPermissionRepo extends InMemoryIdentityRows {
|
|
152
|
+
constructor(_required, { initialRows = [] } = {}) {
|
|
153
|
+
super(_required, { initialRows });
|
|
154
|
+
}
|
|
155
|
+
async listByPolicyId(required) {
|
|
156
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.policyId === required.policyId);
|
|
157
|
+
}
|
|
158
|
+
async save(record) {
|
|
159
|
+
const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
|
|
160
|
+
if (index === -1) {
|
|
161
|
+
this.rows.push(record);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.rows[index] = record;
|
|
165
|
+
}
|
|
166
|
+
async deleteByPolicyId(required) {
|
|
167
|
+
this.rows = this.rows.filter((row) => !(row.workspaceId === required.workspaceId && row.policyId === required.policyId));
|
|
168
|
+
}
|
|
169
|
+
async delete(required) {
|
|
170
|
+
this.rows = this.rows.filter((row) => !(row.workspaceId === required.workspaceId && row.id === required.id));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
export class InMemoryRolePolicyRepo extends InMemoryIdentityRows {
|
|
174
|
+
constructor(_required, { initialRows = [] } = {}) {
|
|
175
|
+
super(_required, { initialRows });
|
|
176
|
+
}
|
|
177
|
+
async listByRoleId(required) {
|
|
178
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.roleId === required.roleId);
|
|
179
|
+
}
|
|
180
|
+
async listByPolicyId(required) {
|
|
181
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.policyId === required.policyId);
|
|
182
|
+
}
|
|
183
|
+
async save(record) {
|
|
184
|
+
const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
|
|
185
|
+
if (index === -1) {
|
|
186
|
+
this.rows.push(record);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this.rows[index] = record;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
export class InMemoryPrincipalRoleRepo extends InMemoryIdentityRows {
|
|
193
|
+
constructor(_required, { initialRows = [] } = {}) {
|
|
194
|
+
super(_required, { initialRows });
|
|
195
|
+
}
|
|
196
|
+
async listByPrincipalId(required) {
|
|
197
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.principalId === required.principalId);
|
|
198
|
+
}
|
|
199
|
+
async listByRoleId(required) {
|
|
200
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.roleId === required.roleId);
|
|
201
|
+
}
|
|
202
|
+
async save(record) {
|
|
203
|
+
const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
|
|
204
|
+
if (index === -1) {
|
|
205
|
+
this.rows.push(record);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
this.rows[index] = record;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
export class InMemoryPrincipalPolicyRepo extends InMemoryIdentityRows {
|
|
212
|
+
constructor(_required, { initialRows = [] } = {}) {
|
|
213
|
+
super(_required, { initialRows });
|
|
214
|
+
}
|
|
215
|
+
async listByPrincipalId(required) {
|
|
216
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.principalId === required.principalId);
|
|
217
|
+
}
|
|
218
|
+
async listByPolicyId(required) {
|
|
219
|
+
return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.policyId === required.policyId);
|
|
220
|
+
}
|
|
221
|
+
async save(record) {
|
|
222
|
+
const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
|
|
223
|
+
if (index === -1) {
|
|
224
|
+
this.rows.push(record);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
this.rows[index] = record;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=repo.memory.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Clock, IdGenerator, UUID } from "@jini-ai/core/primitives";
|
|
2
|
+
import type { IdentityRepos, PasswordHasherPort } from "../core/ports.js";
|
|
3
|
+
export interface SeedIdentityDeps {
|
|
4
|
+
repos: IdentityRepos;
|
|
5
|
+
hasher: PasswordHasherPort;
|
|
6
|
+
clock: Clock;
|
|
7
|
+
idGen: IdGenerator;
|
|
8
|
+
}
|
|
9
|
+
export interface SeedIdentityInput {
|
|
10
|
+
workspaceId: UUID;
|
|
11
|
+
/** The host explicitly chooses the first operator username. */
|
|
12
|
+
ownerUsername: string;
|
|
13
|
+
/**
|
|
14
|
+
* Required, and deliberately without a default.
|
|
15
|
+
*
|
|
16
|
+
* This function mints the first credential that can administer a workspace. A library-supplied
|
|
17
|
+
* fallback would mean every host that forgot to pass one shipped the *same* owner password, and
|
|
18
|
+
* the omission would look like working code rather than a misconfiguration. Where the value comes
|
|
19
|
+
* from — an environment variable, an operator prompt, a secret store, a generated string — is a
|
|
20
|
+
* decision only the host can make, because only the host knows its deployment model. Making this
|
|
21
|
+
* required turns "forgot to decide" into a compile error instead of a shared default credential.
|
|
22
|
+
*/
|
|
23
|
+
ownerPassword: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SeedIdentityOptions {
|
|
26
|
+
ownerEmail?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface SeedIdentityResult {
|
|
29
|
+
ownerPrincipalId: UUID;
|
|
30
|
+
systemPrincipalId: UUID;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Seed first-boot identity data.
|
|
34
|
+
*
|
|
35
|
+
* Idempotent in two distinct senses, and both are load-bearing:
|
|
36
|
+
* - A seed that RAN TO COMPLETION is a no-op — the owner-username lookup below early-returns after
|
|
37
|
+
* a single confirming read (`ensureOwnerRoleBinding`) and writes nothing. (This path does not
|
|
38
|
+
* reconcile a built-in policy whose permission list has since grown; that is the host's job — see
|
|
39
|
+
* the host's `applyBuiltinRoleGrants` / `migrateDeprecatedPermissionGrants`, chained onto
|
|
40
|
+
* `identityReady`.)
|
|
41
|
+
* - "Ran to completion" is judged on the owner user AND its role link, not the user alone. The link
|
|
42
|
+
* is the seed's last write, so the user is not on its own evidence the seed finished — see
|
|
43
|
+
* `ensureOwnerRoleBinding` for what an interrupt between those two writes costs.
|
|
44
|
+
* - A seed that was INTERRUPTED is resumed, not replayed: every step converges onto the rows a
|
|
45
|
+
* previous attempt already wrote and fills in only what is missing. See the block comment above
|
|
46
|
+
* `ensureBuiltinRole` for why this function must survive being killed halfway.
|
|
47
|
+
*
|
|
48
|
+
* @complexity O(1) — fixed small number of inserts (4 roles/policies, ~2
|
|
49
|
+
* dozen policy_permissions, 3 principals, 1 user, 1 role assignment).
|
|
50
|
+
* @overallScore 100
|
|
51
|
+
*/
|
|
52
|
+
export declare function seedIdentity(required: {
|
|
53
|
+
deps: SeedIdentityDeps;
|
|
54
|
+
input: SeedIdentityInput;
|
|
55
|
+
}, optional?: SeedIdentityOptions): Promise<SeedIdentityResult>;
|
|
56
|
+
//# sourceMappingURL=seed.d.ts.map
|