@classic-homes/auth 1.1.0 → 1.5.2

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.
@@ -0,0 +1,3 @@
1
+ export { authActions, authStore, currentUser, isAuthenticated } from './chunk-ZJYMNGGH.js';
2
+ import './chunk-NCVJ2HGP.js';
3
+ import './chunk-X7KH4DDN.js';
@@ -1,6 +1,6 @@
1
- import { authService } from './chunk-RCD423GF.js';
2
- import { authStore, currentUser, isAuthenticated, authActions } from './chunk-B5LAK7V6.js';
3
- import { isInitialized, initAuth, getUserRoles } from './chunk-VFEGS6FR.js';
1
+ import { authService } from './chunk-O6GYC4PA.js';
2
+ import { authStore, currentUser, isAuthenticated, authActions } from './chunk-ZJYMNGGH.js';
3
+ import { isInitialized, initAuth, getUserRoles } from './chunk-X7KH4DDN.js';
4
4
 
5
5
  // src/svelte/guards/auth-guard.ts
6
6
  function checkAuth(options = {}) {
@@ -1,4 +1,4 @@
1
- import { getConfig, getStorage, getFetch, isValidRedirectUrl } from './chunk-VFEGS6FR.js';
1
+ import { getConfig, getStorage, getFetch, isValidRedirectUrl } from './chunk-X7KH4DDN.js';
2
2
 
3
3
  // src/core/client.ts
4
4
  var isRefreshing = false;
@@ -77,7 +77,7 @@ function updateStoredTokens(accessToken, refreshToken) {
77
77
  parsed.accessToken = accessToken;
78
78
  parsed.refreshToken = refreshToken;
79
79
  storage.setItem(storageKey, JSON.stringify(parsed));
80
- import('./auth.svelte-54WDRZ6V.js').then(({ authStore }) => {
80
+ import('./auth.svelte-YNXMXION.js').then(({ authStore }) => {
81
81
  authStore.updateTokens(accessToken, refreshToken);
82
82
  }).catch(() => {
83
83
  });
@@ -92,7 +92,7 @@ function clearStoredAuth() {
92
92
  async function expireSession() {
93
93
  clearStoredAuth();
94
94
  try {
95
- const { authStore } = await import('./auth.svelte-54WDRZ6V.js');
95
+ const { authStore } = await import('./auth.svelte-YNXMXION.js');
96
96
  authStore.handleSessionExpired();
97
97
  } catch {
98
98
  }
@@ -538,7 +538,7 @@ var authApi = {
538
538
  await api.delete(`/auth/api-keys/${keyId}`, true);
539
539
  },
540
540
  /**
541
- * Update an API key's name.
541
+ * Update an API key's name, description, role, or permissions.
542
542
  */
543
543
  async updateApiKey(keyId, data) {
544
544
  await api.put(`/auth/api-keys/${keyId}`, data, true);
@@ -1,5 +1,5 @@
1
- import { authApi } from './chunk-FDOOY3IL.js';
2
- import { getUserRoles, hasAnyRole } from './chunk-VFEGS6FR.js';
1
+ import { authApi } from './chunk-NCVJ2HGP.js';
2
+ import { getUserRoles, hasAnyRole } from './chunk-X7KH4DDN.js';
3
3
 
4
4
  // src/core/guards.ts
5
5
  function isMfaChallengeResponse(response) {
@@ -59,7 +59,7 @@ var AuthService = class {
59
59
  }
60
60
  if (options?.autoSetAuth !== false && !isMfaChallengeResponse(response)) {
61
61
  try {
62
- const { authStore } = await import('./auth.svelte-54WDRZ6V.js');
62
+ const { authStore } = await import('./auth.svelte-YNXMXION.js');
63
63
  authStore.setAuth(
64
64
  response.accessToken,
65
65
  response.refreshToken,
@@ -186,10 +186,12 @@ var AuthService = class {
186
186
  await authApi.revokeApiKey(keyId);
187
187
  }
188
188
  /**
189
- * Update an API key's name.
189
+ * Update an API key. Accepts a plain string as a name-only update for
190
+ * backward compatibility, or an UpdateApiKeyRequest to change name,
191
+ * description, role, or permissions.
190
192
  */
191
- async updateApiKey(keyId, name) {
192
- await authApi.updateApiKey(keyId, { name });
193
+ async updateApiKey(keyId, data) {
194
+ await authApi.updateApiKey(keyId, typeof data === "string" ? { name: data } : data);
193
195
  }
194
196
  // ============================================================================
195
197
  // MFA Management
@@ -243,7 +245,7 @@ var AuthService = class {
243
245
  }
244
246
  if (options?.autoSetAuth !== false) {
245
247
  try {
246
- const { authStore } = await import('./auth.svelte-54WDRZ6V.js');
248
+ const { authStore } = await import('./auth.svelte-YNXMXION.js');
247
249
  authStore.setAuth(
248
250
  response.accessToken,
249
251
  response.refreshToken,
@@ -171,6 +171,7 @@ var ROLE_NAMES = [
171
171
  "marketing_staff",
172
172
  "purchasing_staff",
173
173
  "sales_staff",
174
+ "stormwater_staff",
174
175
  "warranty_staff",
175
176
  "employee",
176
177
  "user",
@@ -204,6 +205,7 @@ var ROLE_HIERARCHY = {
204
205
  marketing_staff: 2,
205
206
  purchasing_staff: 2,
206
207
  sales_staff: 2,
208
+ stormwater_staff: 2,
207
209
  warranty_staff: 2,
208
210
  manager: 3,
209
211
  admin: 4
@@ -1,5 +1,5 @@
1
- import { authApi } from './chunk-FDOOY3IL.js';
2
- import { isInitialized, getConfig, hasRole, hasAnyRole, hasAllRoles, decodeJWT, getStorage, getDefaultStorage } from './chunk-VFEGS6FR.js';
1
+ import { authApi } from './chunk-NCVJ2HGP.js';
2
+ import { isInitialized, getConfig, hasRole, hasAnyRole, hasAllRoles, decodeJWT, getStorage, getDefaultStorage } from './chunk-X7KH4DDN.js';
3
3
 
4
4
  // src/svelte/stores/auth.svelte.ts
5
5
  var STORAGE_VERSION = 2;
@@ -1,6 +1,6 @@
1
- import { e as LoginCredentials, f as LoginResponse, g as LogoutResponse, R as RegisterData, k as RegisterResponse, U as User, j as ProfileUpdateData, C as ChangePasswordData, n as Session, A as ApiKey, c as CreateApiKeyRequest, d as CreateApiKeyResponse, i as MFAStatus, h as MFASetupResponse, M as MFAChallengeData, D as Device, p as UserPreferences, L as LinkedAccount, m as SecurityEvent, P as Pagination, q as UserRolesResponse } from '../types-DXLdCdNC.js';
2
- export { a as AuthConfig, b as AuthState, l as ResetPasswordData, S as SSOConfig, o as StorageAdapter, r as createMemoryStorage, s as createSessionStorage, t as getConfig, u as getDefaultStorage, v as getFetch, w as getStorage, x as initAuth, y as isInitialized, z as resetConfig } from '../types-DXLdCdNC.js';
3
- export { A as AuthService, L as LoginOptions, M as MFAVerifyOptions, R as RoleDeniedError, a as authService, f as formatUserRoles, g as getAvatarFallback, b as getDisplayName, c as getGreeting, d as getUserEmail, e as getUserInitials, i as isRoleDeniedError } from '../user-utils-mQMLo7Il.js';
1
+ import { e as LoginCredentials, f as LoginResponse, g as LogoutResponse, R as RegisterData, k as RegisterResponse, p as User, j as ProfileUpdateData, C as ChangePasswordData, n as Session, A as ApiKey, c as CreateApiKeyRequest, d as CreateApiKeyResponse, U as UpdateApiKeyRequest, i as MFAStatus, h as MFASetupResponse, M as MFAChallengeData, D as Device, q as UserPreferences, L as LinkedAccount, m as SecurityEvent, P as Pagination, r as UserRolesResponse } from '../types-C6MqT3DB.js';
2
+ export { a as AuthConfig, b as AuthState, l as ResetPasswordData, S as SSOConfig, o as StorageAdapter, s as createMemoryStorage, t as createSessionStorage, u as getConfig, v as getDefaultStorage, w as getFetch, x as getStorage, y as initAuth, z as isInitialized, B as resetConfig } from '../types-C6MqT3DB.js';
3
+ export { A as AuthService, L as LoginOptions, M as MFAVerifyOptions, R as RoleDeniedError, a as authService, f as formatUserRoles, g as getAvatarFallback, b as getDisplayName, c as getGreeting, d as getUserEmail, e as getUserInitials, i as isRoleDeniedError } from '../user-utils-Dla77tvM.js';
4
4
 
5
5
  /**
6
6
  * HTTP Client
@@ -185,11 +185,9 @@ declare const authApi: {
185
185
  */
186
186
  revokeApiKey(keyId: string): Promise<void>;
187
187
  /**
188
- * Update an API key's name.
188
+ * Update an API key's name, description, role, or permissions.
189
189
  */
190
- updateApiKey(keyId: string, data: {
191
- name: string;
192
- }): Promise<void>;
190
+ updateApiKey(keyId: string, data: UpdateApiKeyRequest): Promise<void>;
193
191
  /**
194
192
  * Get MFA status for the current user.
195
193
  */
@@ -471,11 +469,16 @@ declare function extractClaims<T extends string>(token: string, claims: T[]): Pi
471
469
  *
472
470
  * Mirrors `ROLE_NAMES` in the API. `builder`/`customer_service`/`demo`/
473
471
  * `stormwater` are staff-tier clones of `agent`; the `<department>_staff` roles
474
- * are grant-on-top docs roles held alongside another role; `employee` is the
475
- * read-only base staff floor (default for Authentik SSO); `vendor`/`customer`/
476
- * `subcontractor` are clones of `user`, row-scoped to their own homes.
472
+ * are grant-on-top docs roles held alongside another role, one per department
473
+ * the API lists in `DEPARTMENT_SCOPES`; `employee` is the read-only base staff
474
+ * floor (default for Authentik SSO); `vendor`/`customer`/`subcontractor` are
475
+ * clones of `user`, row-scoped to their own homes.
476
+ *
477
+ * `stormwater` and `stormwater_staff` are two different roles: the first is the
478
+ * field app's clone of `agent`, the second is that department's docs role.
479
+ * Someone on the stormwater team who also reads the docs holds both.
477
480
  */
478
- declare const ROLE_NAMES: readonly ["admin", "manager", "agent", "builder", "customer_service", "demo", "stormwater", "accounting_staff", "architecture_staff", "construction_staff", "crl_staff", "design_staff", "hr_staff", "it_staff", "landdev_staff", "marketing_staff", "purchasing_staff", "sales_staff", "warranty_staff", "employee", "user", "vendor", "customer", "subcontractor", "guest"];
481
+ declare const ROLE_NAMES: readonly ["admin", "manager", "agent", "builder", "customer_service", "demo", "stormwater", "accounting_staff", "architecture_staff", "construction_staff", "crl_staff", "design_staff", "hr_staff", "it_staff", "landdev_staff", "marketing_staff", "purchasing_staff", "sales_staff", "stormwater_staff", "warranty_staff", "employee", "user", "vendor", "customer", "subcontractor", "guest"];
479
482
  /**
480
483
  * A known role name.
481
484
  *
@@ -554,4 +557,4 @@ declare function hasAnyRole(user: Pick<User, 'roles'> | null | undefined, roles:
554
557
  */
555
558
  declare function hasAllRoles(user: Pick<User, 'roles'> | null | undefined, roles: readonly string[]): boolean;
556
559
 
557
- export { ApiKey, type ApiRequestOptions, type ApiResponse, ChangePasswordData, CreateApiKeyRequest, CreateApiKeyResponse, Device, type JWTPayload, LinkedAccount, LoginCredentials, LoginResponse, LogoutResponse, MFAChallengeData, MFASetupResponse, MFAStatus, Pagination, ProfileUpdateData, ROLE_HIERARCHY, ROLE_NAMES, RegisterData, RegisterResponse, type RoleName, SecurityEvent, Session, User, UserPreferences, UserRolesResponse, api, apiRequest, authApi, clearStoredAuth, computePrimaryRole, decodeJWT, extractClaims, extractData, getAccessToken, getAvailableMethods, getEffectiveLevel, getMfaToken, getRefreshToken, getSessionToken, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, isLoginSuccessResponse, isMfaChallengeResponse, isTokenExpired, updateStoredTokens };
560
+ export { ApiKey, type ApiRequestOptions, type ApiResponse, ChangePasswordData, CreateApiKeyRequest, CreateApiKeyResponse, Device, type JWTPayload, LinkedAccount, LoginCredentials, LoginResponse, LogoutResponse, MFAChallengeData, MFASetupResponse, MFAStatus, Pagination, ProfileUpdateData, ROLE_HIERARCHY, ROLE_NAMES, RegisterData, RegisterResponse, type RoleName, SecurityEvent, Session, UpdateApiKeyRequest, User, UserPreferences, UserRolesResponse, api, apiRequest, authApi, clearStoredAuth, computePrimaryRole, decodeJWT, extractClaims, extractData, getAccessToken, getAvailableMethods, getEffectiveLevel, getMfaToken, getRefreshToken, getSessionToken, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, isLoginSuccessResponse, isMfaChallengeResponse, isTokenExpired, updateStoredTokens };
@@ -1,3 +1,3 @@
1
- export { AuthService, RoleDeniedError, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, isRoleDeniedError } from '../chunk-RCD423GF.js';
2
- export { api, apiRequest, authApi, clearStoredAuth, extractData, getAccessToken, getRefreshToken, getSessionToken, updateStoredTokens } from '../chunk-FDOOY3IL.js';
3
- export { ROLE_HIERARCHY, ROLE_NAMES, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, extractClaims, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isInitialized, isTokenExpired, resetConfig } from '../chunk-VFEGS6FR.js';
1
+ export { AuthService, RoleDeniedError, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, isRoleDeniedError } from '../chunk-O6GYC4PA.js';
2
+ export { api, apiRequest, authApi, clearStoredAuth, extractData, getAccessToken, getRefreshToken, getSessionToken, updateStoredTokens } from '../chunk-NCVJ2HGP.js';
3
+ export { ROLE_HIERARCHY, ROLE_NAMES, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, extractClaims, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isInitialized, isTokenExpired, resetConfig } from '../chunk-X7KH4DDN.js';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as ApiKey, a as AuthConfig, b as AuthState, C as ChangePasswordData, c as CreateApiKeyRequest, d as CreateApiKeyResponse, D as Device, L as LinkedAccount, e as LoginCredentials, f as LoginResponse, g as LogoutResponse, M as MFAChallengeData, h as MFASetupResponse, i as MFAStatus, P as Pagination, j as ProfileUpdateData, R as RegisterData, k as RegisterResponse, l as ResetPasswordData, S as SSOConfig, m as SecurityEvent, n as Session, o as StorageAdapter, U as User, p as UserPreferences, q as UserRolesResponse, r as createMemoryStorage, s as createSessionStorage, t as getConfig, u as getDefaultStorage, v as getFetch, w as getStorage, x as initAuth, y as isInitialized, z as resetConfig } from './types-DXLdCdNC.js';
1
+ export { A as ApiKey, a as AuthConfig, b as AuthState, C as ChangePasswordData, c as CreateApiKeyRequest, d as CreateApiKeyResponse, D as Device, L as LinkedAccount, e as LoginCredentials, f as LoginResponse, g as LogoutResponse, M as MFAChallengeData, h as MFASetupResponse, i as MFAStatus, P as Pagination, j as ProfileUpdateData, R as RegisterData, k as RegisterResponse, l as ResetPasswordData, S as SSOConfig, m as SecurityEvent, n as Session, o as StorageAdapter, U as UpdateApiKeyRequest, p as User, q as UserPreferences, r as UserRolesResponse, s as createMemoryStorage, t as createSessionStorage, u as getConfig, v as getDefaultStorage, w as getFetch, x as getStorage, y as initAuth, z as isInitialized, B as resetConfig } from './types-C6MqT3DB.js';
2
2
  export { ApiRequestOptions, ApiResponse, JWTPayload, ROLE_HIERARCHY, ROLE_NAMES, RoleName, api, apiRequest, authApi, clearStoredAuth, computePrimaryRole, decodeJWT, extractClaims, extractData, getAccessToken, getAvailableMethods, getEffectiveLevel, getMfaToken, getRefreshToken, getSessionToken, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, isLoginSuccessResponse, isMfaChallengeResponse, isTokenExpired, updateStoredTokens } from './core/index.js';
3
- export { A as AuthService, L as LoginOptions, M as MFAVerifyOptions, R as RoleDeniedError, a as authService, f as formatUserRoles, g as getAvatarFallback, b as getDisplayName, c as getGreeting, d as getUserEmail, e as getUserInitials, i as isRoleDeniedError } from './user-utils-mQMLo7Il.js';
3
+ export { A as AuthService, L as LoginOptions, M as MFAVerifyOptions, R as RoleDeniedError, a as authService, f as formatUserRoles, g as getAvatarFallback, b as getDisplayName, c as getGreeting, d as getUserEmail, e as getUserInitials, i as isRoleDeniedError } from './user-utils-Dla77tvM.js';
4
4
  export { AuthClient, AuthGuardOptions, AuthGuardResult, AuthHookOptions, CreateAuthClientOptions, NavFilterOptions, RoleRestrictedItem, authActions, authStore, canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, currentUser, filterByAccess, filterNavSections, isAuthenticated, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './svelte/index.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './chunk-A2KRBRIC.js';
2
- export { AuthService, RoleDeniedError, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, isRoleDeniedError } from './chunk-RCD423GF.js';
3
- export { authActions, authStore, currentUser, isAuthenticated } from './chunk-B5LAK7V6.js';
4
- export { api, apiRequest, authApi, clearStoredAuth, extractData, getAccessToken, getRefreshToken, getSessionToken, updateStoredTokens } from './chunk-FDOOY3IL.js';
5
- export { ROLE_HIERARCHY, ROLE_NAMES, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, extractClaims, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isInitialized, isTokenExpired, resetConfig } from './chunk-VFEGS6FR.js';
1
+ export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './chunk-GVNUEBEP.js';
2
+ export { AuthService, RoleDeniedError, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, isRoleDeniedError } from './chunk-O6GYC4PA.js';
3
+ export { authActions, authStore, currentUser, isAuthenticated } from './chunk-ZJYMNGGH.js';
4
+ export { api, apiRequest, authApi, clearStoredAuth, extractData, getAccessToken, getRefreshToken, getSessionToken, updateStoredTokens } from './chunk-NCVJ2HGP.js';
5
+ export { ROLE_HIERARCHY, ROLE_NAMES, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, extractClaims, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isInitialized, isTokenExpired, resetConfig } from './chunk-X7KH4DDN.js';
@@ -1,7 +1,7 @@
1
- import { b as AuthState, U as User, a as AuthConfig } from '../types-DXLdCdNC.js';
2
- export { x as initAuth, y as isInitialized } from '../types-DXLdCdNC.js';
3
- import { a as authService } from '../user-utils-mQMLo7Il.js';
4
- export { R as RoleDeniedError, f as formatUserRoles, g as getAvatarFallback, b as getDisplayName, c as getGreeting, d as getUserEmail, e as getUserInitials, i as isRoleDeniedError } from '../user-utils-mQMLo7Il.js';
1
+ import { b as AuthState, p as User, a as AuthConfig } from '../types-C6MqT3DB.js';
2
+ export { y as initAuth, z as isInitialized } from '../types-C6MqT3DB.js';
3
+ import { a as authService } from '../user-utils-Dla77tvM.js';
4
+ export { R as RoleDeniedError, f as formatUserRoles, g as getAvatarFallback, b as getDisplayName, c as getGreeting, d as getUserEmail, e as getUserInitials, i as isRoleDeniedError } from '../user-utils-Dla77tvM.js';
5
5
 
6
6
  /**
7
7
  * Auth Store
@@ -1,5 +1,5 @@
1
- export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from '../chunk-A2KRBRIC.js';
2
- export { RoleDeniedError, formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials, isRoleDeniedError } from '../chunk-RCD423GF.js';
3
- export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-B5LAK7V6.js';
4
- import '../chunk-FDOOY3IL.js';
5
- export { initAuth, isInitialized } from '../chunk-VFEGS6FR.js';
1
+ export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from '../chunk-GVNUEBEP.js';
2
+ export { RoleDeniedError, formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials, isRoleDeniedError } from '../chunk-O6GYC4PA.js';
3
+ export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-ZJYMNGGH.js';
4
+ import '../chunk-NCVJ2HGP.js';
5
+ export { initAuth, isInitialized } from '../chunk-X7KH4DDN.js';
@@ -1,4 +1,4 @@
1
- import { U as User, D as Device, f as LoginResponse, m as SecurityEvent, n as Session, A as ApiKey, L as LinkedAccount, g as LogoutResponse, h as MFASetupResponse, i as MFAStatus, k as RegisterResponse, p as UserPreferences, o as StorageAdapter, b as AuthState, a as AuthConfig } from '../types-DXLdCdNC.js';
1
+ import { p as User, D as Device, f as LoginResponse, m as SecurityEvent, n as Session, A as ApiKey, L as LinkedAccount, g as LogoutResponse, h as MFASetupResponse, i as MFAStatus, k as RegisterResponse, q as UserPreferences, o as StorageAdapter, b as AuthState, a as AuthConfig } from '../types-C6MqT3DB.js';
2
2
 
3
3
  /**
4
4
  * User Fixtures
@@ -1,4 +1,4 @@
1
- import { hasRole, hasAnyRole, hasAllRoles, initAuth, resetConfig, getUserRoles, isTokenExpired, decodeJWT } from '../chunk-VFEGS6FR.js';
1
+ import { hasRole, hasAnyRole, hasAllRoles, initAuth, resetConfig, getUserRoles, isTokenExpired, decodeJWT } from '../chunk-X7KH4DDN.js';
2
2
 
3
3
  // src/testing/fixtures/users.ts
4
4
  var mockUser = {
@@ -258,6 +258,21 @@ interface ApiKey {
258
258
  createdAt: string;
259
259
  usageCount?: number;
260
260
  }
261
+ /**
262
+ * Payload for updating an existing API key. All fields optional; at least one
263
+ * must be provided. Role/permission changes are validated server-side against
264
+ * the editor's own grants (same escalation guards as create) and take effect
265
+ * on the key's next request — enforcement reads the stored row live.
266
+ */
267
+ interface UpdateApiKeyRequest {
268
+ name?: string;
269
+ /** null clears the description */
270
+ description?: string | null;
271
+ /** Changing the role without `permissions` re-inherits the new role's full set */
272
+ role?: string;
273
+ /** Replacement permission set; must be a subset of the editor's own permissions */
274
+ permissions?: string[];
275
+ }
261
276
  interface CreateApiKeyRequest {
262
277
  name: string;
263
278
  description?: string;
@@ -371,4 +386,4 @@ interface ResetPasswordData {
371
386
  newPassword: string;
372
387
  }
373
388
 
374
- export { type ApiKey as A, type ChangePasswordData as C, type Device as D, type LinkedAccount as L, type MFAChallengeData as M, type Pagination as P, type RegisterData as R, type SSOConfig as S, type User as U, type AuthConfig as a, type AuthState as b, type CreateApiKeyRequest as c, type CreateApiKeyResponse as d, type LoginCredentials as e, type LoginResponse as f, type LogoutResponse as g, type MFASetupResponse as h, type MFAStatus as i, type ProfileUpdateData as j, type RegisterResponse as k, type ResetPasswordData as l, type SecurityEvent as m, type Session as n, type StorageAdapter as o, type UserPreferences as p, type UserRolesResponse as q, createMemoryStorage as r, createSessionStorage as s, getConfig as t, getDefaultStorage as u, getFetch as v, getStorage as w, initAuth as x, isInitialized as y, resetConfig as z };
389
+ export { type ApiKey as A, resetConfig as B, type ChangePasswordData as C, type Device as D, type LinkedAccount as L, type MFAChallengeData as M, type Pagination as P, type RegisterData as R, type SSOConfig as S, type UpdateApiKeyRequest as U, type AuthConfig as a, type AuthState as b, type CreateApiKeyRequest as c, type CreateApiKeyResponse as d, type LoginCredentials as e, type LoginResponse as f, type LogoutResponse as g, type MFASetupResponse as h, type MFAStatus as i, type ProfileUpdateData as j, type RegisterResponse as k, type ResetPasswordData as l, type SecurityEvent as m, type Session as n, type StorageAdapter as o, type User as p, type UserPreferences as q, type UserRolesResponse as r, createMemoryStorage as s, createSessionStorage as t, getConfig as u, getDefaultStorage as v, getFetch as w, getStorage as x, initAuth as y, isInitialized as z };
@@ -1,4 +1,4 @@
1
- import { e as LoginCredentials, f as LoginResponse, g as LogoutResponse, R as RegisterData, k as RegisterResponse, U as User, j as ProfileUpdateData, n as Session, A as ApiKey, c as CreateApiKeyRequest, d as CreateApiKeyResponse, i as MFAStatus, h as MFASetupResponse, M as MFAChallengeData, D as Device, p as UserPreferences, L as LinkedAccount, m as SecurityEvent, P as Pagination } from './types-DXLdCdNC.js';
1
+ import { e as LoginCredentials, f as LoginResponse, g as LogoutResponse, R as RegisterData, k as RegisterResponse, p as User, j as ProfileUpdateData, n as Session, A as ApiKey, c as CreateApiKeyRequest, d as CreateApiKeyResponse, U as UpdateApiKeyRequest, i as MFAStatus, h as MFASetupResponse, M as MFAChallengeData, D as Device, q as UserPreferences, L as LinkedAccount, m as SecurityEvent, P as Pagination } from './types-C6MqT3DB.js';
2
2
 
3
3
  /**
4
4
  * Auth Service
@@ -158,9 +158,11 @@ declare class AuthService {
158
158
  */
159
159
  revokeApiKey(keyId: string): Promise<void>;
160
160
  /**
161
- * Update an API key's name.
161
+ * Update an API key. Accepts a plain string as a name-only update for
162
+ * backward compatibility, or an UpdateApiKeyRequest to change name,
163
+ * description, role, or permissions.
162
164
  */
163
- updateApiKey(keyId: string, name: string): Promise<void>;
165
+ updateApiKey(keyId: string, data: string | UpdateApiKeyRequest): Promise<void>;
164
166
  /**
165
167
  * Get MFA status for the current user.
166
168
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/auth",
3
- "version": "1.1.0",
3
+ "version": "1.5.2",
4
4
  "description": "Authentication services and Svelte bindings for Classic Theme apps",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,3 +0,0 @@
1
- export { authActions, authStore, currentUser, isAuthenticated } from './chunk-B5LAK7V6.js';
2
- import './chunk-FDOOY3IL.js';
3
- import './chunk-VFEGS6FR.js';