@happyvertical/smrt-users 0.31.0 → 0.31.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.
- package/dist/chunks/{TerminalAuthService-DoAMQ_yn.js → TerminalAuthService-DsQBk1Hc.js} +161 -71
- package/dist/chunks/TerminalAuthService-DsQBk1Hc.js.map +1 -0
- package/dist/chunks/{index-DkoYIvIu.js → index-Cp33Tyha.js} +10 -10
- package/dist/chunks/{index-DkoYIvIu.js.map → index-Cp33Tyha.js.map} +1 -1
- package/dist/collections/GroupMemberCollection.d.ts +9 -0
- package/dist/collections/GroupMemberCollection.d.ts.map +1 -1
- package/dist/collections/SessionCollection.d.ts.map +1 -1
- package/dist/index.js +38 -100
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +2 -2
- package/dist/smrt-knowledge.json +4 -4
- package/dist/svelte/components/InviteUserModal.svelte +72 -169
- package/dist/svelte/components/InviteUserModal.svelte.d.ts.map +1 -1
- package/dist/svelte/components/UserCard.svelte +2 -1
- package/dist/svelte/components/UserCard.svelte.d.ts.map +1 -1
- package/dist/svelte/components/UserForm.svelte +11 -4
- package/dist/svelte/components/UserForm.svelte.d.ts.map +1 -1
- package/dist/svelte/components/UserMenu.svelte +100 -25
- package/dist/svelte/components/UserMenu.svelte.d.ts +5 -4
- package/dist/svelte/components/UserMenu.svelte.d.ts.map +1 -1
- package/dist/svelte/components/__tests__/InviteUserModal.test.js +11 -0
- package/dist/svelte/components/__tests__/UserMenu.test.js +45 -0
- package/dist/svelte/components/__tests__/UserStatus.test.js +36 -0
- package/dist/sveltekit/index.d.ts +7 -1
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit.js +15 -8
- package/dist/sveltekit.js.map +1 -1
- package/package.json +8 -8
- package/dist/chunks/TerminalAuthService-DoAMQ_yn.js.map +0 -1
|
@@ -6,14 +6,14 @@ import { MembershipStatus, OverrideEffect, SessionStatus, TenantStatus, TenantPe
|
|
|
6
6
|
ObjectRegistry.registerPackageManifest(
|
|
7
7
|
new URL("./manifest.json", import.meta.url)
|
|
8
8
|
);
|
|
9
|
-
var __defProp$
|
|
10
|
-
var __getOwnPropDesc$
|
|
11
|
-
var __decorateClass$
|
|
12
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
9
|
+
var __defProp$a = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __decorateClass$b = (decorators, target, key, kind) => {
|
|
12
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
|
|
13
13
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14
14
|
if (decorator = decorators[i])
|
|
15
15
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
16
|
-
if (kind && result) __defProp$
|
|
16
|
+
if (kind && result) __defProp$a(target, key, result);
|
|
17
17
|
return result;
|
|
18
18
|
};
|
|
19
19
|
let UsersCliAuthRequest = class extends SmrtObject {
|
|
@@ -26,31 +26,31 @@ let UsersCliAuthRequest = class extends SmrtObject {
|
|
|
26
26
|
expiresAt = /* @__PURE__ */ new Date();
|
|
27
27
|
approvedAt = null;
|
|
28
28
|
};
|
|
29
|
-
__decorateClass$
|
|
29
|
+
__decorateClass$b([
|
|
30
30
|
field({ type: "text" })
|
|
31
31
|
], UsersCliAuthRequest.prototype, "userCode", 2);
|
|
32
|
-
__decorateClass$
|
|
32
|
+
__decorateClass$b([
|
|
33
33
|
field({ type: "text" })
|
|
34
34
|
], UsersCliAuthRequest.prototype, "deviceCodeHash", 2);
|
|
35
|
-
__decorateClass$
|
|
35
|
+
__decorateClass$b([
|
|
36
36
|
field({ type: "text" })
|
|
37
37
|
], UsersCliAuthRequest.prototype, "status", 2);
|
|
38
|
-
__decorateClass$
|
|
38
|
+
__decorateClass$b([
|
|
39
39
|
field({ type: "text" })
|
|
40
40
|
], UsersCliAuthRequest.prototype, "userId", 2);
|
|
41
|
-
__decorateClass$
|
|
41
|
+
__decorateClass$b([
|
|
42
42
|
field({ type: "text" })
|
|
43
43
|
], UsersCliAuthRequest.prototype, "tenantId", 2);
|
|
44
|
-
__decorateClass$
|
|
44
|
+
__decorateClass$b([
|
|
45
45
|
field({ type: "text" })
|
|
46
46
|
], UsersCliAuthRequest.prototype, "sessionId", 2);
|
|
47
|
-
__decorateClass$
|
|
47
|
+
__decorateClass$b([
|
|
48
48
|
field({ type: "datetime" })
|
|
49
49
|
], UsersCliAuthRequest.prototype, "expiresAt", 2);
|
|
50
|
-
__decorateClass$
|
|
50
|
+
__decorateClass$b([
|
|
51
51
|
field({ type: "datetime", nullable: true })
|
|
52
52
|
], UsersCliAuthRequest.prototype, "approvedAt", 2);
|
|
53
|
-
UsersCliAuthRequest = __decorateClass$
|
|
53
|
+
UsersCliAuthRequest = __decorateClass$b([
|
|
54
54
|
smrt({
|
|
55
55
|
tableName: "users_cli_auth_requests",
|
|
56
56
|
api: { include: [] },
|
|
@@ -98,6 +98,68 @@ class UsersCliAuthRequestCollection extends SmrtCollection {
|
|
|
98
98
|
return count;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
+
var __defProp$9 = Object.defineProperty;
|
|
102
|
+
var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
|
|
103
|
+
var __decorateClass$a = (decorators, target, key, kind) => {
|
|
104
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
|
|
105
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
106
|
+
if (decorator = decorators[i])
|
|
107
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
108
|
+
if (kind && result) __defProp$9(target, key, result);
|
|
109
|
+
return result;
|
|
110
|
+
};
|
|
111
|
+
let Group = class extends SmrtObject {
|
|
112
|
+
tenantId;
|
|
113
|
+
/**
|
|
114
|
+
* Display name for the group
|
|
115
|
+
*/
|
|
116
|
+
name = "";
|
|
117
|
+
/**
|
|
118
|
+
* Description of the group
|
|
119
|
+
*/
|
|
120
|
+
description = "";
|
|
121
|
+
constructor(options = {}) {
|
|
122
|
+
super(options);
|
|
123
|
+
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
124
|
+
if (options.name !== void 0) this.name = options.name;
|
|
125
|
+
if (options.description !== void 0)
|
|
126
|
+
this.description = options.description;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
__decorateClass$a([
|
|
130
|
+
foreignKey("Tenant", { required: true })
|
|
131
|
+
], Group.prototype, "tenantId", 2);
|
|
132
|
+
Group = __decorateClass$a([
|
|
133
|
+
smrt({
|
|
134
|
+
// #1400: read-only generated surface — RBAC/identity writes go through
|
|
135
|
+
// permission-gated services, not auth-only generated CRUD.
|
|
136
|
+
api: { include: ["list", "get"] },
|
|
137
|
+
mcp: { include: ["list", "get"] },
|
|
138
|
+
cli: true
|
|
139
|
+
})
|
|
140
|
+
], Group);
|
|
141
|
+
class GroupCollection extends SmrtCollection {
|
|
142
|
+
static _itemClass = Group;
|
|
143
|
+
/**
|
|
144
|
+
* Find all groups in a tenant
|
|
145
|
+
*/
|
|
146
|
+
async findByTenant(tenantId) {
|
|
147
|
+
return await this.list({
|
|
148
|
+
where: { tenantId },
|
|
149
|
+
orderBy: "name ASC"
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Find group by slug within a tenant
|
|
154
|
+
*/
|
|
155
|
+
async findBySlug(slug, tenantId) {
|
|
156
|
+
const results = await this.list({
|
|
157
|
+
where: { slug, tenantId },
|
|
158
|
+
limit: 1
|
|
159
|
+
});
|
|
160
|
+
return results.length > 0 ? results[0] : null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
101
163
|
var __defProp$8 = Object.defineProperty;
|
|
102
164
|
var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
|
|
103
165
|
var __decorateClass$9 = (decorators, target, key, kind) => {
|
|
@@ -135,6 +197,22 @@ GroupMember = __decorateClass$9([
|
|
|
135
197
|
], GroupMember);
|
|
136
198
|
class GroupMemberCollection extends SmrtCollection {
|
|
137
199
|
static _itemClass = GroupMember;
|
|
200
|
+
/** Memoized Group collection, used to resolve the Group table name. */
|
|
201
|
+
groupCollection;
|
|
202
|
+
/**
|
|
203
|
+
* Resolve the database table name for the `Group` model from the registry
|
|
204
|
+
* (via a shared-connection GroupCollection) rather than hardcoding `groups`.
|
|
205
|
+
* A `@smrt({ tableName })` override or table prefix on Group would otherwise
|
|
206
|
+
* make raw joins reference a non-existent or foreign table.
|
|
207
|
+
*/
|
|
208
|
+
async getGroupTableName() {
|
|
209
|
+
if (!this.groupCollection) {
|
|
210
|
+
this.groupCollection = await GroupCollection.create({
|
|
211
|
+
db: this.options.db
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return this.groupCollection.tableName;
|
|
215
|
+
}
|
|
138
216
|
/**
|
|
139
217
|
* Find all members of a group
|
|
140
218
|
*/
|
|
@@ -203,10 +281,11 @@ class GroupMemberCollection extends SmrtCollection {
|
|
|
203
281
|
* This prevents cross-tenant permission leakage by filtering groups by tenant
|
|
204
282
|
*/
|
|
205
283
|
async getGroupIdsForTenant(userId, tenantId) {
|
|
284
|
+
const groupTable = await this.getGroupTableName();
|
|
206
285
|
const sql = `
|
|
207
286
|
SELECT gm.group_id
|
|
208
287
|
FROM ${this.tableName} gm
|
|
209
|
-
INNER JOIN
|
|
288
|
+
INNER JOIN ${groupTable} g ON g.id = gm.group_id
|
|
210
289
|
WHERE gm.user_id = ? AND g.tenant_id = ?
|
|
211
290
|
`;
|
|
212
291
|
const result = await this.db.query(sql, userId, tenantId);
|
|
@@ -1047,8 +1126,17 @@ class SessionCollection extends SmrtCollection {
|
|
|
1047
1126
|
if (!session) return null;
|
|
1048
1127
|
if (!session.isValid()) {
|
|
1049
1128
|
if (session.isExpired() && session.status === SessionStatus.ACTIVE) {
|
|
1050
|
-
|
|
1051
|
-
await
|
|
1129
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1130
|
+
await this.db.query(
|
|
1131
|
+
`UPDATE ${this.tableName}
|
|
1132
|
+
SET status = ?, updated_at = ?
|
|
1133
|
+
WHERE id = ? AND status = ? AND expires_at < ?`,
|
|
1134
|
+
SessionStatus.EXPIRED,
|
|
1135
|
+
now,
|
|
1136
|
+
sessionId,
|
|
1137
|
+
SessionStatus.ACTIVE,
|
|
1138
|
+
now
|
|
1139
|
+
);
|
|
1052
1140
|
}
|
|
1053
1141
|
return null;
|
|
1054
1142
|
}
|
|
@@ -5042,53 +5130,55 @@ class TerminalAuthRateLimitError extends TerminalAuthError {
|
|
|
5042
5130
|
}
|
|
5043
5131
|
}
|
|
5044
5132
|
export {
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5133
|
+
checkKeyLength as $,
|
|
5134
|
+
Tenant as A,
|
|
5135
|
+
TenantHierarchyError as B,
|
|
5136
|
+
TenantPermissionOverride as C,
|
|
5049
5137
|
DEFAULT_ROLES as D,
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5138
|
+
TenantPermissionOverrideCollection as E,
|
|
5139
|
+
TerminalAuthError as F,
|
|
5140
|
+
Group as G,
|
|
5141
|
+
TerminalAuthRateLimitError as H,
|
|
5142
|
+
TerminalAuthService as I,
|
|
5143
|
+
User as J,
|
|
5144
|
+
UserCollection as K,
|
|
5145
|
+
decodeOidcTransaction as L,
|
|
5058
5146
|
MembershipCollection as M,
|
|
5059
|
-
|
|
5147
|
+
encodeOidcTransaction as N,
|
|
5060
5148
|
OidcLoginError as O,
|
|
5061
5149
|
PermissionCollection as P,
|
|
5062
|
-
|
|
5150
|
+
generateSessionId as Q,
|
|
5063
5151
|
RolePermission as R,
|
|
5064
5152
|
Session as S,
|
|
5065
5153
|
TenantCollection as T,
|
|
5066
5154
|
UsersCliAuthRequest as U,
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5155
|
+
getCurrentSessionPermissionContext as V,
|
|
5156
|
+
getRequestScopedDatabase as W,
|
|
5157
|
+
getUsersOidcConfig as X,
|
|
5158
|
+
resolveOidcProviderConfig as Y,
|
|
5159
|
+
withSessionPermissionContext as Z,
|
|
5160
|
+
getSigKey as _,
|
|
5073
5161
|
isValidPermissionSlug as a,
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5162
|
+
subtleAlgorithm as a0,
|
|
5163
|
+
JWSInvalid as a1,
|
|
5164
|
+
isDisjoint as a2,
|
|
5165
|
+
validateCrit as a3,
|
|
5166
|
+
checkKeyType as a4,
|
|
5167
|
+
encode as a5,
|
|
5168
|
+
encode$1 as a6,
|
|
5169
|
+
concat as a7,
|
|
5170
|
+
normalizeKey as a8,
|
|
5171
|
+
JWTClaimsBuilder as a9,
|
|
5172
|
+
JWTInvalid as aa,
|
|
5173
|
+
errors as ab,
|
|
5174
|
+
jwtVerify as ac,
|
|
5175
|
+
compactVerify as ad,
|
|
5176
|
+
createLocalJWKSet as ae,
|
|
5177
|
+
createRemoteJWKSet as af,
|
|
5178
|
+
customFetch as ag,
|
|
5179
|
+
flattenedVerify as ah,
|
|
5180
|
+
importJWK as ai,
|
|
5181
|
+
jwksCache as aj,
|
|
5092
5182
|
DEFAULT_TENANT_POLICY as b,
|
|
5093
5183
|
DEFAULT_ROLE_SLUGS as c,
|
|
5094
5184
|
UsersCliAuthRequestCollection as d,
|
|
@@ -5097,22 +5187,22 @@ export {
|
|
|
5097
5187
|
DEFAULT_CLI_SESSION_TTL_SECONDS as g,
|
|
5098
5188
|
DEFAULT_SESSION_TTL as h,
|
|
5099
5189
|
isValidEmail as i,
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5190
|
+
GroupCollection as j,
|
|
5191
|
+
GroupMember as k,
|
|
5192
|
+
GroupMemberCollection as l,
|
|
5193
|
+
GroupRole as m,
|
|
5104
5194
|
normalizeEmail as n,
|
|
5105
|
-
|
|
5195
|
+
GroupRoleCollection as o,
|
|
5106
5196
|
parsePermissionSlug as p,
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5197
|
+
MAX_TENANT_HIERARCHY_DEPTH as q,
|
|
5198
|
+
Membership as r,
|
|
5199
|
+
MembershipOverride as s,
|
|
5200
|
+
MembershipOverrideCollection as t,
|
|
5201
|
+
OidcLoginService as u,
|
|
5202
|
+
Permission as v,
|
|
5203
|
+
PermissionResolver as w,
|
|
5204
|
+
RolePermissionCollection as x,
|
|
5205
|
+
SessionCollection as y,
|
|
5206
|
+
SessionService as z
|
|
5117
5207
|
};
|
|
5118
|
-
//# sourceMappingURL=TerminalAuthService-
|
|
5208
|
+
//# sourceMappingURL=TerminalAuthService-DsQBk1Hc.js.map
|