@makolabs/ripple 1.6.1 → 1.6.3

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.
@@ -275,19 +275,22 @@ async function fetchUserPermissions(userId) {
275
275
  if (userData?.data?.data && Array.isArray(userData.data.data)) {
276
276
  // Deduplicate permissions by using a Set
277
277
  const allPermissions = userData.data.data.flatMap((key) => key.scopes || []);
278
- return Array.from(new Set(allPermissions));
278
+ const dedupedPermissions = Array.from(new Set(allPermissions));
279
+ return dedupedPermissions;
279
280
  }
280
281
  else if (userData?.scopes) {
281
- return Array.isArray(userData.scopes) ? userData.scopes : [userData.scopes];
282
+ const permissions = Array.isArray(userData.scopes) ? userData.scopes : [userData.scopes];
283
+ return permissions;
282
284
  }
283
285
  return [];
284
286
  }
285
- catch {
287
+ catch (error) {
286
288
  try {
287
289
  const allKeysData = await makeAdminRequest('/admin/keys');
288
290
  const userKey = allKeysData.data.data.find((key) => key.sub === userId && key.client_id === CLIENT_ID && key.status === 'active');
289
291
  if (userKey) {
290
- return Array.isArray(userKey.scopes) ? userKey.scopes : [userKey.scopes];
292
+ const permissions = Array.isArray(userKey.scopes) ? userKey.scopes : [userKey.scopes];
293
+ return permissions;
291
294
  }
292
295
  return [];
293
296
  }
@@ -345,10 +348,10 @@ async function refreshTokenIfSelfUpdate(userId) {
345
348
  export const updateUserPermissions = command('unchecked', async (options) => {
346
349
  const { userId, permissions } = options;
347
350
  try {
348
- // Fetch all keys to find user's active keys
349
- const allKeysData = await makeAdminRequest('/admin/keys');
351
+ // Fetch all keys for this specific user (not paginated, gets all keys)
352
+ const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${userId}`);
350
353
  // Find ALL active keys for this user (not just one)
351
- const userKeys = allKeysData.data.data.filter((key) => key.sub === userId && key.client_id === CLIENT_ID && key.status === 'active');
354
+ const userKeys = (allKeysData?.data?.data || []).filter((key) => key.status === 'active');
352
355
  // Delete all old active keys to ensure clean state
353
356
  if (userKeys.length > 0) {
354
357
  await Promise.all(userKeys.map((key) => makeAdminRequest(`/admin/keys/${key.id}`, {
@@ -164,10 +164,11 @@
164
164
  role: formData.role,
165
165
  permissions: formData.permissions
166
166
  };
167
+
167
168
  await onSave(userData, mode);
168
169
  handleClose();
169
170
  } catch (error) {
170
- console.error('Error saving user:', error);
171
+ console.error('[UserModal] Error saving user:', error);
171
172
  formErrors.submit = error instanceof Error ? error.message : 'Failed to save user';
172
173
  } finally {
173
174
  saving = false;
@@ -175,11 +176,14 @@
175
176
  }
176
177
 
177
178
  function handleRoleChange(roleValue: string) {
178
- formData.role = roleValue;
179
179
  const role = roles?.find((r: Role) => r.value === roleValue);
180
- if (role) {
181
- formData.permissions = [...role.permissions];
182
- }
180
+
181
+ // Reassign entire formData object to ensure Svelte 5 reactivity
182
+ formData = {
183
+ ...formData,
184
+ role: roleValue,
185
+ permissions: role ? [...role.permissions] : []
186
+ };
183
187
  }
184
188
 
185
189
  async function handleRegenerateApiKey() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makolabs/ripple",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "Simple Svelte 5 powered component library ✨",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {